nRF Secure Immutable Bootloader

The nRF Secure Immutable Bootloader (NSIB), previously also known as B0 or b0, is a secure bootloader built and maintained by Nordic Semiconductor. It is specifically tailored for the immutable bootloader architecture of a secure boot chain. It can verify and boot a second-stage bootloader or application while providing a persistent and reliable Root of Trust (RoT).

See Secure bootloader chain for more information about the full bootloader chain.


Currently, the NSIB does not support performing firmware updates over the SMP transport. If the application using the NSIB requires SMP-based firmware updates, such as Bluetooth® LE DFU, include MCUboot as a second-stage bootloader.


The NSIB supports the following development kits:

Hardware platforms


Board name

Build target

nRF9160 DK




nRF5340 DK




nRF52 DK




nRF52840 DK




nRF52833 DK




nRF21540 DK




The NSIB can only boot images that enable the firmware information module, see the Firmware information module.


The NSIB implements a simple and reliable Root of Trust (RoT) for a secure boot chain:

  1. Locks the flash memory.

    To enable the RoT, it locks the flash memory address range containing itself and its configuration using the hardware available on the given architecture.

    For additional details on locking, see the Hardware flash write protection driver.

  2. Selects the next slot in the boot chain.

    The next stage in the boot chain can either be an application or another bootloader:

    • When the next stage is an application, you can allocate one or two slots for it.

    • When the next stage is a second-stage bootloader, two slots are always used.

    Each slot has a version number, and the bootloader will select the slot with the latest version.

    For more information about creating a second stage bootloader, see Adding an upgradable bootloader.

  3. Verifies the next stage in the boot chain.

    The next image has metadata containing the full public key that corresponds to the private key used to sign the firmware. This public key is checked against the provisioned hashes of public keys to determine if the image is valid.

    All public key hashes at lower indices than the matching hash are permanently invalidated at this point. You can use this mechanism to decommission broken keys.

  4. Boots the next stage in the boot chain.

    All peripherals that have been used are reset and the next stage is booted.

  5. Shares the cryptographic library.

    The NSIB shares some of its functionality through an external API (EXT_API).

    For more information on the process, see Bootloader crypto. For more information on EXT_API, see External APIs.


The public key hashes are not compiled with the source code of the NSIB. Instead, they must be written to the device in a process called provisioning.

The hashes are automatically generated by the build system based on the specified private key and the additional public keys.

By default, the hashes are placed directly into the NSIB HEX file and then automatically provisioned when the HEX file is programmed to the device.

However, in a more realistic manufacturing process, you can program the NSIB HEX file and the HEX file containing the hashes separately, using the Python scripts located in the scripts/bootloader folder.

In either case, the NSIB accesses the provisioned data at run time using the Bootloader storage library.

OTP regions

The one-time programmable (OTP) region is a special region of the User Information Configuration Registers (UICR) that only allows flash memory writes in half-word lengths, and only when the target half-word has the value of 0xFFFF.

On the SoCs that support an OTP region, such as the nRF9160 and nRF5340, the provisioned data is held in the OTP region instead of the internal flash memory.

Because of these design constraints, the following limitations apply:

  • The public key hash must not contain half-words with the value 0xFFFF, as such hashes cannot be guaranteed to be immutable when placed in the OTP region. If any such hashes are provisioned, the NSIB will refuse to boot. If your public key hash is found to contain this value, it must be regenerated.

  • Provisioned data cannot be written more than once to the target device. When programming images that contain flash memory content in the UICR region, such as the NSIB image, the UICR must first be erased.


On the nRF9160 and nRF5340, the UICR can only be erased by erasing the entire flash memory.

To erase the entire flash memory, do the following:

Using west:

west flash --erase

Using nrfjprog:

nrfjprog -f NRF91 --eraseall

Flash memory layout

The flash memory layout is defined by the samples/bootloader/pm.yml file, which establishes four main partitions:

  • B0 - The NSIB image.

  • Provision - The provisioned data.

  • S0 - Slot 0.

  • S1 - Slot 1.

The default location for placing the next image in the boot chain is S0. This would result, for example, in a flash memory layout like the following, when using the nrf52840dk_nrf52840 board:

B0 flash memory layout

B0 flash memory layout


When the Provision area is in the OTP region, it will not appear in the flash memory layout. See OTP regions for more information.

Pre-signed variants

When two slots are present, two images must be built. One that is executable from slot 0, and the other one from slot 1. Building the image for slot 1 is done by enabling the CONFIG_BUILD_S1_VARIANT option.

When the image for the next stage in the boot chain is upgraded, the new image is written to the slot with the oldest image version. See Monotonic counter for more information about versioning.

