Zephyr and the Memory Footprint: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
Do you want to use [https://zephyrproject.org/ Zephyr RTOS] on a Microcontroller with only a few bytes of Flash? Let's try it! | Do you want to use [https://zephyrproject.org/ Zephyr RTOS] on a Microcontroller with only a few bytes of Flash? Let's try it! | ||
On the [https://docs.zephyrproject.org/latest/guides/optimizations/footprint.html Optimizing for Footprint] doc site you will find some hints how to reduce the memory footprint. With this I could reduce the kernel to 6872 bytes | On the [https://docs.zephyrproject.org/latest/guides/optimizations/footprint.html Optimizing for Footprint] doc site you will find some hints how to reduce the memory footprint. | ||
Ok let's do it. I compiled the following application by using this configs: | |||
{| style="width: 100%;" | |||
| style="width: 50%; vertical-align:top;" | | |||
main.c: | |||
<syntaxhighlight lang="c"> | |||
void main (void) { | |||
uint32_t i = 0; | |||
// run the loop for ever | |||
while (true) { | |||
i++; | |||
} | |||
} | |||
</syntaxhighlight> | |||
| style="width: 50%; vertical-align:top;"| | |||
prj.conf: | |||
<syntaxhighlight lang="c"> | |||
# disable all peripherals | |||
CONFIG_GPIO=n | |||
CONFIG_SERIAL=n | |||
CONFIG_SPI=n | |||
CONFIG_I2C=n | |||
# disable the boot banner | |||
CONFIG_BOOT_BANNER=n | |||
#disable all debug and log messages | |||
CONFIG_DEBUG=n | |||
</syntaxhighlight> | |||
|} | |||
With this application and settings I could reduce the kernel to 6872 bytes: | |||
<syntaxhighlight lang="bash">west build -p auto -b <board name> </syntaxhighlight> | |||
<syntaxhighlight lang="sh"> | <syntaxhighlight lang="sh"> | ||
| Line 9: | Line 44: | ||
IDT_LIST: 56 B 2 KB 2.73% | IDT_LIST: 56 B 2 KB 2.73% | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Ok, this is just the kernel to have an idea how much flash it needs. You can analyze the memory usage from the rom/ram-report (for more details have a look at the Zephyr [https://docs.zephyrproject.org/latest/guides/optimizations/tools.html Optimization Tools]). | |||
But how much does a small hello world application need, for example? | But how much does a small hello world application need, for example? | ||
Revision as of 12:09, 26 January 2021
Do you want to use Zephyr RTOS on a Microcontroller with only a few bytes of Flash? Let's try it!
On the Optimizing for Footprint doc site you will find some hints how to reduce the memory footprint. Ok let's do it. I compiled the following application by using this configs:
|
main.c: void main (void) {
uint32_t i = 0;
// run the loop for ever
while (true) {
i++;
}
}
|
prj.conf: # disable all peripherals
CONFIG_GPIO=n
CONFIG_SERIAL=n
CONFIG_SPI=n
CONFIG_I2C=n
# disable the boot banner
CONFIG_BOOT_BANNER=n
#disable all debug and log messages
CONFIG_DEBUG=n
|
With this application and settings I could reduce the kernel to 6872 bytes:
west build -p auto -b <board name>
Memory region Used Size Region Size %age Used
FLASH: 6872 B 16 KB 41.94%
SRAM: 1232 B 2 KB 60.16%
IDT_LIST: 56 B 2 KB 2.73%
Ok, this is just the kernel to have an idea how much flash it needs. You can analyze the memory usage from the rom/ram-report (for more details have a look at the Zephyr Optimization Tools).
But how much does a small hello world application need, for example?