ARMmbed/mbed-cli

GCC_ARM compiler reports wrong code size

zhiyong-ft opened this issue · 2 comments

Hi,
When I tried to down size an app from STM32F401RE to STM32F401RC, I noticed the code size reported by GCC_ARM is usually less than actual code size. For the following blinky code:

#include "mbed.h"

int main() {
    Watchdog &watchdog = Watchdog::get_instance();
    watchdog.start(30000);
    printf("system started\r\n");

    DigitalOut led(PA_5);

    while (1)
    {
        printf("%d: System running\r\n", time(NULL));
        led = !led;
        ThisThread::sleep_for(1000);
        watchdog.kick();
    }
}

Running the following command:

mbed compile -t gcc_arm -m nucleo_f401re --profile release

leads to output:

Total Static RAM memory (data + bss): 14320(+48) bytes
Total Flash memory (text + data): 52276(+9736) bytes

However, when I open the generated HEX file in STM32CubeProgrammer, the code size reported to be 0xD648 = 54856

In the actual app I am working on, the code size reported by GCC_ARM is usually 70+KB less than actual size, something like 200KB vs 300KB. As a result, I ended up with a small batch of PCB that I don't know what to do with.

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers.
Internal Jira reference: https://jira.arm.com/browse/IOTBTOOL-676

I had reported this recently, but could not fix it completely. ARMmbed/mbed-os#12541