From 699c610103ef059c583b9d1ca11317a7273a6562 Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Sun, 28 Nov 2021 13:03:37 +0000 Subject: [PATCH 1/4] Copy ITCM data for user code Gets some basic usage working at least --- 32blit-stm32/startup_user.s | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/32blit-stm32/startup_user.s b/32blit-stm32/startup_user.s index 75cb8dbad..ba2915cbd 100644 --- a/32blit-stm32/startup_user.s +++ b/32blit-stm32/startup_user.s @@ -76,6 +76,23 @@ LoopCopyDataInit: cmp r2, r3 bcc CopyDataInit +// Copy ITCM + movs r1, #0 + b LoopCopyITCMInit +CopyITCMInit: + ldr r3, =itcm_data + add r3, r4 + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyITCMInit: + ldr r0, =itcm_text_start + ldr r3, =itcm_text_end + adds r2, r0, r1 + cmp r2, r3 + bcc CopyITCMInit + ldr r2, =_sbss b LoopFillZerobss @@ -124,4 +141,4 @@ g_pfnVectors: .weak init .thumb_set init,main -*/ \ No newline at end of file +*/ From 6ca43a441ff19f00613562c707b0d7331c22d2ac Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Tue, 7 Dec 2021 15:08:25 +0000 Subject: [PATCH 2/4] Share ITCM between firmware/user Roughly 50/50 split. (4+28+2k/30k) --- 32blit-stm32/STM32H750VBTx.ld | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/32blit-stm32/STM32H750VBTx.ld b/32blit-stm32/STM32H750VBTx.ld index 7337150f3..c953f9696 100644 --- a/32blit-stm32/STM32H750VBTx.ld +++ b/32blit-stm32/STM32H750VBTx.ld @@ -50,7 +50,8 @@ FRAMEBUFFER (rw) : ORIGIN = 0x3000FC00, LENGTH = 225K RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K PERSIST (rw) : ORIGIN = 0x38800000, LENGTH = 4K ITCMISR (xrw) : ORIGIN = 0x00000000, LENGTH = 4K -ITCMRAM (xrw) : ORIGIN = 0x00001000, LENGTH = 58K +ITCMRAM (xrw) : ORIGIN = DEFINED(FLASH_TARGET_INT) ? 0x00001000 : 0x00008000, + LENGTH = DEFINED(FLASH_TARGET_INT) ? 28K : 30K MAIN_RAM (xrw) : ORIGIN = DEFINED(FLASH_TARGET_INT) ? 0x30000000 : 0x24000000, LENGTH = DEFINED(FLASH_TARGET_INT) ? 63K : 362K From 927befd6ec22a108ff7bb9cabec564021303b2de Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Tue, 7 Dec 2021 15:25:18 +0000 Subject: [PATCH 3/4] Merge more sections into ITCM Stuff like .itcm.some_func, so we can have working --gc-sections --- 32blit-stm32/STM32H750VBTx.ld | 1 + 1 file changed, 1 insertion(+) diff --git a/32blit-stm32/STM32H750VBTx.ld b/32blit-stm32/STM32H750VBTx.ld index c953f9696..86f9fa6c0 100644 --- a/32blit-stm32/STM32H750VBTx.ld +++ b/32blit-stm32/STM32H750VBTx.ld @@ -186,6 +186,7 @@ SECTIONS . = ALIGN(4); itcm_text_start = .; *(.itcm) /* ITCM code section */ + *(.itcm*) . = ALIGN(4); itcm_text_end = .; } >ITCMRAM AT> FLASH From c95c82d2c9ea7bb55d988d1246ba79825b3a6b3a Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Tue, 7 Dec 2021 16:05:59 +0000 Subject: [PATCH 4/4] Add some "fast code" macros Inspired by the "not in flash" macros from the pico sdk (and the pico support uses those) --- 32blit/32blit.hpp | 1 + 32blit/engine/fast_code.hpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 32blit/engine/fast_code.hpp diff --git a/32blit/32blit.hpp b/32blit/32blit.hpp index df342da9c..b68c3b0c1 100644 --- a/32blit/32blit.hpp +++ b/32blit/32blit.hpp @@ -4,6 +4,7 @@ #include "audio/mp3-stream.hpp" #include "engine/api.hpp" #include "engine/engine.hpp" +#include "engine/fast_code.hpp" #include "engine/file.hpp" #include "engine/input.hpp" #include "engine/menu.hpp" diff --git a/32blit/engine/fast_code.hpp b/32blit/engine/fast_code.hpp new file mode 100644 index 000000000..9b6b0bf71 --- /dev/null +++ b/32blit/engine/fast_code.hpp @@ -0,0 +1,14 @@ +#pragma once + +#ifdef TARGET_32BLIT_HW +#define blit_fast_code(fn) __attribute__((section(".itcm." #fn))) fn +#define blit_no_inline_fast_code(fn) __attribute__((noinline)) blit_fast_code(fn) +#elif defined(PICO_BUILD) +#include + +#define blit_fast_code(fn) __not_in_flash_func(fn) +#define blit_no_inline_fast_code(fn) __no_inline_not_in_flash_func(fn) +#else +#define blit_fast_code(fn) fn +#define blit_no_inline_fast_code(fn) fn +#endif