0
votes

I have built firmware for stm32f4, so I have *.elf an *.bin files. If I load *.bin file into internal flash it runs correctly. But if I want load this firmware to another address different from default (0x08000000) and run it from my bootloader, of course it does not works. I fix memory area address in project settings (I use CooCox 1.7.6 if it matter) and it begins runing from the bootloader.

I don't want rebuild project every time I load firmware in standalone mode or using bootloader. So I'm looking for method that will allow me to make *.bin files from *.elf, which will be able to load from the different addresses.

I tried manualy interupt vector table fixing. It allow me to run small blinker project but it doesn't work for more complex projects. I must be missing something.

Then I tried objcopy with --change-addresses but unfortunately it doesn't work. I get the same file without any difference.

I think, it is a general problem and there are solution for it but I must be missing something important.

Any help would be appreciated!

2
If I had a nickel for every time we answered this question. Please see all the prior answers to this question...What you are looking for is position independent code PIC -fpic or some such option if you are using gcc, and there is work on your part to repopulate/adjust the global table once relocated. or you could just link for the correct address and not have to deal with it...old_timer
@old_timer Thank you for your reply!Konstantin T.
That would be a tough to do that. It would be more of making sure any interrupts and jumps are well taken care of. I would suggest to look at some other similar answers here.Dheeraj Kumar
What is the point?0___________
@old_timerit will not work I afraid. Library functions are not relocable and you need different startup codes. I do not see the reason of it.0___________

2 Answers

1
votes

You have to compile your code as position independent. See the -fpic and -fPIC options of gcc. Or you need a loader that understands the relocation table of the ELF image.

-1
votes

I do not think so that would work well in your case because when you are compiling the file to run with boot loader, you also needs to make sure that Interrupt vector also have been moved to the new location else there will be a problem in executing some of the functions.