nRF5340: Network core bootloader

The network core bootloader sample, also called B0n, is an immutable first-stage bootloader that can update the application firmware on the network core of the nRF5340 System on Chip (SoC).

Requirements

The sample supports the following development kit:

Hardware platforms

PCA

Board name

Build target

nRF5340 DK

PCA10095

nrf5340dk_nrf5340

nrf5340dk_nrf5340_cpunet

Overview

The network core bootloader sample protects the flash memory areas allocated to both itself and the application running on the network core.

You must use this sample as a child image of a multi-image build, where MCUboot is enabled and there is a network core application. MCUboot verifies and shares with the network core bootloader any new network core application image received through a device firmware update (DFU) transport layer, like a serial or a Bluetooth® LE connection. For this reason, without MCUboot, this sample does nothing else but directly launches the application.

During the boot process, the network core bootloader sample and MCUboot interact as follows:

  1. When MCUboot receives a new network core application image, it writes the configuration for the network core bootloader to the shared SRAM.

    The configuration includes an update instruction and both the SHA and the data of the image.

  2. The network core bootloader locks the flash memory areas containing itself and its configuration.

    The ACL peripheral is used for locking. For details on locking, see the Hardware flash write protection driver.

  3. The network core bootloader performs any pending network core firmware update.

    It calls the Peripheral CPU DFU (PCD) library to inspect the SRAM region shared with the application core:

    1. If MCUboot has written an update instruction, the network core bootloader copies the specified data range to the application partition on the network core.

    2. Once the copy is done, the network core bootloader compares the SHA of the data in the application partition against the SHA specified in the shared SRAM.

    3. It then communicates the result of the comparison to MCUboot using the shared SRAM.

  4. The network core bootloader then locks the flash memory areas containing the network core application.

    The ACL peripheral is used for locking. For details on locking, see the Hardware flash write protection driver.

  5. The network core bootloader boots the application on the network core.

    After performing a potential firmware update and enabling flash memory protection, the network core bootloader uninitializes all peripherals that it used and boots the application.

Building and running

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

Follow the steps below to include the sample as a child image in a multi-image build that contains a network core application:

  1. To add MCUboot to the build, enable the CONFIG_BOOTLOADER_MCUBOOT option in the application that runs on the application core. The build system includes the sample in the build by automatically enabling the CONFIG_SECURE_BOOT option for the application that runs on the network core.

  2. To enable the Peripheral CPU DFU (PCD) library for MCUboot, set the CONFIG_PCD_APP option when building its image.

The build system generates a new set of firmware update files. These files match the ones described in Using MCUboot in nRF Connect SDK, except that they contain the network core application firmware and are prefixed with net_core_.

See Configuring your application for information on how to enable the required configuration options. Then follow the instructions in Building and programming a sample to build and program the images for the network and application core.

Note

To try out the network core bootloader sample, use the Bluetooth: Peripheral UART sample as the basis for the multi-image build. This sample automatically includes the network core sample Bluetooth: HCI RPMsg when built for the nRF5340 DK. Then apply the options mentioned to include the network core bootloader sample with MCUboot.

Testing

After programming the sample to your development kit, complete the following steps to test it:

  1. Connect to the kit that runs this sample with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.

    Note

    The nRF5340 DK has multiple UART instances, so the correct port must be identified. See Getting logging output for additional details.

  2. Reset the kit.

  3. Observe that the output includes the following line:

    Done updating network core
    

Dependencies

This sample uses the following nRF Connect SDK libraries:

The sample also uses drivers from nrfx.