Skip to content

Adding a sysbuild example #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ Before getting started, make sure you have a proper Zephyr development
environment. Follow the official
[Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html).


### Python VENV

To get started its recommended to initialize a virtual-environment for python.

```
mkdir -p my-workspace
cd my-workspace
python -m venv .venv
source .venv/bin/activate # note. activate.{fish,csh} etc for other shells!
```

From there you can install west and all the required python dependencies for zephyr's build system
without touching your system's python installation.

```
pip install west
```

### Initialization

The first step is to initialize the workspace folder (``my-workspace``) where
Expand All @@ -68,6 +87,12 @@ cd my-workspace
west update
```

Before building, ensure all required python packages are installed

```
west packages pip --install
```

### Building and running

To build the application, run the following command:
Expand Down
33 changes: 33 additions & 0 deletions app/boards/nucleo_f413zh.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/

/* This devicetree overlay file will be automatically picked by the Zephyr
* build system when building the sample for the nucleo_f413zh board. It shows
* how the example-application can be built on sample boards already provided
* by Zephyr.
*/

/ {
example_sensor: example-sensor {
compatible = "zephyr,example-sensor";
input-gpios = <&gpioc 13 (GPIO_ACTIVE_HIGH)>;
};

blink_led: blink-led {
compatible = "blink-gpio-led";
led-gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
blink-period-ms = <1000>;
};
};

&gpioc {
status = "okay";
};

&gpiob {
status = "okay";
};


12 changes: 12 additions & 0 deletions sysbuild-example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
# Author: James Walmsley <[email protected]>

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
test_sysbuild()

project(hello_world)

target_sources(app PRIVATE mfg_image/src/main.c)

11 changes: 11 additions & 0 deletions sysbuild-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Example Sysbuild Project

The aim of this folder is to demonstrate a typical sysbuild project from the ground-up.

## Build

```
cd my-workspace/example-application
west build --sysbuild sysbuild
```

9 changes: 9 additions & 0 deletions sysbuild-example/dfu_app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2025 James Walmsley <[email protected]>
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZPEHYR_BASE})

project(dfu_app)
target_sources(app PRIVATE src/main.c)

9 changes: 9 additions & 0 deletions sysbuild-example/dfu_app/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="bootloader/mcuboot/root-rsa-2048.pem"
CONFIG_FLASH=y
CONFIG_IMG_MANAGER=y
CONFIG_STREAM_FLASH=y
CONFIG_USB_DFU_CLASS=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_FLASH_MAP=y

15 changes: 15 additions & 0 deletions sysbuild-example/dfu_app/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2025 James Walmsley
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/sys/printk.h>

int main(void)
{
printk("Hello world from %s\n", CONFIG_BOARD_TARGET);

return 0;
}


9 changes: 9 additions & 0 deletions sysbuild-example/mfg_image/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2025 James Walmsley <[email protected]>
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZPEHYR_BASE})

project(mfg_image)
target_sources(app PRIVATE src/main.c)

1 change: 1 addition & 0 deletions sysbuild-example/mfg_image/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_BOOTLOADER_MCUBOOT=y
14 changes: 14 additions & 0 deletions sysbuild-example/mfg_image/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2025 James Walmsley
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/sys/printk.h>

int main(void)
{
printk("Manufacturing image on: %s\n", CONFIG_BOARD_TARGET);

return 0;
}

Empty file added sysbuild-example/prj.conf
Empty file.
15 changes: 15 additions & 0 deletions sysbuild-example/sysbuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2025 James Walmsley <[email protected]>
# SPDX-License-Identifier: Apache-2.0

ExternalZephyrProject_Add(
APPLICATION mfg_image
SOURCE_DIR ${APP_DIR}/mfg_image
)

ExternalZephyrProject_Add(
APPLICATION dfu_app
SOURCE_DIR ${APP_DIR}/dfu_app
)

add_dependencies(${DEFAULT_IMAGE} mfg_image)
add_dependencies(${DEFAULT_IMAGE} dfu_app)
1 change: 1 addition & 0 deletions sysbuild-example/sysbuild.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SB_CONFIG_BOOTLOADER_MCUBOOT=y
2 changes: 2 additions & 0 deletions sysbuild-example/sysbuild/mcuboot.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_BOOT_SWAP_USING_SCRATCH=y

2 changes: 2 additions & 0 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ manifest:
- cmsis # required by the ARM port
- hal_nordic # required by the custom_plank board (Nordic based)
- hal_stm32 # required by the nucleo_f302r8 board (STM32 based)
- mcuboot
- mbedtls
Loading