This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
manual:ports:armcm3_stm32f2 [2019/09/24 22:12] 127.0.0.1 external edit |
manual:ports:armcm3_stm32f2 [2021/09/02 10:43] voorburg [Vector table location] |
||
---|---|---|---|
Line 14: | Line 14: | ||
In case you want to manually change the size of the bootloader, make sure the size is aligned to the sectors as outlined in the flashLayout[] array in file flash.c. For the STM32F2xx targets, the first sector is 0x4000 (16 kbyte) in size, which is also the smallest erase size of the flash memory. This means that even though a bootloader, configured to just use one communication interface, can fit in about 6 kbyte, on STM32F2xx targets the minimal bootloader size is still 16 kbyte. | In case you want to manually change the size of the bootloader, make sure the size is aligned to the sectors as outlined in the flashLayout[] array in file flash.c. For the STM32F2xx targets, the first sector is 0x4000 (16 kbyte) in size, which is also the smallest erase size of the flash memory. This means that even though a bootloader, configured to just use one communication interface, can fit in about 6 kbyte, on STM32F2xx targets the minimal bootloader size is still 16 kbyte. | ||
- | Because the bootloader remaps the base address of the interrupt vector table, make sure that your program's initialization routine does not set it back to its original location. This is the case if you use function SystemInit() from ST's driver library. To correct this you need to remove the following lines from function SystemInit(): | + | Before the bootloader starts your firmware, it automatically reconfigured the start address of the interrupt vector table. Unfortunately, the default system initialization function SystemInit() from ST's driver library, overwrites this change. This function is implemented in source file system_stm32f2xx.c. To correct this you need to explicitly set the start address of the interrupt vector table as the first thing in function main(). Here is an example of how this can be done when using STM32CubeIDE: |
- | <code> | + | Add the following function to main.c: |
- | #ifdef VECT_TAB_SRAM | + | |
- | SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ | + | |
- | #else | + | |
- | SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ | + | |
- | #endif | + | |
- | </code> | + | |
+ | <code c> | ||
+ | static void VectorBase_Config(void) | ||
+ | { | ||
+ | /* The constant array with vectors of the vector table is declared externally in the | ||
+ | * c-startup code. | ||
+ | */ | ||
+ | extern const unsigned long g_pfnVectors[]; | ||
+ | |||
+ | /* Remap the vector table to where the vector table is located for this program. */ | ||
+ | SCB->VTOR = (unsigned long)&g_pfnVectors[0]; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | And call this newly added function at the start of main(): | ||
+ | |||
+ | <code c> | ||
+ | int main(void) | ||
+ | { | ||
+ | /* Configure the vector table base address. */ | ||
+ | VectorBase_Config(); | ||
+ | |||
+ | ... | ||
+ | |||
+ | } | ||
+ | </code> | ||
===== Checksum location ===== | ===== Checksum location ===== |