Hi,
I assume you are building "Debug_FLASH" build configuration which is basically creating ROM image of your application. There should not be any content in your binary file in RAM - since after power on reset such a RAM section is not initialized.
If a binary file (ROM image) contains a block of data placed into RAM - this creates huge gap since RAM starts around at 0x2000_0000 whereas FLASH memory block starts at 0x0000_0000.
A Raw Binary file is continuous memory block and the gaps are filled with a dummy values.
This is possibly the reason why your raw binary file is so big.
I'd recommend you to check the s-record file and search for RAM addresses. If your s-record contains a RAM address try to match this address with a linker section that is responsible for this.
Seems in your case the section responsible for the gap is ".CustomSectionBlock".
The solution is to change the load address of this block and place it into FLASH.
.CustomSectionBlock : AT(ROM Address)
where "ROM Address" is address in rom where image of this ram section should be placed.
Typically it is the first free address in FLASH after all ROM sections (.text, rodata,...)
Could you possibly post your .ld file and .map file if it does not help.
Regards,
Stan