Skip to content

Commit b34c975

Browse files
committed
sysbuild: full example of sysbuild with mcuboot and multiple images
1 parent 76f9e7a commit b34c975

File tree

13 files changed

+99
-0
lines changed

13 files changed

+99
-0
lines changed

sysbuild-example/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Author: James Walmsley <[email protected]>
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
test_sysbuild()
8+
9+
project(hello_world)
10+
11+
target_sources(app PRIVATE mfg_image/src/main.c)
12+

sysbuild-example/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Example Sysbuild Project
2+
3+
The aim of this folder is to demonstrate a typical sysbuild project from the ground-up.
4+
5+
## Build
6+
7+
```
8+
cd my-workspace/example-application
9+
west build --sysbuild sysbuild
10+
```
11+
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 James Walmsley <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZPEHYR_BASE})
6+
7+
project(dfu_app)
8+
target_sources(app PRIVATE src/main.c)
9+

sysbuild-example/dfu_app/prj.conf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CONFIG_BOOTLOADER_MCUBOOT=y
2+
CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="bootloader/mcuboot/root-rsa-2048.pem"
3+
CONFIG_FLASH=y
4+
CONFIG_IMG_MANAGER=y
5+
CONFIG_STREAM_FLASH=y
6+
CONFIG_USB_DFU_CLASS=y
7+
CONFIG_USB_DEVICE_STACK=y
8+
CONFIG_FLASH_MAP=y
9+

sysbuild-example/dfu_app/src/main.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2025 James Walmsley
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/sys/printk.h>
7+
8+
int main(void)
9+
{
10+
printk("Hello world from %s\n", CONFIG_BOARD_TARGET);
11+
12+
return 0;
13+
}
14+
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 James Walmsley <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZPEHYR_BASE})
6+
7+
project(mfg_image)
8+
target_sources(app PRIVATE src/main.c)
9+

sysbuild-example/mfg_image/prj.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_BOOTLOADER_MCUBOOT=y

sysbuild-example/mfg_image/src/main.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2025 James Walmsley
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/sys/printk.h>
7+
8+
int main(void)
9+
{
10+
printk("Manufacturing image on: %s\n", CONFIG_BOARD_TARGET);
11+
12+
return 0;
13+
}
14+

sysbuild-example/prj.conf

Whitespace-only changes.

sysbuild-example/sysbuild.cmake

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2025 James Walmsley <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
ExternalZephyrProject_Add(
5+
APPLICATION mfg_image
6+
SOURCE_DIR ${APP_DIR}/mfg_image
7+
)
8+
9+
ExternalZephyrProject_Add(
10+
APPLICATION dfu_app
11+
SOURCE_DIR ${APP_DIR}/dfu_app
12+
)
13+
14+
add_dependencies(${DEFAULT_IMAGE} mfg_image)
15+
add_dependencies(${DEFAULT_IMAGE} dfu_app)

sysbuild-example/sysbuild.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SB_CONFIG_BOOTLOADER_MCUBOOT=y
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_BOOT_SWAP_USING_SCRATCH=y
2+

west.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ manifest:
2121
- hal_nordic # required by the custom_plank board (Nordic based)
2222
- hal_stm32 # required by the nucleo_f302r8 board (STM32 based)
2323
- mcuboot
24+
- mbedtls

0 commit comments

Comments
 (0)