Skip to content
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

samples: basic: add multitarget_hello_world #69652

Merged
merged 2 commits into from
May 13, 2024
Merged
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
4 changes: 2 additions & 2 deletions MAINTAINERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/_scripts/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
1 change: 1 addition & 0 deletions samples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Samples and Demos
classic
basic/*
userspace/*
sysbuild/*
subsys/subsys.rst
net/net.rst
bluetooth/bluetooth.rst
Expand Down
8 changes: 8 additions & 0 deletions samples/sysbuild/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions samples/sysbuild/hello_world/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -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"
69 changes: 69 additions & 0 deletions samples/sysbuild/hello_world/README.rst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

CONFIG_BOARD_ENABLE_CPUNET=y
1 change: 1 addition & 0 deletions samples/sysbuild/hello_world/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no additional configuration is required
8 changes: 8 additions & 0 deletions samples/sysbuild/hello_world/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions samples/sysbuild/hello_world/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# no additional configuration is required
44 changes: 44 additions & 0 deletions samples/sysbuild/hello_world/sample.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions samples/sysbuild/hello_world/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
* 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;
}
15 changes: 15 additions & 0 deletions samples/sysbuild/hello_world/sysbuild.cmake
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SB_CONFIG_REMOTE_BOARD="nrf5340dk/nrf5340/cpunet"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpuppr"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpuppr/xip"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpurad"
10 changes: 10 additions & 0 deletions samples/sysbuild/sysbuild.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _sysbuild-samples:

Sysbuild samples
################

.. toctree::
:maxdepth: 1
:glob:

**/*
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading