Hello Nordicsemi community,
1) manual build of mcuboot - When trying to build the mcuboot for nrf5340 via the mcuboot/samples/zephyr via the west build command, the build fails with a missing header file pm_config.h.
It seems related to the pcd dfu.
-- west build: building application [1/251] Preparing syscall dependency handling [32/251] Building C object CMakeFiles/app.dir/main.c.obj FAILED: CMakeFiles/app.dir/main.c.obj ccache /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.4.0-ncs1-1711-g6bc4a6cda158 -DKERNEL -DMBEDTLS_CONFIG_FILE=\"mcuboot-mbedtls-cfg.h\" -DNRF5340_XXAA_APPLICATION -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I../include -I../targets -I/opt/nrf/bootloader/mcuboot/boot/bootutil/include -I/opt/nrf/zephyr/include -Izephyr/include/generated -I/opt/nrf/zephyr/soc/arm/nordic_nrf/nrf53 -I/opt/nrf/nrf/include -I/opt/nrf/modules/hal/cmsis/CMSIS/Core/Include -I/opt/nrf/modules/hal/nordic/nrfx -I/opt/nrf/modules/hal/nordic/nrfx/drivers/include -I/opt/nrf/modules/hal/nordic/nrfx/mdk -I/opt/nrf/modules/hal/nordic/. -I/opt/nrf/modules/crypto/mbedtls/include -I/opt/nrf/modules/crypto/mbedtls/configs -isystem /opt/nrf/zephyr/lib/libc/minimal/include -isystem /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/include -isystem /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -isystem /opt/nrf/nrfxlib/crypto/nrf_cc312_platform/include -Og -imacros /opt/nrf/bootloader/mcuboot/boot/zephyr/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros /opt/nrf/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/opt/nrf/bootloader/mcuboot/boot/zephyr=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/nrf/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/nrf=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/main.c.obj -MF CMakeFiles/app.dir/main.c.obj.d -o CMakeFiles/app.dir/main.c.obj -c ../main.c In file included from ../main.c:57: /opt/nrf/nrf/include/dfu/pcd.h:35:10: fatal error: pm_config.h: No such file or directory 35 | #include <pm_config.h> | ^~~~~~~~~~~~~ compilation terminated. [39/251] Building C object CMakeFiles/app.dir/opt/nrf/bootloader/mcuboot/boot/bootutil/src/loader.c.obj FAILED: CMakeFiles/app.dir/opt/nrf/bootloader/mcuboot/boot/bootutil/src/loader.c.obj ccache /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.4.0-ncs1-1711-g6bc4a6cda158 -DKERNEL -DMBEDTLS_CONFIG_FILE=\"mcuboot-mbedtls-cfg.h\" -DNRF5340_XXAA_APPLICATION -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I../include -I../targets -I/opt/nrf/bootloader/mcuboot/boot/bootutil/include -I/opt/nrf/zephyr/include -Izephyr/include/generated -I/opt/nrf/zephyr/soc/arm/nordic_nrf/nrf53 -I/opt/nrf/nrf/include -I/opt/nrf/modules/hal/cmsis/CMSIS/Core/Include -I/opt/nrf/modules/hal/nordic/nrfx -I/opt/nrf/modules/hal/nordic/nrfx/drivers/include -I/opt/nrf/modules/hal/nordic/nrfx/mdk -I/opt/nrf/modules/hal/nordic/. -I/opt/nrf/modules/crypto/mbedtls/include -I/opt/nrf/modules/crypto/mbedtls/configs -isystem /opt/nrf/zephyr/lib/libc/minimal/include -isystem /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/include -isystem /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -isystem /opt/nrf/nrfxlib/crypto/nrf_cc312_platform/include -Og -imacros /opt/nrf/bootloader/mcuboot/boot/zephyr/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros /opt/nrf/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/opt/nrf/bootloader/mcuboot/boot/zephyr=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/nrf/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/nrf=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/opt/nrf/bootloader/mcuboot/boot/bootutil/src/loader.c.obj -MF CMakeFiles/app.dir/opt/nrf/bootloader/mcuboot/boot/bootutil/src/loader.c.obj.d -o CMakeFiles/app.dir/opt/nrf/bootloader/mcuboot/boot/bootutil/src/loader.c.obj -c /opt/nrf/bootloader/mcuboot/boot/bootutil/src/loader.c In file included from /opt/nrf/bootloader/mcuboot/boot/bootutil/src/loader.c:49: /opt/nrf/nrf/include/dfu/pcd.h:35:10: fatal error: pm_config.h: No such file or directory 35 | #include <pm_config.h> | ^~~~~~~~~~~~~ compilation terminated. [41/251] Building C object CMakeFiles/app.dir/opt/nrf/bootloader/mcuboot/boot/bootutil/src/swap_move.c.obj ninja: build stopped: subcommand failed.
2) config enabled mcuboot - If I do not build the mcuboot manually and just enable the CONFIG_BOOTLOADER_MCUBOOT=y in a sample projects prj.conf, the child image for mcuboot seems to build fine. After the flash, the app crashes, I either suspect the app image is not signed with the mcuboot root key, or the mcuboot image itself is incorrect.
=== child image mcuboot - begin === Including boilerplate (Zephyr base): /opt/nrf/zephyr/cmake/app/boilerplate.cmake -- Application: /opt/nrf/bootloader/mcuboot/boot/zephyr -- Zephyr version: 2.4.99 (/opt/nrf/zephyr) -- Found Python3: /usr/bin/python3.6 (found suitable exact version "3.6.9") found components: Interpreter -- Found west (found suitable version "0.8.0", minimum required is "0.7.1") -- Board: nrf5340pdk_nrf5340_cpuapp -- Cache files will be written to: /root/.cache/zephyr CMake Warning at /opt/nrf/zephyr/cmake/host-tools.cmake:31 (message): Could NOT find dtc: Found unsuitable version "1.4.5", but required is at least "1.4.6" (found /usr/bin/dtc). Optional devicetree error checking with dtc will not be performed. Call Stack (most recent call first): /opt/nrf/zephyr/cmake/app/boilerplate.cmake:570 (include) /opt/nrf/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include) /opt/nrf/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate) CMakeLists.txt:44 (find_package) -- Found toolchain: gnuarmemb (/opt/gcc-arm-none-eabi-9-2019-q4-major) -- Found BOARD.dts: /opt/nrf/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts -- Found devicetree overlay: /opt/nrf/bootloader/mcuboot/boot/zephyr/dts.overlay -- Generated zephyr.dts: /tmp/my_zephyr_app/build/mcuboot/zephyr/zephyr.dts -- Generated devicetree_unfixed.h: /tmp/my_zephyr_app/build/mcuboot/zephyr/include/generated/devicetree_unfixed.h Parsing /opt/nrf/bootloader/mcuboot/boot/zephyr/Kconfig Loaded configuration '/opt/nrf/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340pdk_nrf5340_cpuapp_defconfig' Merged configuration '/opt/nrf/bootloader/mcuboot/boot/zephyr/prj.conf' Configuration saved to '/tmp/my_zephyr_app/build/mcuboot/zephyr/.config' Kconfig header saved to '/tmp/my_zephyr_app/build/mcuboot/zephyr/include/generated/autoconf.h' -- The C compiler identification is GNU 9.2.1 -- The CXX compiler identification is GNU 9.2.1 -- The ASM compiler identification is GNU -- Found assembler: /opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gcc CMake Warning at /opt/nrf/zephyr/kernel/CMakeLists.txt:54 (message): Single threaded mode (CONFIG_MULTITHREADING=n) is deprecated CMake Warning at /opt/nrf/zephyr/CMakeLists.txt:1354 (message): WARNING: The board 'nrf5340pdk_nrf5340_cpuapp' is deprecated and will be removed in version v2.6.0 MCUBoot bootloader key file: /opt/nrf/bootloader/mcuboot/root-rsa-2048.pem -- Configuring done -- Generating done -- Build files have been written to: /tmp/my_zephyr_app/build/mcuboot === child image mcuboot - end === CMake Warning at /opt/nrf/nrf/cmake/mcuboot.cmake:120 (message): --------------------------------------------------------- --- WARNING: Using default MCUBoot key, it should not --- --- be used for production. --- --------------------------------------------------------- Call Stack (most recent call first): /opt/nrf/bootloader/mcuboot/zephyr/CMakeLists.txt:1 (include) -- Build type: -- Host: Linux/x86_64 -- Target: Generic/arm -- Machine: cortexm -- Looking for include file stdatomic.h -- Looking for include file stdatomic.h - found -- Host: Linux/x86_64 -- Target: Generic/arm -- Machine: cortexm -- C_FLAGS : -Wall -Wextra -- Looking for include file fcntl.h -- Looking for include file fcntl.h - found CMake Warning at /opt/nrf/zephyr/CMakeLists.txt:1354 (message): WARNING: The board 'nrf5340pdk_nrf5340_cpuapp' is deprecated and will be removed in version v2.6.0 -- Configuring done -- Generating done -- Build files have been written to: /tmp/my_zephyr_app/build -- west build: building application [1/194] Preparing syscall dependency handling [6/194] Performing build step for 'mcuboot_subimage' [1/252] Preparing syscall dependency handling [247/252] Linking C executable zephyr/zephyr_prebuilt.elf Memory region Used Size Region Size %age Used FLASH: 38228 B 48 KB 77.78% SRAM: 24144 B 504 KB 4.68% IDT_LIST: 72 B 2 KB 3.52% [252/252] Linking C executable zephyr/zephyr.elf [22/194] Building C object CMakeFiles/app.dir/src/main_thread_task.c.obj ... [181/194] Linking C executable zephyr/zephyr_prebuilt.elf Memory region Used Size Region Size %age Used FLASH: 37508 B 491008 B 7.64% SRAM: 19336 B 504 KB 3.75% IDT_LIST: 88 B 2 KB 4.30% [194/194] Generating zephyr/merged.hex -- west flash: rebuilding [0/1] cd /tmp/my_zephyr_app/build/zephyr/cmake/flash && /usr/local/bin/cmake -E echo -- west flash: using runner nrfjprog Using board 960164651 -- runners.nrfjprog: Flashing file: /tmp/my_zephyr_app/build/zephyr/merged.hex -- runners.nrfjprog: Generating CP_APPLICATION hex file /tmp/my_zephyr_app/build/zephyr/GENERATED_CP_APPLICATION_merged.hex Parsing hex file. Erasing page at address 0x0. Erasing page at address 0x1000. Erasing page at address 0x2000. Erasing page at address 0x3000. Erasing page at address 0x4000. Erasing page at address 0x5000. Erasing page at address 0x6000. Erasing page at address 0x7000. Erasing page at address 0x8000. Erasing page at address 0x9000. Erasing page at address 0x10000. Erasing page at address 0x11000. Erasing page at address 0x12000. Erasing page at address 0x13000. Erasing page at address 0x14000. Erasing page at address 0x15000. Erasing page at address 0x16000. Erasing page at address 0x17000. Erasing page at address 0x18000. Erasing page at address 0x19000. Applying system reset. Checking that the area to write is not protected. Programming device. Applying pin reset. -- runners.nrfjprog: Board with serial number 960164651 flashed successfully.
*** Booting Zephyr OS build v2.4.0-ncs1-1711-g6bc4a6cda158 *** *** Booting Zephyr OS build v2.4.0-ncs1-1711-g6bc4a6cda158 *** *** Booting Zephyr OS build v2.4.0-ncs1-1711-g6bc4a6cda158 *** *** Booting Zephyr OS build v2.4.0-ncs1-1711-g6bc4a6cda158 *** *** Booting Zephyr OS build v2.4.0-ncs1-1711-g6bc4a6cda158 *** [00:00:00.257,995] <err> fatal_error: Resetting system
Ideally I would like to be able to build the mcuboot manually and flash it onto the board prior to the primary image being flashed. (only building the mcuboot once)
Thank you for your support