If this image is faulty and cannot be booted, the other partition will always hold a working image that is booted instead.

When using the nrf52840dk_nrf52840 board, this would produce a flash memory layout like the following:

B0 flash memory layout with MCUboot

B0 flash memory layout with MCUboot

Signature keys

The ECDSA-p256 key type is supported for validating the next image in the boot chain.

By default, when not explicitly defined, a private/public key pair is generated during the build. However, these key pairs should only be used during development. See Using development keys for more details.

For details on creating and using custom signature keys, refer to the Adding a custom signature key file documentation.

Monotonic counter

A non-volatile monotonic counter can be stored in the Provision area and is used to implement anti-rollback protection.

Counter updates are written to slots in the Provision area, with each new counter update occupying a new slot. For this reason, the number of counter updates, and therefore firmware version updates, is limited.

Using a counter is optional and can be configured for the application using configuration options. You can also configure the supported number of updates, but the number is limited by the size of the Provision area and how much of that area is taken up by other features, like public key hashes. In addition, you can configure what firmware version of the image you want to boot.



To set options for child images, such as NSIB and MCUboot, see the Image-specific variables section.


See Configuring your application for information about how to permanently or temporarily change the configuration.

FEM support

You can add support for the nRF21540 front-end module to this sample by using one of the following options, depending on your hardware:

  • Build the sample for one board that contains the nRF21540 FEM, such as nrf21540dk_nrf52840.

  • Manually create a devicetree overlay file that describes how FEM is connected to the nRF5 SoC in your device. See Set devicetree overlays for different ways of adding the overlay file.

  • Provide nRF21540 FEM capabilities by using a shield, for example the nRF21540 EK shield that is available in the nRF Connect SDK. In this case, build the project for a board connected to the shield you are using with an appropriate variable included in the build command, for example SHIELD=nrf21540_ek. This variable instructs the build system to append the appropriate devicetree overlay file.

    To build the sample in the nRF Connect for VS Code IDE for an nRF52840 DK with the nRF21540 EK attached, add the shield variable in the build configuration’s Extra CMake arguments and rebuild the build configuration. For example: -DSHIELD=nrf21540_ek.

    See nRF Connect for VS Code extension pack documentation for more information.

    See Programming nRF21540 EK for information about how to program when you are using a board with a network core, for example nRF5340 DK.

Each of these options adds the description of the nRF21540 FEM to the devicetree. See Working with RF front-end modules for more information about FEM in the nRF Connect SDK.

To add support for other front-end modules, add the respective devicetree file entries to the board devicetree file or the devicetree overlay file.

Building and running

This sample can be found under samples/bootloader in the nRF Connect SDK folder structure.

To build the sample with Visual Studio Code, follow the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation. See Building and programming an application for other building and programming scenarios and Testing and debugging an application for general information about testing and debugging in the nRF Connect SDK.


The NSIB should be included as a child image in a multi-image build, rather than being built stand-alone. While it is technically possible to build the NSIB by itself and merge it into other application images, this process is not supported. To reduce the development time and potential issues with this route, let the existing nRF Connect SDK infrastructure for multi-image builds handle the integration.

For building and running the NSIB with an application, see Adding an immutable bootloader.

Building and running using Visual Studio Code

This sample can be found under samples/bootloader in the nRF Connect SDK folder structure.

To add the NSIB as a child image to your application, complete the following steps:

  1. Create a private key in PEM format.

  2. Enable the nRF Secure Immutable Bootloader through Kconfig as follows:

    1. Select Kconfig in the Actions View to open the nRF Kconfig tab.

    2. Expand Modules > nrf > Nordic nRF Connect > Bootloader and set Use Secure Bootloader to enable CONFIG_SECURE_BOOT.

    3. Expand Use Secure Bootloader. Under Private key PEM file (CONFIG_SB_SIGNING_KEY_FILE), enter the path to the private key that you created.

      You can also modify other additional configuration options, but that is not recommended. The default settings are suitable for most use cases.


      If you need more flexibility with signing, or if you do not want the build system to handle your private key, choose CONFIG_SB_SIGNING_CUSTOM, and also specify CONFIG_SB_SIGNING_COMMAND and CONFIG_SB_SIGNING_PUBLIC_KEY. You can use the Search modules bar in nRF Kconfig to find these options. These options allow you to define the signing command.

    4. Click Save.

  3. Select Build in the Actions View to start the build process. The build process creates two images, one for the NSIB and one for the application, and merges them.

  4. Select Flash in the Actions View to program the resulting image to your device.


See Testing the bootloader chain for testing of the expected runtime behavior of the NSIB when built with an application.


The following nRF Connect SDK libraries are used:

It uses the following sdk-nrfxlib libraries: