Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


You are viewing a reply to Change application on Reset !  

Change application on Reset !

Hi Tarek,

Yes, each applications have its Reset Handler, but maybe this is not the way to do this, if you can help me on this it’s will be cool.

Regards

Tunisia

In that case, this could be a solution :

SwapApp:
  ldr r0, =0x08019F40
  bx  r0

Reset_Handler:  
  /* boot swap management */
  ldr r0, =0x20000270
  ldr r1, =0xFEED0001
  ldr r2, [r0]
  cmp r1, r2
  bne SwapApp
  /* end of boot swap management */

  ldr   sp, =_estack      /* set stack pointer */
  ........

So, if I follow what’s you saids, I don’t need to touch to SP et PC ?


I try with your code, but without success, or only half !

When I do a Reset, I switch from App1 to App2 but afterthe program loop in main of App2..

Tunisia

I’ve tested the solution without issues.
So, I will share with you a complete example tomorrow :-)

Thanks Tarek because I didn’t see the issue here..
Tunisia

Look, while driving home, I have remembered that STM32L072CZ has dual bank boot capability, so this could be achieved by changing dynamically the the BFB2 option bit.
This could be a cutting edge solution !

Back to the first one, the pb could be that we jumbed directly to the App2’ main.
So, could you verify that 0x08019F40 is really the App2 Reset Handler Address ?

App2 address is now 0x08018000 (not 0x08019F40), and 0x08018000 it’s first address of bank 1.

From .map file :

.text.Reset_Handler
0x08023534 0x50 Projects/SW4STM32/startup_stm32l072xx.o
0x08023534 Reset_Handler

So we need to jump to 0x08023534, in order to init memory, system and go to main.

Tunisia

In that case :

SwapApp:
  ldr r0, =0x08023534
  bx  r0

Reset_Handler:  
  /* boot swap management */
  ldr r0, =0x20000270
  ldr r1, =0xFEED0001
  ldr r2, [r0]
  cmp r1, r2
  bne SwapApp
  /* end of boot swap management */

  ldr   sp, =_estack      /* set stack pointer */
  ........

In cortex M0+ it’s not BNE but BEQ

-> Suffix : EQ Flags : Z = 1 Meaning : Equal, last flag setting result was zero.

From The STM32L0 Cortex-M0+ instruction set :-)

So made this :

/* boot swap management */

ldr r4, =0x20000000 //load address of the value stored in .c
ldrb r5, r4 //load in r5 value stored in .c
ldr r6, =0xFEED0001 //to compare
cmp r5, r6 //compare value from .c (store in RAM) to r6 (fixed value)
beq SwapApp //if equal Reboot from App2
/* end of boot swap management */


ldr r0, =_estack
mov sp, r0 /* set stack pointer */
/* Copy the data segment initializers from flash to SRAM */
movs r1, #0

b LoopCopyDataInit

SwapApp:
ldr r0, =0x08023534
bx r0