How to control the size of compiler output file (.hex)

I am currently building a project for device R7FS5D97E3A01CFP, which has 2 MBytes of program flash. My initial code build has less than 30 KBytes of flash utilization, as indicated by this Berkely format size console output at the end of the build:


'Building target: Freebird_MAR2022.elf'
'Invoking: GNU Arm Cross C++ Linker'
arm-none-eabi-g++ @""
'Finished building target: Freebird_MAR2022.elf'
' '
'Invoking: GNU Arm Cross Create Flash Image'
arm-none-eabi-objcopy -O ihex --gap-fill 0xff "Freebird_MAR2022.elf" "Freebird_MAR2022.hex"
'Invoking: GNU Arm Cross Print Size'
arm-none-eabi-size --format=berkeley "Freebird_MAR2022.elf"
text data bss dec hex filename
28000 224 6696 34920 8868 Freebird_MAR2022.elf
'Finished building: Freebird_MAR2022.siz'
' '
'Finished building: Freebird_MAR2022.hex'

--------------------------end snip-----------------------------------------------------------------------------------------------

Here are my output settings:

The resulting .hex file ends up being 45.1 MB (47,306,526 bytes). Examining it tells me why - 0xFFs are extended across the entire 2 MBytes of flash space. If one is going to deploy field updates, this is unnecessary - the program file should end at the program flash limit. I can find no documentation from Renesas, but I think this fill option is controllable with the "Other flags" setting shown in the lower right highlighted part of the screenshot above. I tried setting this to "--gap 0xff" instead of "--gap-fil 0xff" with no change in hex output file size or content. Does anyone know how to cut the hex file off at the last line generated for real code space? Thanks in adance!

--gap-fill 0xff

Parents Reply Children
No Data