I am currently testing with NRF5340DK using latest stable nRFConnectSDK release downloaded to my linux environment following the instruction here (developer.nordicsemi.com/.../installing.html). My directory looks like follow:
~/nrf-sdk$ ls bootloader modules nrf nrfxlib test tools zephyrCode
My questions are as below:
1.How to build BL1 for the nrf5340?
2. How to build BL1 and BL2 such that they use Cryptocell accelerator? Or does it really matter, in that does the speed for bootup get affected if we do not use the accelerator?
3. Is it possible to run bl1 on flash/NVM instead of in the real ROM?
4. I tried to build with tfm application with the nrf Zephyr SDK we cannot build BL1 and BL2, but with the regular/main Zephyr whiteout nrf sdk, I can build BL2. Below is the log I tried to build with latest nrf sdk (nrf connect).
west build -p always -b nrf5340dk_nrf5340_cpuapp_ns samples/tfm_integration/tfm_regression_test -t menuconfig
In menuconfig, I enabled use_secure_bootloader flag .
Here is the build log.
zephyr@edgeware01-1:~/nrf-sdk/zephyr$ rm -rf build/ zephyr@edgeware01-1:~/nrf-sdk/zephyr$ west build -p always -b nrf5340dk_nrf5340_ cpuapp_ns samples/tfm_integration/tfm_regression_test -t menuconfig -- west build: generating a build system Loading Zephyr default modules (Zephyr base). -- Application: /home/zephyr/nrf-sdk/zephyr/samples/tfm_integration/tfm_regressi on_test -- CMake version: 3.26.0 -- Found Python3: /usr/bin/python3.10 (found suitable exact version "3.10.6") fo und components: Interpreter -- Cache files will be written to: /home/zephyr/.cache/zephyr -- Zephyr version: 3.3.99 (/home/zephyr/nrf-sdk/zephyr) -- Found west (found suitable version "1.1.0", minimum required is "0.7.1") -- Board: nrf5340dk_nrf5340_cpuapp_ns -- Found host-tools: zephyr 0.16.1 (/home/zephyr/zephyr-sdk-0.16.1) -- Found toolchain: zephyr 0.16.1 (/home/zephyr/zephyr-sdk-0.16.1) -- Found Dtc: /home/zephyr/zephyr-sdk-0.16.1/sysroots/x86_64-pokysdk-linux/usr/b in/dtc (found suitable version "1.6.0", minimum required is "1.4.6") -- Found BOARD.dts: /home/zephyr/nrf-sdk/zephyr/boards/arm/nrf5340dk_nrf5340/nrf 5340dk_nrf5340_cpuapp_ns.dts -- Generated zephyr.dts: /home/zephyr/nrf-sdk/zephyr/build/zephyr/zephyr.dts -- Generated devicetree_generated.h: /home/zephyr/nrf-sdk/zephyr/build/zephyr/in clude/generated/devicetree_generated.h -- Including generated dts.cmake file: /home/zephyr/nrf-sdk/zephyr/build/zephyr/ dts.cmake warning: Experimental symbol TFM_EXPERIMENTAL is enabled. Parsing /home/zephyr/nrf-sdk/zephyr/Kconfig Loaded configuration '/home/zephyr/nrf-sdk/zephyr/boards/arm/nrf5340dk_nrf5340/n rf5340dk_nrf5340_cpuapp_ns_defconfig' Merged configuration '/home/zephyr/nrf-sdk/zephyr/samples/tfm_integration/tfm_re gression_test/prj.conf' Configuration saved to '/home/zephyr/nrf-sdk/zephyr/build/zephyr/.config' Kconfig header saved to '/home/zephyr/nrf-sdk/zephyr/build/zephyr/include/genera ted/autoconf.h' -- Found GnuLd: /home/zephyr/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/ar m-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38 ") -- The C compiler identification is GNU 12.2.0 -- The CXX compiler identification is GNU 12.2.0 -- The ASM compiler identification is GNU -- Found assembler: /home/zephyr/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephy r-eabi-gcc CMake Warning at /home/zephyr/nrf-sdk/zephyr/CMakeLists.txt:839 (message): No SOURCES given to Zephyr library: lib__libc__common Excluding target from build. Dropping partition 'nonsecure_storage' since it is empty. -- Configuring done (14.6s) -- Generating done (0.2s) -- Build files have been written to: /home/zephyr/nrf-sdk/zephyr/build -- west build: running target menuconfig [0/1] cd /home/zephyr/nrf-sdk/zephyr/b...py /home/zephyr/nrf-sdk/zephyr/Kconfig Loaded configuration '/home/zephyr/nrf-sdk/zephyr/build/zephyr/.config' No changes to save (for '/home/zephyr/nrf-sdk/zephyr/build/zephyr/.config') zephyr@edgeware01-1:~/nrf-sdk/zephyr$ west build -b nrf5340dk_nrf5340_cpuapp_ns samples/tfm_integration/tfm_regression_test [0/1] Re-running CMake... Loading Zephyr default modules (Zephyr base (cached)). -- Application: /home/zephyr/nrf-sdk/zephyr/samples/tfm_integration/tfm_regressi on_test -- CMake version: 3.26.0 -- Cache files will be written to: /home/zephyr/.cache/zephyr -- Zephyr version: 3.3.99 (/home/zephyr/nrf-sdk/zephyr) -- Found west (found suitable version "1.1.0", minimum required is "0.7.1") -- Board: nrf5340dk_nrf5340_cpuapp_ns -- Found host-tools: zephyr 0.16.1 (/home/zephyr/zephyr-sdk-0.16.1) -- Found toolchain: zephyr 0.16.1 (/home/zephyr/zephyr-sdk-0.16.1) -- Found BOARD.dts: /home/zephyr/nrf-sdk/zephyr/boards/arm/nrf5340dk_nrf5340/nrf 5340dk_nrf5340_cpuapp_ns.dts -- Generated zephyr.dts: /home/zephyr/nrf-sdk/zephyr/build/zephyr/zephyr.dts -- Generated devicetree_generated.h: /home/zephyr/nrf-sdk/zephyr/build/zephyr/in clude/generated/devicetree_generated.h -- Including generated dts.cmake file: /home/zephyr/nrf-sdk/zephyr/build/zephyr/ dts.cmake warning: Experimental symbol TFM_EXPERIMENTAL is enabled. Parsing /home/zephyr/nrf-sdk/zephyr/Kconfig Loaded configuration '/home/zephyr/nrf-sdk/zephyr/build/zephyr/.config' No change to configuration in '/home/zephyr/nrf-sdk/zephyr/build/zephyr/.config' Kconfig header saved to '/home/zephyr/nrf-sdk/zephyr/build/zephyr/include/genera ted/autoconf.h' Changed board to secure nrf5340dk_nrf5340_cpuapp (NOT NS) === child image b0 - begin === loading initial cache file /home/zephyr/nrf-sdk/zephyr/build/b0/child_image_prel oad.cmake Loading Zephyr default modules (Zephyr base). -- Application: /home/zephyr/nrf-sdk/nrf/samples/bootloader -- CMake version: 3.26.0 -- Found Python3: /usr/bin/python3.10 (found suitable exact version "3.10.6") fo und components: Interpreter -- Cache files will be written to: /home/zephyr/.cache/zephyr -- Zephyr version: 3.3.99 (/home/zephyr/nrf-sdk/zephyr) -- Found west (found suitable version "1.1.0", minimum required is "0.7.1") -- Board: nrf5340dk_nrf5340_cpuapp -- Found host-tools: zephyr 0.16.1 (/home/zephyr/zephyr-sdk-0.16.1) -- Found toolchain: zephyr 0.16.1 (/home/zephyr/zephyr-sdk-0.16.1) -- Found Dtc: /home/zephyr/zephyr-sdk-0.16.1/sysroots/x86_64-pokysdk-linux/usr/b in/dtc (found suitable version "1.6.0", minimum required is "1.4.6") -- Found BOARD.dts: /home/zephyr/nrf-sdk/zephyr/boards/arm/nrf5340dk_nrf5340/nrf 5340dk_nrf5340_cpuapp.dts -- Generated zephyr.dts: /home/zephyr/nrf-sdk/zephyr/build/b0/zephyr/zephyr.dts -- Generated devicetree_generated.h: /home/zephyr/nrf-sdk/zephyr/build/b0/zephyr /include/generated/devicetree_generated.h -- Including generated dts.cmake file: /home/zephyr/nrf-sdk/zephyr/build/b0/zeph yr/dts.cmake Parsing /home/zephyr/nrf-sdk/zephyr/Kconfig Loaded configuration '/home/zephyr/nrf-sdk/zephyr/boards/arm/nrf5340dk_nrf5340/n rf5340dk_nrf5340_cpuapp_defconfig' Merged configuration '/home/zephyr/nrf-sdk/nrf/samples/bootloader/prj.conf' Merged configuration '/home/zephyr/nrf-sdk/nrf/samples/bootloader/boards/nrf5340 dk_nrf5340_cpuapp.conf' Merged configuration '/home/zephyr/nrf-sdk/nrf/subsys/partition_manager/partitio n_manager_enabled.conf' Configuration saved to '/home/zephyr/nrf-sdk/zephyr/build/b0/zephyr/.config' Kconfig header saved to '/home/zephyr/nrf-sdk/zephyr/build/b0/zephyr/include/gen erated/autoconf.h' -- Found GnuLd: /home/zephyr/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/../lib/gcc/ar m-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38 ") -- The C compiler identification is GNU 12.2.0 -- The CXX compiler identification is GNU 12.2.0 -- The ASM compiler identification is GNU -- Found assembler: /home/zephyr/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephy r-eabi-gcc CMake Warning at /home/zephyr/nrf-sdk/zephyr/CMakeLists.txt:839 (message): No SOURCES given to Zephyr library: lib__libc__common Excluding target from build. -- Configuring done (5.3s) -- Generating done (0.1s) -- Build files have been written to: /home/zephyr/nrf-sdk/zephyr/build/b0 === child image b0 - end === CMake Warning at /home/zephyr/nrf-sdk/nrf/subsys/bootloader/cmake/debug_keys.cma ke:36 (message): -------------------------------------------------------------- --- WARNING: Using generated NSIB public/private key-pair. --- --- It should not be used for production. --- --- See CONFIG_SB_SIGNING_KEY_FILE --- -------------------------------------------------------------- Call Stack (most recent call first): /home/zephyr/nrf-sdk/nrf/subsys/bootloader/cmake/provision_hex.cmake:37 (inclu de) /home/zephyr/nrf-sdk/nrf/subsys/CMakeLists.txt:17 (include) CMake Warning at /home/zephyr/nrf-sdk/zephyr/CMakeLists.txt:839 (message): No SOURCES given to Zephyr library: lib__libc__common Excluding target from build. Dropping partition 's1_pad' since its size is 0. Dropping partition 's0_pad' since its size is 0. Dropping partition 'nonsecure_storage' since it is empty. -- Configuring done (12.3s) -- Generating done (0.1s) -- Build files have been written to: /home/zephyr/nrf-sdk/zephyr/build [0/286] Generating signing key [2/286] Preparing syscall dependency handling [6/286] Generating include/generated/version.h -- Zephyr version: 3.3.99 (/home/zephyr/nrf-sdk/zephyr), build: v3.3.99-ncs1-1 [8/286] Performing build step for 'b0_subimage' [1/156] Preparing syscall dependency handling [2/156] Generating include/generated/version.h -- Zephyr version: 3.3.99 (/home/zephyr/nrf-sdk/zephyr), build: v3.3.99-ncs1-1 [146/156] Linking C executable zephyr/zephyr_pre0.elf [150/156] Linking C executable zephyr/zephyr_pre1.elf [156/156] Linking C executable zephyr/zephyr.elf Memory region Used Size Region Size %age Used FLASH: 23560 B 32 KB 71.90% RAM: 4432 B 256 KB 1.69% IDT_LIST: 0 GB 2 KB 0.00% [14/286] Generating ../../tfm/CMakeCache.txt -- Found Git: /usr/bin/git (found version "2.34.1") -- The C compiler identification is GNU 12.2.0 -- The ASM compiler identification is GNU -- Found assembler: /home/zephyr/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephy r-eabi-gcc -- Found Python3: /usr/bin/python3.10 (found version "3.10.6") found components: Interpreter -- Found Python3: /usr/bin/python3.10 (found suitable exact version "3.10.6") fo und components: Interpreter -- Cache files will be written to: /home/zephyr/.cache/zephyr -- Configuring done (1.2s) -- Generating done (0.2s) -- Build files have been written to: /home/zephyr/nrf-sdk/zephyr/build/tfm [20/286] Creating public key from private key used for signing [23/286] Performing build step for 'tfm' [370/370] Generating ../../bin/tfm_ns.hex [25/286] Creating data to be provision...e Bootloader, storing to provision.hex [26/286] Performing install step for 'tfm' -- Install configuration: "MinSizeRel" [269/286] Linking C executable zephyr/zephyr_pre0.elf [273/286] Linking C executable zephyr/zephyr_pre1.elf [279/286] Linking C executable zephyr/zephyr.elf Memory region Used Size Region Size %age Used FLASH: 22656 B 96 KB 23.05% RAM: 4832 B 256 KB 1.84% IDT_LIST: 0 GB 2 KB 0.00% [282/286] Creating signature of application [284/286] Creating validation for zephyr.hex, storing to [286/286] Generating zephyr/merged.hex
but I don't see any bl2 image in below directory.
ls build/tfm/bin/ tfm_ns.axf tfm_ns.elf tfm_ns.map tfm_s.bin tfm_s.hex tfm_ns.bin tfm_ns.hex tfm_s.axf tfm_s.elf tfm_s.mapCode
I also tried enabling SECURE_BOOT_CRYPTO, but it doesn't generate bl2 image as well