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.
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 features that your application does not use.
The following subsections give more information on how to optimize specific subsystems.
Bluetooth
Complete the following actions to optimize the Bluetooth® part of your application:
Disable features that your application does not use. For example, disable the following features:
Data Length Update
Extended Advertising
PHY Update
Security Manager Protocol (if no encryption and authentication is needed)
GATT Caching
GATT Service Changed
Reduce the stack sizes of the Bluetooth internal threads where possible. Use the Thread analyzer to analyze the stack usage.
The following configuration options affect the stack sizes of the Bluetooth threads:
Reduce the overall number and the sizes of the Bluetooth buffers, based on the expected data traffic in your application.
The following configuration options affect the Bluetooth buffers:
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
.
Thread
Complete the following actions to optimize the Thread part of your application:
Disable features that your application does not use. For example, disable the following features:
Asserts
Logging
Network shell and OpenThread CLI shell support (see Additional configuration options)
Reduce the stack sizes of the Thread internal threads where possible. Use the Thread analyzer to analyze the stack usage.
The following configuration options affect the stack sizes of the Thread threads:
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
.