diff --git a/README.md b/README.md index ceb2c51e..940cff9f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: diff --git a/app/boards/nucleo_f413zh.overlay b/app/boards/nucleo_f413zh.overlay new file mode 100644 index 00000000..c99fc78e --- /dev/null +++ b/app/boards/nucleo_f413zh.overlay @@ -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"; +}; + + diff --git a/sysbuild-example/CMakeLists.txt b/sysbuild-example/CMakeLists.txt new file mode 100644 index 00000000..40063d71 --- /dev/null +++ b/sysbuild-example/CMakeLists.txt @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: Apache-2.0 +# Author: James Walmsley <james@fullfat-fs.co.uk> + +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) + diff --git a/sysbuild-example/README.md b/sysbuild-example/README.md new file mode 100644 index 00000000..fef6b668 --- /dev/null +++ b/sysbuild-example/README.md @@ -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 +``` + diff --git a/sysbuild-example/dfu_app/CMakeLists.txt b/sysbuild-example/dfu_app/CMakeLists.txt new file mode 100644 index 00000000..ce1c4c99 --- /dev/null +++ b/sysbuild-example/dfu_app/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2025 James Walmsley <james@fullfat-fs.co.uk> +# 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) + diff --git a/sysbuild-example/dfu_app/prj.conf b/sysbuild-example/dfu_app/prj.conf new file mode 100644 index 00000000..3c0f8a65 --- /dev/null +++ b/sysbuild-example/dfu_app/prj.conf @@ -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 + diff --git a/sysbuild-example/dfu_app/src/main.c b/sysbuild-example/dfu_app/src/main.c new file mode 100644 index 00000000..11244a57 --- /dev/null +++ b/sysbuild-example/dfu_app/src/main.c @@ -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; +} + + diff --git a/sysbuild-example/mfg_image/CMakeLists.txt b/sysbuild-example/mfg_image/CMakeLists.txt new file mode 100644 index 00000000..e402fcda --- /dev/null +++ b/sysbuild-example/mfg_image/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2025 James Walmsley <james@fullfat-fs.co.uk> +# 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) + diff --git a/sysbuild-example/mfg_image/prj.conf b/sysbuild-example/mfg_image/prj.conf new file mode 100644 index 00000000..0608e7a8 --- /dev/null +++ b/sysbuild-example/mfg_image/prj.conf @@ -0,0 +1 @@ +CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/sysbuild-example/mfg_image/src/main.c b/sysbuild-example/mfg_image/src/main.c new file mode 100644 index 00000000..36822190 --- /dev/null +++ b/sysbuild-example/mfg_image/src/main.c @@ -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; +} + diff --git a/sysbuild-example/prj.conf b/sysbuild-example/prj.conf new file mode 100644 index 00000000..e69de29b diff --git a/sysbuild-example/sysbuild.cmake b/sysbuild-example/sysbuild.cmake new file mode 100644 index 00000000..913f34b3 --- /dev/null +++ b/sysbuild-example/sysbuild.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2025 James Walmsley <james@fullfat-fs.co.uk> +# 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) diff --git a/sysbuild-example/sysbuild.conf b/sysbuild-example/sysbuild.conf new file mode 100644 index 00000000..47f00ff3 --- /dev/null +++ b/sysbuild-example/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/sysbuild-example/sysbuild/mcuboot.conf b/sysbuild-example/sysbuild/mcuboot.conf new file mode 100644 index 00000000..166d338f --- /dev/null +++ b/sysbuild-example/sysbuild/mcuboot.conf @@ -0,0 +1,2 @@ +CONFIG_BOOT_SWAP_USING_SCRATCH=y + diff --git a/west.yml b/west.yml index 6bb551cb..be221a50 100644 --- a/west.yml +++ b/west.yml @@ -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