Memory footprint optimization

When developing an application, ROM and RAM footprint are important factors, especially when the firmware runs on the most resource-constrained devices like nRF52810 or nRF52811.

General recommendations

To reduce the memory footprint, ensure that your application uses the minimum required resources and tune the nRF Connect SDK configuration parameters. Complete the following actions to optimize your application:

  • Follow the guides for optimizing Zephyr. Also see the implementation of the Minimal footprint sample.

  • Analyze stack usage in each thread of your application by using the Thread analyzer. Reduce the stack sizes where possible.

  • Limit or disable debugging features, such as logging or asserts.

  • Go through each component and subsystem and turn off all peripherals and features that your application does not use.

The following subsections give more information on how to optimize specific subsystems.

Bluetooth

Besides applying General recommendations, you can also complete the following actions to optimize the Bluetooth® part of your application:

For reference, you can find minimal footprint configurations of the Bluetooth: Peripheral LBS sample in nrf/samples/bluetooth/peripheral_lbs/minimal.conf and the Bluetooth: Peripheral UART sample in nrf/samples/bluetooth/peripheral_uart/minimal.conf.

Matter

Besides applying General recommendations, you can also complete the following actions to optimize the Matter part of your application:

  • Make sure Zephyr’s Shell is disabled for your application. Related configuration options are listed in a dedicated section in each Matter sample’s prj.conf file.

  • Use prj_release.conf for building the application. The release configuration has a smaller memory footprint than the default, debug-enabled prj.conf.

  • If the logs in your application do not use the default log level, you can change the default log level of Zephyr modules from info to warning by setting CONFIG_LOG_DEFAULT_LEVEL to 2.

  • Change the log level of the Matter logs from debug to info by setting CONFIG_MATTER_LOG_LEVEL_INFO to y.

  • Reduce the verbosity of assert messages by setting CONFIG_ASSERT_VERBOSE to n.

  • Check Thread memory footprint optimization actions, as the Matter application layer uses OpenThread.

Thread

The current Thread memory requirements are listed on the OpenThread memory requirements page.

Besides applying General recommendations, you can also complete the following actions to optimize the Thread part of your application:

For reference, you can find minimal footprint configurations for the single protocol and multiprotocol variants of the Thread: CLI sample in nrf/samples/openthread/cli/overlay-minimal_*protocol.conf.

Zigbee

The current Zigbee memory requirements are listed on the Zigbee memory requirements page.

Apply General recommendations to optimize the Zigbee part of your application.