Tool & Version: Arm Compiler for Embedded 6.21 (fromelf [5ec1f200]), Keil MDK
Background:
I have a scatter file with a FILL 0xFF region at a specific Flash address (0x6E70), intended to reserve space for a "keystore blob" that will be written by a post-build merge tool. The region must appear as all-0xFF in the output .bin file so the merge tool can verify the slot is blank before writing (Also incase if un-merged bin was mis-programmed into MCU, the firmware will not mis-read the previous programmed information).
LR_LOADER 0x00000000 0x00007000 { ER_CODE 0x00000000 0x00007000 { startup_M2L31.o (RESET, +First) .ANY (+RO) } ER_KEYSTORE_BLANK 0x00006E70 FILL 0xFF 0x90 { } RW_IRAM1 0x20000000 0x00009800 { .ANY (+RW +ZI) } ER_RAMFUNC 0x20009800 0x00000800 { rmc.o (+RO) } }
Problem:
The FILL 0xFF region is correctly present in the .axf file — confirmed via fromelf --text -v, which shows:
Name : ER_KEYSTORE_BLANK Type : SHT_PROGBITS Addr : 0x00006e70
However, when converting to a flat binary with fromelf --bin, the output .bin is only ~13 KB. The ER_KEYSTORE_BLANK region (which is entirely 0xFF) is silently dropped from the output, because fromelf --bin trims trailing bytes that match the erased Flash state (0xFF).
Question:
Is there a fromelf command-line option that forces the output .bin to include all regions up to a specified end address, regardless of whether the trailing content is all 0xFF?
I reviewed the --help output (which is minimal for this licensed edition) and tried --bincombined, but that is intended for merging multiple input images, not for controlling output padding.
Workarounds I am aware of but would prefer to avoid: - Post-processing the .bin with a Python script to pad to the target size - Using --i32 (Intel HEX) as an intermediate format and converting separately
Any official parameter or recommended approach would be appreciated.
Hello,
I _think_ the issue is that your ER_KEYSTORE_BLANK region is not at a fixed address, and so has a different LOAD address than EXECUTION address.
If you search the generated binary you will likely find it elsewhere. The scatterloading init code would then copy this to 0x6e70 at startup.
Try adding FIXED to the definition of this section:
ER_KEYSTORE_BLANK 0x00006E70 FIXED FILL 0xFF 0x90 {}