This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can I relocate code

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?

Parents Reply Children
  • You either inform your compiler to generate position-independent code. Or you create two targets - one for application area A and one for application area B.

    I don't work with your specific processor, but I would guess it has a mapping to move the interrupt vectors into RAM. Your two applications will then be responsible to copy their vectors into this RAM region before switching the mapping and activating interrupts.

  • could I change the interrupt vectors to secondary loads ISRs. I assume the vectors are at the top of the code, I could back them up, copy them from the secondary top to the primary with an added offset then just jump to the new image? If it fails then here would be a reboot and I could get the boot loader to re-configure the vectors back. How does that sound?

  • Look at the description of the vector table for your specific processor. But if the processor can map the vectors to RAM (which I believe it can) then the two applications can copy the vector table from their flash region and into this RAM region.

    If you get a watchdog reset (provided you let your boot loader activate the boot loader and configured it for resetting the processor), you will arrive back into your boot loader again and the boot loader may then decide to start the other application.