Can anyone shed light on why there is a discrepancy between what ‘mbed compile’ reports and what later goes in the bin (or elf) file?
Initially, I didn’t check the size of the .bin/.elf file and took what mbed reported as correct. However, when deploying+running i kept ending up in mbed_fault_handler with a Hard Fault for no reason. After some analysis, it turns out the mbed compile reported codesize is incorrect. The .bin/.elf data is much bigger. When loading, no error was generated by the STM flash loading tools (even though all the firmware couldn’t be loaded in flash). This led to the Hard fault.
Anyway, coming back to the mbed misreporting issue:
For an example project, mbed compile reports:
Total Static RAM memory (data + bss): 2544(+2544) bytes
Total Flash memory (text + data): 24512(+24512) bytes
However, analyzing the .bin (or elf) file:
ls -l example.bin
Reports: 31312 bytes
i.e. a difference of 4256 bytes
What is this the source of this difference?
Analyzing the .elf file it can be seen that the .text section contains the difference.
(.elf .text section is 31160 bytes, even though you would have expected something like 27056 bytes (24512+2544)).