Bootloader configuration in Matter
All Matter nodes are required to implement a firmware update mechanism that validates the authenticity of new firmware before executing it. To meet this requirement, Nordic Semiconductor recommends using MCUboot bootloader for installing a new firmware image.
This page contains guidelines for configuring the MCUboot bootloader in Matter projects.
Adding MCUboot to application
Read Adding MCUboot as an immutable bootloader to learn how to add MCUboot to an nRF Connect SDK application. Some Matter samples include Device Firmware Update (DFU) support out of the box, as listed in the sample feature matrix table.
MCUboot minimal configuration
MCUboot is by default configured to enable debug features, such as logs. You can reduce the size of the bootloader image by disabling unnecessary features.
See the following files for the MCUboot minimal configuration used by Matter samples in the nRF Connect SDK:
prj.conffile located in each sample’ssysbuild/mcubootdirectoryBoard files located in each sample’s
sysbuild/mcuboot/boardsdirectoryKconfig.sysbuildfile located in each sample’s directory.
This configuration allows to reduce the flash partition occupied by MCUboot to 24 kB.
Partition layout
Note
The Partition Manager is a component in the nRF Connect SDK and is responsible for handling the memory partitioning at build time.
This functionality is in the process of being deprecated and replaced by Zephyr’s default devicetree-based memory partitioning. It is recommended that all new designs using Nordic devices, excluding the nRF91 Series devices, are to be built with DTS instead of Partition Manager. Partition Manager will be removed from the nRF Connect SDK by the end of 2026 from the main branch.
For more information on how to configure partitions using DTS and how to migrate your existing configuration to DTS, see the following pages:
A bootloader is a critical component in a Matter device, ensuring secure firmware updates and authenticating new application images. All Nordic Matter samples in the nRF Connect SDK use MCUboot as the primary bootloader, with configuration and partitioning adapted to application and device needs.
Consider the following when defining partitions for your end product:
Use the default partition layout for your target SoC by including the base partition file
<soc_name>_cpuapp_partitions.dtsilocated under thenrf/dts/samples/matterdirectory. Include the base partition file in yourboards/<board_name>.overlayboard file using the following line:#include "<samples/matter/<soc_name>_cpuapp_partitions.dtsi>"
To modify the partition layout, copy the whole content of the base partition file to your
boards/<board_name>.overlayboard file and modify the partitions as needed. See Configuring memory usage to learn how to adjust the partition sizes.Given the size of the Matter stack, it is usually not possible to fit both the primary and the secondary slot in the internal flash in order to store the current and the new firmware image, respectively. Instead, you should use the external flash to host the secondary slot.
Note
Remember to enable a proper flash driver when placing the secondary slot in the external flash. For example, if you develop your application on a Nordic Semiconductor’s development kit that includes a QSPI NOR flash module, set the
CONFIG_NORDIC_QSPI_NORKconfig option.When selecting the partition sizes, take into account that some of the partitions, such as settings and factory data ones, are not modified during the DFU process. This means that performing DFU from one firmware version to another using different partition sizes might not be possible, and you cannot change the partition sizes without reprogramming the device. Trying to perform DFU between applications that use incompatible partition sizes can result in unwanted application behavior, depending on which partitions are overlapping. In some cases, this might corrupt some partitions; in others, this can lead to a DFU failure.
The MCUboot requires its
slot0_partitionandslot1_partitionpartitions to be located under offsets being aligned to the 4 kB flash page size. Selecting offset values that are not aligned to 4 kB for these partitions will lead to erase failures, and result in a DFU failure.
Partition names
The following tables summarize the partitions by target.
nRF52840 DK
Devicetree node label |
Purpose |
Location |
|---|---|---|
|
MCUboot bootloader. |
SoC internal flash |
|
Primary application image (includes MCUboot swap metadata inside the region). |
SoC internal flash |
|
Matter factory data. |
SoC internal flash |
|
Non-volatile settings Zephyr settings storage. |
SoC internal flash |
|
Secondary application slot for MCUboot DFU. |
External QSPI flash ( |
nRF5340 DK & Nordic Thingy:53 (application core and external flash; network core uses flash1)
Devicetree node label |
Purpose |
Location |
|---|---|---|
|
MCUboot bootloader. |
Application core internal flash |
|
Primary application image (includes MCUboot swap metadata inside the region). |
Application core internal flash |
|
Matter factory data. |
Application core internal flash |
|
Non-volatile settings Zephyr settings storage. |
Application core internal flash |
|
Secondary application slot for MCUboot DFU. |
External QSPI ( |
|
Network core image update slot. |
External QSPI ( |
|
Immutable first-stage network core loader (B0n). |
Network core flash ( |
|
B0n provisioning key storage. |
Network core flash |
|
Network core firmware. |
Network core flash |
nRF54L15 & nRF54L10 & nRF54LM20 DKs
Devicetree node label |
Purpose |
Location |
|---|---|---|
|
MCUboot. |
RRAM ( |
|
Primary image. |
RRAM |
|
Secondary application slot for MCUboot DFU. |
External QSPI ( |
|
Matter factory data. |
RRAM |
|
Non-volatile settings Zephyr settings storage. |
RRAM |
|
TF-M secure application (TF-M code). |
RRAM |
|
TF-M non-secure application (User application). |
RRAM |
|
TF-M secure storage partitions (TF-M builds only). |
RRAM |
Settings partition
The nRF Connect platform in Matter uses Zephyr’s Settings API to provide the storage capabilities to the Matter stack.
This requires that you define the settings_storage partition in the flash.
The recommended minimum size of the partition is 32 kB, but you can reserve even more space if your application uses the storage extensively.
The Zephyr settings storage is implemented by the Zephyr NVS (Non-Volatile Storage) or ZMS (Zephyr Memory Storage) backends. You can select either backend, and the selection affects several factors, such as the operational performance or memory lifetime. To achieve the optimal experience, it is recommended to use:
NVS backend for the flash-based nRF52 and nRF53 SoC families.
ZMS backend for the RRAM- and MRAM-based nRF54 SoC families.
The settings backend uses multiple sectors of 4 kB each, and it must use the appropriate number of sectors to cover the entire settings partition area. To configure the number of sectors used by the backend, set the corresponding Kconfig option to the desired value:
CONFIG_SETTINGS_NVS_SECTOR_COUNTfor the NVSCONFIG_SETTINGS_ZMS_SECTOR_COUNTfor the ZMS
For example, to cover a settings partition of 32 kB in size, you require 8 sectors.
As you can see in Reference Matter memory layouts, Matter samples in the nRF Connect SDK reserve exactly 32 kB for the settings_storage partition.
Factory data partition
If you make a real Matter product, you also need the factory_data partition to store the factory data.
The factory data contains a set of immutable device identifiers, certificates and cryptographic keys, programmed onto a device at the time of the device fabrication.
For that partition one flash page of 4 kB should be enough in most use cases.
By default, the factory_data partition is write-protected with the Hardware flash write protection driver (fprotect).
The hardware limitations require that the write-protected areas are aligned to CONFIG_FPROTECT_BLOCK_SIZE.
For this reason, to effectively implement fprotect, make sure that the partition layout of the application meets the following requirements:
The
factory_datapartition is placed right after theapppartition in the address space (that is, thefactory_datapartition offset must be equal to the last address of theapppartition).The
settings_storagepartition size is a multiple ofCONFIG_FPROTECT_BLOCK_SIZE, which may differ depending on the SoC in use.
See the following figure and check the Reference Matter memory layouts to make sure your implementation is correct.
Factory data partition implementation criteria for fprotect
In case your memory map does not follow these requirements, you can still use the factory data implementation without the write protection by setting the CONFIG_CHIP_FACTORY_DATA_WRITE_PROTECT to n, although this is not recommended.
See the Generating factory data section on the Device Attestation page for more information about the factory data in Matter.
Signing keys
MCUboot uses asymmetric cryptography to validate the authenticity of firmware. The public key embedded in the bootloader image is used to validate the signature of a firmware image that is about to be booted. If the signature check fails, MCUboot rejects the image and either:
rolls back to the last valid firmware image if the fallback recovery has not been disabled using the MCUboot’s
SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLYKconfig option.fails to boot.
Note
To help you get started with MCUboot and ease working with sample applications, MCUboot comes with a default key pair for the firmware image validation. As the key pair is publicly known, it provides no protection against the image forgery. For this reason, when making a real product, it is of the greatest importance to replace it with a unique key pair, known only to the device maker.
Read Adding a custom signature key file to learn how to configure MCUboot to use a custom key pair.
Downgrade protection
The downgrade protection mechanism makes it impossible for an attacker to trick a user to install a firmware image older than the currently installed one.
The attacker might want to do this to reintroduce old security vulnerabilities that have already been fixed in newer firmware revisions.
You should enable the downgrade protection mechanism if you choose to enable MCUboot’s SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY Kconfig option, which disables the fallback recovery in case of a faulty upgrade.
Image compression
The MCUboot image compression feature allows you to reduce the size of the firmware image that is being installed. This is done by compressing the image before it is written to the secondary slot.
Thanks to the compression, the secondary slot can be smaller than the primary one. This is especially useful when you do not want to use external flash for the secondary slot, and you need to place the new image in the internal memory.
You can enable this feature by setting the following Kconfig options in your application’s sysbuild configuration file:
If your application has used external flash for the secondary slot and you want to stop using it, disable the following Kconfig options in your application’s sysbuild configuration file: