Purpose
I want my build system to produce one binary file that includes:
- The bootloader
- The application binary
- The application header (for the bootloader)
Here's a small overview of the memory layout (nothing out of the ordinary here)
The build system already concatenates the bootloader and the application in a post-compilation script.
In other words, only the header is missing.
Problem
What's the best way to generate and inject the application header in the memory?
Possible solutions
- Create a .bin file just for the header and use
cat
to inject it in my final binary - Use linker file to hardcode the header (is this possible?)
- Use a script to read the final binary and hardcode the header
- Other?
What is the best solution for injecting data in memory in a post compilation script?
SRecord is a great tool for doing all kinds of manipulation on binary and other file types used for embedded code images.
In this case, given a binary bootheader.bin to insert at offset 0x8000 in image.bin:
The tool is somewhat arcane, but the documentaton includes numerous examples covering various common tasks.