samples/drivers/mbox: Convert to sysbuild and add support for nrf5340bsim

Convert this sample application build to sysbuild,
and add support for the nrf5340bsim target.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-10-24 10:24:55 +02:00 committed by Maureen Helm
commit eab2d89f53
8 changed files with 87 additions and 35 deletions

View file

@ -6,35 +6,19 @@
cmake_minimum_required(VERSION 3.20.0) cmake_minimum_required(VERSION 3.20.0)
set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/mbox_ipc_remote-prefix/src/mbox_ipc_remote-build/zephyr) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
if("${BOARD}" STREQUAL "nrf5340dk_nrf5340_cpuapp") if(("${BOARD}" STREQUAL "nrf5340dk_nrf5340_cpuapp") OR
set(BOARD_REMOTE "nrf5340dk_nrf5340_cpunet") ("${BOARD}" STREQUAL "nrf5340bsim_nrf5340_cpuapp") OR
elseif("${BOARD}" STREQUAL "adp_xc7k_ae350") ("${BOARD}" STREQUAL "adp_xc7k_ae350") OR
set(BOARD_REMOTE "adp_xc7k_ae350") ("${BOARD}" STREQUAL "mimxrt595_evk_cm33"))
elseif("${BOARD}" STREQUAL "mimxrt595_evk_cm33") message(STATUS "${BOARD} compile as Main in this sample")
set(BOARD_REMOTE "nrf5340dk_nrf5340_cpunet")
else() else()
message(FATAL_ERROR "${BOARD} is not supported for this sample") message(FATAL_ERROR "${BOARD} is not supported for this sample")
endif() endif()
message(STATUS "${BOARD} compile as Main in this sample")
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(mbox_ipc) project(mbox_ipc)
enable_language(C ASM) enable_language(C ASM)
target_sources(app PRIVATE src/main.c) target_sources(app PRIVATE src/main.c)
include(ExternalProject)
ExternalProject_Add(
mbox_ipc_remote
SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote
INSTALL_COMMAND "" # This particular build system has no install command
CMAKE_CACHE_ARGS -DBOARD:STRING=${BOARD_REMOTE}
BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/${KERNEL_BIN_NAME}"
# NB: Do we need to pass on more CMake variables?
BUILD_ALWAYS True
)

View file

@ -0,0 +1,12 @@
# Copyright 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
source "share/sysbuild/Kconfig"
config REMOTE_BOARD
string
default "nrf5340dk_nrf5340_cpunet" if $(BOARD) = "nrf5340dk_nrf5340_cpuapp"
default "nrf5340bsim_nrf5340_cpunet" if $(BOARD) = "nrf5340bsim_nrf5340_cpuapp"
default "adp_xc7k_ae350" if $(BOARD) = "adp_xc7k_ae350"
default "nrf5340dk_nrf5340_cpunet" if $(BOARD) = "mimxrt595_evk_cm33"

View file

@ -21,6 +21,7 @@ Building the application for nrf5340dk_nrf5340_cpuapp
:zephyr-app: samples/drivers/mbox/ :zephyr-app: samples/drivers/mbox/
:board: nrf5340dk_nrf5340_cpuapp :board: nrf5340dk_nrf5340_cpuapp
:goals: debug :goals: debug
:west-args: --sysbuild
Open a serial terminal (minicom, putty, etc.) and connect the board with the Open a serial terminal (minicom, putty, etc.) and connect the board with the
following settings: following settings:
@ -58,3 +59,23 @@ core:
Pong (on channel 1) Pong (on channel 1)
Ping (on channel 0) Ping (on channel 0)
Pong (on channel 1) Pong (on channel 1)
Building the application for the simulated nrf5340bsim
******************************************************
.. zephyr-app-commands::
:zephyr-app: samples/drivers/mbox/
:host-os: unix
:board: nrf5340bsim_nrf5340_cpuapp
:goals: build
:west-args: --sysbuild
Then you can execute your application using:
.. code-block:: console
$ ./build/zephyr/zephyr.exe -nosim
# Press Ctrl+C to exit
You can expect a similar output as in the real HW in the invoking console.

