From 6b884369023dc12a9844b50cddb110d520067dab Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Fri, 10 May 2024 09:59:01 +0200 Subject: [PATCH 1/2] samples: move with_mcuboot sample to samples/sysbuild This creates a new category of samples that demonstrate certain features of sysbuild. "application development" was a very generic name. Signed-off-by: Gerard Marull-Paretas --- MAINTAINERS.yml | 4 ++-- doc/_scripts/redirects.py | 1 + samples/index.rst | 1 + samples/sysbuild/sysbuild.rst | 10 ++++++++++ .../sysbuild/with_mcuboot/CMakeLists.txt | 0 .../sysbuild/with_mcuboot/README.rst | 0 .../sysbuild/with_mcuboot/prj.conf | 0 .../sysbuild/with_mcuboot/sample.yaml | 2 +- .../sysbuild/with_mcuboot/src/main.c | 0 .../sysbuild/with_mcuboot/sysbuild.conf | 0 .../sysbuild/with_mcuboot/sysbuild/mcuboot.conf | 0 11 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 samples/sysbuild/sysbuild.rst rename samples/{application_development => }/sysbuild/with_mcuboot/CMakeLists.txt (100%) rename samples/{application_development => }/sysbuild/with_mcuboot/README.rst (100%) rename samples/{application_development => }/sysbuild/with_mcuboot/prj.conf (100%) rename samples/{application_development => }/sysbuild/with_mcuboot/sample.yaml (90%) rename samples/{application_development => }/sysbuild/with_mcuboot/src/main.c (100%) rename samples/{application_development => }/sysbuild/with_mcuboot/sysbuild.conf (100%) rename samples/{application_development => }/sysbuild/with_mcuboot/sysbuild/mcuboot.conf (100%) diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index 42e70bdb0b607f..77f9820f681b61 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -3761,12 +3761,12 @@ Sysbuild: - "57300" files: - share/sysbuild/ - - samples/application_development/sysbuild/ + - samples/sysbuild/ - doc/build/sysbuild/ labels: - "area: Sysbuild" tests: - - sample.application_development.sysbuild + - sample.sysbuild Task Watchdog: status: maintained diff --git a/doc/_scripts/redirects.py b/doc/_scripts/redirects.py index bf4f9262749a29..91586470feabdc 100644 --- a/doc/_scripts/redirects.py +++ b/doc/_scripts/redirects.py @@ -199,6 +199,7 @@ ('reference/usermode/overview', 'kernel/usermode/overview'), ('reference/usermode/syscalls', 'kernel/usermode/syscalls'), ('reference/util/index', 'kernel/util/index'), + ('samples/application_development/with_mcuboot/README', 'samples/sysbuild/with_mcuboot/README'), ('samples/drivers/adc/README', 'samples/drivers/adc/adc_dt/README'), ('samples/drivers/kscan_touch', 'samples/subsys/input/input'), ('samples/drivers/led_apa102/README', 'samples/drivers/led_strip/README'), diff --git a/samples/index.rst b/samples/index.rst index 8581a330d40a8f..0120c87769d7e9 100644 --- a/samples/index.rst +++ b/samples/index.rst @@ -13,6 +13,7 @@ Samples and Demos classic basic/* userspace/* + sysbuild/* subsys/subsys.rst net/net.rst bluetooth/bluetooth.rst diff --git a/samples/sysbuild/sysbuild.rst b/samples/sysbuild/sysbuild.rst new file mode 100644 index 00000000000000..c959e82a3a3bac --- /dev/null +++ b/samples/sysbuild/sysbuild.rst @@ -0,0 +1,10 @@ +.. _sysbuild-samples: + +Sysbuild samples +################ + +.. toctree:: + :maxdepth: 1 + :glob: + + **/* diff --git a/samples/application_development/sysbuild/with_mcuboot/CMakeLists.txt b/samples/sysbuild/with_mcuboot/CMakeLists.txt similarity index 100% rename from samples/application_development/sysbuild/with_mcuboot/CMakeLists.txt rename to samples/sysbuild/with_mcuboot/CMakeLists.txt diff --git a/samples/application_development/sysbuild/with_mcuboot/README.rst b/samples/sysbuild/with_mcuboot/README.rst similarity index 100% rename from samples/application_development/sysbuild/with_mcuboot/README.rst rename to samples/sysbuild/with_mcuboot/README.rst diff --git a/samples/application_development/sysbuild/with_mcuboot/prj.conf b/samples/sysbuild/with_mcuboot/prj.conf similarity index 100% rename from samples/application_development/sysbuild/with_mcuboot/prj.conf rename to samples/sysbuild/with_mcuboot/prj.conf diff --git a/samples/application_development/sysbuild/with_mcuboot/sample.yaml b/samples/sysbuild/with_mcuboot/sample.yaml similarity index 90% rename from samples/application_development/sysbuild/with_mcuboot/sample.yaml rename to samples/sysbuild/with_mcuboot/sample.yaml index 785bc0d24004d0..e1f456405a7cc8 100644 --- a/samples/application_development/sysbuild/with_mcuboot/sample.yaml +++ b/samples/sysbuild/with_mcuboot/sample.yaml @@ -2,7 +2,7 @@ sample: description: Sample with MCUboot built through sysbuild name: with mcuboot tests: - sample.application_development.sysbuild.with_mcuboot: + sample.sysbuild.with_mcuboot: sysbuild: true # Platform allowed is used as twister using sysbuild still lacks proper # filtering support, see discussion in #49552. diff --git a/samples/application_development/sysbuild/with_mcuboot/src/main.c b/samples/sysbuild/with_mcuboot/src/main.c similarity index 100% rename from samples/application_development/sysbuild/with_mcuboot/src/main.c rename to samples/sysbuild/with_mcuboot/src/main.c diff --git a/samples/application_development/sysbuild/with_mcuboot/sysbuild.conf b/samples/sysbuild/with_mcuboot/sysbuild.conf similarity index 100% rename from samples/application_development/sysbuild/with_mcuboot/sysbuild.conf rename to samples/sysbuild/with_mcuboot/sysbuild.conf diff --git a/samples/application_development/sysbuild/with_mcuboot/sysbuild/mcuboot.conf b/samples/sysbuild/with_mcuboot/sysbuild/mcuboot.conf similarity index 100% rename from samples/application_development/sysbuild/with_mcuboot/sysbuild/mcuboot.conf rename to samples/sysbuild/with_mcuboot/sysbuild/mcuboot.conf From dcd6fc6e0018cca5937a3c2b611618ca85a37191 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Fri, 1 Mar 2024 10:14:14 +0100 Subject: [PATCH 2/2] samples: sysbuild: add hello world for multiple board targets Add a new "hello world" sample that can be built for multiple board targets. This sample can be used to see if Zephyr boots successfully with _minimal_ configuration on SoCs with multiple cores, or boards with multiple SoCs. The following configurations are provided for now: - nRF5340 DK: cpuapp+cpunet - nRF54H20 DK: cpuapp+cpurad, cpuapp+cpuppr, cpuapp+cpuppr(xip) Note that because of a quoting bug somewhere in the build system, SB_CONFIG_REMOTE_BOARD is specified in .conf files (see the sysbuild/ directory). This should be fixed in the near future. Signed-off-by: Gerard Marull-Paretas --- samples/sysbuild/hello_world/CMakeLists.txt | 8 +++ samples/sysbuild/hello_world/Kconfig.sysbuild | 7 ++ samples/sysbuild/hello_world/README.rst | 69 +++++++++++++++++++ .../boards/nrf5340dk_nrf5340_cpuapp.conf | 4 ++ samples/sysbuild/hello_world/prj.conf | 1 + .../hello_world/remote/CMakeLists.txt | 8 +++ samples/sysbuild/hello_world/remote/prj.conf | 1 + samples/sysbuild/hello_world/sample.yaml | 44 ++++++++++++ samples/sysbuild/hello_world/src/main.c | 13 ++++ samples/sysbuild/hello_world/sysbuild.cmake | 15 ++++ .../sysbuild/nrf5340dk_nrf5340_cpunet.conf | 1 + .../sysbuild/nrf54h20dk_nrf54h20_cpuppr.conf | 1 + .../nrf54h20dk_nrf54h20_cpuppr_xip.conf | 1 + .../sysbuild/nrf54h20dk_nrf54h20_cpurad.conf | 1 + 14 files changed, 174 insertions(+) create mode 100644 samples/sysbuild/hello_world/CMakeLists.txt create mode 100644 samples/sysbuild/hello_world/Kconfig.sysbuild create mode 100644 samples/sysbuild/hello_world/README.rst create mode 100644 samples/sysbuild/hello_world/boards/nrf5340dk_nrf5340_cpuapp.conf create mode 100644 samples/sysbuild/hello_world/prj.conf create mode 100644 samples/sysbuild/hello_world/remote/CMakeLists.txt create mode 100644 samples/sysbuild/hello_world/remote/prj.conf create mode 100644 samples/sysbuild/hello_world/sample.yaml create mode 100644 samples/sysbuild/hello_world/src/main.c create mode 100644 samples/sysbuild/hello_world/sysbuild.cmake create mode 100644 samples/sysbuild/hello_world/sysbuild/nrf5340dk_nrf5340_cpunet.conf create mode 100644 samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpuppr.conf create mode 100644 samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpuppr_xip.conf create mode 100644 samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf diff --git a/samples/sysbuild/hello_world/CMakeLists.txt b/samples/sysbuild/hello_world/CMakeLists.txt new file mode 100644 index 00000000000000..f58082ab8dfd85 --- /dev/null +++ b/samples/sysbuild/hello_world/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(hello_world) +target_sources(app PRIVATE src/main.c) diff --git a/samples/sysbuild/hello_world/Kconfig.sysbuild b/samples/sysbuild/hello_world/Kconfig.sysbuild new file mode 100644 index 00000000000000..edec01b94c98d8 --- /dev/null +++ b/samples/sysbuild/hello_world/Kconfig.sysbuild @@ -0,0 +1,7 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" + +config REMOTE_BOARD + string "The board used for remote target" diff --git a/samples/sysbuild/hello_world/README.rst b/samples/sysbuild/hello_world/README.rst new file mode 100644 index 00000000000000..2cb0208205188f --- /dev/null +++ b/samples/sysbuild/hello_world/README.rst @@ -0,0 +1,69 @@ +.. zephyr:code-sample:: sysbuild_hello_world + :name: Hello World for multiple board targets using Sysbuild + + Run a hello world sample on multiple board targets + +Overview +******** + +The sample demonstrates how to build a Hello World application for two board +targets with :ref:`sysbuild`. This sample can be useful to test, for example, +SoCs with multiple cores as each core is exposed as a board target. Other +scenarios could include boards embedding multiple SoCs. When building with +Zephyr Sysbuild, the build system adds additional images based on the options +selected in the project's additional configuration and build files. + +All images use the same :file:`main.c` that prints the board target on which the +application is programmed. + +Building and Running +******************** + +This sample needs to be built with Sysbuild by using the ``--sysbuild`` option. +The remote board needs to be specified using ``SB_CONFIG_REMOTE_BOARD``. Some +additional settings may be required depending on the platform, for example, +to boot a remote core. + +.. note:: + It is recommended to use sample setups from + :zephyr_file:`samples/basic/multitarget_hello_world/sample.yaml` using the + ``-T`` option. + +Here's an example to build and flash the sample for the +:ref:`nrf54h20dk_nrf54h20`, using application and radio cores: + +.. zephyr-app-commands:: + :zephyr-app: samples/basic/multitarget_hello_world + :board: nrf54h20dk/nrf54h20/cpuapp + :west-args: --sysbuild + :gen-args: -DSB_CONFIG_REMOTE_BOARD='"nrf54h20dk/nrf54h20/cpurad"' + :goals: build flash + :compact: + +The same can be achieved by using the +:zephyr_file:`samples/basic/multitarget_hello_world/sample.yaml` setup: + +.. zephyr-app-commands:: + :zephyr-app: samples/basic/multitarget_hello_world + :board: nrf54h20dk/nrf54h20/cpuapp + :west-args: -T sample.basic.multitarget_hello_world.nrf54h20dk_cpuapp_cpurad + :goals: build flash + :compact: + +After programming the sample to your board, you should observe a hello world +message in the Zephyr console configured on each target. For example, for the +sample above: + +Application core + + .. code-block:: console + + *** Booting Zephyr OS build v3.6.0-274-g466084bd8c5d *** + Hello world from nrf54h20dk/nrf54h20/cpuapp + +Radio core + + .. code-block:: console + + *** Booting Zephyr OS build v3.6.0-274-g466084bd8c5d *** + Hello world from nrf54h20dk/nrf54h20/cpurad diff --git a/samples/sysbuild/hello_world/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/sysbuild/hello_world/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 00000000000000..046b18c7559ab9 --- /dev/null +++ b/samples/sysbuild/hello_world/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,4 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_BOARD_ENABLE_CPUNET=y diff --git a/samples/sysbuild/hello_world/prj.conf b/samples/sysbuild/hello_world/prj.conf new file mode 100644 index 00000000000000..becd6a5481915e --- /dev/null +++ b/samples/sysbuild/hello_world/prj.conf @@ -0,0 +1 @@ +# no additional configuration is required diff --git a/samples/sysbuild/hello_world/remote/CMakeLists.txt b/samples/sysbuild/hello_world/remote/CMakeLists.txt new file mode 100644 index 00000000000000..62961aff1840b5 --- /dev/null +++ b/samples/sysbuild/hello_world/remote/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(remote) +target_sources(app PRIVATE ../src/main.c) diff --git a/samples/sysbuild/hello_world/remote/prj.conf b/samples/sysbuild/hello_world/remote/prj.conf new file mode 100644 index 00000000000000..becd6a5481915e --- /dev/null +++ b/samples/sysbuild/hello_world/remote/prj.conf @@ -0,0 +1 @@ +# no additional configuration is required diff --git a/samples/sysbuild/hello_world/sample.yaml b/samples/sysbuild/hello_world/sample.yaml new file mode 100644 index 00000000000000..5add79c52ba826 --- /dev/null +++ b/samples/sysbuild/hello_world/sample.yaml @@ -0,0 +1,44 @@ +sample: + name: Hello World for multiple board targets using Sysbuild + description: | + Hello World application that builds for multiple targets. Both images print + the board target they were run on. + +common: + build_only: true + sysbuild: true + +tests: + sample.sysbuild.hello_world.nrf5340dk_cpuapp_cpunet: + platform_allow: + - nrf5340dk/nrf5340/cpuapp + integration_platforms: + - nrf5340dk/nrf5340/cpuapp + extra_args: + SB_CONF_FILE=sysbuild/nrf5340dk_nrf5340_cpunet.conf + + sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpurad: + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + + sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpuppr: + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpuppr.conf + hello_world_SNIPPET=nordic-ppr + + sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpuppr_xip: + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpuppr_xip.conf + hello_world_SNIPPET=nordic-ppr-xip diff --git a/samples/sysbuild/hello_world/src/main.c b/samples/sysbuild/hello_world/src/main.c new file mode 100644 index 00000000000000..af5b6fd3dbe747 --- /dev/null +++ b/samples/sysbuild/hello_world/src/main.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +int main(void) +{ + printk("Hello world from %s\n", CONFIG_BOARD_TARGET); + + return 0; +} diff --git a/samples/sysbuild/hello_world/sysbuild.cmake b/samples/sysbuild/hello_world/sysbuild.cmake new file mode 100644 index 00000000000000..b59062d881f171 --- /dev/null +++ b/samples/sysbuild/hello_world/sysbuild.cmake @@ -0,0 +1,15 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if("${SB_CONFIG_REMOTE_BOARD}" STREQUAL "") + message(FATAL_ERROR "REMOTE_BOARD must be set to a valid board name") +endif() + +ExternalZephyrProject_Add( + APPLICATION remote + SOURCE_DIR ${APP_DIR}/remote + BOARD ${SB_CONFIG_REMOTE_BOARD} +) + +add_dependencies(hello_world remote) +sysbuild_add_dependencies(FLASH hello_world remote) diff --git a/samples/sysbuild/hello_world/sysbuild/nrf5340dk_nrf5340_cpunet.conf b/samples/sysbuild/hello_world/sysbuild/nrf5340dk_nrf5340_cpunet.conf new file mode 100644 index 00000000000000..b8ae05d4ef6fa6 --- /dev/null +++ b/samples/sysbuild/hello_world/sysbuild/nrf5340dk_nrf5340_cpunet.conf @@ -0,0 +1 @@ +SB_CONFIG_REMOTE_BOARD="nrf5340dk/nrf5340/cpunet" diff --git a/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpuppr.conf b/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpuppr.conf new file mode 100644 index 00000000000000..f50bc8553a0118 --- /dev/null +++ b/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpuppr.conf @@ -0,0 +1 @@ +SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpuppr" diff --git a/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpuppr_xip.conf b/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpuppr_xip.conf new file mode 100644 index 00000000000000..270c92c09a4f3f --- /dev/null +++ b/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpuppr_xip.conf @@ -0,0 +1 @@ +SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpuppr/xip" diff --git a/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf b/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 00000000000000..dd863e78d99339 --- /dev/null +++ b/samples/sysbuild/hello_world/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1 @@ +SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpurad"