... I need to insert a text header at the start of the hex file with things like version information ...
Without using an external tool, this might be hard to do. However, you could try these steps:
1. Store version info in the program memory with a fixed address, for example,
#define VERSION_NUMBER 0x11223344
const uint32_t __attribute__((space(prog), address(0x9D001000), keep)) version = VERSION_NUMBER;
2. Extract 1D00_1000 - 1D00_1003 from the application hex file and append the hex content to the beginning of the application hex file itself.
- Post-build command
hexmate r1D001000-1D001003,%1 -Oversion.hex
copy version.hex + %1 app_with_version.hex
:020000041D00DD <-- 1D00_1000: 0x11223344
:00000001FF <---- EOF
:00000001FF <--- EOF
The problem is that this hex file contains two type 1 EOF records. Would that confuse your installer or bootloader?