2021-06-23 02:09 AM
I'm trying to implement a bootloader for my application and need to shift my application to a higher address. I've updated the linker script such that the application starts at address 0x08040200 and this seems to work. However, when I start debugging the application and the startup script tries to jump to systemInit it returns a hardfault (FORCED -> [STKERR, IMPRECISERR])
I've taken the basic cubeMX project and made following changes:
linker:
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20001000, LENGTH = 76K
FLASH (rx) : ORIGIN = 0x8040200, LENGTH = 192K
}
...
after .data
/* Extra ROM section (last one) to make sure the binary size is a multiple of the AES block size (16 bytes) */
.align16 :
{
. = . + 1; /* _edata=. is aligned on 8 bytes so could be aligned on 16 bytes: add 1 byte gap */
. = ALIGN(16) - 1; /* increment the location counter until next 16 bytes aligned address (-1 byte) */
BYTE(0); /* allocate 1 byte (value is 0) to be a multiple of 16 bytes */
} > FLASH
in system32_stm32l1xx.c
#define VECT_TAB_OFFSET 0x40200U
but systemInit does not get called so I suppose the problem is in my linkerfile.
Solved! Go to Solution.
2021-07-15 05:51 AM
After some debugging I found out the stack pointer was not properly in the startup script (generated by cubeMX). This was no problem when running at address 0x0800 0000 but after shifting the whole application, this line needed to be added in the script:
Reset_Handler:
ldr sp, =_estack /* add this to startup script */
/* Copy the data segment initializers from flash to SRAM */
...
2021-07-15 05:51 AM
After some debugging I found out the stack pointer was not properly in the startup script (generated by cubeMX). This was no problem when running at address 0x0800 0000 but after shifting the whole application, this line needed to be added in the script:
Reset_Handler:
ldr sp, =_estack /* add this to startup script */
/* Copy the data segment initializers from flash to SRAM */
...