diff --git a/32blit-stm32/STM32H750VBTx.ld b/32blit-stm32/STM32H750VBTx.ld index 7337150f3..86f9fa6c0 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 @@ -185,6 +186,7 @@ SECTIONS . = ALIGN(4); itcm_text_start = .; *(.itcm) /* ITCM code section */ + *(.itcm*) . = ALIGN(4); itcm_text_end = .; } >ITCMRAM AT> FLASH 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 +*/ 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