2010-04-14 09:42 PM
how to compile program using only relative jumps?
2011-05-17 04:47 AM
The first thing the program contains, is the interrupt vector.
The interrupt vector already contains the stack pointer and pointers to your interrupt service routines.These pointers are absolute adresses already. Your copy algorithm needs to update each interrupt pointer with the new location. It would be easier to use the bootloader approach, where you have loader and program at fixed locations in the flash. There is an AppNote from ST that explains how to jump between the two locations. It's quite easy, as long as you don't intend to do a mass erase. You can erase and program the flash sector by sector, so you can update your program from the bootloader and the bootloader from your program.2011-05-17 04:47 AM
The interrupts will be turned off before the ''reprogramming'' - thank you for this remark.
I agree that the use of constan areas of program is a variant of decision of the problem. Another variant - write a loader part using assambler (and commands with relative jumps only).2011-05-17 04:47 AM
With GCC it is ''-fPIC'' for Position Indipendent Code. You have to change the data and absolute jumps (like interrupt table) yourself. The interrupt table (and the rest of Position Dependent Data) should be changed before writing it to flash. Otherwise you need to create the interrupt table in RAM and after every restart. If you correct them before flashing, you only have to change the interrupt table base address.
2011-05-17 04:47 AM
Very, very, very thanks!