Adding the nRF Secure Bootloader in custom board with nRF5340

Hi all,

I'm developing a project on top of nRF5340. Thus I created a custom board definition in my project area:

boards/arm/demo_board/
├── board.cmake
├── CMakeLists.txt
├── demo_board_cpuapp_defconfig
├── demo_board_cpuapp.dts
├── demo_board_cpuapp_ns_defconfig
├── demo_board_cpuapp_ns.dts
├── demo_board_cpuapp_ns.yaml
├── demo_board_cpuapp.yaml
├── demo_board_cpunet_defconfig
├── demo_board_cpunet.dts
├── demo_board_cpunet-pinctrl.dtsi
├── demo_board_cpunet.yaml
├── Kconfig
├── Kconfig.board
├── Kconfig.defconfig
├── nrf5340_cpuapp_common.dts
├── nrf5340_cpuapp_common-pinctrl.dtsi
├── nrf5340_cpuapp_partition_conf.dts
├── nrf5340_cpunet_reset.c
├── nrf5340_shared_sram_planning_conf.dts
└── pre_dt_board.cmake

That is a direct copy of ncs/zephyr/boards/arm/nrf5340dk_nrf5340/ -folder. Just renamed case sensitively all instances of "nrf5340dk_nrf5340" to "demo_board" to get a starting point for my custom HW definition.

west build -b demo_board_cpuapp_ns

builds nicely and seems to output correct logging in the nRF5340DK environment.

It also seems that I am able to add the MCUboot in the system (CONFIG_BOOTLOADER_MCUBOOT=y), but the problems arise, when I try adding the nRF Secure Bootloader (CONFIG_SECURE_BOOT=y).

Still everything is ok, when building for the nrf5340dk_nrf5340_cpuapp_ns target, but the west build -b demo_board_cpuapp_ns results in a compilation error:

ncs/zephyr/include/zephyr/arch/arm/aarch32/misc.h:26: undefined reference to `sys_clock_cycle_get_32'

I don't understand why this happens. The board definition is an exact copy of the devkit board definition. Just renamed and replaced under the project folder and before adding the secure nRF bootloader everything has been working fine.

I compared the build folders of the successful and failure builds and noticed differences (other than renaming) in the build/b0/zephyr/include/generated/autoconf.h file. The failed version had these additional lines that are missing from the successful build:

#define CONFIG_HW_CC3XX 1
#define CONFIG_NRF_CC3XX_PLATFORM 1
#define CONFIG_CC3XX_MUTEX_LOCK 1

I don't know if these have anything to do with my problem. But it also seems that I'm not able to undefine those. They are still there after build folder delete and:

west build -b demo_board_cpuapp_ns -d build_demo -- -Db0CONFIG_HW_CC3XX=n -Db0CONFIG_NRF_CC3XX_PLATFORM=n -Db0CONFIG_CC3XX_MUTEX_LOCK=n

My environment:

    Ubuntu 22.04.2 LTS

    Zephyr version: 3.2.99

    zephyr-sdk-0.15.2

    nRF Connect SDK: 2.3.0

Any ideas what I'm missing in the custom board definition or Secure Bootloader addition?

Parents
  • Hi tgoos,

    We found the issue yesterday and know the fix. But before we begin, I would like to reiterate that right now, as of NCS v2.3.0, the two-stage bootloader solution is not working. 

    Below I will explain why the custom board build is different from the built-in-SDK nRF5340 DK board and how to fix it; this thus relieve us of the concern that there is some undiscovered bug in the board definition.

    There is a Kconfig fragment file that is included in b0 child image build for the nrf5340dk_nrf5340_cpuapp and _ns boards.

    However, because your custom board is named differently, the build process will not pick up this fragment file.

    The solution is, via one of many ways, include the necessary configurations into your b0 child image build.

    Here are a couple of options:

    1. Copy that file over as <your project root>/child_image/b0.conf
      The downside is that all builds for non nRF5340 boards will also be affected

    2. Copy that file over to your project root folder, and include it in the build as a Kconfig fragment for b0 via
      -Db0_OVERLAY_CONFIG=<Full path to the fragment file>

    I am in dialogues with our internal team to investigate a better way to handle the Kconfig configuration for nRF5340 builds.

    References:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/multi_image/index.html
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.3.0/zephyr/develop/application/index.html#important-build-system-variables 

    Hieu

Reply
  • Hi tgoos,

    We found the issue yesterday and know the fix. But before we begin, I would like to reiterate that right now, as of NCS v2.3.0, the two-stage bootloader solution is not working. 

    Below I will explain why the custom board build is different from the built-in-SDK nRF5340 DK board and how to fix it; this thus relieve us of the concern that there is some undiscovered bug in the board definition.

    There is a Kconfig fragment file that is included in b0 child image build for the nrf5340dk_nrf5340_cpuapp and _ns boards.

    However, because your custom board is named differently, the build process will not pick up this fragment file.

    The solution is, via one of many ways, include the necessary configurations into your b0 child image build.

    Here are a couple of options:

    1. Copy that file over as <your project root>/child_image/b0.conf
      The downside is that all builds for non nRF5340 boards will also be affected

    2. Copy that file over to your project root folder, and include it in the build as a Kconfig fragment for b0 via
      -Db0_OVERLAY_CONFIG=<Full path to the fragment file>

    I am in dialogues with our internal team to investigate a better way to handle the Kconfig configuration for nRF5340 builds.

    References:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/multi_image/index.html
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.3.0/zephyr/develop/application/index.html#important-build-system-variables 

    Hieu

Children
No Data
Related