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

Change load region at runtime

Hi All,

I am implementing a software upgrade mechanism (burning a new image into a flash memory area).

The problem:
I don't know how to change the load region address at runtime.

Flash contains booter and application
Additionally I allocated an area for new sw application on the same flash.
After burning the new sw into the allocated area on the flash,
I want to run the new sw instead of the old one.

Booter already knows how to jump to the new code in the flash.
The problem is that new and old code are both compiled with the same
scatter loading region mapping, so when i run the new code
from the new address it still uses the "old" scatter loading region,
i.e. it loads my old code.

Is there a way of setting the LR address to be relative and not absolute.

Of course i can compile the new SW with new scatter mapping, but this doesn't help me, because i don't know if it will run as a "new" or "old" image.

Thanks in advance

Parents
  • You'd need to use an object file format with relocation information. ELF (AXF) has such a format, but you might want to create your own minimally complicated version.

    This is basic linker/loader stuff, should be covered in college level classes.

    For Cortex-Mx implementations the biggest issue is absolute addresses in the Vector Table, if the rest of your code is Position-Independent, then you just need to fix up the vectors as you write to a new memory area.

Reply
  • You'd need to use an object file format with relocation information. ELF (AXF) has such a format, but you might want to create your own minimally complicated version.

    This is basic linker/loader stuff, should be covered in college level classes.

    For Cortex-Mx implementations the biggest issue is absolute addresses in the Vector Table, if the rest of your code is Position-Independent, then you just need to fix up the vectors as you write to a new memory area.

Children