File tree 19 files changed +232
-0
lines changed 19 files changed +232
-0
lines changed Original file line number Diff line number Diff line change
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(REQUIRED)
8
+
9
+ project (sysbuild-example)
10
+
11
+ target_sources (app PRIVATE main_image/src/main.c)
12
+
Original file line number Diff line number Diff line change
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-example \
10
+ -DEXTRA_DTC_OVERLAY_FILE=(pwd)/sysbuild-example/overlays/nucleo_f413zh_partitions.overlay \
11
+ -Dmcuboot_EXTRA_DTC_OVERLAY_FILE=(pwd)/sysbuild-example/overlays/nucleo_f413zh_partitions.overlay \
12
+ -Dmfg_image_EXTRA_DTC_OVERLAY_FILE=(pwd)/sysbuild-example/overlays/nucleo_f413zh_partitions.overlay \
13
+ -Ddfu_app_EXTRA_DTC_OVERLAY_FILE=(pwd)/sysbuild-example/overlays/nucleo_f413zh_partitions.overlay
14
+ ```
15
+
Original file line number Diff line number Diff line change
1
+ / {
2
+ chosen {
3
+ zephyr,code-partition = &app_partition;
4
+ };
5
+ };
6
+
7
+
Original file line number Diff line number Diff line change
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{ZEPHYR_BASE} )
6
+
7
+ project (dfu_app)
8
+ target_sources (app PRIVATE src/main.c)
9
+
Original file line number Diff line number Diff line change
1
+ / {
2
+ chosen {
3
+ zephyr,code-partition = &app_partition;
4
+ };
5
+ };
6
+
7
+
Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
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 2 %s\n" , CONFIG_BOARD_TARGET );
11
+
12
+ return 0 ;
13
+ }
14
+
15
+
Original file line number Diff line number Diff line change
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 ("Main image on: %s\n" , CONFIG_BOARD_TARGET );
11
+ return 0 ;
12
+ }
13
+
14
+
Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
1
+ / {
2
+ chosen {
3
+ zephyr,code-partition = &app_partition;
4
+ };
5
+ };
6
+
7
+
Original file line number Diff line number Diff line change
1
+ CONFIG_BOOTLOADER_MCUBOOT=y
2
+ CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="bootloader/mcuboot/root-rsa-2048.pem"
Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
1
+ /delete-node/ &slot0_partition;
2
+ /delete-node/ &slot1_partition;
3
+ /delete-node/ &scratch_partition;
4
+
5
+ &flash0 {
6
+ /*
7
+ * Setting the erase/write block sizes for stm32f4xx
8
+ * Its not defined in the main dts because the devices
9
+ * have varying sector sizes.
10
+ *
11
+ * However we can use 128K as a working size across
12
+ * the mcuboot slots.
13
+ */
14
+ erase-block-size = <DT_SIZE_K(128)>;
15
+ write-block-size = <1>;
16
+
17
+ partitions {
18
+ /*
19
+ *
20
+ */
21
+ app_partition: app_partition@a {
22
+ label = "app-max-size";
23
+ reg = <0x00020000 DT_SIZE_K(512)>;
24
+ };
25
+
26
+ /*
27
+ * This paritition layout is for SWAP_WITH_MOVE,
28
+ * Where the primary slot must be 1 sector bigger than the secondary slot!
29
+ */
30
+ slot0_partition: partition@20000 {
31
+ label = "image-0";
32
+ reg = <0x00020000 DT_SIZE_K(512 + 128)>;
33
+
34
+ };
35
+
36
+ slot1_partition: partition@C0000 {
37
+ label = "image-1";
38
+ reg = <0x000C0000 DT_SIZE_K(512)>;
39
+ };
40
+ };
41
+ };
42
+
Original file line number Diff line number Diff line change
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_FLASH_MAP=y
7
+
Original file line number Diff line number Diff line change
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)
16
+
Original file line number Diff line number Diff line change
1
+ SB_CONFIG_BOOTLOADER_MCUBOOT=y
2
+ SB_CONFIG_MCUBOOT_MODE_SWAP_USING_MOVE=y
3
+
Original file line number Diff line number Diff line change
1
+ / {
2
+ chosen {
3
+ zephyr,code-partition = &boot_partition;
4
+ };
5
+ };
6
+
7
+
Original file line number Diff line number Diff line change
1
+ CONFIG_PM=n
2
+
3
+ CONFIG_MAIN_STACK_SIZE=10240
4
+
5
+ CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
6
+ CONFIG_BOOT_ENCRYPT_IMAGE=n
7
+
8
+ CONFIG_BOOT_UPGRADE_ONLY=n
9
+ CONFIG_BOOT_BOOTSTRAP=y
10
+
11
+ ### mbedTLS has its own heap
12
+ # CONFIG_HEAP_MEM_POOL_SIZE is not set
13
+
14
+ ### We never want Zephyr's copy of tinycrypt. If tinycrypt is needed,
15
+ ### MCUboot has its own copy in tree.
16
+ # CONFIG_TINYCRYPT is not set
17
+ # CONFIG_TINYCRYPT_ECC_DSA is not set
18
+ # CONFIG_TINYCRYPT_SHA256 is not set
19
+
20
+ CONFIG_FLASH=y
21
+
22
+ ### Various Zephyr boards enable features that we don't want.
23
+ # CONFIG_BT is not set
24
+ # CONFIG_BT_CTLR is not set
25
+ # CONFIG_I2C is not set
26
+
27
+ CONFIG_LOG=y
28
+ CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL
29
+ ### Ensure Zephyr logging changes don't use more resources
30
+ CONFIG_LOG_DEFAULT_LEVEL=0
31
+ ### Use info log level by default
32
+ CONFIG_MCUBOOT_LOG_LEVEL_INF=y
33
+ ### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y
34
+ CONFIG_CBPRINTF_NANO=y
35
+ ### Use the minimal C library to reduce flash usage
36
+ CONFIG_MINIMAL_LIBC=y
Original file line number Diff line number Diff line change @@ -21,3 +21,4 @@ manifest:
21
21
- hal_nordic # required by the custom_plank board (Nordic based)
22
22
- hal_stm32 # required by the nucleo_f302r8 board (STM32 based)
23
23
- mcuboot
24
+ - mbedtls
You can’t perform that action at this time.
0 commit comments