MCUBoot build issue CMake Error "NOT" "EXISTS" when adding mcuboot.conf

Hello,

I've been having issues trying to add MCUBoot to our application. The app is based on the Common Application Framework (CAF) with a structure based on the nrf_desktop application. 

├───app
│   │   CMakeLists.txt
│   │   Kconfig
│   │
│   ├───configuration
│   │   ├───custom_board
│   │   │       buttons_def.h
│   │   │       prj.conf
│   │   │
│   │   ├───nrf52dk_nrf52832
│   │   │   │   app.overlay
│   │   │   │   buttons_def.h
│   │   │   │   prj.conf
│   │   │   │   prj_a.conf
│   │   │   │
│   │   │   └───child_image
│   │   │           priv.pem
│   │   │
│   │   └───_common
│   │           ble_adv_def.h
│   │           btn_service.h
│   │           debug.conf
│   │           dev_descr.h
│   │           led_state.h
│   │           led_state_def.h
│   │
│   └───src
│       │   main.c
│       │
│       └───modules
│               CMakeLists.txt
│               Kconfig
│               Kconfig.led_state
│               led_state.c
│
├───boards
│   └───arm
│       └───custom_board
│               custom_board.dts
│               custom_board.yaml
│               custom_board_defconfig
│               board.cmake
│               Kconfig.board
│               Kconfig.defconfig
│ 
├───drivers
│   │   CMakeLists.txt
│   │   Kconfig
│   │
│   └───sensor
│       │   CMakeLists.txt
│       │   Kconfig
│       │
│       └───examplesensor
│               CMakeLists.txt
│               examplesensor.c
│               Kconfig
│
├───dts
│   └───bindings
│       └───sensor
│               zephyr,examplesensor.yaml

When I add MCUBoot to the nrf52dk's prj.conf using
CONFIG_MCUMGR=y
CONFIG_CAF_BLE_SMP=y
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
CONFIG_MCUMGR_SMP_BT=y
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
The build fails with

[257/257] Linking C executable zephyr\zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 34432 B 48 KB 70.05%
SRAM: 23744 B 64 KB 36.23%
IDT_LIST: 0 GB 2 KB 0.00%
[279/297] Linking C executable zephyr\zephyr_prebuilt.elf
FAILED: zephyr/zephyr_prebuilt.elf zephyr/zephyr_prebuilt.map
cmd.exe /C "cd . && C:\ncs\v1.8.0\toolchain\opt\bin\arm-none-eabi-gcc.exe @CMakeFiles\zephyr_prebuilt.rsp -o zephyr\zephyr_prebuilt.elf && cmd.exe /C "cd /D C:\Users\Mark\Documents\Projects\Ratio\ratio-shift-firmware\app\build_dk_mech_dbg\zephyr && C:\ncs\v1.8.0\toolchain\opt\bin\cmake.exe -E echo ""
c:/ncs/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: zephyr\zephyr_prebuilt.elf section `rodata' will not fit in region `FLASH'
c:/ncs/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 21940 bytes

 

So, following https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/device-firmware-update-dfu-with-mcuboot-bootloader and the documentation in https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_multi_image.html#image-specific-variables I added a mcuboot.conf file in the child_image directory with 

CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x40000
CONFIG_SIZE_OPTIMIZATIONS=y
Think that it should be merged with the default bootloader .conf. However, I now get
CMake Error at C:\ncs\v1.8.0\zephyr\cmake\extensions.cmake:2035 (if):
if given arguments:

"NOT" "EXISTS" "C:/ncs/v1.8.0/nrf/subsys/partition_manager/partition_manager_enabled.conf" "C:/Users/Mark/Documents/Projects/foobar/app/configuration/nrf52dk_nrf52832/child_image/mcuboot.conf"

Unknown arguments specified
Call Stack (most recent call first):
c:\Users\Mark\Documents\Projects\foobar\app\build_dk_mech_dbg\CMakeLists.txt:52 (assert_exists)


This is the build command: 
west build --build-dir app/build_dk_dbg --board nrf52dk_nrf52832 --pristine --cmake-only app -- -DOVERLAY_CONFIG='C:/Users/User/Documents/Projects/foobar/app/configuration/_common/debug.conf' -DCONF_FILE='C:/Users/User/Documents/Projects/foobar/app/configuration/nrf52dk_nrf52832/prj_a.conf

I must say that I find the combination of the partition manager and configuration in child_image .conf files quite confusing. Any help is appreciated!

Parents
  • Ok, I've gotten a bit further.

    1. I think the flash overflow was due to the application image being too big, not the MCUboot bootloader. It would have been useful if the build logs told you that though! Reducing the things included in the application makes it work

    2. mcuboot.conf would not be merged with the default config because of the parent build being proj_a.conf. So the file would have to be called mcuboot_a.conf.

    However, I'd like to reduce the size of MCUboot now, to gain extra space for the application. If I just want a single .conf file for MCUboot to always replace the default .prj, how do I do that?

    I've currently added a child_image/mcuboot/prj_a.conf with the contents of the default prj_minimal + 

    CONFIG_PM_PARTITION_SIZE_MCUBOOT=9000 but it's not being picked up.

    Also, I don't want the same prj_a, prj_b, prj_c .conf files with the same content for multiple builds but I don't know how to avoid that!
  • Ok, I've managed to do it using command line arguments, adding -Dmcuboot_CONF_FILE=<full_path_to>/mcuboot.conf

Reply Children
Related