From 02d7d7e9eb65c6d87988f0ef9056471e35ac0986 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 19 Sep 2019 13:06:40 -0500 Subject: [PATCH 1/7] samples: openamp: prep for additional board support Move board specific conf info boards/.conf to support other board/SoCs with this sample. Signed-off-by: Kumar Gala --- samples/subsys/ipc/openamp/boards/lpcxpresso54114_m4.conf | 3 +++ samples/subsys/ipc/openamp/prj.conf | 3 --- .../subsys/ipc/openamp/remote/boards/lpcxpresso54114_m0.conf | 1 + samples/subsys/ipc/openamp/remote/prj.conf | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 samples/subsys/ipc/openamp/boards/lpcxpresso54114_m4.conf create mode 100644 samples/subsys/ipc/openamp/remote/boards/lpcxpresso54114_m0.conf diff --git a/samples/subsys/ipc/openamp/boards/lpcxpresso54114_m4.conf b/samples/subsys/ipc/openamp/boards/lpcxpresso54114_m4.conf new file mode 100644 index 000000000000..b5432c4c56e0 --- /dev/null +++ b/samples/subsys/ipc/openamp/boards/lpcxpresso54114_m4.conf @@ -0,0 +1,3 @@ +CONFIG_IPM_MCUX=y +CONFIG_SLAVE_CORE_MCUX=y +CONFIG_SLAVE_IMAGE_MCUX="${ZEPHYR_BINARY_DIR}/../openamp_remote-prefix/src/openamp_remote-build/zephyr/zephyr.bin" diff --git a/samples/subsys/ipc/openamp/prj.conf b/samples/subsys/ipc/openamp/prj.conf index a9b5cad7d290..d9b869b60337 100644 --- a/samples/subsys/ipc/openamp/prj.conf +++ b/samples/subsys/ipc/openamp/prj.conf @@ -1,8 +1,5 @@ CONFIG_PRINTK=y CONFIG_IPM=y -CONFIG_IPM_MCUX=y -CONFIG_SLAVE_CORE_MCUX=y -CONFIG_SLAVE_IMAGE_MCUX="${ZEPHYR_BINARY_DIR}/../openamp_remote-prefix/src/openamp_remote-build/zephyr/zephyr.bin" CONFIG_TIMESLICE_SIZE=1 CONFIG_MAIN_STACK_SIZE=2048 CONFIG_HEAP_MEM_POOL_SIZE=4096 diff --git a/samples/subsys/ipc/openamp/remote/boards/lpcxpresso54114_m0.conf b/samples/subsys/ipc/openamp/remote/boards/lpcxpresso54114_m0.conf new file mode 100644 index 000000000000..2360fff8e423 --- /dev/null +++ b/samples/subsys/ipc/openamp/remote/boards/lpcxpresso54114_m0.conf @@ -0,0 +1 @@ +CONFIG_IPM_MCUX=y diff --git a/samples/subsys/ipc/openamp/remote/prj.conf b/samples/subsys/ipc/openamp/remote/prj.conf index 7a08439febe6..9b8ceae532f2 100644 --- a/samples/subsys/ipc/openamp/remote/prj.conf +++ b/samples/subsys/ipc/openamp/remote/prj.conf @@ -1,7 +1,6 @@ CONFIG_STDOUT_CONSOLE=n CONFIG_PRINTK=n CONFIG_IPM=y -CONFIG_IPM_MCUX=y CONFIG_PLATFORM_SPECIFIC_INIT=n CONFIG_HEAP_MEM_POOL_SIZE=4096 CONFIG_OPENAMP=y From 45a61193b49eeecb45f2638a2f759b0dddb91478 Mon Sep 17 00:00:00 2001 From: Karl Zhang Date: Thu, 11 Jul 2019 21:49:30 +0800 Subject: [PATCH 2/7] samples: openamp: Remove exclusive compile of openAMP Add configuable shared memory address for openAMP samples. There is a plan to add more platforms supported for openAMP in zephyr. Each platform can specify the shared memory address and device by device tree and add it's support in openAMP samples. Signed-off-by: Karl Zhang Signed-off-by: Kumar Gala --- samples/subsys/ipc/openamp/CMakeLists.txt | 21 +++++++++---- samples/subsys/ipc/openamp/Kconfig | 30 +++++++++++++++++++ samples/subsys/ipc/openamp/common.h | 17 +++++++---- .../ipc/openamp/lpcxpresso54114_m4.overlay | 20 +++++++++++++ .../subsys/ipc/openamp/remote/CMakeLists.txt | 11 +++---- samples/subsys/ipc/openamp/remote/Kconfig | 30 +++++++++++++++++++ samples/subsys/ipc/openamp/remote/src/main.c | 4 +-- samples/subsys/ipc/openamp/src/main.c | 4 +-- 8 files changed, 116 insertions(+), 21 deletions(-) create mode 100644 samples/subsys/ipc/openamp/Kconfig create mode 100644 samples/subsys/ipc/openamp/lpcxpresso54114_m4.overlay create mode 100644 samples/subsys/ipc/openamp/remote/Kconfig diff --git a/samples/subsys/ipc/openamp/CMakeLists.txt b/samples/subsys/ipc/openamp/CMakeLists.txt index 95e866dfb276..804fd4230016 100644 --- a/samples/subsys/ipc/openamp/CMakeLists.txt +++ b/samples/subsys/ipc/openamp/CMakeLists.txt @@ -1,17 +1,21 @@ cmake_minimum_required(VERSION 3.13.1) # Copyright (c) 2018 Nordic Semiconductor ASA +# Copyright (c) 2019 Linaro Limited # # SPDX-License-Identifier: Apache-2.0 # -set(BOARD lpcxpresso54114_m4) + +if("${BOARD}" STREQUAL "lpcxpresso54114_m4") + set(BOARD_REMOTE "lpcxpresso54114_m0") +else() + message(FATAL_ERROR "${BOARD} was not supported for this sample") +endif() + +message(INFO " ${BOARD} compile as Master in this sample") include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) project(openamp) -if(NOT ("${BOARD}" STREQUAL "lpcxpresso54114_m4")) - message(FATAL_ERROR "${BOARD} was specified, but this sample only supports lpcxpresso54114_m4") -endif() - enable_language(C ASM) target_sources(app PRIVATE src/main.c) @@ -22,10 +26,15 @@ ExternalProject_Add( openamp_remote SOURCE_DIR ${APPLICATION_SOURCE_DIR}/remote 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" # NB: Do we need to pass on more CMake variables? BUILD_ALWAYS True ) -add_dependencies(core_m0_inc_target openamp_remote) + +if(("${BOARD}" STREQUAL "lpcxpresso54114_m4")) + add_dependencies(core_m0_inc_target openamp_remote) +endif() target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/samples/subsys/ipc/openamp/Kconfig b/samples/subsys/ipc/openamp/Kconfig new file mode 100644 index 000000000000..39bbc199d0bb --- /dev/null +++ b/samples/subsys/ipc/openamp/Kconfig @@ -0,0 +1,30 @@ +# Private config options for openamp sample app + +# Copyright (c) 2020 Linaro Limited +# SPDX-License-Identifier: Apache-2.0 + +# Workaround for not being able to have commas in macro arguments +DT_CHOSEN_Z_IPC_SHM := zephyr,ipc_shm +DT_CHOSEN_Z_IPC := zephyr,ipc + +config OPENAMP_IPC_SHM_BASE_ADDRESS + hex + default "$(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_IPC_SHM))" + help + This option specifies base address of the memory region to + be used for the OpenAMP IPC shared memory + +config OPENAMP_IPC_SHM_SIZE + hex + default "$(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_IPC_SHM))" + help + This option specifies size of the memory region to be used + for the OpenAMP IPC shared memory + +config OPENAMP_IPC_DEV_NAME + string + default "$(dt_chosen_label,$(DT_CHOSEN_Z_IPC))" + help + This option specifies the device name for the IPC device to be used + +source "Kconfig.zephyr" diff --git a/samples/subsys/ipc/openamp/common.h b/samples/subsys/ipc/openamp/common.h index 27ceaf094d00..2386eb8715d8 100644 --- a/samples/subsys/ipc/openamp/common.h +++ b/samples/subsys/ipc/openamp/common.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2018 Nordic Semiconductor ASA - * Copyright (c) 2018 Linaro Limited + * Copyright (c) 2018-2019 Linaro Limited * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,16 +8,21 @@ #ifndef COMMON_H__ #define COMMON_H__ -#define SHM_START_ADDR 0x04000400 -#define SHM_SIZE 0x7c00 +#define VDEV_START_ADDR CONFIG_OPENAMP_IPC_SHM_BASE_ADDRESS +#define VDEV_SIZE CONFIG_OPENAMP_IPC_SHM_SIZE + +#define VDEV_STATUS_ADDR VDEV_START_ADDR +#define VDEV_STATUS_SIZE 0x400 + +#define SHM_START_ADDR (VDEV_START_ADDR + VDEV_STATUS_SIZE) +#define SHM_SIZE (VDEV_SIZE - VDEV_STATUS_SIZE) #define SHM_DEVICE_NAME "sramx.shm" #define VRING_COUNT 2 -#define VRING_RX_ADDRESS 0x04007800 -#define VRING_TX_ADDRESS 0x04007C00 +#define VRING_RX_ADDRESS (VDEV_START_ADDR + SHM_SIZE - VDEV_STATUS_SIZE) +#define VRING_TX_ADDRESS (VDEV_START_ADDR + SHM_SIZE) #define VRING_ALIGNMENT 4 #define VRING_SIZE 16 -#define VDEV_STATUS_ADDR 0x04000000 #endif diff --git a/samples/subsys/ipc/openamp/lpcxpresso54114_m4.overlay b/samples/subsys/ipc/openamp/lpcxpresso54114_m4.overlay new file mode 100644 index 000000000000..61e3476ecb4f --- /dev/null +++ b/samples/subsys/ipc/openamp/lpcxpresso54114_m4.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 = &sramx1; + zephyr,ipc = &mailbox0; + }; + + sramx1:memory@4000000{ + compatible = "mmio-sram"; + reg = <0x4000000 0x8000>; + }; +}; diff --git a/samples/subsys/ipc/openamp/remote/CMakeLists.txt b/samples/subsys/ipc/openamp/remote/CMakeLists.txt index a6cc307808de..884de45722ae 100644 --- a/samples/subsys/ipc/openamp/remote/CMakeLists.txt +++ b/samples/subsys/ipc/openamp/remote/CMakeLists.txt @@ -1,16 +1,17 @@ cmake_minimum_required(VERSION 3.13.1) # Copyright (c) 2018 Nordic Semiconductor ASA +# Copyright (c) 2019 Linaro Limited # # SPDX-License-Identifier: Apache-2.0 # -set(BOARD lpcxpresso54114_m0) +if(("${BOARD}" STREQUAL "lpcxpresso54114_m0")) + message(INFO " ${BOARD} compile as slave in this sample") +else() + message(FATAL_ERROR "${BOARD} was not supported for this sample") +endif() include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) project(openamp_remote) -if(NOT ("${BOARD}" STREQUAL "lpcxpresso54114_m0")) - message(FATAL_ERROR "${BOARD} was specified, but this sample only supports lpcxpresso54114_m0") -endif() - target_sources(app PRIVATE src/main.c) target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) diff --git a/samples/subsys/ipc/openamp/remote/Kconfig b/samples/subsys/ipc/openamp/remote/Kconfig new file mode 100644 index 000000000000..39bbc199d0bb --- /dev/null +++ b/samples/subsys/ipc/openamp/remote/Kconfig @@ -0,0 +1,30 @@ +# Private config options for openamp sample app + +# Copyright (c) 2020 Linaro Limited +# SPDX-License-Identifier: Apache-2.0 + +# Workaround for not being able to have commas in macro arguments +DT_CHOSEN_Z_IPC_SHM := zephyr,ipc_shm +DT_CHOSEN_Z_IPC := zephyr,ipc + +config OPENAMP_IPC_SHM_BASE_ADDRESS + hex + default "$(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_IPC_SHM))" + help + This option specifies base address of the memory region to + be used for the OpenAMP IPC shared memory + +config OPENAMP_IPC_SHM_SIZE + hex + default "$(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_IPC_SHM))" + help + This option specifies size of the memory region to be used + for the OpenAMP IPC shared memory + +config OPENAMP_IPC_DEV_NAME + string + default "$(dt_chosen_label,$(DT_CHOSEN_Z_IPC))" + help + This option specifies the device name for the IPC device to be used + +source "Kconfig.zephyr" diff --git a/samples/subsys/ipc/openamp/remote/src/main.c b/samples/subsys/ipc/openamp/remote/src/main.c index 0f24b3f0a460..ac9c04bac828 100644 --- a/samples/subsys/ipc/openamp/remote/src/main.c +++ b/samples/subsys/ipc/openamp/remote/src/main.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2018, NXP * Copyright (c) 2018, Nordic Semiconductor ASA - * Copyright (c) 2018, Linaro Limited + * Copyright (c) 2018-2019, Linaro Limited * * SPDX-License-Identifier: Apache-2.0 */ @@ -168,7 +168,7 @@ void app_task(void *arg1, void *arg2, void *arg3) } /* setup IPM */ - ipm_handle = device_get_binding("MAILBOX_0"); + ipm_handle = device_get_binding(CONFIG_OPENAMP_IPC_DEV_NAME); if (ipm_handle == NULL) { printk("device_get_binding failed to find device\n"); return; diff --git a/samples/subsys/ipc/openamp/src/main.c b/samples/subsys/ipc/openamp/src/main.c index ef4699d63c63..b8c86b40cedc 100644 --- a/samples/subsys/ipc/openamp/src/main.c +++ b/samples/subsys/ipc/openamp/src/main.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2018, NXP * Copyright (c) 2018, Nordic Semiconductor ASA - * Copyright (c) 2018, Linaro Limited + * Copyright (c) 2018-2019, Linaro Limited * * SPDX-License-Identifier: Apache-2.0 */ @@ -192,7 +192,7 @@ void app_task(void *arg1, void *arg2, void *arg3) } /* setup IPM */ - ipm_handle = device_get_binding("MAILBOX_0"); + ipm_handle = device_get_binding(CONFIG_OPENAMP_IPC_DEV_NAME); if (ipm_handle == NULL) { printk("device_get_binding failed to find device\n"); return; From a1cc21830d89a4403e7c994c0769af3a0392b3bb Mon Sep 17 00:00:00 2001 From: Karl Zhang Date: Tue, 16 Jul 2019 10:46:20 +0800 Subject: [PATCH 3/7] samples: openamp: Keep document up to date Update serial output for both master and remote. Signed-off-by: Karl Zhang --- samples/subsys/ipc/openamp/README.rst | 34 +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/samples/subsys/ipc/openamp/README.rst b/samples/subsys/ipc/openamp/README.rst index bd71856ce031..71a3bebb8b5f 100644 --- a/samples/subsys/ipc/openamp/README.rst +++ b/samples/subsys/ipc/openamp/README.rst @@ -8,10 +8,10 @@ Overview This application demonstrates how to use OpenAMP with Zephyr. It is designed to demonstrate how to integrate OpenAMP with Zephyr both from a build perspective -and code. Currently this integration is specific to the LPC54114 SoC. +and code. -Building the application -************************* +Building the application for lpcxpresso54114_m4 +*********************************************** .. zephyr-app-commands:: :zephyr-app: samples/subsys/ipc/openamp @@ -27,17 +27,31 @@ following settings: - Stop bits: 1 Reset the board and the following message will appear on the corresponding -serial port: +serial port, one is master another is remote: .. code-block:: console - ***** Booting Zephyr OS v1.11.0-1377-g580b9add47 ***** + **** Booting Zephyr OS build zephyr-v1.14.0-2064-g888fc98fddaa **** Starting application thread! - OpenAMP demo started - Primary core received a message: 1 - Primary core received a message: 3 - Primary core received a message: 5 + OpenAMP[master] demo started + Master core received a message: 1 + Master core received a message: 3 + Master core received a message: 5 ... - Primary core received a message: 101 + Master core received a message: 99 + OpenAMP demo ended. + + +.. code-block:: console + + **** Booting Zephyr OS build zephyr-v1.14.0-2064-g888fc98fddaa **** + Starting application thread! + + OpenAMP[remote] demo started + Remote core received a message: 0 + Remote core received a message: 2 + Remote core received a message: 4 + ... + Remote core received a message: 98 OpenAMP demo ended. From 8b1021353f30132332e1aef1cbf1d122a4488376 Mon Sep 17 00:00:00 2001 From: Karl Zhang Date: Fri, 26 Jul 2019 10:13:25 +0800 Subject: [PATCH 4/7] IPM: Add MHU as default IPM for sse-200 subsystem Set sse-200 subsystem using MHU (Message Handling Unit) as default. Signed-off-by: Karl Zhang --- boards/arm/mps2_an521/Kconfig.defconfig | 7 +++++++ boards/arm/v2m_musca/Kconfig.defconfig | 7 +++++++ boards/arm/v2m_musca_b1/Kconfig.defconfig | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/boards/arm/mps2_an521/Kconfig.defconfig b/boards/arm/mps2_an521/Kconfig.defconfig index ce85a4e387d4..9f1df66905f4 100644 --- a/boards/arm/mps2_an521/Kconfig.defconfig +++ b/boards/arm/mps2_an521/Kconfig.defconfig @@ -44,4 +44,11 @@ config I2C_SBCON default y depends on I2C +if IPM + +config IPM_MHU + default y + +endif # IPM + endif diff --git a/boards/arm/v2m_musca/Kconfig.defconfig b/boards/arm/v2m_musca/Kconfig.defconfig index e4f2132493b9..eca4ffc89d8f 100644 --- a/boards/arm/v2m_musca/Kconfig.defconfig +++ b/boards/arm/v2m_musca/Kconfig.defconfig @@ -43,4 +43,11 @@ config TIMER_DTMR_CMSDK_APB endif # COUNTER +if IPM + +config IPM_MHU + default y + +endif # IPM + endif diff --git a/boards/arm/v2m_musca_b1/Kconfig.defconfig b/boards/arm/v2m_musca_b1/Kconfig.defconfig index e91edfa415ad..af0f2ce8a550 100644 --- a/boards/arm/v2m_musca_b1/Kconfig.defconfig +++ b/boards/arm/v2m_musca_b1/Kconfig.defconfig @@ -33,4 +33,11 @@ config UART_PL011_PORT1 endif # SERIAL +if IPM + +config IPM_MHU + default y + +endif # IPM + endif From 688043d331c53fd51c76998b4c8042cc7b2afc3c Mon Sep 17 00:00:00 2001 From: Karl Zhang Date: Mon, 15 Jul 2019 18:39:41 +0800 Subject: [PATCH 5/7] 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 --- samples/subsys/ipc/openamp/CMakeLists.txt | 7 ++++++- samples/subsys/ipc/openamp/README.rst | 8 ++++++++ samples/subsys/ipc/openamp/mps2_an521.overlay | 20 +++++++++++++++++++ .../subsys/ipc/openamp/remote/CMakeLists.txt | 4 +++- samples/subsys/ipc/openamp/remote/src/main.c | 6 ++++++ samples/subsys/ipc/openamp/sample.yaml | 2 +- samples/subsys/ipc/openamp/src/main.c | 11 ++++++++++ 7 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 samples/subsys/ipc/openamp/mps2_an521.overlay diff --git a/samples/subsys/ipc/openamp/CMakeLists.txt b/samples/subsys/ipc/openamp/CMakeLists.txt index 804fd4230016..e6d6a723d87f 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 71a3bebb8b5f..757c2d0b8e33 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 000000000000..aff3c460cbc0 --- /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 884de45722ae..971085e2ac32 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 ac9c04bac828..c3e99453a204 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 4f6d5b97f57e..7d04f96407ef 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 b8c86b40cedc..09adbf2c6010 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 From 9be33b7dda9370283375a62bf53c6f1551572765 Mon Sep 17 00:00:00 2001 From: Karl Zhang Date: Tue, 16 Jul 2019 10:26:13 +0800 Subject: [PATCH 6/7] samples: openamp: Add support for Musca A Musca A is a dual core SoC with both cores are CM33. Add openAMP to support on it. Signed-off-by: Karl Zhang --- samples/subsys/ipc/openamp/CMakeLists.txt | 2 ++ samples/subsys/ipc/openamp/README.rst | 8 ++++++++ .../subsys/ipc/openamp/remote/CMakeLists.txt | 3 ++- samples/subsys/ipc/openamp/remote/src/main.c | 3 ++- samples/subsys/ipc/openamp/sample.yaml | 2 +- samples/subsys/ipc/openamp/src/main.c | 6 ++++-- samples/subsys/ipc/openamp/v2m_musca.overlay | 20 +++++++++++++++++++ 7 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 samples/subsys/ipc/openamp/v2m_musca.overlay diff --git a/samples/subsys/ipc/openamp/CMakeLists.txt b/samples/subsys/ipc/openamp/CMakeLists.txt index e6d6a723d87f..67a3ba6ace38 100644 --- a/samples/subsys/ipc/openamp/CMakeLists.txt +++ b/samples/subsys/ipc/openamp/CMakeLists.txt @@ -12,6 +12,8 @@ if("${BOARD}" STREQUAL "lpcxpresso54114_m4") elseif("${BOARD}" STREQUAL "mps2_an521") set(QEMU_EXTRA_FLAGS "-device;loader,file=${REMOTE_ZEPHYR_DIR}/zephyr.elf") set(BOARD_REMOTE "mps2_an521_nonsecure") +elseif("${BOARD}" STREQUAL "v2m_musca") + set(BOARD_REMOTE "v2m_musca_nonsecure") else() message(FATAL_ERROR "${BOARD} was not supported for this sample") endif() diff --git a/samples/subsys/ipc/openamp/README.rst b/samples/subsys/ipc/openamp/README.rst index 757c2d0b8e33..fe3b143762ad 100644 --- a/samples/subsys/ipc/openamp/README.rst +++ b/samples/subsys/ipc/openamp/README.rst @@ -26,6 +26,14 @@ Building the application for mps2_an521 :board: mps2_an521 :goals: debug +Building the application for v2m_musca +************************************** + +.. zephyr-app-commands:: + :zephyr-app: samples/subsys/ipc/openamp + :board: v2m_musca + :goals: debug + Open a serial terminal (minicom, putty, etc.) and connect the board with the following settings: diff --git a/samples/subsys/ipc/openamp/remote/CMakeLists.txt b/samples/subsys/ipc/openamp/remote/CMakeLists.txt index 971085e2ac32..0561d91e55cd 100644 --- a/samples/subsys/ipc/openamp/remote/CMakeLists.txt +++ b/samples/subsys/ipc/openamp/remote/CMakeLists.txt @@ -6,7 +6,8 @@ cmake_minimum_required(VERSION 3.13.1) # if(("${BOARD}" STREQUAL "lpcxpresso54114_m0") - OR "${BOARD}" STREQUAL "mps2_an521_nonsecure") + OR "${BOARD}" STREQUAL "mps2_an521_nonsecure" + OR "${BOARD}" STREQUAL "v2m_musca_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 c3e99453a204..66b03816d2ac 100644 --- a/samples/subsys/ipc/openamp/remote/src/main.c +++ b/samples/subsys/ipc/openamp/remote/src/main.c @@ -73,7 +73,8 @@ static u32_t virtio_get_features(struct virtio_device *vdev) static void virtio_notify(struct virtqueue *vq) { -#if defined(CONFIG_SOC_MPS2_AN521) +#if defined(CONFIG_SOC_MPS2_AN521) || \ + defined(CONFIG_SOC_V2M_MUSCA_A) u32_t current_core = sse_200_platform_get_cpu_id(); ipm_send(ipm_handle, 0, current_core ? 0 : 1, 0, 1); diff --git a/samples/subsys/ipc/openamp/sample.yaml b/samples/subsys/ipc/openamp/sample.yaml index 7d04f96407ef..2f0a083ecfe2 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 mps2_an521 + platform_whitelist: lpcxpresso54114_m4 mps2_an521 v2m_musca 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 09adbf2c6010..31f432899115 100644 --- a/samples/subsys/ipc/openamp/src/main.c +++ b/samples/subsys/ipc/openamp/src/main.c @@ -84,7 +84,8 @@ static void virtio_set_features(struct virtio_device *vdev, static void virtio_notify(struct virtqueue *vq) { -#if defined(CONFIG_SOC_MPS2_AN521) +#if defined(CONFIG_SOC_MPS2_AN521) || \ + defined(CONFIG_SOC_V2M_MUSCA_A) u32_t current_core = sse_200_platform_get_cpu_id(); ipm_send(ipm_handle, 0, current_core ? 0 : 1, 0, 1); @@ -286,7 +287,8 @@ void main(void) (k_thread_entry_t)app_task, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); -#if defined(CONFIG_SOC_MPS2_AN521) +#if defined(CONFIG_SOC_MPS2_AN521) || \ + defined(CONFIG_SOC_V2M_MUSCA_A) wakeup_cpu1(); k_sleep(500); #endif /* #if defined(CONFIG_SOC_MPS2_AN521) */ diff --git a/samples/subsys/ipc/openamp/v2m_musca.overlay b/samples/subsys/ipc/openamp/v2m_musca.overlay new file mode 100644 index 000000000000..a713dd604693 --- /dev/null +++ b/samples/subsys/ipc/openamp/v2m_musca.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@20018000 { + compatible = "mmio-sram"; + reg = <0x20018000 0x8000>; + }; +}; From a21437f00d93621d5ba620d143d3a5048985cfbc Mon Sep 17 00:00:00 2001 From: Karl Zhang Date: Tue, 6 Aug 2019 14:55:31 +0800 Subject: [PATCH 7/7] samples: openamp: Add support for Musca B1 Musca B1 is a dual core SoC with both cores are CM33. Add openAMP to support on it. Signed-off-by: Karl Zhang --- samples/subsys/ipc/openamp/CMakeLists.txt | 2 ++ samples/subsys/ipc/openamp/README.rst | 8 ++++++++ .../subsys/ipc/openamp/remote/CMakeLists.txt | 3 ++- samples/subsys/ipc/openamp/remote/src/main.c | 3 ++- samples/subsys/ipc/openamp/sample.yaml | 2 +- samples/subsys/ipc/openamp/src/main.c | 6 ++++-- .../subsys/ipc/openamp/v2m_musca_b1.overlay | 20 +++++++++++++++++++ 7 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 samples/subsys/ipc/openamp/v2m_musca_b1.overlay diff --git a/samples/subsys/ipc/openamp/CMakeLists.txt b/samples/subsys/ipc/openamp/CMakeLists.txt index 67a3ba6ace38..b9d1d0ee9d9b 100644 --- a/samples/subsys/ipc/openamp/CMakeLists.txt +++ b/samples/subsys/ipc/openamp/CMakeLists.txt @@ -14,6 +14,8 @@ elseif("${BOARD}" STREQUAL "mps2_an521") set(BOARD_REMOTE "mps2_an521_nonsecure") elseif("${BOARD}" STREQUAL "v2m_musca") set(BOARD_REMOTE "v2m_musca_nonsecure") +elseif("${BOARD}" STREQUAL "v2m_musca_b1") + set(BOARD_REMOTE "v2m_musca_b1_nonsecure") else() message(FATAL_ERROR "${BOARD} was not supported for this sample") endif() diff --git a/samples/subsys/ipc/openamp/README.rst b/samples/subsys/ipc/openamp/README.rst index fe3b143762ad..701dbae09ad0 100644 --- a/samples/subsys/ipc/openamp/README.rst +++ b/samples/subsys/ipc/openamp/README.rst @@ -34,6 +34,14 @@ Building the application for v2m_musca :board: v2m_musca :goals: debug +Building the application for v2m_musca_b1 +***************************************** + +.. zephyr-app-commands:: + :zephyr-app: samples/subsys/ipc/openamp + :board: v2m_musca_b1 + :goals: debug + Open a serial terminal (minicom, putty, etc.) and connect the board with the following settings: diff --git a/samples/subsys/ipc/openamp/remote/CMakeLists.txt b/samples/subsys/ipc/openamp/remote/CMakeLists.txt index 0561d91e55cd..74a2fd71d9ff 100644 --- a/samples/subsys/ipc/openamp/remote/CMakeLists.txt +++ b/samples/subsys/ipc/openamp/remote/CMakeLists.txt @@ -7,7 +7,8 @@ cmake_minimum_required(VERSION 3.13.1) if(("${BOARD}" STREQUAL "lpcxpresso54114_m0") OR "${BOARD}" STREQUAL "mps2_an521_nonsecure" - OR "${BOARD}" STREQUAL "v2m_musca_nonsecure") + OR "${BOARD}" STREQUAL "v2m_musca_nonsecure" + OR "${BOARD}" STREQUAL "v2m_musca_b1_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 66b03816d2ac..86d44d5da233 100644 --- a/samples/subsys/ipc/openamp/remote/src/main.c +++ b/samples/subsys/ipc/openamp/remote/src/main.c @@ -74,7 +74,8 @@ static u32_t virtio_get_features(struct virtio_device *vdev) static void virtio_notify(struct virtqueue *vq) { #if defined(CONFIG_SOC_MPS2_AN521) || \ - defined(CONFIG_SOC_V2M_MUSCA_A) + defined(CONFIG_SOC_V2M_MUSCA_A) || \ + defined(CONFIG_SOC_V2M_MUSCA_B1) u32_t current_core = sse_200_platform_get_cpu_id(); ipm_send(ipm_handle, 0, current_core ? 0 : 1, 0, 1); diff --git a/samples/subsys/ipc/openamp/sample.yaml b/samples/subsys/ipc/openamp/sample.yaml index 2f0a083ecfe2..e17964e6c571 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 mps2_an521 v2m_musca + platform_whitelist: lpcxpresso54114_m4 mps2_an521 v2m_musca v2m_musca_b1 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 31f432899115..08c24f92c903 100644 --- a/samples/subsys/ipc/openamp/src/main.c +++ b/samples/subsys/ipc/openamp/src/main.c @@ -85,7 +85,8 @@ static void virtio_set_features(struct virtio_device *vdev, static void virtio_notify(struct virtqueue *vq) { #if defined(CONFIG_SOC_MPS2_AN521) || \ - defined(CONFIG_SOC_V2M_MUSCA_A) + defined(CONFIG_SOC_V2M_MUSCA_A) || \ + defined(CONFIG_SOC_V2M_MUSCA_B1) u32_t current_core = sse_200_platform_get_cpu_id(); ipm_send(ipm_handle, 0, current_core ? 0 : 1, 0, 1); @@ -288,7 +289,8 @@ void main(void) NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); #if defined(CONFIG_SOC_MPS2_AN521) || \ - defined(CONFIG_SOC_V2M_MUSCA_A) + defined(CONFIG_SOC_V2M_MUSCA_A) || \ + defined(CONFIG_SOC_V2M_MUSCA_B1) wakeup_cpu1(); k_sleep(500); #endif /* #if defined(CONFIG_SOC_MPS2_AN521) */ diff --git a/samples/subsys/ipc/openamp/v2m_musca_b1.overlay b/samples/subsys/ipc/openamp/v2m_musca_b1.overlay new file mode 100644 index 000000000000..a2473c4cc09b --- /dev/null +++ b/samples/subsys/ipc/openamp/v2m_musca_b1.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@20060000 { + compatible = "mmio-sram"; + reg = <0x20060000 0x8000>; + }; +};