STM32L152RE application shifted to new address results in hardfault FORCED on startup with debugger
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 */
} > FLASHin system32_stm32l1xx.c
#define VECT_TAB_OFFSET 0x40200Ubut systemInit does not get called so I suppose the problem is in my linkerfile.
