Errors with building a sample project with MCUboot

Hi,

I am following these steps to build a sample project to try out OTA updates of the firmware.

https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/ncs-dfu

However the issue is that when I add CONFIG_BOOTLOADER_MCUBOOT, my builds start to fail. I tried with both 1.8.0 and 1.9.1 sdk

# Ensure an MCUboot-compatible binary is generated.
CONFIG_BOOTLOADER_MCUBOOT=y

The error I get is:

---------------------------------------------------------------------------------------------------------------------------------

> Executing task: nRF Connect: Build: peripheral_lbs/build (active) <

Building peripheral_lbs
west build --build-dir /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs

[0/1] Re-running CMake...
Including boilerplate (Zephyr base (cached)): /opt/nordic/ncs/v1.9.1/zephyr/cmake/app/boilerplate.cmake
-- Application: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs
-- Zephyr version: 2.7.99 (/opt/nordic/ncs/v1.9.1/zephyr), build: v2.7.99-ncs1-1
-- Found west (found suitable version "0.12.0", minimum required is "0.7.1")
-- Board: nrf52840dk_nrf52840
-- Cache files will be written to: /Users/macuser/Library/Caches/zephyr
-- Found dtc: /opt/nordic/ncs/v1.9.1/toolchain/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (/opt/nordic/ncs/v1.9.1/toolchain)
-- Found BOARD.dts: /opt/nordic/ncs/v1.9.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
-- Generated zephyr.dts: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/zephyr/dts.cmake
Parsing /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/Kconfig
Loaded configuration '/opt/nordic/ncs/v1.9.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
Merged configuration '/Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/prj.conf'
Configuration saved to '/Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/zephyr/.config'
Kconfig header saved to '/Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/zephyr/include/generated/autoconf.h'

=== child image mcuboot - begin ===
loading initial cache file /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/mcuboot/child_image_preload.cmake
Including boilerplate (Zephyr base): /opt/nordic/ncs/v1.9.1/zephyr/cmake/app/boilerplate.cmake
-- Application: /opt/nordic/ncs/v1.9.1/bootloader/mcuboot/boot/zephyr
-- Zephyr version: 2.7.99 (/opt/nordic/ncs/v1.9.1/zephyr), build: v2.7.99-ncs1-1
-- Found Python3: /Users/macuser/opt/anaconda3/bin/python3.9 (found suitable exact version "3.9.7") found components: Interpreter
-- Board: nrf52840dk_nrf52840
-- Cache files will be written to: /Users/macuser/Library/Caches/zephyr
-- Found dtc: /opt/nordic/ncs/v1.9.1/toolchain/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (/opt/nordic/ncs/v1.9.1/toolchain)
-- Found BOARD.dts: /opt/nordic/ncs/v1.9.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
-- Found devicetree overlay: /opt/nordic/ncs/v1.9.1/nrf/modules/mcuboot/usb.overlay
-- Found devicetree overlay: /opt/nordic/ncs/v1.9.1/bootloader/mcuboot/boot/zephyr/dts.overlay
-- Generated zephyr.dts: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/mcuboot/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/mcuboot/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/mcuboot/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/mcuboot/zephyr/dts.cmake
Parsing /opt/nordic/ncs/v1.9.1/bootloader/mcuboot/boot/zephyr/Kconfig
/opt/nordic/ncs/v1.9.1/zephyr/scripts/kconfig/kconfig.py: /opt/nordic/ncs/v1.9.1/bootloader/mcuboot/boot/zephyr/Kconfig:11: '/modules/mcuboot/boot/zephyr/Kconfig' not found (in 'source "$(ZEPHYR_NRF_MODULE_DIR)/modules/mcuboot/boot/zephyr/Kconfig"'). Check that environment variables are set correctly (e.g. $srctree, which is set to '/opt/nordic/ncs/v1.9.1/zephyr'). Also note that unset environment variables expand to the empty string.
CMake Error at /opt/nordic/ncs/v1.9.1/zephyr/cmake/kconfig.cmake:272 (message):
command failed with return code: 1
Call Stack (most recent call first):
/opt/nordic/ncs/v1.9.1/zephyr/cmake/app/boilerplate.cmake:544 (include)
/opt/nordic/ncs/v1.9.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
/opt/nordic/ncs/v1.9.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
/Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/CMakeLists.txt:44 (find_package)


-- Configuring incomplete, errors occurred!
CMake Error at /opt/nordic/ncs/v1.9.1/nrf/cmake/multi_image.cmake:409 (message):
CMake generation for mcuboot failed, aborting. Command: 1
Call Stack (most recent call first):
/opt/nordic/ncs/v1.9.1/nrf/cmake/multi_image.cmake:150 (add_child_image_from_source)
/opt/nordic/ncs/v1.9.1/nrf/modules/mcuboot/CMakeLists.txt:216 (add_child_image)


