Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running multiple applications in STM32 flash

Tags:

embedded

stm32

I would like to have two applications in my STM32 flash, one is basically a boot and the other the 'main' application. I have figured out how to load each of them into different areas of flash, and after taking a memory dump everything looks like it is in the right place.

So when I do a reset it loads the boot, all the boot does at the moment is jump to the application. Debugging the boot, this all appears to work correctly. However the problems arrives after i've made the jump to the application, it just executes one instruction (assembly) and then jumps back to the boot. It should stay in the application indefinitely.

My question is then, where should I 'jump' to in the app?

It seems that there are a few potential spots, such as the interrupt vectors, the reset handler, the main function of the app. Actually I've tried all of those with no success.

Hopefully that makes sense, i'll update the question if not.

thanks for your help! Richard

Updates:

  • I had a play around in the debugger and manually changed the program counter to the main of the application, and well that worked a charm, so it makes me think there is something wrong with my jump, why doesn't the program counter keep going after the jump?
  • Actually it seems to be the PSR, the 'T' gets reset on the jump, if I set that again after the jump it continues on with the app as I desire
  • Ok found a solution, seems that you need to have the PC LSB set to 1 when you do a branch or it falls into the 'ARM' mode (32 bit instruction instead of 16 bit instructions like in the 'thumb' mode. Quite an obscure little problem, thanks for letting me share it with you!
like image 689
Richard Avatar asked Oct 19 '08 09:10

Richard


2 Answers

Make sure you jump to an address where the LSB is 1. See this site for an explanation: https://www.embedded.com/introduction-to-arm-thumb/

like image 154
Richard Avatar answered Oct 19 '22 10:10

Richard


You might want to search for the IAP (In-application programmer) it allows you to bootload code from the RS232 psort on the stm32. I started using and since it provides the source code, it is very simple to modify it for your purposes. basically after a reset you can code the IAP to bootload either from say address 0x08002000 or address 0x08003000. then all you have to do is set a flag in your application code then say restart and the new application will then run I hope this helps.

like image 39
jramirez Avatar answered Oct 19 '22 09:10

jramirez