2026-05-04 10:38 AM - edited 2026-05-04 10:38 AM
Heyho,
I recently started using ITCM SRAM in my H733 project, functions there working well.
Then I thought that it might make sense to also copy the vector table and some interrupt handlers to ITCM.
And this for the custom bootloader (BL) and the application.
... and now I have some strange effect when jumping back and forth:
I'm basically using the same functions with different addresses, and in main also doing the same at start: copying the vector table to ITCM
.... and now that I almost completed this post, I found that I moved the SysTick init after the peripheral clock init in the bootloader, and this uses the SysTick. Oh my... nothing to do with ITCM.
Always good to write things down! :D
Thanks anyway!
2026-05-04 10:19 PM
At least I can show how simple it is to get the vector table into ITCM RAM:
in linker script I "split" the ITCM for vector table, functions, and heap & stack (amazing that this is working!):
ITCMRAMVEC (xrw) : ORIGIN = 0x00000000, LENGTH = 1K /* instruction RAM - vector table */
ITCMRAM (xrw) : ORIGIN = 0x00000400, LENGTH = 31K /* instruction RAM */
ITCM_HPST(xrw) : ORIGIN = 0x00008000, LENGTH = 32K /* ITCM heap & stack */
...
/* ITCM_RAM VECTOR TABLE section */
.ItcmVecSection (NOLOAD):
{
. = ALIGN(8);
*(.ItcmVecSection)
*(.ItcmVecSection*)
. = ALIGN(8);
} >ITCMRAMVEC
Then simple using an attribute for an array and copying.
Not sure about the size, though, I guess there's something more elegant than simply using VECTOR_TABLE_SIZE.
#define __ATT_SECT_ITCM_VECT __attribute__((section(".ItcmVecSection")))
...
#define VECTOR_TABLE_SIZE 768UL
...
/* vector table in ITCM SRAM
* to reduce interrupt access time
*/
__ATT_SECT_ITCM_VECT uint8_t u8NewVectorTable[VECTOR_TABLE_SIZE];
...
first thing in main:
SCB->VTOR = FLASH_INT_ADDR_START | FLASH_INT_ADDR_OFFS_BOOT_VECT;
uint8_t *pu8OrigVectorTable = (uint8_t *)SCB->VTOR;
/* copy vector table from flash to ITCM */
for( uint32_t i = 0; i < (uint32_t)sizeof(u8NewVectorTable); i++ ) u8NewVectorTable[i] = pu8OrigVectorTable[i];
/* set the new interrupt vector table */
SCB->VTOR = (uint32_t)&u8NewVectorTable[0];
Works well in real liefe for bootloader and application, yet: anything wrong with that stuff ?