Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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] | 108 | 0 | 17 |
[lib]/c.a | 24793 | 2472 | 89 |
[lib]/gcc.a | 3112 | 0 | 0 |
[lib]/misc | 208 | 12 | 28 |
mbed-os/drivers | 192 | 4 | 100 |
mbed-os/features | 108 | 4 | 88 |
mbed-os/hal | 1707 | 4 | 68 |
mbed-os/platform | 2834 | 264 | 221 |
mbed-os/rtos | 10394 | 168 | 6073 |
mbed-os/targets | 8622 | 4 | 744 |
src/main.o | 60 | 4 | 28 |
Subtotals | 52138 | 2936 | 7456 |
+----+-+-++
Total Static RAM memory (data + bss): 10392 bytes
Total Flash memory (text + data): 55074 bytes
+----+-+-++
Module | .text | .data | .bss |
+----+-+-++
[fill] | 104 | 0 | 14 |
[lib]/c.a | 15851 | 2472 | 56 |
[lib]/gcc.a | 3112 | 0 | 0 |
[lib]/misc | 208 | 12 | 28 |
mbed-os/drivers | 136 | 4 | 100 |
mbed-os/features | 108 | 4 | 88 |
mbed-os/hal | 1406 | 4 | 68 |
mbed-os/platform | 1499 | 8 | 213 |
mbed-os/rtos | 10017 | 168 | 6073 |
mbed-os/targets | 8115 | 4 | 744 |
src/main.o | 60 | 4 | 28 |
Subtotals | 40616 | 2680 | 7412 |
+----+-+-++
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 03 Jul 2018