nRF SDK Samples Fail to Build with CONFIG_BOOTLOADER_MCUBOOT

I'm working through the process of building and flashing code to a Thingy53 dev kit (nRF5340). I am attempting to generate a DFU compatible build output from a sample but it's failing.

I'm attempted to build and flash the "blinky" example from the zephyr samples included with the SDK install. I copied the "blinky" folder form the install location to my home directory in a working location. If I attempt to build the software without making any changes everything compiles but I only get .hex files in the output. The build succeeds but I don't get all of the possible output file formats.

I was trying to generate the .zip files for the DFU update over USB so I added the line `CONFIG_BOOTLOADER_MCUBOOT=y` to my "prj.conf" file in the blinky directory. When I do this and I re-run the build either through VSCode IDE or through command line with west I get a bunch of errors related to undefined macros. Below is a copy of the errors.

I'm not sure what I am doing wrong, all of the documentation indicates that I can add one line to the conf file and it should build for DFU and generate the output files I desire.

System Setup:
Windows 10
nRF SDK v2.2.0
VSCode Editor w/ all nRF extensions

There are even more errors than what is listed below but these are the first set to fail during the build. It is just more undeclared macros.

C:/ncs/v2.2.0/bootloader/mcuboot/boot/zephyr/flash_map_extended.c: In function 'flash_area_id_from_multi_image_slot':
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: error: 'PM_MCUBOOT_PRIMARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
45 | PM_MCUBOOT_PRIMARY_1_ID : \
| ^~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:54:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
54 | case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
| ^~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: note: each undeclared identifier is reported only once for each function it appears in
45 | PM_MCUBOOT_PRIMARY_1_ID : \
| ^~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:54:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
54 | case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
| ^~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:50:12: error: 'PM_MCUBOOT_SECONDARY_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
50 | PM_MCUBOOT_SECONDARY_ID: \
| ^~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:56:20: note: in expansion of macro 'FLASH_AREA_IMAGE_SECONDARY'
56 | case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:52:12: error: 'PM_MCUBOOT_SECONDARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
52 | PM_MCUBOOT_SECONDARY_1_ID: \
| ^~~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:56:20: note: in expansion of macro 'FLASH_AREA_IMAGE_SECONDARY'
56 | case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.2.0/bootloader/mcuboot/boot/zephyr/flash_map_extended.c: In function 'flash_area_id_to_multi_image_slot':
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: error: 'PM_MCUBOOT_PRIMARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
45 | PM_MCUBOOT_PRIMARY_1_ID : \
| ^~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:73:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
73 | if (area_id == FLASH_AREA_IMAGE_PRIMARY(image_index)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:50:12: error: 'PM_MCUBOOT_SECONDARY_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
50 | PM_MCUBOOT_SECONDARY_ID: \
| ^~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:77:20: note: in expansion of macro 'FLASH_AREA_IMAGE_SECONDARY'
77 | if (area_id == FLASH_AREA_IMAGE_SECONDARY(image_index)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:52:12: error: 'PM_MCUBOOT_SECONDARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
52 | PM_MCUBOOT_SECONDARY_1_ID: \
| ^~~~~~~~~~~~~~~~~~~~~~~~~
C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:77:20: note: in expansion of macro 'FLASH_AREA_IMAGE_SECONDARY'
77 | if (area_id == FLASH_AREA_IMAGE_SECONDARY(image_index)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
[89/309] Building C object CMakeFiles/app.dir/C_/ncs/v2.2.0/bootloader/mcuboot/boot/bootutil/src/bootutil_misc.c.obj

Parents
  • Originally I was working through this training: https://academy.nordicsemi.com/topic/exercise-2-1/

    But I'm still waiting for my JTAG adapter cable to arrive so I was attempting to program via USB following these instructions: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/working_with_nrf/nrf53/thingy53_gs.html 

    But the sample that I compiled using the instructions from the previous step didn't generate any *.bin or *.zip files. So I used this documentation to try and trigger their generation in the build: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/build_and_config_system/index.html#app-build-output-files 

    Side note: I tried installing the SDK v2.3.0 through the toolchain manager originally but it wasn't fully installing. It didn't actually install of the necessary pieces but it says it was complete. I tried uninstalling and reinstalling twice and I only get a partial install each time with no errors.

  • Hi,

    I think solving the issue regarding getting a working installation of the SDK up and running should be our priority for now, and after that I will guide you through getting a working sample with DFU support up and running. I will answer the statements in your previous replies with a couple of questions, and finish off with some questions regarding getting the installation working.

    zachwork said:
    Originally I was working through this training: https://academy.nordicsemi.com/topic/exercise-2-1/

    How far did you get through the training? Were you able to complete lesson 1 and get successfully build a sample?

    zachwork said:

    But I'm still waiting for my JTAG adapter cable to arrive so I was attempting to program via USB following these instructions: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/working_with_nrf/nrf53/thingy53_gs.html 

    But the sample that I compiled using the instructions from the previous step didn't generate any *.bin or *.zip files. So I used this documentation to try and trigger their generation in the build: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/app_dev/build_and_config_system/index.html#app-build-output-files 

    The first link regarding getting started with the Thingy:53 does only contain steps to use precompiled samples which does not require you to generate any builds. Could you verify if you were able to see the precompiled *.bins for the various samples in the zip in step 1-2 under "Updating through USB"?

    If you wish to generate your own builds, the best step is to go through section 1 of the Academy course you linked, and then open a sample through the toolchain manager

    zachwork said:
    Side note: I tried installing the SDK v2.3.0 through the toolchain manager originally but it wasn't fully installing. It didn't actually install of the necessary pieces but it says it was complete. I tried uninstalling and reinstalling twice and I only get a partial install each time with no errors.

    Could you state the following:

    1. Which OS are you using?
      1. Supported OS's can be seen here: developer.nordicsemi.com/.../recommended_versions.html
    2. Which version of the toolchain manager are you running?
    3. Are you able to install other instances of nRF Connect SDK through the toolchain manager according to lesson 1 in the DevAcademy? https://academy.nordicsemi.com/lessons/lesson-1-nrf-connect-sdk-introduction/

    Kind regards,
    Andreas

  • My system setup is below:

    OS: Windows 10 Enterprise V. 10.0.19044

    nRF Connect for Desktop: v4.1.1

    Toolchain Manager: v1.2.4

    When I first tried to install v2.3.0 of the SDK I had nothing else installed from nRF on my computer and I got a partial install. I removed that version and installed v2.2.0 without issue.

    This morning I updated the toolchain manager to v1.2.5 and am uninstalling any instance of the SDK. I will then reinstall v2.3.0 and see if it works.

  • After updating the toolchain manager and installing v2.3.0 of the SDK the blinky example now compiles with the DFU variant without the need for modifications.

    BUT now I have other examples failing to compile for the thingy53_nrf5340_cpuapp_ns board target. I'm trying to build the peripheral_uart sample from the nrf SDK and it's erroring out on a line of code in the main.c file.

    Seems like something is wrong with the configuration or my toolchain install.

    Do I have to use a different .conf file than prj.conf for the thingy53 target?


    [140/402] Building C object CMakeFiles/app.dir/src/main.c.obj
    FAILED: CMakeFiles/app.dir/src/main.c.obj
    C:\ncs\toolchains\v2.3.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_USER_CONFIG_FILE=\"nrf-config-user.h\" -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DNRF_TRUSTZONE_NONSECURE -DTFM_PSA_API -DUSE_PARTITION_MANAGER=1 -D__PROGRAM_START -D__ZEPHYR__=1 -I../. -IC:/ncs/v2.3.0/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.3.0/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/ncs/v2.3.0/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.3.0/zephyr/subsys/bluetooth -IC:/ncs/v2.3.0/zephyr/subsys/usb/device -IC:/ncs/v2.3.0/zephyr/subsys/settings/include -IC:/ncs/v2.3.0/nrf/include -IC:/ncs/v2.3.0/nrf/include/tfm -IC:/ncs/v2.3.0/nrf/tests/include -Itfm/generated/interface/include -IC:/ncs/v2.3.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.3.0/modules/hal/nordic/nrfx -IC:/ncs/v2.3.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.3.0/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.3.0/zephyr/modules/hal_nordic/nrfx/. -Imodules/libmetal/libmetal/lib/include -IC:/ncs/v2.3.0/modules/lib/open-amp/open-amp/lib/include -IC:/ncs/v2.3.0/modules/debug/segger/SEGGER -IC:/ncs/v2.3.0/modules/debug/segger/Config -IC:/ncs/v2.3.0/zephyr/modules/segger/. -IC:/ncs/v2.3.0/modules/crypto/tinycrypt/lib/include -Itfm/install/interface/include -IC:/ncs/v2.3.0/nrfxlib/softdevice_controller/include -Imodules/nrfxlib/nrfxlib/nrf_security/src/include/generated -IC:/ncs/v2.3.0/nrfxlib/nrf_security/include -IC:/ncs/v2.3.0/nrfxlib/nrf_security/include/mbedtls -IC:/ncs/v2.3.0/modules/crypto/mbedtls/include -IC:/ncs/v2.3.0/modules/crypto/mbedtls/include/mbedtls -IC:/ncs/v2.3.0/modules/crypto/mbedtls/include/psa -IC:/ncs/v2.3.0/modules/crypto/mbedtls/library -IC:/ncs/v2.3.0/nrfxlib/crypto/nrf_oberon/include/mbedtls -IC:/ncs/v2.3.0/nrfxlib/crypto/nrf_oberon/include -isystem C:/ncs/v2.3.0/zephyr/lib/libc/minimal/include -isystem c:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include -isystem c:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include-fixed -fno-strict-aliasing -Os -imacros C:/Users/brongzr1/Documents/Repositories/nRF_experiments/sdk_peripheral_uart/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.3.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/Users/brongzr1/Documents/Repositories/nRF_experiments/sdk_peripheral_uart=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.3.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.3.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles\app.dir\src\main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c ../src/main.c
    ../src/main.c: In function 'uart_test_async_api':
    ../src/main.c:230:22: error: 'const struct uart_driver_api' has no member named 'callback_set'; did you mean 'irq_callback_set'?
    230 | return (api->callback_set != NULL);
    | ^~~~~~~~~~~~
    | irq_callback_set
    [149/402] Building C object zephyr/drivers/usb/device/CMakeFiles/drivers__usb__device.dir/usb_dc_nrfx.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\v2.3.0\opt\bin\cmake.EXE' --build 'C:\Users\brongzr1\Documents\Repositories\nRF_experiments\sdk_peripheral_uart\build'

  • I ended up solving this new issue by commenting the following lines from the main.c code:

    Lines 225-221:

    // static bool uart_test_async_api(const struct device *dev)
    // {
    // 	const struct uart_driver_api *api =
    // 			(const struct uart_driver_api *)dev->api;
    
    // 	return (api->callback_set != NULL);
    // }
    Lines 262-266:
    	// if (IS_ENABLED(CONFIG_BT_NUS_UART_ASYNC_ADAPTER) && !uart_test_async_api(uart)) {
    	// 	/* Implement API adapter */
    	// 	uart_async_adapter_init(async_adapter, uart);
    	// 	uart = async_adapter;
    	// }
    Doing this allowed it to fully compile on V2.3.0 of the SDK.
    Wrapping up the solution to my original MCUBOOT question was to upgrade to the latest SDK at the time.
    The solution to the SDK not properly installing was to update the toolchain manager to the latest version.
    And finally the solution to my peripheral_uart example not compiling was to remove the lines related to async_uart.
  • Hi,

    zachwork said:
    Wrapping up the solution to my original MCUBOOT question was to upgrade to the latest SDK at the time.
    The solution to the SDK not properly installing was to update the toolchain manager to the latest version.
    And finally the solution to my peripheral_uart example not compiling was to remove the lines related to async_uart.

    Glad you managed to get everything to compile and run, and thank you for sharing the fixes! We really appreciate it.

    Let me know if this concludes this case for now, or if you have any unanswered or new questions related to this topic

    Kind regards,
    Andreas

  • I think this fully closes this question/case. If I run into other issues I will make a separate ticket.

Reply Children
No Data
Related