2009-03-31 04:54 AM
STM32 code relocation
2011-05-17 04:07 AM
I'm designing a application downloader that can be run from the main application. The mechanism I want to employ would be to load a replacement application into a secondary ''bank'' of flash and then do a soft reboot into that region without having to copy it into the normal running location. Does this chip have a mechanism that would allow me to do this, I'm assuming that the Interupt vector table would have to move also. Also would the compiler produce relocatable code using relative instead of fixed location jumps?
2011-05-17 04:07 AM
Hi Mark,
I'm not aware you can produce relocatable code using relative instead of fixed location jumps. Even if you could it might have a big impact on performance The way I do this is to store the new app external (serial Flash or SD card etc) and once I have it stored and validated I reset where my bootloader loads it into the application area nd runs it. You could take the same approach but store your new app in an area of internal flash and then get your bootloader to detect it and copy it into the application area before jumping to it. This way the app you are going to run always lives at the same address. Trevor2011-05-17 04:07 AM
Hi Trevor
Unfortunately I only have the flash area to play with, I can, given enough space, use three images in the flash, and move them around allowing the state changes I need. But I'm trying to avoid this for reasons of room and speed. Thanks for your advice. Mark2011-05-17 04:07 AM
Mark,
There is no extra space requirement or external memory requirement. With both methods you can have two apps stored at one time. You have an app and you store a new app above it and once you know you have it all correct you reset and let your bootloader copy the new app over the old one. The bootloader then ''marks'' the new app as deleted (by just zeroing one byte or something). See below I agree there is some extra time spent copying the new app over the old one but would be quite quick. ------------ | bootloader | |------------| | | | app | | | |------------| | | | new app | | | ------------2011-05-17 04:07 AM
Trevor
I have a similar thread running on the Keil forum and have been told I can do this, if I inform the compiler to produce position-independent code and I map the interrupt vectors into RAM. Them I can just jump to the relocated code and it should work. Do you think this is posible? Mark2011-05-17 04:07 AM
Hi Mark,
I can't say either way as I've never tried this. If someone on the other forum thinks it is possible then I have no reason not to believe this. If you try please let us know how you get on. Regards Trevor2011-05-17 04:07 AM
I will, but first I need to understand how the interupt vectors work and where they are normally located, what is the best reference document for this?
2011-05-17 04:07 AM
Trevor or anyone who knows
I have found a reference to ''NVIC vector table offset register'' will this do what I think it will do, i.e will it move the position of the vector table, giving me the ability to do what I need. I am still having problems finding any documentation on how this NVIC stuff works. Mark2011-05-17 04:07 AM
I've never tried this so I don't know, sorry.