cancel
Showing results for 
Search instead for 
Did you mean: 

how to compile program using only relative jumps?

yagov
Associate II
Posted on April 15, 2010 at 06:42

how to compile program using only relative jumps?

4 REPLIES 4
mrost9
Associate II
Posted on May 17, 2011 at 13:47

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.

yagov
Associate II
Posted on May 17, 2011 at 13:47

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).
damh
Associate II
Posted on May 17, 2011 at 13:47

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.

yagov
Associate II
Posted on May 17, 2011 at 13:47

Very, very, very thanks!