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:
parent
f871bf9a02
commit
eab2d89f53
8 changed files with 87 additions and 35 deletions
|
@ -6,35 +6,19 @@
|
|||
|
||||
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")
|
||||
set(BOARD_REMOTE "nrf5340dk_nrf5340_cpunet")
|
||||
elseif("${BOARD}" STREQUAL "adp_xc7k_ae350")
|
||||
set(BOARD_REMOTE "adp_xc7k_ae350")
|
||||
elseif("${BOARD}" STREQUAL "mimxrt595_evk_cm33")
|
||||
set(BOARD_REMOTE "nrf5340dk_nrf5340_cpunet")
|
||||
if(("${BOARD}" STREQUAL "nrf5340dk_nrf5340_cpuapp") OR
|
||||
("${BOARD}" STREQUAL "nrf5340bsim_nrf5340_cpuapp") OR
|
||||
("${BOARD}" STREQUAL "adp_xc7k_ae350") OR
|
||||
("${BOARD}" STREQUAL "mimxrt595_evk_cm33"))
|
||||
message(STATUS "${BOARD} compile as Main in this sample")
|
||||
else()
|
||||
message(FATAL_ERROR "${BOARD} is not supported for this sample")
|
||||
endif()
|
||||
|
||||
message(STATUS "${BOARD} compile as Main in this sample")
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(mbox_ipc)
|
||||
|
||||
enable_language(C ASM)
|
||||
|
||||
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
|
||||
)
|
||||
|
|
12
samples/drivers/mbox/Kconfig.sysbuild
Normal file
12
samples/drivers/mbox/Kconfig.sysbuild
Normal 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"
|
|
@ -21,6 +21,7 @@ Building the application for nrf5340dk_nrf5340_cpuapp
|
|||
:zephyr-app: samples/drivers/mbox/
|
||||
:board: nrf5340dk_nrf5340_cpuapp
|
||||
:goals: debug
|
||||
:west-args: --sysbuild
|
||||
|
||||
Open a serial terminal (minicom, putty, etc.) and connect the board with the
|
||||
following settings:
|
||||
|
@ -58,3 +59,23 @@ core:
|
|||
Pong (on channel 1)
|
||||
Ping (on channel 0)
|
||||
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.
|
||||
|
|
|
@ -6,15 +6,16 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
if("${BOARD}" STREQUAL "nrf5340dk_nrf5340_cpunet")
|
||||
message(STATUS "${BOARD} compile as remote in this sample")
|
||||
elseif("${BOARD}" STREQUAL "adp_xc7k_ae350")
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
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")
|
||||
else()
|
||||
message(FATAL_ERROR "${BOARD} is not supported for this sample")
|
||||
endif()
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(mbox_ipc_remote)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
CONFIG_MBOX_NRFX_IPC=y
|
||||
CONFIG_BUILD_OUTPUT_EXE=n
|
|
@ -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
|
|
@ -1,9 +1,12 @@
|
|||
sample:
|
||||
name: MBOX IPC sample
|
||||
tests:
|
||||
common:
|
||||
sysbuild: true
|
||||
sample.drivers.mbox:
|
||||
platform_allow:
|
||||
- nrf5340dk_nrf5340_cpuapp
|
||||
- nrf5340bsim_nrf5340_cpuapp
|
||||
- adp_xc7k_ae350
|
||||
- mimxrt595_evk_cm33
|
||||
integration_platforms:
|
||||
|
|
38
samples/drivers/mbox/sysbuild.cmake
Normal file
38
samples/drivers/mbox/sysbuild.cmake
Normal 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()
|
Loading…
Add table
Add a link
Reference in a new issue