Intel hex format and position-independent code using gcc

I'm not sure if this is specific to the processor that I use, so why am I using Cortex M0 +. I was wondering: if I create a hex file through gcc using -fPIC, I create ... Position Independent Code. However, the hex hex file format that I get from objcopy always has the address information in each line header. If I try to write a bootloader, I just ignore this information, skip the bytes associated with it and load the actual code into memory wherever I want, or do I need to track it somehow?

+7
arm bootloader
source share
1 answer

The intel-HEX format was specifically developed for software PROM, EPROMS, or processors with internal EPROM and is commonly used with programmers for these devices. Addresses at the beginning of entries have nothing to do with program code. They indicate at which PROM address the data will be written. Remember also that PROM can be displayed anywhere in the address space of the processor, so the final address can change in any case.

Until you want to program the PROM, you must delete anything other than the data from the records. (Do not forget the checksum at the end ;-)

Since I understand the intel-HEX format, records should not be contiguous, there may be gaps between them.

Some notes:

The -f PIC option is not responsible for the intel-HEX format. I think somewhere in your command lines you will find -O ihex. If you want to have a file that can be executed, objcopy provides more suitable output formats.

As long as you do not write the earlier steps of the boot process yourself, you do not load the bootloader - it will be downloaded for you. The address at which this happens is usually fixed and does not change. Therefore, there is no need for a position-independent code, but that won't hurt either.

+1
source share

All Articles