Error with MCU boot build.

Hi,

I am trying to get the sample projects working with the dongle, I am having difficulty with compiling the bluetooth examples using the provided instructions:

https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/boards/nordic/nrf52840dongle/doc/index.html

As per Option 2, I have installed nrfutil, set up the build environment, downloaded the mcuboot git and checked it version 1.8:

cd ~/ncs/v3.0.0/mcuboot
git checkout v1.8.0

I have no issue building the initial blinky example, but I would like to test one of the bluetooth sample that utilize the SoftDevice and Zephyr RTOS.

When I try and build the prerequisite MCUboot the build fails with the following errors:

(v3.0.0) ellie:[gregor]:~/ncs/v3.0.0$ west build -b nrf52840dongle/nrf52840 -d build/mcuboot mcuboot/boot/zephyr
-- west build: generating a build system
Loading Zephyr module(s) (Zephyr base): sysbuild_default
-- Found Python3: /home/gregor/ncs/toolchains/7cbc0036f4/usr/local/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter 
-- Cache files will be written to: /home/gregor/.cache/zephyr
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52840dongle, qualifiers: nrf52840
Parsing /home/gregor/ncs/v3.0.0/zephyr/share/sysbuild/Kconfig
Loaded configuration '/home/gregor/ncs/v3.0.0/build/mcuboot/_sysbuild/empty.conf'
Merged configuration '/home/gregor/ncs/v3.0.0/build/mcuboot/_sysbuild/empty.conf'
Configuration saved to '/home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/.config'
Kconfig header saved to '/home/gregor/ncs/v3.0.0/build/mcuboot/_sysbuild/autoconf.h'
-- 
   ****************************
   * Running CMake for zephyr *
   ****************************

