while trying to implement a bootloader on a custom F303CC I wanted to understand elf files and use this for flashing my uC to have more information about the addresses used etc.
platform = ststm32
board = robotdyn_blackpill_f303cc
framework = cmsis
Linker script is the default one provided by Cube.
To do so, I created a simple program in C# to generate a bin file out of elf and compare it to the bin generated during pio build.
For STM32, ROM sits at address 0x800 0000, and RAM at 0x200 0000.
But the bin file also contains the data section at location 0x200 0000.
The linker file also states for the data section:
/* Initialized data sections goes into RAM, load LMA copy after code */
Therefore init values need to be stored in flash.
So I added the section and my total flash size equals 5748 bytes including padding (see Total size in screenshot).
All headers from the elf file are also listed.
But in pio flash size is reported as:
RAM: [== ] 17.1% (used 7004 bytes from 40960 bytes)
Flash: [========= ] 87.0% (used 5344 bytes from 6144 bytes)
This behavior is similar with an arduino project on F303CC:
Checking size .pio\build\robotdyn_blackpill_f303cc\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [== ] 15.1% (used 6192 bytes from 40960 bytes)
Flash: [= ] 9.8% (used 25204 bytes from 256000 bytes)
Is this intentional? Or is it just an oversight and just a check for 0x8 memory addresses is done?
Which also does not fit the size used.