how to add a project like a custom child image?

Hello:

 

I am Enrique Martinez. Currently I work with nRF52840 in nRFConnect SDK for VS Code. I have problems with documentation about Multi-Image builds ( https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/config_and_build/multi_image.html  and https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/config_and_build/multi_image.html#ug-multi-image). I would like to add my project my_mcuboot (a MCUBoot copy with some printk("") messages) like a child image to my parent project (a blinky sample). This is because I would like to learn how to add my projects like a child image.

 

I have tried to follow the documentation but the Defining and enabling a child image and  Adding a child image using Zephyr modules sections are not clear for me.

The procedure that I follow is as follows:

 

1. I add the following code in the CmakeLists.txt of my parent project 

# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(inter_less8_exer1_1)

target_sources(app PRIVATE src/main.c)

if (CONFIG_MY_MCUBOOT)

   add_child_image(

     NAME my_mcuboot

     SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/my_mcuboot

     )

endif()

 

 

2. I create a Kconfig file in my parent project folder nex to CMakeLists.txt file and I add the simbol named MY_MCUBOOT

 

 

source "Kconfig.zephyr"

config MY_MCUBOOT

    bool "Enable my mcuboot"

    default n

 

 

3. I add the build strategy with the next Kconf option (CONF_MY_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE=y) into the prj.conf file of child image

 

#MY_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE=y

CONF_MY_MCUBOOT_BUILD_STRATEGY_FROM_SOURCE=y

 

4. I add my Kconf option(CONF_MY_MCUBOOT=y)into the prj.conf file of parent image

CONFIG_GPIO=y

# Enable MCUboot

#CONFIG_BOOTLOADER_MCUBOOT=y

CONFIG_MY_MCUBOOT=y

5. I make a pristine build  

When building is stoped by error, the terminal display the next log:

Building inter_less8_exer1_1

C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir c:/nordic/inter_less8_exer1_1/build c:/nordic/inter_less8_exer1_1"

[0/1] Re-running CMake...

Loading Zephyr default modules (Zephyr base (cached)).

-- Application: C:/nordic/inter_less8_exer1_1

-- CMake version: 3.21.0

-- Cache files will be written to: C:/ncs/v2.6.0/zephyr/.cache

-- Zephyr version: 3.5.99 (C:/ncs/v2.6.0/zephyr)

-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")

-- Board: nrf52840dk_nrf52840

-- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)

-- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)

-- Found BOARD.dts: C:/ncs/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts

-- Generated zephyr.dts: C:/nordic/inter_less8_exer1_1/build/zephyr/zephyr.dts

-- Generated devicetree_generated.h: C:/nordic/inter_less8_exer1_1/build/zephyr/include/generated/devicetree_generated.h

-- Including generated dts.cmake file: C:/nordic/inter_less8_exer1_1/build/zephyr/dts.cmake

Parsing C:/nordic/inter_less8_exer1_1/Kconfig

Loaded configuration 'C:/ncs/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'

Merged configuration 'c:/nordic/inter_less8_exer1_1/prj.conf'

Configuration saved to 'C:/nordic/inter_less8_exer1_1/build/zephyr/.config'

Kconfig header saved to 'C:/nordic/inter_less8_exer1_1/build/zephyr/include/generated/autoconf.h'

CMake Error at C:/ncs/v2.6.0/nrf/cmake/multi_image.cmake:159 (message):

CONFIG_PARTITION_MANAGER_ENABLED was not set for image my_mcuboot.This

option must be set for an image to support being added as a childimage

through 'add_child_image'. This is typically done by invoking the

`build_strategy` kconfig template for the child image.

Call Stack (most recent call first):

CMakeLists.txt:10 (add_child_image)

 

-- Configuring incomplete, errors occurred!

See also "C:/nordic/inter_less8_exer1_1/build/CMakeFiles/CMakeOutput.log".

See also "C:/nordic/inter_less8_exer1_1/build/CMakeFiles/CMakeError.log".

FAILED: build.ninja

C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.exe --regenerate-during-build -SC:\nordic\inter_less8_exer1_1 -BC:\nordic\inter_less8_exer1_1\build

ninja: error: rebuilding 'build.ninja': subcommand failed

FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE' --build 'c:\nordic\inter_less8_exer1_1\build'

