Adding raw binary file to project

Asked by Mateusz

I have 2 separate projects: bootloader and application.

While building bootloader project I've added the following line in post-build steps in Eclipse:
arm-none-eabi-objcopy -S -O binary "${ProjName}.elf" "${ProjName}.bin", so *.bin file was created.

Now, in the application project, I'd like to add this *.bin at specified addresses in order to produce one *.hex/*elf file.

Can arm-none-eabi-objcopy be used for this purpose?
Or is there linker command that could add *.bin file to *.o files during linking?

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Mateusz
Solved:
Last query:
Last reply:
Revision history for this message
Marc Singer (eleventen) said :
#1

I have done something similar in my projects. There used to be a bug/feature of binutils that prevented clean linkage of imported blobs. It's possible that this has changed in the n-years since I last tried doing this.

What I did instead was to modify the project build to convert the blobs to C files, compile them, and then link them as objects. Doing so meant it was easy to capitalize on named linker segments to organize this data.

So, while there are switches and apparent features in objcopy for handling what you (we) want to do, I found that the build was more predictable when I made the conversion step first.

FWIW IIRC, the original barrier to smooth integration of blobs using objcopy was that the linker complained that the imported blob had an invalid type. It was something in the ARM identifiers for program segments.

E.g.

#pragma GCC optimize ("O0")
static const unsigned char data[] __attribute__((section(".blobs"))) = {
 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
...
 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x34,
 0x35, 0x00, 0xb8, 0xed,
};

Revision history for this message
Mateusz (mateusz-kaskow) said :
#2

Hi,
thanks for hint.
At the moment I decided to another approach, which is OK for me:
1. I have 2 separate projects: bootloader and application.
2. While building bootloader, *.hex file is generated
3. While building application, *.hex file is generated
4. External tool, that combine these *.hex files into one *.hex file is used.

Revision history for this message
Mateusz (mateusz-kaskow) said :
#3

Hi,
thanks for hint.
At the moment I decided to another approach, which is OK for me:
1. I have 2 separate projects: bootloader and application.
2. While building bootloader, *.hex file is generated
3. While building application, *.hex file is generated
4. External tool, that combine these *.hex files into one *.hex file is used.