This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Append / Link a .bin blob to own .bin in make-/linker-file

I need to append another binary-file (image.bin) to the generated bin-file from my own nRF makefile Project in Eclipse with Cross ARM GCC. My research showed me several possibilities how to do this, but none did work out for me:

  1. ld -r -b binary -o image1.o image1.bin: this creates a "elf32-little" object file (like all the other generated .o-files in this project) which can be added to the list of .o-files to be used: OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS) image1.o. The macros generated during the progress to refer to the image in my program (_binary_image_bin_end, _binary_image_bin_start,_binary_image_bin_size) are declared as extern in my program and their value will be printed for control. The symbol table is put in the .data section. The problem is, that the image is loaded completely into RAM, which leads to linker errors, because it's too big.
  2. objcopy --rename-section .data=external_image,alloc,load,readonly,data,contents -I binary -O elf32-little image.bin image.o: this creates also an "elf32-little" object file, but www.devever.net/.../incbin says, that you can change the section where the data will be placed by renaming the section. The macros generated are the same as above. When refering to them in my program I get the linker error "unknown architecture of input file `image.o' is incompatible with arm".
  3. Create a section in the linker-file that used an .o-file as input (sorry about the formatting, I cannot make it work correctly): SECTIONS { .external_image ALIGN(4): { PROVIDE(__start_image = .); image.o PROVIDE(__end_image = .); } > FLASH }INSERT AFTER .text;

(I found this implementation at mcuoneclipse.com/.../) If I use an .o-file created with objcopy, a compatibility error comes again, and with the generated file by ld, the creating of the section works. The problem then is, that the .o-file is not inserted and the section stays empty. Only the macros for start and end are created.

Related