Migrating a Zephyr Project from Child/Parent Build System to Sysbuild: First Steps and Questions

Migrating a Zephyr Project from Child/Parent Build System to Sysbuild: First Steps and Questions

I’m currently in the process of migrating my Zephyr project from the traditional child/parent build system to the newer sysbuild system. While I’ve found the transition to be a bit challenging, I’m excited about the potential benefits that sysbuild offers, such as improved scalability and maintainability.

Current Project Structure

My current project structure is as follows:

application
├── CMakeLists.txt
├── prj.conf
├── boards
│ └── arm
│ ├── board_A
│ └── board_B
├── child_image
│ └── mcuboot
│ ├── prj.conf
│ └── boards
│ ├── board_A.conf
│ └── board_B.conf
├── keys
│ ├── board_A.pem
│ └── board_B.pem
└── src

Initial Steps

From what I understand, the first step in migrating to sysbuild is to remove the child_image folder and replace it with a sysbuild folder. Additionally, a sysbuild.conf file needs to be created. I’ve followed the steps outlined in a helpful post I found, which provided a good foundation for understanding the migration process.

Modified Project Structure

After making the necessary changes, my project structure now looks like this:

application
├── CMakeLists.txt
├── prj.conf
├── sysbuild.conf
├── boards
│ └── arm
│ ├── board_A
│ └── board_B
├── sysbuild
│ └── mcuboot
│ ├── prj.conf
│ └── boards
│ ├── board_A.conf
│ └── board_B.conf
├── keys
│ ├── board_A.pem
│ └── board_B.pem
└── src

Configuration Files

Here’s a brief overview of the key configuration files I’ve modified:

CMakeLists.txt

cmake

SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(gravity_sensor)

target_sources(app PRIVATE
src/main.c
src/app.c
src/status_led.c
src/ble_connection.c
src/icm20948.c
src/error_managing.c
src/memory.c
src/bsm.c
)

prj.conf

conf
CONFIG_LOG=y
CONFIG_LOG_MAX_LEVEL=2
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=n
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_RING_BUFFER=y
CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_REBOOT=y

printf floats support

CONFIG_CBPRINTF_LIBC_SUBSTS=y
CONFIG_CBPRINTF_FP_SUPPORT=y

time library support

CONFIG_NEWLIB_LIBC=y
CONFIG_POSIX_API=y

SOC’s peripherals configuration

CONFIG_GPIO=y
CONFIG_PWM=y
CONFIG_LED=y
CONFIG_I2C=y
CONFIG_NRFX_SPIM0=y
CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_PPI=y

NVS memory configuration

CONFIG_NVS=y

Flash memory support configuration

CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FLASH_MAP=y

BLE configuration

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME=“Gravity Sensor”
CONFIG_BT_DEVICE_APPEARANCE=1345
CONFIG_BT_MAX_CONN=1
CONFIG_BT_LL_SOFTDEVICE=y
CONFIG_BT_BUF_ACL_RX_SIZE=502
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_CONN_TX_MAX=10
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_BUF_ACL_TX_SIZE=502
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_CTLR_PHY_2M=y
CONFIG_BT_CTLR_RX_BUFFERS=2
CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=4000000
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_CONN_RSSI=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=6
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=80
CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

DFU configuration

CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_CRC=y
CONFIG_MCUMGR=y
CONFIG_STREAM_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_FLASH=y
CONFIG_THREAD_MONITOR=y
CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
CONFIG_STATS=y
CONFIG_STATS_NAMES=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUMGR_GRP_IMG=y
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_STAT=y
CONFIG_LOG=y
CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_SERIAL=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_CONSOLE=y
CONFIG_MCUMGR_TRANSPORT_UART=y
CONFIG_BASE64=y

sysbuild.conf

conf
SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y
SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=n
SB_CONFIG_BOOT_SIGNATURE_TYPE_RSA=y
SB_CONFIG_BOOT_SIGNATURE_KEY_FILE=“path/to/key.pem”

Challenges Encountered

Despite these modifications, I’m still encountering an error during the build process. The error message indicates an issue with the CMake configuration, specifically with the list GET command receiving an empty list. I’m not entirely sure what’s causing this, but I suspect it might be related to how the sysbuild configuration is being interpreted.

Questions

  1. Sysbuild Configuration: What exactly should be included in the sysbuild folder and the sysbuild.conf file? Are there any specific guidelines or best practices for setting these up?
  2. Project Configuration: Are there any changes I need to make to the existing prj.conf and CMakeLists.txt files to ensure compatibility with the sysbuild system?
  3. Error Resolution: How can I troubleshoot and resolve the CMake error I’m encountering? Are there any common pitfalls or known issues with the sysbuild migration process?

Seeking Assistance

I’m hoping the community can provide some guidance or insights into these questions. If anyone has experience with migrating projects to the sysbuild system, I’d greatly appreciate any tips, tricks, or resources you can share.

Looking forward to hearing from you all!