* The terminal process terminated with exit code: 1.

* Terminal will be reused by tasks, press any key to close it.

* Executing task: nRF Connect: Build [pristine]: inter_less8_exer1_1/build (active)

Building inter_less8_exer1_1

C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir c:/nordic/inter_less8_exer1_1/build c:/nordic/inter_less8_exer1_1 --pristine --board nrf52840dk_nrf52840 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DBOARD_ROOT=c:/nordic/my_boards -Dmcuboot_DTC_OVERLAY_FILE=C:/ncs/v2.6.0/nrf/modules/mcuboot/usb.overlay -Dmcuboot_OVERLAY_CONFIG=C:/ncs/v2.6.0/nrf/subsys/partition_manager/partition_manager_enabled.conf;C:/nordic/inter_less8_exer1_1/child_image/mcuboot.conf -DCACHED_CONF_FILE=c:/nordic/inter_less8_exer1_1/prj.conf"

-- west build: generating a build system

Loading Zephyr default modules (Zephyr base).

-- Application: C:/nordic/inter_less8_exer1_1

-- CMake version: 3.21.0

-- Found Python3: C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe (found suitable version "3.9.13", minimum required is "3.8") found components: Interpreter

-- Cache files will be written to: C:/ncs/v2.6.0/zephyr/.cache

-- Zephyr version: 3.5.99 (C:/ncs/v2.6.0/zephyr)

-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")

-- Board: nrf52840dk_nrf52840

-- Found host-tools: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)

-- Found toolchain: zephyr 0.16.5 (C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk)

-- Found Dtc: C:/ncs/toolchains/cf2149caf2/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")

-- Found BOARD.dts: C:/ncs/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts

-- Generated zephyr.dts: C:/nordic/inter_less8_exer1_1/build/zephyr/zephyr.dts

-- Generated devicetree_generated.h: C:/nordic/inter_less8_exer1_1/build/zephyr/include/generated/devicetree_generated.h

-- Including generated dts.cmake file: C:/nordic/inter_less8_exer1_1/build/zephyr/dts.cmake

Parsing C:/nordic/inter_less8_exer1_1/Kconfig

Loaded configuration 'C:/ncs/v2.6.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'

Merged configuration 'c:/nordic/inter_less8_exer1_1/prj.conf'

Configuration saved to 'C:/nordic/inter_less8_exer1_1/build/zephyr/.config'

Kconfig header saved to 'C:/nordic/inter_less8_exer1_1/build/zephyr/include/generated/autoconf.h'

-- Found GnuLd: c:/ncs/toolchains/cf2149caf2/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/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe

CMake Error at C:/ncs/v2.6.0/nrf/cmake/multi_image.cmake:159 (message):

CONFIG_PARTITION_MANAGER_ENABLED was not set for image my_mcuboot.This

option must be set for an image to support being added as a childimage

through 'add_child_image'. This is typically done by invoking the

`build_strategy` kconfig template for the child image.

Call Stack (most recent call first):

CMakeLists.txt:10 (add_child_image)

 

-- Configuring incomplete, errors occurred!

See also "C:/nordic/inter_less8_exer1_1/build/CMakeFiles/CMakeOutput.log".

See also "C:/nordic/inter_less8_exer1_1/build/CMakeFiles/CMakeError.log".

FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe '-Bc:\nordic\inter_less8_exer1_1\build' -GNinja -DBOARD=nrf52840dk_nrf52840 -DNCS_TOOLCHAIN_VERSION=NONE -DBOARD_ROOT=c:/nordic/my_boards -Dmcuboot_DTC_OVERLAY_FILE=C:/ncs/v2.6.0/nrf/modules/mcuboot/usb.overlay '-Dmcuboot_OVERLAY_CONFIG=C:/ncs/v2.6.0/nrf/subsys/partition_manager/partition_manager_enabled.conf;C:/nordic/inter_less8_exer1_1/child_image/mcuboot.conf' -DCACHED_CONF_FILE=c:/nordic/inter_less8_exer1_1/prj.conf '-Sc:\nordic\inter_less8_exer1_1'

 

I can apreciate that the error is due to the partition manager is not enable and it recomends to add a build strategy to enable it. 

 

Then, Could you tell me step by step what I have to do to add my_mcuboot project like a child image? please.

 

Thanks for reading

Related