Skip to content

Commit 88c3679

Browse files
Karl Zhanggalak
Karl Zhang
authored andcommitted
samples: openamp: Add support for mps2_an521
AN521 is a dual core FPGA on MPS2+ with both cores are CM33. Add openAMP to support on it. Core 0 is primary core, it runs as master, core 1 is remote, it runs as slave. Signed-off-by: Karl Zhang <[email protected]>
1 parent faeeb4a commit 88c3679

File tree

7 files changed

+55
-3
lines changed

7 files changed

+55
-3
lines changed

samples/subsys/ipc/openamp/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ cmake_minimum_required(VERSION 3.13.1)
55
# SPDX-License-Identifier: Apache-2.0
66
#
77

8+
set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/openamp_remote-prefix/src/openamp_remote-build/zephyr)
9+
810
if("${BOARD}" STREQUAL "lpcxpresso54114_m4")
911
set(BOARD_REMOTE "lpcxpresso54114_m0")
12+
elseif("${BOARD}" STREQUAL "mps2_an521")
13+
set(QEMU_EXTRA_FLAGS "-device;loader,file=${REMOTE_ZEPHYR_DIR}/zephyr.elf")
14+
set(BOARD_REMOTE "mps2_an521_nonsecure")
1015
else()
1116
message(FATAL_ERROR "${BOARD} was not supported for this sample")
1217
endif()
@@ -28,7 +33,7 @@ ExternalProject_Add(
2833
INSTALL_COMMAND "" # This particular build system has no install command
2934
CMAKE_CACHE_ARGS -DBOARD:string=${BOARD_REMOTE}
3035
CMAKE_CACHE_ARGS -DDTC_OVERLAY_FILE:string=${DTC_OVERLAY_FILE}
31-
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/openamp_remote-prefix/src/openamp_remote-build/zephyr/zephyr.bin"
36+
BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/zephyr.bin"
3237
# NB: Do we need to pass on more CMake variables?
3338
BUILD_ALWAYS True
3439
)

samples/subsys/ipc/openamp/README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ Building the application for lpcxpresso54114_m4
1818
:board: lpcxpresso54114_m4
1919
:goals: debug
2020

21+
Building the application for mps2_an521
22+
***************************************
23+
24+
.. zephyr-app-commands::
25+
:zephyr-app: samples/subsys/ipc/openamp
26+
:board: mps2_an521
27+
:goals: debug
28+
2129
Open a serial terminal (minicom, putty, etc.) and connect the board with the
2230
following settings:
2331

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2019 Linaro Limited
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
/*
10+
* shared memory reserved for the inter-processor communication
11+
*/
12+
zephyr,ipc_shm = &sramx;
13+
zephyr,ipc = &mhu0;
14+
};
15+
16+
sramx: memory@28180000 {
17+
compatible = "mmio-sram";
18+
reg = <0x28180000 0x8000>;
19+
};
20+
};

samples/subsys/ipc/openamp/remote/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ cmake_minimum_required(VERSION 3.13.1)
44
#
55
# SPDX-License-Identifier: Apache-2.0
66
#
7-
if(("${BOARD}" STREQUAL "lpcxpresso54114_m0"))
7+
8+
if(("${BOARD}" STREQUAL "lpcxpresso54114_m0")
9+
OR "${BOARD}" STREQUAL "mps2_an521_nonsecure")
810
message(INFO " ${BOARD} compile as slave in this sample")
911
else()
1012
message(FATAL_ERROR "${BOARD} was not supported for this sample")

samples/subsys/ipc/openamp/remote/src/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@ static u32_t virtio_get_features(struct virtio_device *vdev)
7373

7474
static void virtio_notify(struct virtqueue *vq)
7575
{
76+
#if defined(CONFIG_SOC_MPS2_AN521)
77+
u32_t current_core = sse_200_platform_get_cpu_id();
78+
79+
ipm_send(ipm_handle, 0, current_core ? 0 : 1, 0, 1);
80+
#else
7681
u32_t dummy_data = 0x00110011; /* Some data must be provided */
7782

7883
ipm_send(ipm_handle, 0, 0, &dummy_data, sizeof(dummy_data));
84+
#endif /* #if defined(CONFIG_SOC_MPS2_AN521) */
7985
}
8086

8187
struct virtio_dispatch dispatch = {

samples/subsys/ipc/openamp/sample.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sample:
44
name: OpenAMP example integration
55
tests:
66
sample.ipc.openamp:
7-
platform_whitelist: lpcxpresso54114_m4
7+
platform_whitelist: lpcxpresso54114_m4 mps2_an521
88
tags: ipm
99
harness: console
1010
harness_config:

samples/subsys/ipc/openamp/src/main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ static void virtio_set_features(struct virtio_device *vdev,
8484

8585
static void virtio_notify(struct virtqueue *vq)
8686
{
87+
#if defined(CONFIG_SOC_MPS2_AN521)
88+
u32_t current_core = sse_200_platform_get_cpu_id();
89+
90+
ipm_send(ipm_handle, 0, current_core ? 0 : 1, 0, 1);
91+
#else
8792
u32_t dummy_data = 0x55005500; /* Some data must be provided */
8893

8994
ipm_send(ipm_handle, 0, 0, &dummy_data, sizeof(dummy_data));
95+
#endif /* #if defined(CONFIG_SOC_MPS2_AN521) */
9096
}
9197

9298
struct virtio_dispatch dispatch = {
@@ -279,6 +285,11 @@ void main(void)
279285
k_thread_create(&thread_data, thread_stack, APP_TASK_STACK_SIZE,
280286
(k_thread_entry_t)app_task,
281287
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
288+
289+
#if defined(CONFIG_SOC_MPS2_AN521)
290+
wakeup_cpu1();
291+
k_sleep(500);
292+
#endif /* #if defined(CONFIG_SOC_MPS2_AN521) */
282293
}
283294

284295
/* Make sure we clear out the status flag very early (before we bringup the

0 commit comments

Comments
 (0)