Loading Zephyr default modules (Zephyr base).
-- Application: /home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr
-- CMake version: 3.21.0
-- Found Python3: /home/gregor/ncs/toolchains/7cbc0036f4/usr/local/bin/python (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter 
-- Cache files will be written to: /home/gregor/.cache/zephyr
-- Zephyr version: 4.0.99 (/home/gregor/ncs/v3.0.0/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52840dongle, qualifiers: nrf52840
-- Found host-tools: zephyr 0.17.0 (/home/gregor/ncs/toolchains/7cbc0036f4/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.17.0 (/home/gregor/ncs/toolchains/7cbc0036f4/opt/zephyr-sdk)
-- Found Dtc: /home/gregor/ncs/toolchains/7cbc0036f4/usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/gregor/ncs/v3.0.0/zephyr/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts
-- Found devicetree overlay: /home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/dts.overlay
-- Generated zephyr.dts: /home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/zephyr/zephyr.dts
-- Generated pickled edt: /home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/zephyr/edt.pickle
-- Generated zephyr.dts: /home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/zephyr/dts.cmake

warning: LOG_DEFAULT_LEVEL (defined at subsys/logging/Kconfig.filtering:13) was assigned the value
'0' but got the value ''. Check these unsatisfied dependencies: LOG (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_DEFAULT_LEVEL and/or look up
LOG_DEFAULT_LEVEL in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.


warning: USB_COMPOSITE_DEVICE (defined at subsys/usb/device/Kconfig:68) was assigned the value 'n'
but got the value 'y'. See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_USB_COMPOSITE_DEVICE and/or look up
USB_COMPOSITE_DEVICE in the menuconfig/guiconfig interface. The Application Development Primer,
Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
helpful too.


warning: The choice symbol LOG_MODE_MINIMAL (defined at subsys/logging/Kconfig.mode:29) was selected
(set =y), but no symbol ended up as the choice selection. See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_MODE_MINIMAL and/or look up
LOG_MODE_MINIMAL in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.

Parsing /home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/Kconfig
Loaded configuration '/home/gregor/ncs/v3.0.0/zephyr/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_defconfig'
Merged configuration '/home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/prj.conf'
Merged configuration '/home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/boards/nrf52840dongle_nrf52840.conf'
Merged configuration '/home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/zephyr/.config.sysbuild'
Configuration saved to '/home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/zephyr/.config'
Kconfig header saved to '/home/gregor/ncs/v3.0.0/build/mcuboot/zephyr/zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /home/gregor/ncs/toolchains/7cbc0036f4/opt/zephyr-sdk/arm-zephyr-eabi/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/gregor/ncs/toolchains/7cbc0036f4/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Warning at /home/gregor/ncs/v3.0.0/zephyr/subsys/usb/device/CMakeLists.txt:22 (message):
  CONFIG_USB_DEVICE_VID has default value 0x2FE3.

  This value is only for testing and MUST be configured for USB products.


CMake Warning at /home/gregor/ncs/v3.0.0/zephyr/subsys/usb/device/CMakeLists.txt:28 (message):
  CONFIG_USB_DEVICE_PID has default value 0x100.

  This value is only for testing and MUST be configured for USB products.


CMake Warning at /home/gregor/ncs/v3.0.0/nrf/lib/flash_patch/CMakeLists.txt:8 (message):
  

        ----------------------------------------------------------
        --- WARNING: To maintain the integrity of secure boot, ---
        --- enable CONFIG_DISABLE_FLASH_PATCH in production.   ---
        ----------------------------------------------------------


-- Using ccache: /home/gregor/ncs/toolchains/7cbc0036f4/usr/bin/ccache
MCUBoot bootloader key file: /home/gregor/ncs/v3.0.0/mcuboot/root-rsa-2048.pem
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gregor/ncs/v3.0.0/build/mcuboot/zephyr
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gregor/ncs/v3.0.0/build/mcuboot
-- west build: building application
[5/10] Performing build step for 'zephyr'
[1/300] Preparing syscall dependency handling

[5/300] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.0.99 (/home/gregor/ncs/v3.0.0/zephyr), build: v4.0.99-ncs1
[95/300] Building C object zephyr/CMakeFiles/zephyr.dir/home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/serial_adapter.c.obj
FAILED: zephyr/CMakeFiles/zephyr.dir/home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/serial_adapter.c.obj 

/home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/serial_adapter.c:18:10: fatal error: drivers/uart.h: No such file or directory
   18 | #include <drivers/uart.h>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
[99/300] Building C object zephyr/CMakeFiles/zephyr.dir/home/gregor/ncs/v3.0.0/mcuboot/boot/boot_serial/src/boot_serial.c.obj
FAILED: zephyr/CMakeFiles/zephyr.dir/home/gregor/ncs/v3.0.0/mcuboot/boot/boot_serial/src/boot_serial.c.obj 

In file included from /home/gregor/ncs/v3.0.0/mcuboot/boot/boot_serial/src/boot_serial.c:25:
/home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/include/sysflash/sysflash.h:6:10: fatal error: devicetree.h: No such file or directory
    6 | #include <devicetree.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
[108/300] Building C object modules/mbedtls/CMakeFiles/mbedTLSBase.dir/home/gregor/ncs/v3.0.0/modules/crypto/mbedtls/library/sha1.c.obj
FAILED: modules/mbedtls/CMakeFiles/mbedTLSBase.dir/home/gregor/ncs/v3.0.0/modules/crypto/mbedtls/library/sha1.c.obj 

 /home/gregor/ncs/v3.0.0/modules/crypto/mbedtls/library/sha1.c
In file included from /home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/include/config-rsa.h:85,
                 from /home/gregor/ncs/v3.0.0/mcuboot/boot/zephyr/include/mcuboot-mbedtls-cfg.h:25,
                 from /home/gregor/ncs/v3.0.0/modules/crypto/mbedtls/include/mbedtls/build_info.h:115,
                 from /home/gregor/ncs/v3.0.0/modules/crypto/mbedtls/include/library/common.h:14,
                 from /home/gregor/ncs/v3.0.0/modules/crypto/mbedtls/library/sha1.c:13:
/home/gregor/ncs/v3.0.0/modules/crypto/mbedtls/include/mbedtls/check_config.h:24:2: warning: #warning "Do not include mbedtls/check_config.h manually! " "This may cause spurious errors. " "It is included automatically at the right point since Mbed TLS 3.0." [-Wcpp]
   24 | #warning "Do not include mbedtls/check_config.h manually! " \
      |  ^~~~~~~
/home/gregor/ncs/v3.0.0/modules/crypto/mbedtls/include/mbedtls/check_config.h:413:2: error: #error "MBEDTLS_MD_C defined, but no hash algorithm"
  413 | #error "MBEDTLS_MD_C defined, but no hash algorithm"
      |  ^~~~~
[112/300] Building C object zephyr/drivers/gpio/CMakeFiles/drivers__gpio.dir/gpio_nrfx.c.obj
ninja: build stopped: subcommand failed.
FAILED: _sysbuild/sysbuild/images/zephyr-prefix/src/zephyr-stamp/zephyr-build /home/gregor/ncs/v3.0.0/build/mcuboot/_sysbuild/sysbuild/images/zephyr-prefix/src/zephyr-stamp/zephyr-build 
cd /home/gregor/ncs/v3.0.0/build/mcuboot/zephyr && /home/gregor/ncs/toolchains/7cbc0036f4/usr/local/bin/cmake --build .
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /home/gregor/ncs/toolchains/7cbc0036f4/usr/local/bin/cmake --build /home/gregor/ncs/v3.0.0/build/mcuboot

My toolchain directory structure from which I have activated the virtual environment:

This seems in-line with the guidance provided.

(v3.0.0) ellie:[gregor]:~/ncs/v3.0.0$ tree -L 2
.
├── blinky.zip
├── bootloader
│   └── mcuboot
├── mcuboot
│   ├── boot
│   ├── build_info.yml
│   ├── Cargo.lock
│   ├── Cargo.toml
│   ├── ci
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── CODE_OF_CONDUCT.md
│   ├── docs
│   ├── enc-aes128kw.b64
│   ├── enc-aes256kw.b64
│   ├── enc-ec256-priv.pem
│   ├── enc-ec256-pub.pem
│   ├── enc-rsa2048-priv.pem
│   ├── enc-rsa2048-pub.pem
│   ├── enc-x25519-priv.pem
│   ├── enc-x25519-pub.pem
│   ├── ext
│   ├── go.mod
│   ├── LICENSE
│   ├── NOTICE
│   ├── project.yml
│   ├── ptest
│   ├── README.md
│   ├── repository.yml
│   ├── root-ec-p256.pem
│   ├── root-ec-p256-pkcs8.pem
│   ├── root-ed25519.pem
│   ├── root-rsa-2048.pem
│   ├── root-rsa-3072.pem
│   ├── samples
│   ├── scripts
│   ├── sim
│   ├── _sysbuild
│   ├── testplan
│   └── zephyr
├── modules
│   ├── benchmark
│   ├── bsim_hw_models
│   ├── crypto
│   ├── debug
│   ├── fs
│   ├── hal
│   ├── lib
│   └── tee
├── nrf
│   ├── applications
│   ├── boards
│   ├── cmake
│   ├── CMakeLists.txt
│   ├── CODEOWNERS
│   ├── config
│   ├── doc
│   ├── drivers
│   ├── dts
│   ├── ext
│   ├── include
│   ├── Jenkinsfile
│   ├── Kconfig.nrf
│   ├── lib
│   ├── LICENSE
│   ├── modules
│   ├── ncs_version.h.in
│   ├── README.rst
│   ├── samples
│   ├── scripts
│   ├── share
│   ├── snippets
│   ├── soc
│   ├── subsys
│   ├── sysbuild
│   ├── test-manifests
│   ├── tests
│   ├── VERSION
│   ├── west-test.yml
│   ├── west.yml
│   └── zephyr
├── nrfxlib
│   ├── CMakeLists.txt
│   ├── CODEOWNERS
│   ├── common.cmake
│   ├── crypto
│   ├── doc
│   ├── gzll
│   ├── Jenkinsfile
│   ├── Kconfig.nrfxlib
│   ├── lc3
│   ├── LICENSE
│   ├── mpsl
│   ├── nfc
│   ├── nrf_802154
│   ├── nrf_dm
│   ├── nrf_fuel_gauge
│   ├── nrf_modem
│   ├── nrf_rpc
│   ├── nrf_wifi
│   ├── openthread
│   ├── README.rst
│   ├── softdevice_controller
│   ├── softperipheral
│   ├── suit
│   ├── tests
│   └── zephyr
├── test
│   └── cmock
├── tools
│   ├── bsim
│   ├── edtt
│   └── net-tools
└── zephyr
├── arch
├── boards
├── cmake
├── CMakeLists.txt
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.rst
├── doc
├── drivers
├── dts
├── include
├── Jenkinsfile
├── Kconfig
├── Kconfig.constants
├── Kconfig.zephyr
├── kernel
├── lib
├── LICENSE
├── MAINTAINERS.yml
├── misc
├── modules
├── README.rst
├── samples
├── scripts
├── SDK_VERSION
├── share
├── snippets
├── soc
├── submanifests
├── subsys
├── tests
├── VERSION
├── version.h.in
├── west.yml
├── zephyr-env.cmd
└── zephyr-env.sh

Why is the build failing on some headers, and how to fix the TLS encryption issue?

Thanks,

Gregor

  • I worked around the issue by not using MCUboot and building the sample applications directly with the Zephyr platform and CMake/Ninja.

    The application can then be sequenced using the nrfutil pkg generate command...

    #generate build from the v3.0.1/zephyr directory
    
    rm -rf build
    cmake -Bbuild -GNinja -DBOARD=nrf52840dongle "$MY_PROGRAM_DIR"
    
    sleep 5
    
    #generator binary
    ninja -Cbuild
    
    #generate the application zip for nrfutil, softdevice is builtin when using zephyr
    nrfutil pkg generate --hw-version 52                      --sd-req 0x00                      --application build/zephyr/zephyr.hex                      --application-version 1                      zephyr_app_dfu.zip
    
    sleep 5
    
    #push code to device
    nrfutil dfu usb-serial -pkg zephyr_app_dfu.zip -p /dev/ttyACM0
    

Related