View file

@ -6,15 +6,16 @@
cmake_minimum_required(VERSION 3.20.0) cmake_minimum_required(VERSION 3.20.0)
if("${BOARD}" STREQUAL "nrf5340dk_nrf5340_cpunet") find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
message(STATUS "${BOARD} compile as remote in this sample")
elseif("${BOARD}" STREQUAL "adp_xc7k_ae350") if(("${BOARD}" STREQUAL "nrf5340dk_nrf5340_cpunet") OR
("${BOARD}" STREQUAL "nrf5340bsim_nrf5340_cpunet") OR
("${BOARD}" STREQUAL "adp_xc7k_ae350"))
message(STATUS "${BOARD} compile as remote in this sample") message(STATUS "${BOARD} compile as remote in this sample")
else() else()
message(FATAL_ERROR "${BOARD} is not supported for this sample") message(FATAL_ERROR "${BOARD} is not supported for this sample")
endif() endif()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(mbox_ipc_remote) project(mbox_ipc_remote)
target_sources(app PRIVATE src/main.c) target_sources(app PRIVATE src/main.c)

View file

@ -0,0 +1,2 @@
CONFIG_MBOX_NRFX_IPC=y
CONFIG_BUILD_OUTPUT_EXE=n

View file

@ -1,9 +0,0 @@
sample:
name: MBOX IPC sample (remote)
tests:
sample.drivers.mbox_remote:
platform_allow: nrf5340dk_nrf5340_cpunet adp_xc7k_ae350
integration_platforms:
- nrf5340dk_nrf5340_cpunet
tags: mbox
harness: remote

View file

@ -1,9 +1,12 @@
sample: sample:
name: MBOX IPC sample name: MBOX IPC sample
tests: tests:
common:
sysbuild: true
sample.drivers.mbox: sample.drivers.mbox:
platform_allow: platform_allow:
- nrf5340dk_nrf5340_cpuapp - nrf5340dk_nrf5340_cpuapp
- nrf5340bsim_nrf5340_cpuapp
- adp_xc7k_ae350 - adp_xc7k_ae350
- mimxrt595_evk_cm33 - mimxrt595_evk_cm33
integration_platforms: integration_platforms:

View file

@ -0,0 +1,38 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
if("${SB_CONFIG_REMOTE_BOARD}" STREQUAL "")
message(FATAL_ERROR
"Target ${BOARD} not supported for this sample. "
"There is no remote board selected in Kconfig.sysbuild")
endif()
set(REMOTE_APP remote)
ExternalZephyrProject_Add(
APPLICATION ${REMOTE_APP}
SOURCE_DIR ${APP_DIR}/${REMOTE_APP}
BOARD ${SB_CONFIG_REMOTE_BOARD}
)
if("${BOARD}" STREQUAL "nrf5340bsim_nrf5340_cpuapp")
# For the simulated board, the application core build will produce the final executable
# for that, we give it the path to the netcore image
set(NET_LIBRARY_PATH ${CMAKE_BINARY_DIR}/${REMOTE_APP}/zephyr/zephyr.elf)
set_property(TARGET ${DEFAULT_IMAGE} APPEND_STRING PROPERTY CONFIG
"CONFIG_NATIVE_SIMULATOR_EXTRA_IMAGE_PATHS=\"${NET_LIBRARY_PATH}\"\n"
)
# Let's build the net core library first
add_dependencies(${DEFAULT_IMAGE} ${REMOTE_APP})
# Let's meet users expectations of finding the final executable in zephyr/zephyr.exe
add_custom_target(final_executable
ALL
COMMAND
${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/zephyr.exe
${CMAKE_BINARY_DIR}/zephyr/zephyr.exe
DEPENDS ${DEFAULT_IMAGE}
)
endif()