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

nrf53_bsim: Get IPC shared memory buffer size from DT #64320

Merged
merged 1 commit into from
Oct 25, 2023
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 boards/posix/nrf_bsim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ target_sources(native_simulator INTERFACE
common/trace_hook.c
)

if (CONFIG_IPC_SERVICE)
target_sources(native_simulator INTERFACE
if (CONFIG_IPC_SERVICE AND CONFIG_BOARD_NRF5340BSIM_NRF5340_CPUAPP)
zephyr_library_sources(
ipc_backend.c
)
endif()
Expand Down
4 changes: 3 additions & 1 deletion boards/posix/nrf_bsim/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ config BUILD_OUTPUT_BIN
default n

config BUILD_OUTPUT_EXE
default y
# When the IPC service is used, the net core image requires the application core image, as it needs
# access to its IPC buffer. Without it, the executable cannot be built.
default y if !(BOARD_NRF5340BSIM_NRF5340_CPUNET && IPC_SERVICE && (NATIVE_SIMULATOR_EXTRA_IMAGE_PATHS = ""))

config OUTPUT_PRINT_MEMORY_USAGE
default n
Expand Down
26 changes: 19 additions & 7 deletions boards/posix/nrf_bsim/ipc_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@
*/

/*
* This buffer is the shared memory buffer for the RPMSG IPC backed
* in simulation.
* It must be at last as large as the size defined in device tree, but as it will be compiled in
* the native simulator runner context we cannot refer to DT itself to size it.
* The default buffer for this target is defined in
* boards/arm/nrf5340dk_nrf5340/nrf5340_shared_sram_planning_conf.dtsi
* Here we define the shared memory buffers for the RPMSG IPC back-end in simulation.
* In real HW, these are booked in RAM thru device tree configuration.
* In this simulated target, we just define them at build time to have the size defined
* in device tree.
*
* Note that this file is only compiled as part of the application core image, and therefore
* when the network core is built with the IPC service, we cannot produce an executable
* with the network core image alone, as we would lack this buffer during linking.
*/
char IPC0_shm_buffer[65536];

#include "nsi_cpu_if.h"
#include <zephyr/device.h>

#define DT_DRV_COMPAT zephyr_ipc_openamp_static_vrings

#define DEFINE_BACKEND_BUFFER(i) \
NATIVE_SIMULATOR_IF \
char IPC##i##_shm_buffer[DT_REG_SIZE(DT_INST_PHANDLE(i, memory_region))];

DT_INST_FOREACH_STATUS_OKAY(DEFINE_BACKEND_BUFFER)