5 years, 9 months ago.

Reducing mbed rtos footprint to smallest size possible

Using the Mbed-cli, how can I tell the linker to only include code that is actually used. ie. I wan't to see how small of a footprint I can produce using mbed and the rtos.

thanks

1 Answer

5 years, 9 months ago.

Hello Kevin,

You can take a look at these blog posts:

https://os.mbed.com/blog/entry/Optimizing-memory-usage-in-mbed-OS-52/

https://os.mbed.com/blog/entry/Reducing-memory-usage-by-tuning-RTOS-con/

They offer several steps you can take to optimize your memory usage. Hope this helps!

-Karen, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

Ok, I think I have followed these threads. It appears that some of the optimizations come from just using a later version of mbed. I'm currently on the latest mbed 5.9. And I created an mbed_app.json file with the following configuration: ``` { "macros": [ "NDEBUG=1" ], "target_overrides": { "*": { "platform.stdio-flush-at-exit": false } } } ```

Here is the before and after results on a simple blink program. ``` +----+-+-++

Module.text.data.bss

+----+-+-++

[fill]108017
[lib]/c.a24793247289
[lib]/gcc.a311200
[lib]/misc2081228
mbed-os/drivers1924100
mbed-os/features108488
mbed-os/hal1707468
mbed-os/platform2834264221
mbed-os/rtos103941686073
mbed-os/targets86224744
src/main.o60428
Subtotals5213829367456

+----+-+-++ Total Static RAM memory (data + bss): 10392 bytes Total Flash memory (text + data): 55074 bytes

+----+-+-++

Module.text.data.bss

+----+-+-++

[fill]104014
[lib]/c.a15851247256
[lib]/gcc.a311200
[lib]/misc2081228
mbed-os/drivers1364100
mbed-os/features108488
mbed-os/hal1406468
mbed-os/platform14998213
mbed-os/rtos100171686073
mbed-os/targets81154744
src/main.o60428
Subtotals4061626807412

+----+-+-++ Total Static RAM memory (data + bss): 10092 bytes Total Flash memory (text + data): 43296 bytes ```

Should I be able to do better than this?

posted by Kevin McQuown 03 Jul 2018

Have you tried this configuration for the mbed_app.json?

{
    "macros": [
        "NDEBUG=1",
        "OS_TASKCNT=1",
        "OS_IDLESTKSIZE=32",
        "OS_STKSIZE=1",
        "OS_TIMERS=0",
        "OS_FIFOSZ=4",
        "OS_MUTEXCNT=1"
    ],
    "target_overrides": {
        "*": {
            "platform.stdio-flush-at-exit": false
        }
    }
}
posted by Karen Yen 05 Jul 2018