Test: Add integration of the eRPC system
- PSA Client API IDL file
- Client and server init and API wrappers
- Example client application
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
Signed-off-by: Summer Qin <summer.qin@arm.com>
Change-Id: If6180fd3e596c9daabd31262fb10ae0a1583bc9b
diff --git a/erpc/host_example/CMakeLists.txt b/erpc/host_example/CMakeLists.txt
new file mode 100644
index 0000000..3caf2b2
--- /dev/null
+++ b/erpc/host_example/CMakeLists.txt
@@ -0,0 +1,57 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.15)
+
+project("ERPC Host" LANGUAGES CXX C)
+set(CMAKE_CXX_FLAGS "-m32")
+set(CMAKE_C_FLAGS "-m32")
+
+add_executable(erpc_main)
+
+add_subdirectory(../client client)
+
+if (NOT DEFINED ERPC_TRANSPORT)
+ message(FATAL_ERROR "Please select ERPC_TRANSPORT, currently only UART and TCP are supported!")
+endif()
+
+if (ERPC_TRANSPORT STREQUAL "UART")
+ if (NOT DEFINED PORT_NAME)
+ message(FATAL_ERROR "Please provide PORT_NAME!")
+ endif()
+elseif (ERPC_TRANSPORT STREQUAL "TCP")
+ if((NOT DEFINED ERPC_HOST) OR (NOT DEFINED ERPC_PORT))
+ message(FATAL_ERROR "Please provide ERPC_HOST and ERPC_PORT!")
+ endif()
+else()
+ message(FATAL_ERROR "Please provided supported transportation type (UART and TCP)!")
+endif()
+
+target_sources(erpc_main
+ PRIVATE
+ main.c
+ ${ERPC_REPO_PATH}/erpc_c/port/erpc_threading_pthreads.cpp
+ $<$<STREQUAL:${ERPC_TRANSPORT},UART>:${ERPC_REPO_PATH}/erpc_c/setup/erpc_setup_serial.cpp>
+ $<$<STREQUAL:${ERPC_TRANSPORT},UART>:${ERPC_REPO_PATH}/erpc_c/transports/erpc_serial_transport.cpp>
+ $<$<STREQUAL:${ERPC_TRANSPORT},TCP>:${ERPC_REPO_PATH}/erpc_c/setup/erpc_setup_tcp.cpp>
+ $<$<STREQUAL:${ERPC_TRANSPORT},TCP>:${ERPC_REPO_PATH}/erpc_c/transports/erpc_tcp_transport.cpp>
+)
+
+target_link_libraries(erpc_main
+ PRIVATE
+ erpc_client
+ pthread
+)
+
+target_compile_definitions(erpc_main
+ PRIVATE
+ $<$<STREQUAL:${ERPC_TRANSPORT},UART>:ERPC_TRANSPORT_UART>
+ $<$<STREQUAL:${ERPC_TRANSPORT},TCP>:ERPC_TRANSPORT_TCP>
+ $<$<AND:$<STREQUAL:${ERPC_TRANSPORT},UART>,$<BOOL:${PORT_NAME}>>:PORT_NAME="${PORT_NAME}">
+ $<$<AND:$<STREQUAL:${ERPC_TRANSPORT},TCP>,$<BOOL:${ERPC_HOST}>>:ERPC_HOST="${ERPC_HOST}">
+ $<$<AND:$<STREQUAL:${ERPC_TRANSPORT},TCP>,$<BOOL:${ERPC_PORT}>>:ERPC_PORT=${ERPC_PORT}>
+)
diff --git a/erpc/host_example/README.rst b/erpc/host_example/README.rst
new file mode 100644
index 0000000..a00b024
--- /dev/null
+++ b/erpc/host_example/README.rst
@@ -0,0 +1,92 @@
+*********
+eRPC Host
+*********
+
+This host example is only tested for Linux.
+
+Example: UART Transportation on Musca_S1
+========================================
+
+Build instructions on the target
+--------------------------------
+
+.. code-block:: bash
+
+ cd <TF-M base folder>
+ cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=musca_s1 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DCONFIG_TFM_ERPC_TEST_FRAMEWORK=ON ../
+ cmake --build cmake_build/ -- install -j32
+
+Build instructions on the host
+------------------------------
+
+.. code-block:: bash
+
+ cd <TF-M tests base folder>/erpc/host_example
+ cmake -S . -B build -G "Unix Makefiles" -DTFM_INSTALL_PATH=<TF-M install folder> -DERPC_REPO_PATH=<eRPC base folder> -DERPC_TRANSPORT=UART -DPORT_NAME="/dev/ttyACM0"
+ cmake --build build/
+
+Run instructions on the host
+----------------------------
+
+.. code-block:: bash
+
+ cd <TF-M tests base folder>/erpc/host_example
+ ./build/erpc_main
+
+Example: TCP Transportation on AN521 FVP
+========================================
+
+Build instructions on the target
+--------------------------------
+
+.. code-block:: bash
+
+ cd <TF-M base folder>
+ cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DCONFIG_TFM_ERPC_TEST_FRAMEWORK=ON ../
+ cmake --build cmake_build/ -- install -j32
+
+Build instructions on the host
+------------------------------
+
+.. code-block:: bash
+
+ cd <TF-M tests base folder>/erpc/host_example
+ cmake -S . -B build -G "Unix Makefiles" -DTFM_INSTALL_PATH=<TF-M install folder> -DERPC_REPO_PATH=<eRPC base folder> -DERPC_TRANSPORT=TCP -DERPC_HOST="0.0.0.0" -DERPC_PORT=5001
+ cmake --build build/
+
+Run instructions on the host
+----------------------------
+
+Start the AN521 FVP:
+
+.. code-block:: bash
+
+ <DS_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \
+ --parameter fvp_mps2.platform_type=2 \
+ --parameter cpu0.baseline=0 \
+ --parameter cpu0.INITVTOR_S=0x10000000 \
+ --parameter cpu0.semihosting-enable=0 \
+ --parameter fvp_mps2.DISABLE_GATING=0 \
+ --parameter fvp_mps2.telnetterminal0.start_telnet=1 \
+ --parameter fvp_mps2.telnetterminal1.start_telnet=0 \
+ --parameter fvp_mps2.telnetterminal2.start_telnet=0 \
+ --parameter fvp_mps2.telnetterminal0.quiet=0 \
+ --parameter fvp_mps2.telnetterminal1.quiet=1 \
+ --parameter fvp_mps2.telnetterminal2.quiet=1 \
+ --parameter fvp_mps2.UART0.out_file=/dev/stdout \
+ --parameter fvp_mps2.UART0.unbuffered_output=1 \
+ --parameter fvp_mps2.telnetterminal1.mode=raw \
+ --parameter fvp_mps2.UART1.unbuffered_output=1 \
+ --parameter fvp_mps2.mps2_visualisation.disable-visualisation=1 \
+ --application cpu0=<APPLICATION> \
+ --data cpu0=<DATA>@0x10080000 \
+ -M 1
+
+.. code-block:: bash
+
+ cd <TF-M tests base folder>/erpc/host_example
+ ./build/erpc_main
+
+--------------
+
+*Copyright (c) 2023, Arm Limited. All rights reserved.*
diff --git a/erpc/host_example/main.c b/erpc/host_example/main.c
new file mode 100644
index 0000000..b46ab27
--- /dev/null
+++ b/erpc/host_example/main.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stdio.h>
+#include "erpc_port.h"
+#include "erpc_client_start.h"
+#include "tfm_erpc_psa_client_api.h"
+
+int main(int argc, char *argv[])
+{
+ erpc_transport_t transport;
+
+#ifdef ERPC_TRANSPORT_UART
+ transport = erpc_transport_serial_init(PORT_NAME, 115200);
+#elif defined(ERPC_TRANSPORT_TCP)
+ transport = erpc_transport_tcp_init(ERPC_HOST, ERPC_PORT, false);
+#else
+#error "No valid transportation layer selected."
+#endif
+
+ if (!transport) {
+ printf("eRPC transport init failed!\r\n");
+ return 1;
+ }
+
+ erpc_client_start(transport);
+
+ printf("psa_framework_version: %d\r\n", psa_framework_version());
+
+ return 0;
+}