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

Applying Software Updates - Run-time Dynamic Linking

I'm working with the ARM7 LPC2178. I would like to be able to send updates to the microcontroller over one of the UARTs. So my plan was to have a small main loop of code that calls several other independent libraries. Then if a library was updated it could receive the new library over the UART and save the file to the flash. Then it would link to the new library instead of the old one.

I'm pretty new to embedded-C, and I'm not sure if what I'm doing is even possible without an OS. On Windows you would create a DLL and use run-time dynamic linking functions in the <windows.h> header to start using the new library instead of the old one. On Linux or POSIX I would use the <dlfcn.h> header to link in a new ".so" library file.

To do it on the ARM7 without an OS I was thinking I could save a file containing the addresses of the library functions to a file and then use that to create function pointers. Then the main loop could use those function pointers to do all of the work it does.

Then when an update comes I just have to save it to flash. Then determine what chunks of the file need to be put in what region of memory (Code, RO, RW, ZI), and use something like memcpy to put the data where it belongs. Then determine the address of the function(s) in the code and replace the function pointers with the new addresses. And finally save the new function pointers to the file containing the addresses of the library functions, so that the new library is used on startup.

Does any of this sound possible? Are their any tools that can do any of this for me? Would it work even if I figured out what region of memory everything needed to be in or is it not possible?

Also would GCC be better suited for this than Keil? If I understand correctly ".elf" files contain a header with all the information about memory regions and function addresses.

0