diff --git a/samples/subsys/ipc/openamp/CMakeLists.txt b/samples/subsys/ipc/openamp/CMakeLists.txt index 804fd423001..e6d6a723d87 100644 --- a/samples/subsys/ipc/openamp/CMakeLists.txt +++ b/samples/subsys/ipc/openamp/CMakeLists.txt @@ -5,8 +5,13 @@ cmake_minimum_required(VERSION 3.13.1) # SPDX-License-Identifier: Apache-2.0 # +set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/openamp_remote-prefix/src/openamp_remote-build/zephyr) + if("${BOARD}" STREQUAL "lpcxpresso54114_m4") set(BOARD_REMOTE "lpcxpresso54114_m0") +elseif("${BOARD}" STREQUAL "mps2_an521") + set(QEMU_EXTRA_FLAGS "-device;loader,file=${REMOTE_ZEPHYR_DIR}/zephyr.elf") + set(BOARD_REMOTE "mps2_an521_nonsecure") else() message(FATAL_ERROR "${BOARD} was not supported for this sample") endif() @@ -28,7 +33,7 @@ ExternalProject_Add( INSTALL_COMMAND "" # This particular build system has no install command CMAKE_CACHE_ARGS -DBOARD:string=${BOARD_REMOTE} CMAKE_CACHE_ARGS -DDTC_OVERLAY_FILE:string=${DTC_OVERLAY_FILE} - BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/openamp_remote-prefix/src/openamp_remote-build/zephyr/zephyr.bin" + BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/zephyr.bin" # NB: Do we need to pass on more CMake variables? BUILD_ALWAYS True ) diff --git a/samples/subsys/ipc/openamp/README.rst b/samples/subsys/ipc/openamp/README.rst index 71a3bebb8b5..757c2d0b8e3 100644 --- a/samples/subsys/ipc/openamp/README.rst +++ b/samples/subsys/ipc/openamp/README.rst @@ -18,6 +18,14 @@ Building the application for lpcxpresso54114_m4 :board: lpcxpresso54114_m4 :goals: debug +Building the application for mps2_an521 +*************************************** + +.. zephyr-app-commands:: + :zephyr-app: samples/subsys/ipc/openamp + :board: mps2_an521 + :goals: debug + Open a serial terminal (minicom, putty, etc.) and connect the board with the following settings: diff --git a/samples/subsys/ipc/openamp/mps2_an521.overlay b/samples/subsys/ipc/openamp/mps2_an521.overlay new file mode 100644 index 00000000000..aff3c460cbc --- /dev/null +++ b/samples/subsys/ipc/openamp/mps2_an521.overlay @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + /* + * shared memory reserved for the inter-processor communication + */ + zephyr,ipc_shm = &sramx; + zephyr,ipc = &mhu0; + }; + + sramx: memory@28180000 { + compatible = "mmio-sram"; + reg = <0x28180000 0x8000>; + }; +}; diff --git a/samples/subsys/ipc/openamp/remote/CMakeLists.txt b/samples/subsys/ipc/openamp/remote/CMakeLists.txt index 884de45722a..971085e2ac3 100644 --- a/samples/subsys/ipc/openamp/remote/CMakeLists.txt +++ b/samples/subsys/ipc/openamp/remote/CMakeLists.txt @@ -4,7 +4,9 @@ cmake_minimum_required(VERSION 3.13.1) # # SPDX-License-Identifier: Apache-2.0 # -if(("${BOARD}" STREQUAL "lpcxpresso54114_m0")) + +if(("${BOARD}" STREQUAL "lpcxpresso54114_m0") + OR "${BOARD}" STREQUAL "mps2_an521_nonsecure") message(INFO " ${BOARD} compile as slave in this sample") else() message(FATAL_ERROR "${BOARD} was not supported for this sample") diff --git a/samples/subsys/ipc/openamp/remote/src/main.c b/samples/subsys/ipc/openamp/remote/src/main.c index ac9c04bac82..c3e99453a20 100644 --- a/samples/subsys/ipc/openamp/remote/src/main.c +++ b/samples/subsys/ipc/openamp/remote/src/main.c @@ -73,9 +73,15 @@ static u32_t virtio_get_features(struct virtio_device *vdev) static void virtio_notify(struct virtqueue *vq) { +#if defined(CONFIG_SOC_MPS2_AN521) + u32_t current_core = sse_200_platform_get_cpu_id(); + + ipm_send(ipm_handle, 0, current_core ? 0 : 1, 0, 1); +#else u32_t dummy_data = 0x00110011; /* Some data must be provided */ ipm_send(ipm_handle, 0, 0, &dummy_data, sizeof(dummy_data)); +#endif /* #if defined(CONFIG_SOC_MPS2_AN521) */ } struct virtio_dispatch dispatch = { diff --git a/samples/subsys/ipc/openamp/sample.yaml b/samples/subsys/ipc/openamp/sample.yaml index 4f6d5b97f57..7d04f96407e 100644 --- a/samples/subsys/ipc/openamp/sample.yaml +++ b/samples/subsys/ipc/openamp/sample.yaml @@ -4,7 +4,7 @@ sample: name: OpenAMP example integration tests: sample.ipc.openamp: - platform_whitelist: lpcxpresso54114_m4 + platform_whitelist: lpcxpresso54114_m4 mps2_an521 tags: ipm harness: console harness_config: diff --git a/samples/subsys/ipc/openamp/src/main.c b/samples/subsys/ipc/openamp/src/main.c index b8c86b40ced..09adbf2c601 100644 --- a/samples/subsys/ipc/openamp/src/main.c +++ b/samples/subsys/ipc/openamp/src/main.c @@ -84,9 +84,15 @@ static void virtio_set_features(struct virtio_device *vdev, static void virtio_notify(struct virtqueue *vq) { +#if defined(CONFIG_SOC_MPS2_AN521) + u32_t current_core = sse_200_platform_get_cpu_id(); + + ipm_send(ipm_handle, 0, current_core ? 0 : 1, 0, 1); +#else u32_t dummy_data = 0x55005500; /* Some data must be provided */ ipm_send(ipm_handle, 0, 0, &dummy_data, sizeof(dummy_data)); +#endif /* #if defined(CONFIG_SOC_MPS2_AN521) */ } struct virtio_dispatch dispatch = { @@ -279,6 +285,11 @@ void main(void) k_thread_create(&thread_data, thread_stack, APP_TASK_STACK_SIZE, (k_thread_entry_t)app_task, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); + +#if defined(CONFIG_SOC_MPS2_AN521) + wakeup_cpu1(); + k_sleep(500); +#endif /* #if defined(CONFIG_SOC_MPS2_AN521) */ } /* Make sure we clear out the status flag very early (before we bringup the