-- Configuring incomplete, errors occurred!
See also "/Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/CMakeFiles/CMakeOutput.log".
See also "/Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build/CMakeFiles/CMakeError.log".
FAILED: build.ninja
/opt/nordic/ncs/v1.9.1/toolchain/Cellar/cmake/3.21.1/bin/cmake --regenerate-during-build -S/Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs -B/Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build
ninja: error: rebuilding 'build.ninja': subcommand failed
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/v1.9.1/toolchain/bin/cmake --build /Users/macuser/Projects/SB/IP/Zypher/RND/peripheral_lbs/build
The terminal process terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.
---------------------------------------------------------------------------------------------------------------------------------


Any idea what am I might be doing wrong? 

Thanks!
  • Hi Ahmed, 
    I tried here and has no problem with compiling. 
    From the log it seem that the following is missing: 

    Could you check if you can find Kconfig file in your NCS  at this folder: \nrf\modules\mcuboot\boot\zephyr ? 

    If you don't I would suggest to re-install the SDK, I would suggest to do that using Toolchain Manager as instructed here.

  • Hi Hung,

    The Kconfig file is available at given path.




    I originally installed the SDK via nRF Desktop Connect->Toolchain Manager. However I will try to reinstall it again to see if that helps!

    Thanks!

  • Hi, 
    I can see that the folder you are looking at is for v1.8.0 when the complain in the log was about v1.91. Please double check. 

  • Hi, 

    good catch, I pasted the logs in the original post when I tried using 1.9.1 version of SDK as well. That too was failing. Yesterday I uninstalled all versions of SDK and installed 1.8.0 again. Unfortunately, I got same error. I might trying building from scratch on another machine.

    /opt/nordic/ncs/v1.8.0/zephyr/scripts/kconfig/kconfig.py: /opt/nordic/ncs/v1.8.0/bootloader/mcuboot/boot/zephyr/Kconfig:11: '/modules/mcuboot/boot/zephyr/Kconfig' not found (in 'source "$(ZEPHYR_NRF_MODULE_DIR)/modules/mcuboot/boot/zephyr/Kconfig"'). Check that environment variables are set correctly (e.g. $srctree, which is set to '/opt/nordic/ncs/v1.8.0/zephyr'). Also note that unset environment variables expand to the empty string.
    CMake Error at /opt/nordic/ncs/v1.8.0/zephyr/cmake/kconfig.cmake:270 (message):
    command failed with return code: 1
    Call Stack (most recent call first):
    /opt/nordic/ncs/v1.8.0/zephyr/cmake/app/boilerplate.cmake:546 (include)
    /opt/nordic/ncs/v1.8.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
    /opt/nordic/ncs/v1.8.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
    /Users/macuser/Projects/SB/BLE/TestProject/build/CMakeLists.txt:44 (find_package)


    -- Configuring incomplete, errors occurred!
    CMake Error at /opt/nordic/ncs/v1.8.0/nrf/cmake/multi_image.cmake:306 (message):
    CMake generation for mcuboot failed, aborting. Command: 1
    Call Stack (most recent call first):
    /opt/nordic/ncs/v1.8.0/nrf/cmake/multi_image.cmake:68 (add_child_image_from_source)
    /opt/nordic/ncs/v1.8.0/nrf/modules/mcuboot/CMakeLists.txt:216 (add_child_image)


    -- Configuring incomplete, errors occurred!
    See also "/Users/macuser/Projects/SB/BLE/TestProject/build/CMakeFiles/CMakeOutput.log".
    See also "/Users/macuser/Projects/SB/BLE/TestProject/build/CMakeFiles/CMakeError.log".
    FAILED: build.ninja
    /opt/nordic/ncs/v1.8.0/toolchain/Cellar/cmake/3.21.1/bin/cmake --regenerate-during-build -S/Users/macuser/Projects/SB/BLE/TestProject -B/Users/macuser/Projects/SB/BLE/TestProject/build
    ninja: error: rebuilding 'build.ninja': subcommand failed
    FATAL ERROR: command exited with status 1: /opt/nordic/ncs/v1.8.0/toolchain/bin/cmake --build /Users/macuser/Projects/SB/BLE/TestProject/build



  • Hi Imtiz, 

    I don't have much experience with MACOS but can you compile normal application (non MCUBoot) ? 
    Usually on my Windows machine before I can build I would need to run env.cmd in \toolchain\cmd to configure the PATH and the ZPHYR_BASE. It is done automatically if you use Visual Studio Code.

Related