Skip to content

GCC_ARM compiler reports wrong code size #972

Open
@zhiyong-ft

Description

@zhiyong-ft

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions