Change application on Reset !
Hi !
I have 2 binary files for 2 different function/application, in bank 1 and 2 (of my STM32L072CZ). On reset I want to change from bank 1 to bank 2 (so change to Application 2). I see that I need to use a magic value in ram and have the reset handler in the loader recognize that and immediately transfer control to the application !
So I add in my .c :
‘’__ATEerror_t AT_Switch(const char *param)
{
AT_PRINTF(“SWITCH”);
- ((unsigned long *)0x20000270) = 0xFEED0002; // Address RAM STM32L072
NVIC_SystemReset(); // Start APP2
return AT_OK;
}’’
Store a value in RAM (RAM is not cleared over a reset) and call a soft reset !
Does anyone know how to modify the startup .s file in order to make this happen ?
For the moment, I do this but without success :
Reset_Handler:
ldr r0, =_estack
ldr r4, =0x20000000 //load value stored in .c
ldr r5, r4, #0 //charge la valeur a ladresse r4 dans r5 sans offset
str r4, r4, #0 //invalidate
ldr r6, =0xFEED0001 //to compare
ldr r7, =0x08019F40 //APP2_FLASH
mov sp, r0 //set stack pointer
/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
cmp r5, r6 //compare value from .c (store in RAM) to r7
mov sp, r7 //if magic value in RAM = r7, we change sp to APP2_FLASH
b LoopCopyDataInit
Regards