Cannot build new image for FOTA through MCUboot

Hi.

I want to build firmware for FOTA into the slot1 partition.

I'm using NCS 2.5.0 in Visual Studio Code Envrionment.

I already build primary firmware(old firmware) with mcuboot and it works well.

but I want to build new image for update.

As I know, MCUBoot read slot1 that new firmware is located in.

So I want to build new firmware in slot 1, but It doesn't work.

I add CONFIG_BUILD_S1_VARIANT=y and CONFIG_SECURE_BOOT, but Compiler print out about error on Cmake.

Here is my error log

Building test_image_0
west build --build-dir c:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build c:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0 --pristine --board starpickers_l200 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=c:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/prj.conf -DBOARD_ROOT=c:/ncs/v2.5.0/nrf

-- west build: making build dir c:\Users\jswco\OneDrive\Desktop\Github\Firmware\test_image_0\build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0
-- CMake version: 3.20.5
-- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: C:/ncs/v2.5.0/zephyr/.cache
-- Zephyr version: 3.4.99 (C:/ncs/v2.5.0/zephyr)
-- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
-- Board: starpickers_l200
-- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
-- Found Dtc: C:/ncs/toolchains/c57af46cb7/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") 
-- Found BOARD.dts: C:/ncs/v2.5.0/nrf/boards/arm/starpickers_l200/starpickers_l200.dts
-- Generated zephyr.dts: C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/zephyr/zephyr.dts
-- Generated devicetree_generated.h: C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/zephyr/dts.cmake
Parsing C:/ncs/v2.5.0/zephyr/Kconfig
Loaded configuration 'C:/ncs/v2.5.0/nrf/boards/arm/starpickers_l200/starpickers_l200_defconfig'
Merged configuration 'c:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/prj.conf'
Configuration saved to 'C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/zephyr/.config'
Kconfig header saved to 'C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/zephyr/include/generated/autoconf.h'
-- Found GnuLd: c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (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: C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe

=== child image b0 -  begin ===
loading initial cache file C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/b0/child_image_preload.cmake
Loading Zephyr default modules (Zephyr base).
-- Application: C:/ncs/v2.5.0/nrf/samples/bootloader
-- CMake version: 3.20.5
-- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: C:/ncs/v2.5.0/zephyr/.cache
-- Zephyr version: 3.4.99 (C:/ncs/v2.5.0/zephyr)
-- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
-- Board: starpickers_l200
-- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
-- Found Dtc: C:/ncs/toolchains/c57af46cb7/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") 
-- Found BOARD.dts: C:/ncs/v2.5.0/nrf/boards/arm/starpickers_l200/starpickers_l200.dts
-- Generated zephyr.dts: C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/b0/zephyr/zephyr.dts
-- Generated devicetree_generated.h: C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/b0/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/b0/zephyr/dts.cmake

warning: UART_NRFX (defined at drivers/serial/Kconfig.nrfx:6) has direct dependencies (DT_HAS_NORDIC_NRF_UART_ENABLED || DT_HAS_NORDIC_NRF_UARTE_ENABLED) && SERIAL with value n, but is currently being y-selected by the following symbols:
 - SECURE_BOOT_DEBUG_UART (defined at C:/ncs/v2.5.0/nrf\subsys\bootloader/Kconfig:222), with value y, direct dependencies <choice SECURE_BOOT_DEBUG_BACKEND> (value: y), and select condition <choice SECURE_BOOT_DEBUG_BACKEND> (value: y)

warning: UART_CONSOLE (defined at drivers/console/Kconfig:43) has direct dependencies SERIAL && SERIAL_HAS_DRIVER && CONSOLE with value n, but is currently being y-selected by the following symbols:
 - SECURE_BOOT_DEBUG_UART (defined at C:/ncs/v2.5.0/nrf\subsys\bootloader/Kconfig:222), with value y, direct dependencies <choice SECURE_BOOT_DEBUG_BACKEND> (value: y), and select condition <choice SECURE_BOOT_DEBUG_BACKEND> (value: y)

error: Aborting due to Kconfig warnings

Parsing C:/ncs/v2.5.0/zephyr/Kconfig
Loaded configuration 'C:/ncs/v2.5.0/nrf/boards/arm/starpickers_l200/starpickers_l200_defconfig'
Merged configuration 'C:/ncs/v2.5.0/nrf/samples/bootloader/prj.conf'
Merged configuration 'C:/ncs/v2.5.0/nrf/subsys/partition_manager/partition_manager_enabled.conf'
Merged configuration 'C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/b0/zephyr/misc/generated/extra_kconfig_options.conf'
CMake Error at C:/ncs/v2.5.0/zephyr/cmake/modules/kconfig.cmake:348 (message):
  command failed with return code: 1
Call Stack (most recent call first):
  C:/ncs/v2.5.0/nrf/cmake/modules/kconfig.cmake:29 (include)
  C:/ncs/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
  C:/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  C:/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:9 (find_package)


-- Configuring incomplete, errors occurred!
CMake Error at C:/ncs/v2.5.0/nrf/cmake/multi_image.cmake:449 (message):
  CMake generation for b0 failed, aborting.  Command: 1
Call Stack (most recent call first):
  C:/ncs/v2.5.0/nrf/cmake/multi_image.cmake:178 (add_child_image_from_source)
  C:/ncs/v2.5.0/nrf/samples/CMakeLists.txt:18 (add_child_image)


-- Configuring incomplete, errors occurred!
See also "C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/build/CMakeFiles/CMakeError.log".
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe '-Bc:\Users\jswco\OneDrive\Desktop\Github\Firmware\test_image_0\build' -GNinja -DBOARD=starpickers_l200 -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=c:/Users/jswco/OneDrive/Desktop/Github/Firmware/test_image_0/prj.conf -DBOARD_ROOT=c:/ncs/v2.5.0/nrf '-Sc:\Users\jswco\OneDrive\Desktop\Github\Firmware\test_image_0'

 *  The terminal process terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

And this is my prj.conf

# General Config
CONFIG_CPP=y

# RTT Config
CONFIG_CONSOLE=y
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_CBPRINTF_COMPLETE=y
CONFIG_CBPRINTF_FP_SUPPORT=y

# BT 설정
CONFIG_BT=y
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_OBSERVER=y

# MCUBoot
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_BOOTLOADER_MODE_OVERWRITE_ONLY=y

# MCUMGR
CONFIG_SECURE_BOOT=y
CONFIG_BUILD_S1_VARIANT=y
CONFIG_FW_INFO=y
CONFIG_SB_SIGNING_KEY_FILE="C:/ncs/v2.5.0/bootloader/mcuboot/root-rsa-2048.pem"
CONFIG_SERIAL=n

How can I build firmware for Slot 1?

Parents
  • Thank you for reply.

    I checked that postings, but not work for me.

    I still got same message

    warning: UART_NRFX (defined at drivers/serial/Kconfig.nrfx:6) has direct dependencies (DT_HAS_NORDIC_NRF_UART_ENABLED || DT_HAS_NORDIC_NRF_UARTE_ENABLED) && SERIAL with value n, but is currently being y-selected by the following symbols:
     - SECURE_BOOT_DEBUG_UART (defined at C:/ncs/v2.5.0/nrf\subsys\bootloader/Kconfig:222), with value y, direct dependencies <choice SECURE_BOOT_DEBUG_BACKEND> (value: y), and select condition <choice SECURE_BOOT_DEBUG_BACKEND> (value: y)
    
    warning: UART_CONSOLE (defined at drivers/console/Kconfig:43) has direct dependencies SERIAL && SERIAL_HAS_DRIVER && CONSOLE with value n, but is currently being y-selected by the following symbols:
     - SECURE_BOOT_DEBUG_UART (defined at C:/ncs/v2.5.0/nrf\subsys\bootloader/Kconfig:222), with value y, direct dependencies <choice SECURE_BOOT_DEBUG_BACKEND> (value: y), and select condition <choice SECURE_BOOT_DEBUG_BACKEND> (value: y)
    
    error: Aborting due to Kconfig warnings

    How can do?

  • Could you create child_image\create b0.conf under the application to include "CONFIG_SECURE_BOOT_DEBUG=n" to disable debugging NSIB function?

    If you still have the issue, please upload the project and board file. 

  • Thank you for reply.

    I managed to build s1 image for upgrade.

    I modified prj.conf in ncs/v2.5.0/nrf/samples/bootloader, but I didn't set this path by myself.

    So, my question is as follow.

    1. How can I modify s1 image configuration file path?

    2. What is the B0, S0, S1 Image(Its meaning)

    3. Which image can be used as upgrade image? I got lots of hex files.(Plz see below image)

    4. Finally, How can I set the start / end address of each image? I want to use MCUboot-Primary Slot-Secondary Slot structrue.

    5. I want to design my MCU's partition as follow:(pm_static.yml in project folder)

    mcuboot:
      address: 0x00
      end_address: 0x8000
      size: 0x8000
      region: flash_primary
    s0:
      address: 0x8000
      end_address: 0x44000
      size: 0x3C000
      region: flash_primary
    s1:
      address: 0x44000
      end_address: 0x80000
      size: 0x3C000
      region: flash_primary
    sram_primary:
      address: 0x20000000
      end_address: 0x20010000
      region: sram_primary
      size: 0x10000
    

    But it makes error. What is the probielm?

    My intend is that s0 is primary slot, s1 is secondary slot for new firmware, and mcuboot is for bootloader. As you know, nRF52832 has 512KB internal flashes, so I divided it in 3 pieces. but it is not work.

  • Hi,

    jswcomkr said:
    I modified prj.conf in ncs/v2.5.0/nrf/samples/bootloader, but I didn't set this path by myself.

    I would not suggest you modify prj.conf of ncs/v2.5.0/nrf/samples/bootloader directly. You can add the NSIB as a child image to your application by enabling CONFIG_SECURE_BOOT=y. Here is an command example. 

    jswcomkr said:
    1. How can I modify s1 image configuration file path?

    When adding the NSIB as a child image by enabling CONFIG_SECURE_BOOT=y, you can create child_image\create b0.conf under the application to overwrite the configuration. 

    jswcomkr said:
    2. What is the B0, S0, S1 Image(Its meaning)

    B0 is nRF Secure Immutable Bootloader (NSIB). S0 and S1 are updateable MCUboot. See https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.0/nrf/samples/bootloader/README.html#pre-signed-variants 

    jswcomkr said:
    3. Which image can be used as upgrade image? I got lots of hex files.(Plz see below image)

    We have https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.0/nrf/config_and_build/config_and_build_system.html#output-build-files which describes signed_by_mcuboot_and_b0_s0_image_update, which is the image you will want to use. Also, see this post. 

    jswcomkr said:
    4. Finally, How can I set the start / end address of each image? I want to use MCUboot-Primary Slot-Secondary Slot structrue.

    It would be handled by partition manager which would be enabled automatically with muti-build. 

    jswcomkr said:
    5. I want to design my MCU's partition as follow:(pm_static.yml in project folder)

    Remove the pm_static.yml. Let the partition manager handle it for you. 

    jswcomkr said:
    My intend is that s0 is primary slot, s1 is secondary slot for new firmware, and mcuboot is for bootloader.

    S0 and S1 are for updating the mcuboot instead of app.  See https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.0/nrf/samples/bootloader/README.html#pre-signed-variants 

    jswcomkr said:
    As you know, nRF52832 has 512KB internal flashes, so I divided it in 3 pieces. but it is not work.

    Do you want to update mcuboot or just the app?

    If you just want to update the app image, you can just enable the DFU as my colleague suggested in this post. Then, the memory layout would look like this

    -Amanda H.

  • Thank you for reply.

    I checked again and applied it to my project.

    So, I finally got the app_update.hex and bin file.

    I want to write it to memory slot 1 by manually, because LTE modem cannot send any SMP messages.

    So, my plan is as follow.

    1. LTE modem download new binary or hex file(maybe app_update.bin or app_update.hex ??) from our server, and it will be stored in LTE Modem's internal flash.

    2. Read downloaded file LTE modem through UART one by one byte using AT Command and Write it into the slot 1 flash(Maybe from 0x45000)

    3. After write all data, reboot using NVIC_SystemReset(); function.

    4. MCUboot will check new firmware in slot1 automatically.

    5. If it is valid, MCUboot will copy new firmware from slot1 to slot 0.

    6. After the copy is complete, device will reboot and start with new firmware.

    Is it possible?

Reply
  • Thank you for reply.

    I checked again and applied it to my project.

    So, I finally got the app_update.hex and bin file.

    I want to write it to memory slot 1 by manually, because LTE modem cannot send any SMP messages.

    So, my plan is as follow.

    1. LTE modem download new binary or hex file(maybe app_update.bin or app_update.hex ??) from our server, and it will be stored in LTE Modem's internal flash.

    2. Read downloaded file LTE modem through UART one by one byte using AT Command and Write it into the slot 1 flash(Maybe from 0x45000)

    3. After write all data, reboot using NVIC_SystemReset(); function.

    4. MCUboot will check new firmware in slot1 automatically.

    5. If it is valid, MCUboot will copy new firmware from slot1 to slot 0.

    6. After the copy is complete, device will reboot and start with new firmware.

    Is it possible?

Children
Related