Skip to content

Commit 0630c5c

Browse files
gmarullnashif
authored andcommitted
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 <gerard@teslabs.com>
1 parent 8120bd7 commit 0630c5c

14 files changed

+174
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
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(hello_world)
8+
target_sources(app PRIVATE src/main.c)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"
5+
6+
config REMOTE_BOARD
7+
string "The board used for remote target"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.. zephyr:code-sample:: sysbuild_hello_world
2+
:name: Hello World for multiple board targets using Sysbuild
3+
4+
Run a hello world sample on multiple board targets
5+
6+
Overview
7+
********
8+
9+
The sample demonstrates how to build a Hello World application for two board
10+
targets with :ref:`sysbuild`. This sample can be useful to test, for example,
11+
SoCs with multiple cores as each core is exposed as a board target. Other
12+
scenarios could include boards embedding multiple SoCs. When building with
13+
Zephyr Sysbuild, the build system adds additional images based on the options
14+
selected in the project's additional configuration and build files.
15+
16+
All images use the same :file:`main.c` that prints the board target on which the
17+
application is programmed.
18+
19+
Building and Running
20+
********************
21+
22+
This sample needs to be built with Sysbuild by using the ``--sysbuild`` option.
23+
The remote board needs to be specified using ``SB_CONFIG_REMOTE_BOARD``. Some
24+
additional settings may be required depending on the platform, for example,
25+
to boot a remote core.
26+
27+
.. note::
28+
It is recommended to use sample setups from
29+
:zephyr_file:`samples/basic/multitarget_hello_world/sample.yaml` using the
30+
``-T`` option.
31+
32+
Here's an example to build and flash the sample for the
33+
:ref:`nrf54h20dk_nrf54h20`, using application and radio cores:
34+
35+
.. zephyr-app-commands::
36+
:zephyr-app: samples/basic/multitarget_hello_world
37+
:board: nrf54h20dk/nrf54h20/cpuapp
38+
:west-args: --sysbuild
39+
:gen-args: -DSB_CONFIG_REMOTE_BOARD='"nrf54h20dk/nrf54h20/cpurad"'
40+
:goals: build flash
41+
:compact:
42+
43+
The same can be achieved by using the
44+
:zephyr_file:`samples/basic/multitarget_hello_world/sample.yaml` setup:
45+
46+
.. zephyr-app-commands::
47+
:zephyr-app: samples/basic/multitarget_hello_world
48+
:board: nrf54h20dk/nrf54h20/cpuapp
49+
:west-args: -T sample.basic.multitarget_hello_world.nrf54h20dk_cpuapp_cpurad
50+
:goals: build flash
51+
:compact:
52+
53+
After programming the sample to your board, you should observe a hello world
54+
message in the Zephyr console configured on each target. For example, for the
55+
sample above:
56+
57+
Application core
58+
59+
.. code-block:: console
60+
61+
*** Booting Zephyr OS build v3.6.0-274-g466084bd8c5d ***
62+
Hello world from nrf54h20dk/nrf54h20/cpuapp
63+
64+
Radio core
65+
66+
.. code-block:: console
67+
68+
*** Booting Zephyr OS build v3.6.0-274-g466084bd8c5d ***
69+
Hello world from nrf54h20dk/nrf54h20/cpurad
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_BOARD_ENABLE_CPUNET=y

samples/sysbuild/hello_world/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# no additional configuration is required
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
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(remote)
8+
target_sources(app PRIVATE ../src/main.c)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# no additional configuration is required
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
sample:
2+
name: Hello World for multiple board targets using Sysbuild
3+
description: |
4+
Hello World application that builds for multiple targets. Both images print
5+
the board target they were run on.
6+
7+
common:
8+
build_only: true
9+
sysbuild: true
10+
11+
tests:
12+
sample.sysbuild.hello_world.nrf5340dk_cpuapp_cpunet:
13+
platform_allow:
14+
- nrf5340dk/nrf5340/cpuapp
15+
integration_platforms:
16+
- nrf5340dk/nrf5340/cpuapp
17+
extra_args:
18+
SB_CONF_FILE=sysbuild/nrf5340dk_nrf5340_cpunet.conf
19+
20+
sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpurad:
21+
platform_allow:
22+
- nrf54h20dk/nrf54h20/cpuapp
23+
integration_platforms:
24+
- nrf54h20dk/nrf54h20/cpuapp
25+
extra_args:
26+
SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf
27+
28+
sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpuppr:
29+
platform_allow:
30+
- nrf54h20dk/nrf54h20/cpuapp
31+
integration_platforms:
32+
- nrf54h20dk/nrf54h20/cpuapp
33+
extra_args:
34+
SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpuppr.conf
35+
hello_world_SNIPPET=nordic-ppr
36+
37+
sample.sysbuild.hello_world.nrf54h20dk_cpuapp_cpuppr_xip:
38+
platform_allow:
39+
- nrf54h20dk/nrf54h20/cpuapp
40+
integration_platforms:
41+
- nrf54h20dk/nrf54h20/cpuapp
42+
extra_args:
43+
SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpuppr_xip.conf
44+
hello_world_SNIPPET=nordic-ppr-xip
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
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 %s\n", CONFIG_BOARD_TARGET);
11+
12+
return 0;
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if("${SB_CONFIG_REMOTE_BOARD}" STREQUAL "")
5+
message(FATAL_ERROR "REMOTE_BOARD must be set to a valid board name")
6+
endif()
7+
8+
ExternalZephyrProject_Add(
9+
APPLICATION remote
10+
SOURCE_DIR ${APP_DIR}/remote
11+
BOARD ${SB_CONFIG_REMOTE_BOARD}
12+
)
13+
14+
add_dependencies(hello_world remote)
15+
sysbuild_add_dependencies(FLASH hello_world remote)

0 commit comments

Comments
 (0)