This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using a configuration file with mcuboot

SDK Environment: nRF Connect SDK v1.8.0
Target: Decawave DWM1001-DEV. This uses the nRF52832

I used \ncs\v1.8.0\bootloader\mcuboot\samples\zephyr\hello-world as a starting point and used ideas from here and here

I added

set(mcuboot_CONF_FILE
  prj.conf               
  ${CMAKE_CURRENT_LIST_DIR}/mcuboot.conf  
)   

Just after cmake_minimum_required(VERSION 3.8)

And created the file mcuboot.conf

# MCUboot single slot with serial recovery

#CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
#CONFIG_BOOT_SIGNATURE_KEY_FILE="test-key.pem"

CONFIG_MCUBOOT_SERIAL=y

# Setup boot detect pin
CONFIG_BOOT_SERIAL_DETECT_PORT="GPIO_0"
CONFIG_BOOT_SERIAL_DETECT_PIN=2
CONFIG_BOOT_SERIAL_DETECT_PIN_VAL=0

# Enable serial recovery
CONFIG_BOOT_SERIAL_UART=y
CONFIG_UART_CONSOLE=n
CONFIG_CONSOLE=n
CONFIG_CONSOLE_HANDLER=n

# Enable single slot mode
CONFIG_SINGLE_APPLICATION_SLOT=y

When compiled I get the error:

CMake Error at C:/ncs/v1.8.0/nrf/modules/mcuboot/CMakeLists.txt:238 (file):
file STRINGS file "C:/ncs/v1.8.0/nrf/modules/mcuboot/prj.conf" cannot be
read.

prj.conf can be found at /ncs/v1.8.0/bootloader/mcuboot/boot/zephyr/prj.conf

If I instead add

set(mcuboot_CONF_FILE
  /ncs/v1.8.0/bootloader/mcuboot/boot/zephyr/prj.conf               
  ${CMAKE_CURRENT_LIST_DIR}/mcuboot.conf  
) 

Just after cmake_minimum_required(VERSION 3.8), the program compiles ok.

I would rather not have an absolute path to the file here, as this will catch me out when I update the ncs to a newer version.

I tried adding the following instead

set(mcuboot_CONF_FILE                   
  ${ZEPHYR_BASE}/bootloader/mcuboot/boot/zephyr/prj.conf                        
  ${CMAKE_CURRENT_LIST_DIR}/mcuboot.conf  
)       

This does not work as ZEPHYR_BASE is not set yet. If I move this to after find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}), the configuration in mcuboot.conf appears to have no effect.

Is there a better way to handle this?

I have attached the complete project:

6864.hello-world.zip

Built using

west build -b decawave_dwm1001_dev2 --pristine -d build2 /ncs/myapps/bootloader/hello-world -- -DBOARD_ROOT=/ncs/myapps/bootloader/hello-world

Programmed to the device using

west flash --runner nrfjprog --bin-file build/zephyr/app_update.bin -d build2

Firmware updates via the serial port using

mcumgr.exe --conntype=serial --connstring=COM8 image upload build2\zephyr\app_update.bin

Parents
  • Hi David, 
    I found what worked for me the smoothest is putting a mcu_boot.conf into the child_image folder in the project root folder to have an overlay over the original proj.conf
    Doing that I don't need to define the path to the file. 

    I removed the code set(mcuboot_CONF_FILE ... from "CMakeLists.txt"

    Created the folder "child_image" and moved "mcuboot.conf" into it.

    The project now does not build. It appears that "mcuboot.conf" in the folder "child_image" has replaced "\ncs\v1.8.0\bootloader\mcuboot\boot\zephyr\prj.conf" instead of adding to it.

    For a test, I added the contents of "\ncs\v1.8.0\bootloader\mcuboot\boot\zephyr\prj.conf" into the start of "mcuboot.conf". The problem now is that it is trying to find "test-key.pem" at 'C:/ncs/v1.8.0/bootloader/mcuboot/test-key.pem' instead of in the project directory. Changing CONFIG_BOOT_SIGNATURE_KEY_FILE in "mcuboot.conf" to an absolute path fixed that CONFIG_BOOT_SIGNATURE_KEY_FILE="/ncs/myapps/bootloader/key/test-key.pem". The project now builds.

    Is there a way using this method for "mcuboot.conf" in the folder "child_image" to be in addition to "\ncs\v1.8.0\bootloader\mcuboot\boot\zephyr\prj.conf" instead of replacing it?

  • Hi David, 
    Could you tried again with my example here. 
    Please edit mcuboot.conf to point to the absolute folder you copied the project to. 

    I tested with nrf52dk_nrf52832 board and it worked both in VS Code and when compile from command line.

    peripheral_hr_SMP.zip

Reply Children
  • Thanks Hung Bui

    "peripheral_hr_SMP.zip" builds ok for me.

    I went back to see what the difference between your example and mine was. Previously when "mcuboot.conf" was in the folder "child_image", I had to add the contents of "\ncs\v1.8.0\bootloader\mcuboot\boot\zephyr\prj.conf" into the start of "mcuboot.conf" to get it to build. Now for some reason I don't have to. Simply moving "mcuboot.conf" into the folder "child_image" is now working. I have no idea what has changed apart from my computer being restarted.

    I have attached the updated version of hello-world

    hello-world2.zip

Related