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 <karl.zhang@linaro.org> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
ccba01f372
commit
742f55a998
8 changed files with 116 additions and 21 deletions
|
@ -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})
|
||||
|
|
30
samples/subsys/ipc/openamp/Kconfig
Normal file
30
samples/subsys/ipc/openamp/Kconfig
Normal file
|
@ -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"
|
|
@ -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
|
||||
|
|
20
samples/subsys/ipc/openamp/lpcxpresso54114_m4.overlay
Normal file
20
samples/subsys/ipc/openamp/lpcxpresso54114_m4.overlay
Normal file
|
@ -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>;
|
||||
};
|
||||
};
|
|
@ -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}/..)
|
||||
|
|
30
samples/subsys/ipc/openamp/remote/Kconfig
Normal file
30
samples/subsys/ipc/openamp/remote/Kconfig
Normal file
|
@ -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"
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue