Skip to content

Commit 993cb4c

Browse files
carlocaionenashif
authored andcommitted
sample: openamp: Add OpenAMP performance test.
Add a simple sample that tries to answer the silly question: how fast can I move data from one core to another using OpenAMP? It depends on a lot of factors but at least we can use this sample as a skeleton to build tests on top. Signed-off-by: Carlo Caione <[email protected]>
1 parent ca96286 commit 993cb4c

File tree

12 files changed

+785
-0
lines changed

12 files changed

+785
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Copyright (c) 2021 Carlo Caione <[email protected]>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/openamp_remote-prefix/src/openamp_remote-build/zephyr)
10+
11+
if("${BOARD}" STREQUAL "nrf5340dk_nrf5340_cpuapp")
12+
set(BOARD_REMOTE "nrf5340dk_nrf5340_cpunet")
13+
else()
14+
message(FATAL_ERROR "${BOARD} was not supported for this sample")
15+
endif()
16+
17+
message(INFO " ${BOARD} compile as Master in this sample")
18+
19+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
20+
project(openamp_performance)
21+
22+
enable_language(C ASM)
23+
24+
target_sources(app PRIVATE src/main.c)
25+
26+
include(ExternalProject)
27+
28+
ExternalProject_Add(
29+
openamp_performance_remote
30+
SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote
31+
INSTALL_COMMAND "" # This particular build system has no install command
32+
CMAKE_CACHE_ARGS -DBOARD:STRING=${BOARD_REMOTE}
33+
CMAKE_CACHE_ARGS -DDTC_OVERLAY_FILE:STRING=${DTC_OVERLAY_FILE}
34+
BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/${KERNEL_BIN_NAME}"
35+
# NB: Do we need to pass on more CMake variables?
36+
BUILD_ALWAYS True
37+
)
38+
39+
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Private config options for openamp sample app
2+
3+
# Copyright (c) 2021 Carlo Caione <[email protected]>
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# Workaround for not being able to have commas in macro arguments
7+
DT_CHOSEN_Z_IPC_SHM := zephyr,ipc_shm
8+
DT_CHOSEN_Z_IPC_TX := zephyr,ipc_tx
9+
DT_CHOSEN_Z_IPC_RX := zephyr,ipc_rx
10+
11+
config OPENAMP_IPC_SHM_BASE_ADDRESS
12+
hex
13+
default "$(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_IPC_SHM))"
14+
help
15+
This option specifies base address of the memory region to
16+
be used for the OpenAMP IPC shared memory
17+
18+
config OPENAMP_IPC_SHM_SIZE
19+
hex
20+
default "$(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_IPC_SHM))"
21+
help
22+
This option specifies size of the memory region to be used
23+
for the OpenAMP IPC shared memory
24+
25+
config OPENAMP_IPC_DEV_TX_NAME
26+
string
27+
default "$(dt_chosen_label,$(DT_CHOSEN_Z_IPC_TX))" if !IPM_NRFX
28+
default "IPM_1" if (IPM_NRFX && OPENAMP_MASTER)
29+
default "IPM_0" if (IPM_NRFX && OPENAMP_SLAVE)
30+
help
31+
This option specifies the device name for the IPC device to be used (TX)
32+
33+
config OPENAMP_IPC_DEV_RX_NAME
34+
string
35+
default "$(dt_chosen_label,$(DT_CHOSEN_Z_IPC_RX))" if !IPM_NRFX
36+
default "IPM_0" if (IPM_NRFX && OPENAMP_MASTER)
37+
default "IPM_1" if (IPM_NRFX && OPENAMP_SLAVE)
38+
help
39+
This option specifies the device name for the IPC device to be used (RX)
40+
41+
source "Kconfig.zephyr"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CONFIG_BOARD_ENABLE_CPUNET=y
2+
3+
CONFIG_IPM=y
4+
CONFIG_IPM_NRFX=y
5+
6+
CONFIG_IPM_MSG_CH_0_ENABLE=y
7+
CONFIG_IPM_MSG_CH_1_ENABLE=y
8+
9+
CONFIG_IPM_MSG_CH_0_RX=y
10+
CONFIG_IPM_MSG_CH_1_TX=y
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2021 Carlo Caione <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef COMMON_H__
8+
#define COMMON_H__
9+
10+
#define VDEV_START_ADDR CONFIG_OPENAMP_IPC_SHM_BASE_ADDRESS
11+
#define VDEV_SIZE CONFIG_OPENAMP_IPC_SHM_SIZE
12+
13+
#define VDEV_STATUS_ADDR VDEV_START_ADDR
14+
#define VDEV_STATUS_SIZE 0x400
15+
16+
#define SHM_START_ADDR (VDEV_START_ADDR + VDEV_STATUS_SIZE)
17+
#define SHM_SIZE (VDEV_SIZE - VDEV_STATUS_SIZE)
18+
#define SHM_DEVICE_NAME "sramx.shm"
19+
20+
#define VRING_COUNT 2
21+
#define VRING_RX_ADDRESS (VDEV_START_ADDR + SHM_SIZE - VDEV_STATUS_SIZE)
22+
#define VRING_TX_ADDRESS (VDEV_START_ADDR + SHM_SIZE)
23+
#define VRING_ALIGNMENT 4
24+
#define VRING_SIZE 16
25+
26+
struct payload {
27+
unsigned long cnt;
28+
unsigned long size;
29+
unsigned char data[];
30+
};
31+
32+
#endif
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CONFIG_PRINTK=y
2+
3+
CONFIG_IPM=y
4+
CONFIG_TIMESLICE_SIZE=1
5+
CONFIG_MAIN_STACK_SIZE=2048
6+
CONFIG_HEAP_MEM_POOL_SIZE=4096
7+
8+
CONFIG_OPENAMP=y
9+
CONFIG_OPENAMP_SLAVE=n
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) 2021 Carlo Caione <[email protected]>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
if("${BOARD}" STREQUAL "nrf5340dk_nrf5340_cpunet")
10+
message(INFO " ${BOARD} compiles as remote in this sample")
11+
else()
12+
message(FATAL_ERROR "${BOARD} was not supported for this sample")
13+
endif()
14+
15+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
16+
project(openamp_performance_remote)
17+
18+
target_sources(app PRIVATE src/main.c)
19+
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Private config options for openamp sample app
2+
3+
# Copyright (c) 2021 Carlo Caione <[email protected]>
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# Workaround for not being able to have commas in macro arguments
7+
DT_CHOSEN_Z_IPC_SHM := zephyr,ipc_shm
8+
DT_CHOSEN_Z_IPC_TX := zephyr,ipc_tx
9+
DT_CHOSEN_Z_IPC_RX := zephyr,ipc_rx
10+
11+
config OPENAMP_IPC_SHM_BASE_ADDRESS
12+
hex
13+
default "$(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_IPC_SHM))"
14+
help
15+
This option specifies base address of the memory region to
16+
be used for the OpenAMP IPC shared memory
17+
18+
config OPENAMP_IPC_SHM_SIZE
19+
hex
20+
default "$(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_IPC_SHM))"
21+
help
22+
This option specifies size of the memory region to be used
23+
for the OpenAMP IPC shared memory
24+
25+
config OPENAMP_IPC_DEV_TX_NAME
26+
string
27+
default "$(dt_chosen_label,$(DT_CHOSEN_Z_IPC_TX))" if !IPM_NRFX
28+
default "IPM_1" if (IPM_NRFX && OPENAMP_MASTER)
29+
default "IPM_0" if (IPM_NRFX && OPENAMP_SLAVE)
30+
help
31+
This option specifies the device name for the IPC device to be used (TX)
32+
33+
config OPENAMP_IPC_DEV_RX_NAME
34+
string
35+
default "$(dt_chosen_label,$(DT_CHOSEN_Z_IPC_RX))" if !IPM_NRFX
36+
default "IPM_0" if (IPM_NRFX && OPENAMP_MASTER)
37+
default "IPM_1" if (IPM_NRFX && OPENAMP_SLAVE)
38+
help
39+
This option specifies the device name for the IPC device to be used (RX)
40+
41+
source "Kconfig.zephyr"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CONFIG_IPM=y
2+
CONFIG_IPM_NRFX=y
3+
4+
CONFIG_IPM_MSG_CH_0_ENABLE=y
5+
CONFIG_IPM_MSG_CH_1_ENABLE=y
6+
7+
CONFIG_IPM_MSG_CH_0_TX=y
8+
CONFIG_IPM_MSG_CH_1_RX=y
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CONFIG_PRINTK=y
2+
3+
CONFIG_IPM=y
4+
CONFIG_HEAP_MEM_POOL_SIZE=4096
5+
6+
CONFIG_OPENAMP=y
7+
CONFIG_OPENAMP_MASTER=n

0 commit comments

Comments
 (0)