-
Notifications
You must be signed in to change notification settings - Fork 161
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
jameswalmsley
wants to merge
4
commits into
zephyrproject-rtos:main
Choose a base branch
from
jameswalmsley:jw/sysbuild-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a1daf45
readme: Update build instructions to support python venv
jameswalmsley 20b18fe
app: overlay: add support for nucleo_stm32f413zh
jameswalmsley d69b8cc
sysbuild: Adding other modules required for a sysbuild example
jameswalmsley 0d78271
sysbuild: full example of sysbuild with mcuboot and multiple images
jameswalmsley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(REQUIRED) | ||
|
||
project(sysbuild-example) | ||
|
||
target_sources(app PRIVATE main_image/src/main.c) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# 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-example \ | ||
-DEXTRA_DTC_OVERLAY_FILE=(pwd)/sysbuild-example/overlays/nucleo_f413zh_partitions.overlay \ | ||
-Dmcuboot_EXTRA_DTC_OVERLAY_FILE=(pwd)/sysbuild-example/overlays/nucleo_f413zh_partitions.overlay \ | ||
-Dmfg_image_EXTRA_DTC_OVERLAY_FILE=(pwd)/sysbuild-example/overlays/nucleo_f413zh_partitions.overlay \ | ||
-Ddfu_app_EXTRA_DTC_OVERLAY_FILE=(pwd)/sysbuild-example/overlays/nucleo_f413zh_partitions.overlay | ||
``` | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/ { | ||
chosen { | ||
zephyr,code-partition = &app_partition; | ||
}; | ||
}; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{ZEPHYR_BASE}) | ||
|
||
project(dfu_app) | ||
target_sources(app PRIVATE src/main.c) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/ { | ||
chosen { | ||
zephyr,code-partition = &app_partition; | ||
}; | ||
}; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 2 %s\n", CONFIG_BOARD_TARGET); | ||
|
||
return 0; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("Main image on: %s\n", CONFIG_BOARD_TARGET); | ||
return 0; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/ { | ||
chosen { | ||
zephyr,code-partition = &app_partition; | ||
}; | ||
}; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_BOOTLOADER_MCUBOOT=y | ||
CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="bootloader/mcuboot/root-rsa-2048.pem" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
42 changes: 42 additions & 0 deletions
42
sysbuild-example/overlays/nucleo_f413zh_partitions.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/delete-node/ &slot0_partition; | ||
/delete-node/ &slot1_partition; | ||
/delete-node/ &scratch_partition; | ||
|
||
&flash0 { | ||
/* | ||
* Setting the erase/write block sizes for stm32f4xx | ||
* Its not defined in the main dts because the devices | ||
* have varying sector sizes. | ||
* | ||
* However we can use 128K as a working size across | ||
* the mcuboot slots. | ||
*/ | ||
erase-block-size = <DT_SIZE_K(128)>; | ||
write-block-size = <1>; | ||
|
||
partitions { | ||
/* | ||
* | ||
*/ | ||
app_partition: app_partition@a { | ||
label = "app-max-size"; | ||
reg = <0x00020000 DT_SIZE_K(512)>; | ||
}; | ||
|
||
/* | ||
* This paritition layout is for SWAP_WITH_MOVE, | ||
* Where the primary slot must be 1 sector bigger than the secondary slot! | ||
*/ | ||
slot0_partition: partition@20000 { | ||
label = "image-0"; | ||
reg = <0x00020000 DT_SIZE_K(512 + 128)>; | ||
|
||
}; | ||
|
||
slot1_partition: partition@C0000 { | ||
label = "image-1"; | ||
reg = <0x000C0000 DT_SIZE_K(512)>; | ||
}; | ||
}; | ||
}; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
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_FLASH_MAP=y | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# 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) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SB_CONFIG_BOOTLOADER_MCUBOOT=y | ||
SB_CONFIG_MCUBOOT_MODE_SWAP_USING_MOVE=y | ||
|
7 changes: 7 additions & 0 deletions
7
sysbuild-example/sysbuild/mcuboot/boards/nucleo_f413zh.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/ { | ||
chosen { | ||
zephyr,code-partition = &boot_partition; | ||
}; | ||
}; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
CONFIG_PM=n | ||
|
||
CONFIG_MAIN_STACK_SIZE=10240 | ||
|
||
CONFIG_BOOT_SWAP_SAVE_ENCTLV=n | ||
CONFIG_BOOT_ENCRYPT_IMAGE=n | ||
|
||
CONFIG_BOOT_UPGRADE_ONLY=n | ||
CONFIG_BOOT_BOOTSTRAP=y | ||
|
||
### mbedTLS has its own heap | ||
# CONFIG_HEAP_MEM_POOL_SIZE is not set | ||
|
||
### We never want Zephyr's copy of tinycrypt. If tinycrypt is needed, | ||
### MCUboot has its own copy in tree. | ||
# CONFIG_TINYCRYPT is not set | ||
# CONFIG_TINYCRYPT_ECC_DSA is not set | ||
# CONFIG_TINYCRYPT_SHA256 is not set | ||
|
||
CONFIG_FLASH=y | ||
|
||
### Various Zephyr boards enable features that we don't want. | ||
# CONFIG_BT is not set | ||
# CONFIG_BT_CTLR is not set | ||
# CONFIG_I2C is not set | ||
|
||
CONFIG_LOG=y | ||
CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL | ||
### Ensure Zephyr logging changes don't use more resources | ||
CONFIG_LOG_DEFAULT_LEVEL=0 | ||
### Use info log level by default | ||
CONFIG_MCUBOOT_LOG_LEVEL_INF=y | ||
### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y | ||
CONFIG_CBPRINTF_NANO=y | ||
### Use the minimal C library to reduce flash usage | ||
CONFIG_MINIMAL_LIBC=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is the example application project, we want to explain as much as possible here. We should assume that the reader knows very little about Zephyr.
I would add more text here explaining what exactly sysbuild is (link to the docs), and explain what exactly will be built, and what the expected use-case for those build targets/aretifacts is.
Then, I would highlight the command line options on how to build all of the images, only one of them, how to debug (aka the
--domain
flag)A newbie should be pointed into the correct direction, to the right docs, so they can learn further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I'll try to write a "getting started" guide from my understanding, and simple explanations of the concepts.
I'll need you help to review, and correct any mis-understandings I have.