diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8091dfb3..911ad255 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,37 +7,37 @@ assignees: '' --- -**Describe the bug** +## Describe the bug -**To Reproduce** +## To Reproduce -**Expected behavior** +## Expected behavior -**Screenshots** +## Screenshots -**Desktop (please complete the following information):** +## Desktop (please complete the following information) - OS: - eRPC Version: -**Steps you didn't forgot to do** +## Steps you didn't forgot to do - [ ] I checked if there is no related issue opened/closed. - [ ] I checked that there doesn't exist opened PR which is solving this issue. -**Additional context** +## Additional context diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 430d3d04..b525e537 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -7,27 +7,27 @@ assignees: '' --- -**Is your feature request related to a problem? Please describe.** +## Is your feature request related to a problem? Please describe -**Describe the solution you'd like** +## Describe the solution you'd like -**Describe alternatives you've considered** +## Describe alternatives you've considered -**Steps you didn't forgot to do** +## Steps you didn't forgot to do - [ ] I checked if there is no related issue opened/closed. - [ ] I checked that there doesn't exist opened PR which is solving this issue. -**Additional context** +## Additional context diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 88ba296b..1f85d3b3 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -7,12 +7,12 @@ assignees: '' --- -**If you didn't find answer in existing open/closed issues you may ask here** +## If you didn't find answer in existing open/closed issues you may ask here -**Steps you didn't forgot to do** +## Steps you didn't forgot to do - [ ] I checked if there is no related issue opened/closed. - [ ] I checked that there doesn't exist opened/closed PR which is solving this issue. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 65e6ffe7..6e792f9d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,36 +1,36 @@ # Pull request -**Choose Correct** +## Choose Correct - [ ] bug - [ ] feature -**Describe the pull request** +## Describe the pull request -**To Reproduce** +## To Reproduce -**Expected behavior** +## Expected behavior -**Screenshots** +## Screenshots -**Desktop (please complete the following information):** +## Desktop (please complete the following information): - OS: - eRPC Version: -**Steps you didn't forgot to do** +## Steps you didn't forgot to do - [ ] I checked if other PR isn't solving this issue. - [ ] I read Contribution details and did appropriate actions. @@ -38,7 +38,7 @@ If applicable, add screenshots to help explain your problem. - [ ] PR code is formatted. - [ ] Allow edits from maintainers pull request option is set (recommended). -**Additional context** +## Additional context diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index f5be8afe..95f017fd 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -11,4 +11,5 @@ jobs: - uses: DoozyX/clang-format-lint-action@v0.16.2 with: source: '.' + exclude: './examples/zephyr/matrix_multiply_rpmsglite/remote/src/service ./examples/zephyr/matrix_multiply_rpmsglite/src/service ./examples/zephyr/matrix_multiply_uart/src/service' clangFormatVersion: 16 diff --git a/.gitignore b/.gitignore index 8e4ecc71..09fc8040 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,6 @@ boost*/ mingw.7z mingw64/ vs_BuildTools* + +# Zephyr's repo link +__repo__/ \ No newline at end of file diff --git a/LICENSE b/LICENSE index 062e8f37..76727b55 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,3 @@ -Copyright 2014-2016 Freescale Semiconductor, Inc. -Copyright 2016-2024 NXP -All rights reserved. - The BSD 3 Clause License Redistribution and use in source and binary forms, with or without @@ -28,10 +24,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index eb913c22..ad8aabce 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,57 @@ # eRPC +![GitHub all releases](https://img.shields.io/github/downloads/EmbeddedRPC/erpc/total) +[![GitHub License](https://img.shields.io/github/license/EmbeddedRPC/erpc)](/LICENSE) [![Version](https://img.shields.io/github/v/release/EmbeddedRPC/erpc)](https://github.com/EmbeddedRPC/erpc/releases/latest) +![GitHub language count](https://img.shields.io/github/languages/count/EmbeddedRPC/erpc) +![GitHub top language](https://img.shields.io/github/languages/top/EmbeddedRPC/erpc) +![GitHub repo size](https://img.shields.io/github/repo-size/EmbeddedRPC/erpc) +![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/EmbeddedRPC/erpc) +[![GitHub forks](https://img.shields.io/github/forks/EmbeddedRPC/erpc)](https://github.com/EmbeddedRPC/erpc/forks) +![GitHub Repo stars](https://img.shields.io/github/stars/EmbeddedRPC/erpc) +![GitHub watchers](https://img.shields.io/github/watchers/EmbeddedRPC/erpc) +![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/t/EmbeddedRPC/erpc) +![GitHub commits difference between two branches/tags/commits](https://img.shields.io/github/commits-difference/EmbeddedRPC/erpc?base=main&head=develop&label=master%20behind%20develop%20commits) [![Contributors](https://img.shields.io/github/contributors/EmbeddedRPC/erpc)](https://github.com/EmbeddedRPC/erpc/graphs/contributors) [![Issues](https://img.shields.io/github/issues/EmbeddedRPC/erpc)](https://github.com/EmbeddedRPC/erpc/issues) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/EmbeddedRPC/erpc/pulls) -[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/EmbeddedRPC/erpc) - -- [eRPC](#erpc) - - [About](#about) - - [Releases](#releases) - - [Edge releases](#edge-releases) - - [Documentation](#documentation) - - [Examples](#examples) - - [References](#references) - - [Directories](#directories) - - [Building and installing](#building-and-installing) - - [Requirements](#requirements) - - [Windows](#windows) - - [Linux and Cygwin](#linux-and-cygwin) - - [Mac OS X](#mac-os-x) - - [Building](#building) - - [Installing for Python](#installing-for-python) - - [Known issues and limitations](#known-issues-and-limitations) - - [Code providing](#code-providing) +[![PRs Welcome](https://img.shields.io/github/issues-pr/EmbeddedRPC/erpc)](https://github.com/EmbeddedRPC/erpc/pulls) + +* [eRPC](#erpc) + * [About](#about) + * [Releases](#releases) + * [Edge releases](#edge-releases) + * [Documentation](#documentation) + * [Examples](#examples) + * [References](#references) + * [Directories](#directories) + * [Building and installing](#building-and-installing) + * [Requirements](#requirements) + * [Windows](#windows) + * [Linux](#linux) + * [Mac OS X](#mac-os-x) + * [Building](#building) + * [Installing for Python](#installing-for-python) + * [Known issues and limitations](#known-issues-and-limitations) + * [Code providing](#code-providing) ## About +[![Open enhancement issues](https://img.shields.io/github/issues/EmbeddedRPC/erpc/enhancement?labelColor=blue&color=black)](https://github.com/EmbeddedRPC/erpc/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) +[![Closed enhancement issues](https://img.shields.io/github/issues-closed/EmbeddedRPC/erpc/enhancement?labelColor=blue&color=black)](https://github.com/EmbeddedRPC/erpc/issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement) +[![Open enhancement PRs](https://img.shields.io/github/issues-pr/EmbeddedRPC/erpc/enhancement?labelColor=blue&color=black)](https://github.com/EmbeddedRPC/erpc/pulls?q=is%3Apr+is%3Aopen+label%3Aenhancement) +[![Closed enhancement PRs](https://img.shields.io/github/issues-pr-closed/EmbeddedRPC/erpc/enhancement?labelColor=blue&color=black)](https://github.com/EmbeddedRPC/erpc/pulls?q=is%3Apr+is%3Aclosed+label%3Aenhancement) + +[![Open bug issues](https://img.shields.io/github/issues/EmbeddedRPC/erpc/bug?labelColor=darkred&color=black)](https://github.com/EmbeddedRPC/erpc/issues?q=is%3Aissue+is%3Aopen+label%3Abug) +[![Closed bug issues](https://img.shields.io/github/issues-closed/EmbeddedRPC/erpc/bug?labelColor=darkred&color=black)](https://github.com/EmbeddedRPC/erpc/issues?q=is%3Aissue+is%3Aclosed+label%3Abug) +[![Open bug PRs](https://img.shields.io/github/issues-pr/EmbeddedRPC/erpc/bug?labelColor=darkred&color=black)](https://github.com/EmbeddedRPC/erpc/pulls?q=is%3Apr+is%3Aopen+label%3Abug) +[![Closed bug PRs](https://img.shields.io/github/issues-pr-closed/EmbeddedRPC/erpc/bug?labelColor=darkred&color=black)](https://github.com/EmbeddedRPC/erpc/pulls?q=is%3Apr+is%3Aclosed+label%3Abug) + +[![Open question issues](https://img.shields.io/github/issues/EmbeddedRPC/erpc/question?labelColor=darkviolet&color=black)](https://github.com/EmbeddedRPC/erpc/issues?q=is%3Aissue+is%3Aopen+label%3Aquestion) +[![Closed question issues](https://img.shields.io/github/issues-closed/EmbeddedRPC/erpc/question?labelColor=darkviolet&color=black)](https://github.com/EmbeddedRPC/erpc/issues?q=is%3Aissue+is%3Aclosed+label%3Aquestion) + +[![Open help-wanted issues](https://img.shields.io/github/issues/EmbeddedRPC/erpc/help%20wanted?labelColor=darkgreen&color=black)](https://github.com/EmbeddedRPC/erpc/issues?q=is%3Aissue+is%3Aopen+label%3A%22help%20wanted%22) +[![Closed help-wanted issues](https://img.shields.io/github/issues-closed/EmbeddedRPC/erpc/help%20wanted?labelColor=darkgreen&color=black)](https://github.com/EmbeddedRPC/erpc/issues?q=is%3Aissue+is%3Aclosed+label%3A%22help%20wanted%22) + eRPC (Embedded RPC) is an open source Remote Procedure Call (RPC) system for multichip embedded systems and heterogeneous multicore SoCs. Unlike other modern RPC systems, such as the excellent [Apache Thrift](http://thrift.apache.org), eRPC distinguishes itself by being designed for tightly coupled systems, using plain C for remote functions, and having a small code size (<5kB). It is not intended for high performance distributed systems over a network. @@ -36,7 +62,7 @@ A code generator tool called `erpcgen` is included. It accepts input IDL files, Example `.erpc` file: -```java +```C++ // Define a data type. enum LEDName { kRed, kGreen, kBlue } @@ -51,13 +77,53 @@ Client side usage: ```C void example_client(void) { - // Initialize client running over UART. - erpc_client_init( - erpc_transport_cmsis_uart_init(Driver_USART0), - erpc_mbf_dynamic_init()); + erpc_transport_t transport; + erpc_mbf_t message_buffer_factory; + erpc_client_t client_manager; + + /* Init eRPC client infrastructure */ + transport = erpc_transport_cmsis_uart_init(Driver_USART0); + message_buffer_factory = erpc_mbf_dynamic_init(); + client_manager = erpc_client_init(transport, message_buffer_factory); + + /* init eRPC client IO service */ + initIO_client(client_manager); // Now we can call the remote function to turn on the green LED. set_led(kGreen, true); + + /* deinit objects */ + deinitIO_client(); + erpc_client_deinit(client_manager); + erpc_mbf_dynamic_deinit(message_buffer_factory); + erpc_transport_tcp_deinit(transport); +} +``` + +```C++ +void example_client(void) { + erpc_transport_t transport; + erpc_mbf_t message_buffer_factory; + erpc_client_t client_manager; + + /* Init eRPC client infrastructure */ + transport = erpc_transport_cmsis_uart_init(Driver_USART0); + message_buffer_factory = erpc_mbf_dynamic_init(); + client_manager = erpc_client_init(transport, message_buffer_factory); + + /* scope for client service */ + { + /* init eRPC client IO service */ + IO_client client(client_manager); + + // Now we can call the remote function to turn on the green LED. + client.set_led(kGreen, true); + } + + /* deinit objects */ + erpc_client_deinit(client_manager); + erpc_mbf_dynamic_deinit(message_buffer_factory); + erpc_transport_tcp_deinit(transport); } ``` @@ -70,22 +136,68 @@ void set_led(LEDName whichLed, bool onOrOff) { } void example_server(void) { - // Initialize server running over UART. - erpc_server_init( - erpc_transport_cmsis_uart_init(Driver_USART0), - erpc_mbf_dynamic_init()); + erpc_transport_t transport; + erpc_mbf_t message_buffer_factory; + erpc_server_t server; + erpc_service_t service = create_IO_service(); + + /* Init eRPC server infrastructure */ + transport = erpc_transport_cmsis_uart_init(Driver_USART0); + message_buffer_factory = erpc_mbf_dynamic_init(); + server = erpc_server_init(transport, message_buffer_factory); - // Add the IO service. - erpc_add_service_to_server(create_IO_service()); + /* add custom service implementation to the server */ + erpc_add_service_to_server(server, service); // Run the server. erpc_server_run(); + + /* deinit objects */ + destroy_IO_service(service); + erpc_server_deinit(server); + erpc_mbf_dynamic_deinit(message_buffer_factory); + erpc_transport_tcp_deinit(transport); +} +``` + +```C++ +// Implement the remote function. +class IO : public IO_interface +{ + /* eRPC call definition */ + void set_led(LEDName whichLed, bool onOrOff) override { + // implementation goes here + } +} + +void example_server(void) { + erpc_transport_t transport; + erpc_mbf_t message_buffer_factory; + erpc_server_t server; + IO IOImpl; + IO_service io(&IOImpl); + + /* Init eRPC server infrastructure */ + transport = erpc_transport_cmsis_uart_init(Driver_USART0); + message_buffer_factory = erpc_mbf_dynamic_init(); + server = erpc_server_init(transport, message_buffer_factory); + + /* add custom service implementation to the server */ + erpc_add_service_to_server(server, &io); + + /* poll for requests */ + erpc_status_t err = server.run(); + + /* deinit objects */ + erpc_server_deinit(server); + erpc_mbf_dynamic_deinit(message_buffer_factory); + erpc_transport_tcp_deinit(transport); } ``` A number of transports are supported, and new transport classes are easy to write. -Supported transports: +Supported transports can be found in [erpc/erpc_c/transport](/erpc_c/transports) folder. E.g: * CMSIS UART * NXP Kinetis SPI and DSPI @@ -114,7 +226,7 @@ Edge releases can by found on [eRPC CircleCI](https://app.circleci.com/pipelines ## Examples -[Example IDL](examples/README.md) is available in the `examples/` folder. +[Example IDL](examples/README.md) is available in the [examples/](/examples/) folder. Plenty of eRPC multicore and multiprocessor examples can be also found in NXP MCUXpressoSDK packages. Visit [https://mcuxpresso.nxp.com](https://mcuxpresso.nxp.com) to configure, build and download these packages. @@ -145,53 +257,48 @@ This section provides links to interesting erpc-based projects, articles, blogs ## Directories -`doc` - Documentation. +[doc](/doc) - Documentation. -`doxygen` - Configuration and support files for running Doxygen over the eRPC C++ infrastructure and erpcgen code. +[doxygen](/doxygen) - Configuration and support files for running Doxygen over the eRPC C++ infrastructure and erpcgen code. -`erpc_c` - Holds C/C++ infrastructure for eRPC. This is the code you will include in your application. +[erpc_c](/erpc_c) - Holds C/C++ infrastructure for eRPC. This is the code you will include in your application. -`erpc_python` - Holds Python version of the eRPC infrastructure. +[erpc_python](/erpc_python) - Holds Python version of the eRPC infrastructure. -`erpcgen` - Holds source code for erpcgen and makefiles or project files to build erpcgen on Windows, Linux, and OS X. +[erpcgen](/erpcgen) - Holds source code for erpcgen and makefiles or project files to build erpcgen on Windows, Linux, and OS X. -`erpcsniffer` - Holds source code for erpcsniffer application. +[erpcsniffer](/erpcsniffer) - Holds source code for erpcsniffer application. -`examples` - Several example IDL files. +[examples](/examples) - Several example IDL files. -`mk` - Contains common makefiles for building eRPC components. +[mk](/mk) - Contains common makefiles for building eRPC components. -`test` - Client/server tests. These tests verify the entire communications path from client to server and back. +[test](/test) - Client/server tests. These tests verify the entire communications path from client to server and back. -`utilities` - Holds utilities which bring additional benefit to eRPC apps developers. +[utilities](/utilities) - Holds utilities which bring additional benefit to eRPC apps developers. ## Building and installing -These build instructions apply to host PCs and embedded Linux. For bare metal or RTOS embedded environments, you should copy the `erpc_c` directory into your application sources. +These build instructions apply to host PCs and embedded Linux. For bare metal or RTOS embedded environments, you should copy the [erpc_c](/erpc_c) directory into your application sources. The primary build system is makefile based. It builds a static library of the eRPC C/C++ infrastructure, the `erpcgen` executable, and optionally the unit tests. The makefiles are compatible with gcc or clang on Linux, OS X, and Cygwin. A Windows build -of erpcgen using Visual Studio is also available in the `erpcgen/VisualStudio_v14/` directory. -There is also an Xcode project file in the `erpcgen/` directory which can be used to build erpcgen -for OS X. +of erpcgen using Visual Studio is also available in the [erpcgen/VisualStudio_v14](erpcgen/VisualStudio_v14) directory. +There is also an Xcode project file in the [erpcgen](/erpcgen) directory, which can be used to build erpcgen for OS X. ### Requirements #### Windows -Steps are described in [`erpcgen/VisualStudio_v14/readme_erpcgen.txt`](erpcgen/VisualStudio_v14/readme_erpcgen.txt). - -#### Linux and Cygwin +* Related to Visual Studio: steps are described in [`erpcgen/VisualStudio_v14/readme_erpcgen.txt`](erpcgen/VisualStudio_v14/readme_erpcgen.txt). +* mingw compilation can be used too -Install these packages: +#### Linux -* bison: GNU yacc-compatible parser generator -* flex: A fast lexical analyzer generator -* make: the GNU version of the 'make' utility -* python: Python language interpreter 3.6+ work -* gcc-7: GNU C compiler (recommended version) -* g++-7: GNU C++ compiler (recommended version) +```bash +./install_dependencies.sh +``` Mandatory for case, when build for different architecture is needed @@ -199,10 +306,9 @@ Mandatory for case, when build for different architecture is needed #### Mac OS X -Install these packages with [homebrew](http://brew.sh/): - -* bison: GNU yacc-compatible parser generator (version 3.7.3 is recommended) -* flex: A fast lexical analyzer generator (version 2.6.4 is recommended) +```bash +./install_dependencies.sh +``` ### Building @@ -230,7 +336,8 @@ List of top level Makefile targets: * `erpc`: build the liberpc.a static library * `erpcgen`: build the erpcgen tool -* `test`: build the unit tests under the `test/` directory +* `erpcsniffer`: build the sniffer tool +* `test`: build the unit tests under the [test](/test) directory * `all`: build all of the above * `install`: install liberpc.a, erpcgen, and include files @@ -238,7 +345,7 @@ eRPC code is validated with respect to the C++ 11 standard. ### Installing for Python -To install the Python infrastructure for eRPC see instructions in the [erpc_python folder readme](erpc_python/readme.md). +To install the Python infrastructure for eRPC see instructions in the [erpc python readme](/erpc_python/readme.md). ## Known issues and limitations diff --git a/SW-Content-Register.txt b/SW-Content-Register.txt new file mode 100644 index 00000000..aafc9df8 --- /dev/null +++ b/SW-Content-Register.txt @@ -0,0 +1,37 @@ +Release Name: eRPC +Release Version: 1.12.0 +Package License: BSD-3-Clause + +the_bus_pirate Name: The Bus Pirate + Version: NA + Outgoing License: Open Source - CC0 (Public Domain + Dedication License) + License File: http://code.google.com/p/the-bus-pirate/ + Format: source code + Description: OS independent serial interface + Location: + erpc_c/port/erpc_serial.h, + erpc_c/port/erpc_serial.cpp + Origin: Community + Url: http://code.google.com/p/the-bus-pirate/ + +cpp_template Name: CPP Template + Version: NA + Outgoing License: Open Source - MIT + License File: + erpcgen/src/cpptemplate/LICENSE.txt + Format: source code + Description: CPP Template + Location: erpcgen/src/cpptemplate + Origin: Ryan Ginstrom & Martinho Fernandes + +cpp_option_parser Name: C++ option-parser + Version: NA + Outgoing License: Brad Appleton's license + License File: http://www.bradapp.com/ftp/src/libs/C++/Options.tar.gz + , see README file + Format: Plain Text + Description: C++ option-parser + Location: erpcgen/src/options.cpp + Origin: Brad Appleton bradapp@enteract.com + Url: http://www.bradapp.com/ftp/src/libs/C++/Options.html \ No newline at end of file diff --git a/doxygen/Doxyfile.erpc b/doxygen/Doxyfile.erpc index f56fb310..06af371e 100644 --- a/doxygen/Doxyfile.erpc +++ b/doxygen/Doxyfile.erpc @@ -38,7 +38,7 @@ PROJECT_NAME = "eRPC API Reference" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "Rev. 1.12.0" +PROJECT_NUMBER = "Rev. 1.13.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doxygen/Doxyfile.erpcgen b/doxygen/Doxyfile.erpcgen index 77190978..14b11de3 100644 --- a/doxygen/Doxyfile.erpcgen +++ b/doxygen/Doxyfile.erpcgen @@ -38,7 +38,7 @@ PROJECT_NAME = "eRPC Generator (erpcgen)" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "Rev. 1.12.0" +PROJECT_NUMBER = "Rev. 1.13.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doxygen/mainpage_erpc.md b/doxygen/mainpage_erpc.md index a3179645..468cafa5 100644 --- a/doxygen/mainpage_erpc.md +++ b/doxygen/mainpage_erpc.md @@ -9,7 +9,7 @@ When a remote function is called by the client, the function's parameters and an Here is a block diagram of an RPC system: -![](./rpc_block_diagram.png) +![rpc block diagram](./rpc_block_diagram.png) This diagram only shows one direction of communication. It leaves out the reply from the server to send the invoked function's return value. This reply uses basically the same sequence of events, but flows back from the server to the client. diff --git a/erpc_c/infra/erpc_version.h b/erpc_c/infra/erpc_version.h index 1f5188f8..2a1270c6 100644 --- a/erpc_c/infra/erpc_version.h +++ b/erpc_c/infra/erpc_version.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, Freescale Semiconductor, Inc. - * Copyright 2016-2023 NXP + * Copyright 2016-2024 NXP * All rights reserved. * * @@ -20,9 +20,9 @@ //////////////////////////////////////////////////////////////////////////////// //! @brief String version of eRPC. -#define ERPC_VERSION "1.12.0" +#define ERPC_VERSION "1.13.0" //! @brief Integer version of eRPC. -#define ERPC_VERSION_NUMBER 11200 +#define ERPC_VERSION_NUMBER 11300 /*! @} */ diff --git a/erpc_c/port/erpc_serial.cpp b/erpc_c/port/erpc_serial.cpp index 2423ca8e..3b3fdc8d 100644 --- a/erpc_c/port/erpc_serial.cpp +++ b/erpc_c/port/erpc_serial.cpp @@ -220,7 +220,7 @@ int serial_read(int fd, char *buf, int size) ClearCommError(hCom, &errors, NULL); - if (!ReadFile(hCom, temp, RX_BUF_BYTES - bytesToRead, &bytesRead, &s_readOverlap)) + if (!ReadFile(hCom, temp, size - bytesToRead, &bytesRead, &s_readOverlap)) { if (GetLastError() == ERROR_IO_PENDING) { diff --git a/erpc_c/port/erpc_threading.h b/erpc_c/port/erpc_threading.h index b8b662ea..5a194674 100644 --- a/erpc_c/port/erpc_threading.h +++ b/erpc_c/port/erpc_threading.h @@ -128,7 +128,8 @@ class Thread * @param[in] stackSize Stack size. * @param[in] stackPtr Mandatory task stack pointer for static api usage. */ - void init(thread_entry_t entry, uint32_t priority = 0, uint32_t stackSize = 0, thread_stack_pointer stackPtr = NULL); + void init(thread_entry_t entry, uint32_t priority = 0, uint32_t stackSize = 0, + thread_stack_pointer stackPtr = NULL); /*! * @brief This function starts thread execution. diff --git a/erpc_c/setup/erpc_setup_mbox_zephyr.cpp b/erpc_c/setup/erpc_setup_mbox_zephyr.cpp new file mode 100644 index 00000000..75543c5e --- /dev/null +++ b/erpc_c/setup/erpc_setup_mbox_zephyr.cpp @@ -0,0 +1,74 @@ +/* + * Copyright 2023 NXP + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "erpc_manually_constructed.hpp" +#include "erpc_transport_setup.h" +#include "erpc_mbox_zephyr_transport.hpp" + +using namespace erpc; + +//////////////////////////////////////////////////////////////////////////////// +// Variables +//////////////////////////////////////////////////////////////////////////////// + +ERPC_MANUALLY_CONSTRUCTED_STATIC(MBOXTransport, s_transport); + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +erpc_transport_t erpc_transport_zephyr_mbox_init(void *dev, void *tx_channel, void *rx_channel) +{ + erpc_transport_t transport; + MBOXTransport *mboxTransport; + +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC + if (s_transport.isUsed()) + { + mboxTransport = NULL; + } + else + { + s_transport.construct((struct device *)dev, (struct mbox_channel *)tx_channel, + (struct mbox_channel *)rx_channel); + mboxTransport = s_transport.get(); + } + +#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + mboxTransport = + new MBOXTransport((struct device *)dev, (struct mbox_channel *)tx_channel, (struct mbox_channel *)rx_channel); +#else +#error "Unknown eRPC allocation policy!" +#endif + + transport = reinterpret_cast(mboxTransport); + + if (mboxTransport != NULL) + { + if (mboxTransport->init() != kErpcStatus_Success) + { + erpc_transport_zephyr_mbox_deinit(transport); + transport = NULL; + } + } + + return transport; +} + +void erpc_transport_zephyr_mbox_deinit(erpc_transport_t transport) +{ +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC + (void)transport; + s_transport.destroy(); +#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + erpc_assert(transport != NULL); + + MBOXTransport *mboxTransport = reinterpret_cast(transport); + + delete mboxTransport; +#endif +} diff --git a/erpc_c/setup/erpc_setup_uart_zephyr.cpp b/erpc_c/setup/erpc_setup_uart_zephyr.cpp index 42c7242f..b13abe16 100644 --- a/erpc_c/setup/erpc_setup_uart_zephyr.cpp +++ b/erpc_c/setup/erpc_setup_uart_zephyr.cpp @@ -15,7 +15,7 @@ using namespace erpc; // Variables //////////////////////////////////////////////////////////////////////////////// -ERPC_MANUALLY_CONSTRUCTED(UartTransport, s_transport); +ERPC_MANUALLY_CONSTRUCTED_STATIC(UartTransport, s_transport); //////////////////////////////////////////////////////////////////////////////// // Code @@ -24,16 +24,48 @@ ERPC_MANUALLY_CONSTRUCTED(UartTransport, s_transport); erpc_transport_t erpc_transport_zephyr_uart_init(void *dev) { erpc_transport_t transport; + UartTransport *uartTransport; - s_transport.construct((struct device *)dev); - if (s_transport->init() == kErpcStatus_Success) +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC + if (s_transport.isUsed()) { - transport = reinterpret_cast(s_transport.get()); + uartTransport = NULL; } else { - transport = NULL; + s_transport.construct(reinterpret_cast(dev)); + uartTransport = s_transport.get(); + } +#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + uartTransport = new UartTransport(reinterpret_cast(dev)); +#else +#error "Unknown eRPC allocation policy!" +#endif + + transport = reinterpret_cast(uartTransport); + + if (uartTransport != NULL) + { + if (uartTransport->init() != kErpcStatus_Success) + { + erpc_transport_zephyr_uart_deinit(transport); + transport = NULL; + } } return transport; } + +void erpc_transport_zephyr_uart_deinit(erpc_transport_t transport) +{ +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC + (void)transport; + s_transport.destroy(); +#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + erpc_assert(transport != NULL); + + UartTransport *uartTransport = reinterpret_cast(transport); + + delete uartTransport; +#endif +} \ No newline at end of file diff --git a/erpc_c/setup/erpc_transport_setup.h b/erpc_c/setup/erpc_transport_setup.h index fa90a6af..65c3d4be 100644 --- a/erpc_c/setup/erpc_transport_setup.h +++ b/erpc_c/setup/erpc_transport_setup.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. - * Copyright 2016-2022 NXP + * Copyright 2016-2024 NXP * Copyright 2019 ACRIOS Systems s.r.o. * All rights reserved. * @@ -508,6 +508,11 @@ erpc_transport_t erpc_transport_cmsis_uart_init(void *uartDrv); */ void erpc_transport_cmsis_uart_deinit(erpc_transport_t transport); +//@} + +//! @name Zephyr transports setup +//@{ + /*! * @brief Create a Zephyr UART transport. * @@ -520,6 +525,34 @@ void erpc_transport_cmsis_uart_deinit(erpc_transport_t transport); */ erpc_transport_t erpc_transport_zephyr_uart_init(void *dev); +/*! + * @brief Deinitialize Zephyr UART transport. + * + * @param[in] transport Transport which was initialized with init function. + */ +void erpc_transport_zephyr_uart_deinit(erpc_transport_t transport); + +/*! + * @brief Create a Zephyr MBOX transport. + * + * Create a Zephyr MBOX transport instance, to be used on both the server + * and the client side. + * + * @param[in] dev Zephyr MBOX device address. + * @param[in] tx_channel Zephyr MBOX transmit channel. + * @param[in] rx_channel Zephyr MBOX receive channel. + * + * @return Return NULL or erpc_transport_t instance pointer. + */ +erpc_transport_t erpc_transport_zephyr_mbox_init(void *dev, void *tx_channel, void *rx_channel); + +/*! + * @brief Deinitialize Zephyr MBOX transport. + * + * @param[in] transport Transport which was initialized with init function. + */ +void erpc_transport_zephyr_mbox_deinit(erpc_transport_t transport); + //@} //! @name USB CDC transport setup diff --git a/erpc_c/transports/erpc_i2c_slave_transport.cpp b/erpc_c/transports/erpc_i2c_slave_transport.cpp index b96224f8..d90cb287 100644 --- a/erpc_c/transports/erpc_i2c_slave_transport.cpp +++ b/erpc_c/transports/erpc_i2c_slave_transport.cpp @@ -108,39 +108,49 @@ static void I2C_SlaveUserCallback(I2C_Type *base, volatile i2c_slave_transfer_t { /* Address match event */ case kI2C_SlaveAddressMatchEvent: + { transfer->rxData = NULL; transfer->rxSize = 0; break; + } /* Transmit request */ case kI2C_SlaveTransmitEvent: + { /* Update information for transmit process */ transfer->txData = ((I2C_CLB_USER_DATA *)userData)->tx_buffer; transfer->txSize = ((I2C_CLB_USER_DATA *)userData)->tx_size; transfer->rxData = NULL; transfer->rxSize = 0; break; + } /* Setup the slave receive buffer */ case kI2C_SlaveReceiveEvent: + { /* Update information for received process */ transfer->rxData = ((I2C_CLB_USER_DATA *)userData)->rx_buffer; transfer->rxSize = ((I2C_CLB_USER_DATA *)userData)->rx_size; transfer->txData = NULL; transfer->txSize = 0; break; + } /* The master has sent a stop transition on the bus */ case kI2C_SlaveCompletionEvent: + { transport->transfer_cb(); transfer->rxData = NULL; transfer->rxSize = 0; transfer->txData = NULL; transfer->txSize = 0; break; + } default: + { s_isTransferCompleted = false; break; + } } } diff --git a/erpc_c/transports/erpc_lpi2c_slave_transport.cpp b/erpc_c/transports/erpc_lpi2c_slave_transport.cpp index 6a2a6769..5b618dd2 100644 --- a/erpc_c/transports/erpc_lpi2c_slave_transport.cpp +++ b/erpc_c/transports/erpc_lpi2c_slave_transport.cpp @@ -108,20 +108,25 @@ static void LPI2C_SlaveUserCallback(LPI2C_Type *base, lpi2c_slave_transfer_t *tr { /* Transmit request */ case kLPI2C_SlaveTransmitEvent: + { /* Update information for transmit process */ transfer->data = ((LPI2C_CLB_USER_DATA *)userData)->tx_buffer; transfer->dataSize = ((LPI2C_CLB_USER_DATA *)userData)->tx_size; break; + } /* Setup the slave receive buffer */ case kLPI2C_SlaveReceiveEvent: + { /* Update information for received process */ transfer->data = ((LPI2C_CLB_USER_DATA *)userData)->rx_buffer; transfer->dataSize = ((LPI2C_CLB_USER_DATA *)userData)->rx_size; break; + } /* The master has sent a stop transition on the bus */ case kLPI2C_SlaveCompletionEvent: + { /* Filter out dummy transaction completions (additional dummy recv./transmit) */ if (!(transfer->transferredCount == 0 && transfer->dataSize == 0) && transfer->data != NULL) { @@ -130,10 +135,13 @@ static void LPI2C_SlaveUserCallback(LPI2C_Type *base, lpi2c_slave_transfer_t *tr transfer->dataSize = 0; } break; + } default: + { s_isTransferCompleted = false; break; + } } } diff --git a/erpc_c/transports/erpc_mbox_zephyr_transport.cpp b/erpc_c/transports/erpc_mbox_zephyr_transport.cpp new file mode 100644 index 00000000..cf29bd6c --- /dev/null +++ b/erpc_c/transports/erpc_mbox_zephyr_transport.cpp @@ -0,0 +1,192 @@ +/* + * Copyright 2023 NXP + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "erpc_mbox_zephyr_transport.hpp" +#include "erpc_port.h" +#include +#include + +using namespace erpc; + +//////////////////////////////////////////////////////////////////////////////// +// Variables +//////////////////////////////////////////////////////////////////////////////// +static MBOXTransport *s_mbox_instance = NULL; + +RING_BUF_DECLARE(s_rxRingBuffer, MBOX_BUFFER_SIZE); + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +MBOXTransport::MBOXTransport(struct device *dev, struct mbox_channel *tx_channel, struct mbox_channel *rx_channel) : +m_dev(dev), m_tx_channel(tx_channel), m_rx_channel(rx_channel) +#if !ERPC_THREADS_IS(NONE) +, +m_rxSemaphore(), m_txSemaphore() +#endif +{ + s_mbox_instance = this; +} + +MBOXTransport::~MBOXTransport(void) {} + +void MBOXTransport::rx_cb(struct mbox_msg *data) +{ + // Read data to ring buffer + ring_buf_put(&s_rxRingBuffer, static_cast(data->data), data->size); + + // message is complete, unblock caller of the receive function + if (ring_buf_size_get(&s_rxRingBuffer) >= m_transferReceiveRequireBytes) + { + m_isTransferReceiveCompleted = true; +#if !ERPC_THREADS_IS(NONE) + // disable MU rx full interrupt in rtos-based blocking implementation + m_rxSemaphore.put(); +#endif + m_transferReceiveRequireBytes = MBOX_BUFFER_SIZE; + } +} + +/* Transfer callback */ +static void mbox_callback(const struct device *dev, uint32_t channel, void *user_data, struct mbox_msg *data) +{ + s_mbox_instance->rx_cb(data); +} + +erpc_status_t MBOXTransport::init(void) +{ + if (mbox_register_callback(m_rx_channel, mbox_callback, NULL)) + { + printk("mbox_register_callback() error\n"); + return kErpcStatus_InitFailed; + } + + if (mbox_set_enabled(m_rx_channel, 1)) + { + printk("mbox_set_enable() error\n"); + return kErpcStatus_InitFailed; + } + + return kErpcStatus_Success; +} + +erpc_status_t MBOXTransport::receive(MessageBuffer *message) +{ + erpc_status_t status = kErpcStatus_Success; + uint8_t tmp[4]; + uint32_t rxMsgSize = 0; + + if (message == NULL) + { + status = kErpcStatus_ReceiveFailed; + } + else + { +#if !ERPC_THREADS_IS(NONE) + Mutex::Guard lock(m_receiveLock); +#endif + + // Wait for size of the message + waitForBytes(sizeof(uint32_t)); + ring_buf_get(&s_rxRingBuffer, (uint8_t *)&rxMsgSize, sizeof(uint32_t)); + + // Wait for message to be transmitted + waitForBytes(rxMsgSize); + message->setUsed((uint16_t)rxMsgSize); + + if (ring_buf_get(&s_rxRingBuffer, reinterpret_cast(message->get()), rxMsgSize) != rxMsgSize) + { + status = kErpcStatus_ReceiveFailed; + }; + + // Read remaining bytes from ring buffer + ring_buf_get(&s_rxRingBuffer, tmp, 4 - (rxMsgSize % 4)); + + rxMsgSize = 0; + } + + return status; +} + +void MBOXTransport::waitForBytes(uint32_t numOfBytes) +{ + if (ring_buf_size_get(&s_rxRingBuffer) < numOfBytes) + { + m_transferReceiveRequireBytes = numOfBytes; + +/* wait until the receiving is finished */ +#if !ERPC_THREADS_IS(NONE) + (void)m_rxSemaphore.get(); +#else + m_isTransferReceiveCompleted = false; + while (!m_isTransferReceiveCompleted) + { + } +#endif + } +} + +erpc_status_t MBOXTransport::send(MessageBuffer *message) +{ + erpc_status_t status = kErpcStatus_Success; + struct mbox_msg txMsg; + uint32_t txMsgSize = 0; + uint32_t txCntBytes = 0; + uint8_t *txBuffer; + + if (message == NULL) + { + status = kErpcStatus_SendFailed; + } + else + { +#if !ERPC_THREADS_IS(NONE) + Mutex::Guard lock(m_sendLock); +#endif + + txMsgSize = message->getUsed(); + txCntBytes = 0; + txBuffer = message->get(); + + txMsg.data = &txMsgSize; + txMsg.size = sizeof(uint32_t); + + mbox_send(m_tx_channel, &txMsg); + + while (txCntBytes < txMsgSize) + { + txMsg.data = &txBuffer[txCntBytes]; + txMsg.size = sizeof(uint32_t); + + int mboxStatus = mbox_send(m_tx_channel, &txMsg); + + if (mboxStatus == -EBUSY) + { + continue; + } + + if (mboxStatus < 0) + { + return kErpcStatus_SendFailed; + } + + txCntBytes += sizeof(uint32_t); + } + + txMsgSize = 0; + txCntBytes = 0; + txBuffer = NULL; + } + + return status; +} + +bool MBOXTransport::hasMessage(void) +{ + return !ring_buf_is_empty(&s_rxRingBuffer); +} diff --git a/erpc_c/transports/erpc_mbox_zephyr_transport.hpp b/erpc_c/transports/erpc_mbox_zephyr_transport.hpp new file mode 100644 index 00000000..fef8289e --- /dev/null +++ b/erpc_c/transports/erpc_mbox_zephyr_transport.hpp @@ -0,0 +1,132 @@ +/* + * Copyright 2023 NXP + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _EMBEDDED_RPC_ZEPHYR_MBOX_TRANSPORT_H_ +#define _EMBEDDED_RPC_ZEPHYR_MBOX_TRANSPORT_H_ + +#include "erpc_config_internal.h" +#if !ERPC_THREADS_IS(NONE) +#include "erpc_threading.h" +#endif +#include "erpc_transport.hpp" + +extern "C" { +#include +#include +#include +} + +#define MBOX_BUFFER_SIZE ERPC_DEFAULT_BUFFER_SIZE + +/*! + * @addtogroup mbox_transport + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// Classes +//////////////////////////////////////////////////////////////////////////////// + +namespace erpc { +/*! + * @brief Transport to send/receive messages via MBOX. + * + * @ingroup mbox_transport + */ +class MBOXTransport : public Transport +{ +public: + /*! + * @brief Constructor. + * + * @param[in] dev Zephyr MBOX device. + * @param[in] tx_channel Zephyr MBOX tx channel. + * @param[in] rx_channel Zephyr MBOX rx channel. + */ + MBOXTransport(struct device *dev, struct mbox_channel *tx_channel, struct mbox_channel *rx_channel); + + /*! + * @brief Destructor. + */ + virtual ~MBOXTransport(void); + + /*! + * @brief Initialize Zephyr MBOX peripheral configuration structure with values specified in MBOXTransport + * constructor. + * + * @retval kErpcStatus_InitFailed When MBOC init function failed. + * @retval kErpcStatus_Success When MBOX init function was executed successfully. + */ + virtual erpc_status_t init(void); + + /*! + * @brief Start receiving data and stores it to passed message buffer + * + * Initialize receiving of message, it is blocking until doesn't receive complete message. + * + * @param[in] message Message buffer, which will be filled by incoming message. + * + * @return kErpcStatus_Success + */ + virtual erpc_status_t receive(MessageBuffer *message) override; + + /*! + * @brief Function to send prepared message. + * + * @param[in] message Pass message buffer to send. + * + * @retval kErpcStatus_SendFailed Failed to send message buffer. + * @retval kErpcStatus_Success Successfully sent all data. + */ + virtual erpc_status_t send(MessageBuffer *message) override; + + /*! + * @brief Function to check if is new message to receive. + * + * This function should be called before blocking function receive() to avoid waiting for new message. + * + * @return True if exist new message, else false. + */ + virtual bool hasMessage(void) override; + + /*! + * @brief Function called from ISR + * + * Unblocks the receive function. + */ + void rx_cb(struct mbox_msg *data); + +protected: + struct device *m_dev; /*!< Access structure of the MBOX device */ + struct mbox_channel *m_tx_channel; + struct mbox_channel *m_rx_channel; + + volatile bool m_isTransferReceiveCompleted = false; + volatile uint32_t m_transferReceiveRequireBytes = 0; + + /*! + * @brief Function waits for given amount of bytes to be in ring buffer. + * + * @param[in] numOfBytes Required number of bytes in ring buffer + */ + void waitForBytes(uint32_t numOfBytes); + +#if !ERPC_THREADS_IS(NONE) + Semaphore m_rxSemaphore; /*!< Semaphore used by RTOS to block task until the receiving is not complete */ + Semaphore m_txSemaphore; /*!< Semaphore used by RTOS to block task until the sending is not complete */ + + Mutex m_sendLock; /*!< Mutex protecting send. */ + Mutex m_receiveLock; /*!< Mutex protecting receive. */ +#endif +}; + +} // namespace erpc + +/*! @} */ + +#endif // _EMBEDDED_RPC_ZEPHYR_MBOX_TRANSPORT_H_ diff --git a/erpc_c/transports/erpc_spi_master_transport.hpp b/erpc_c/transports/erpc_spi_master_transport.hpp index e2de9bae..1c81ba63 100644 --- a/erpc_c/transports/erpc_spi_master_transport.hpp +++ b/erpc_c/transports/erpc_spi_master_transport.hpp @@ -12,7 +12,6 @@ #include "erpc_framed_transport.hpp" -#include #include extern "C" { diff --git a/erpc_c/transports/erpc_tcp_transport.cpp b/erpc_c/transports/erpc_tcp_transport.cpp index 9712ce6c..c910ec49 100644 --- a/erpc_c/transports/erpc_tcp_transport.cpp +++ b/erpc_c/transports/erpc_tcp_transport.cpp @@ -268,7 +268,7 @@ erpc_status_t TCPTransport::connectClient(void) { #else // globally disable the SIGPIPE signal -#if !defined(__MINGW32__) +#if !defined(__MINGW32__) && !defined(__ZEPHYR__) signal(SIGPIPE, SIG_IGN); #endif #endif // defined(SO_NOSIGPIPE) diff --git a/erpc_c/transports/erpc_uart_zephyr_transport.cpp b/erpc_c/transports/erpc_uart_zephyr_transport.cpp index fe08982a..ee1f3b40 100644 --- a/erpc_c/transports/erpc_uart_zephyr_transport.cpp +++ b/erpc_c/transports/erpc_uart_zephyr_transport.cpp @@ -1,208 +1,206 @@ -/* - * Copyright 2023 NXP - * - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "erpc_uart_zephyr_transport.hpp" -#include -#include -#include - -using namespace erpc; - -//////////////////////////////////////////////////////////////////////////////// -// Variables -//////////////////////////////////////////////////////////////////////////////// - -static volatile bool s_isTransferReceiveCompleted = false; -static volatile bool s_isTransferSendCompleted = false; -static volatile uint32_t s_transferReceiveRequireBytes = 0; -static UartTransport *s_uart_instance = NULL; - -#define UART_BUFFER_SIZE ERPC_DEFAULT_BUFFER_SIZE - -RING_BUF_DECLARE(uart_receive_buf, UART_BUFFER_SIZE); -RING_BUF_DECLARE(uart_send_buf, UART_BUFFER_SIZE); - -//////////////////////////////////////////////////////////////////////////////// -// Code -//////////////////////////////////////////////////////////////////////////////// - -UartTransport::UartTransport(struct device *dev) : -m_dev(dev) -#if !ERPC_THREADS_IS(NONE) -, -m_rxSemaphore(), m_txSemaphore() -#endif -{ - s_uart_instance = this; -} - -UartTransport::~UartTransport(void) {} - -void UartTransport::tx_cb(void) -{ -#if !ERPC_THREADS_IS(NONE) - m_txSemaphore.put(); -#else - s_isTransferSendCompleted = true; -#endif -} - -void UartTransport::rx_cb(void) -{ -#if !ERPC_THREADS_IS(NONE) - m_rxSemaphore.put(); -#else - s_isTransferReceiveCompleted = true; -#endif - s_transferReceiveRequireBytes = UART_BUFFER_SIZE; -} - -/* Transfer callback */ -static void TransferCallback(const struct device *dev, void *user_data) -{ - uint8_t c; - uint32_t size; - uint32_t rx_size; - uint32_t tx_size; - uint8_t *data; - int err; - - if (!uart_irq_update(dev)) - { - return; - } - - if (uart_irq_rx_ready(dev)) - { - size = ring_buf_put_claim(&uart_receive_buf, &data, UART_BUFFER_SIZE); - - /* read until FIFO empty */ - rx_size = uart_fifo_read(dev, data, size); - - if (rx_size < 0) - { - /* Error */ - } - - if (rx_size == size) - { - if (uart_fifo_read(dev, &c, 1) == 1) - { - /* Error - more data in fifo */ - } - } - - err = ring_buf_put_finish(&uart_receive_buf, rx_size); - if (err != 0) - { - /* This shouldn't happen unless rx_size > size */ - } - - /* Enough bytes was received, call receive callback */ - if (ring_buf_size_get(&uart_receive_buf) >= s_transferReceiveRequireBytes) - { - s_uart_instance->rx_cb(); - } - } - - if (uart_irq_tx_ready(dev) && ring_buf_size_get(&uart_send_buf) > 0) - { - /* read one byte from queue */ - size = ring_buf_get_claim(&uart_send_buf, &data, UART_BUFFER_SIZE); - - /* send it thought UART */ - tx_size = uart_fifo_fill(dev, data, size); - if (tx_size < 0) - { - /* Error */ - } - - err = ring_buf_get_finish(&uart_send_buf, tx_size); - if (err != 0) - { - /* bytes_send exceeds amount of valid data in a ring buffer. */ - } - - if (ring_buf_size_get(&uart_send_buf) == 0) - { - /* no more bytes to send; disable tx interrupt */ - uart_irq_tx_disable(dev); - s_uart_instance->tx_cb(); - } - } -} - -erpc_status_t UartTransport::init(void) -{ - erpc_status_t erpcStatus = kErpcStatus_InitFailed; - - int32_t status = uart_irq_callback_user_data_set(m_dev, TransferCallback, this); - - if (status == 0) - { - uart_irq_rx_enable(m_dev); - erpcStatus = kErpcStatus_Success; - } - - return erpcStatus; -} - -erpc_status_t UartTransport::underlyingReceive(uint8_t *data, uint32_t size) -{ - erpc_status_t erpcStatus = kErpcStatus_ReceiveFailed; - - if (ring_buf_size_get(&uart_receive_buf) < size) - { - s_transferReceiveRequireBytes = size; - -/* wait until the receiving is finished */ -#if !ERPC_THREADS_IS(NONE) - (void)m_rxSemaphore.get(); -#else - s_isTransferReceiveCompleted = false; - while (!s_isTransferReceiveCompleted) - { - } -#endif - erpcStatus = kErpcStatus_Success; - } - - /* read data from buffer */ - if (ring_buf_get(&uart_receive_buf, data, size) != size) - { - /* reading error, should not happen */ - erpcStatus = kErpcStatus_ReceiveFailed; - } - - return erpcStatus; -} - -erpc_status_t UartTransport::underlyingSend(const uint8_t *data, uint32_t size) -{ - erpc_status_t erpcStatus = kErpcStatus_SendFailed; - - s_isTransferSendCompleted = false; - - /* fill buffer */ - ring_buf_put(&uart_send_buf, data, size); - - /* enable transport */ - uart_irq_tx_enable(m_dev); - -/* wait until the sending is finished */ -#if !ERPC_THREADS_IS(NONE) - (void)m_txSemaphore.get(); -#else - while (!s_isTransferSendCompleted) - { - } -#endif - - erpcStatus = kErpcStatus_Success; - - return erpcStatus; -} +/* + * Copyright 2023 NXP + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "erpc_uart_zephyr_transport.hpp" +#include +#include +#include + +using namespace erpc; + +//////////////////////////////////////////////////////////////////////////////// +// Variables +//////////////////////////////////////////////////////////////////////////////// + +static volatile bool s_isTransferReceiveCompleted = false; +static volatile bool s_isTransferSendCompleted = false; +static volatile uint32_t s_transferReceiveRequireBytes = 0; +static UartTransport *s_uart_instance = NULL; + +#define UART_BUFFER_SIZE ERPC_DEFAULT_BUFFER_SIZE + +RING_BUF_DECLARE(uart_receive_buf, UART_BUFFER_SIZE); +RING_BUF_DECLARE(uart_send_buf, UART_BUFFER_SIZE); + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +UartTransport::UartTransport(struct device *dev) : +m_dev(dev) +#if !ERPC_THREADS_IS(NONE) +, +m_rxSemaphore(), m_txSemaphore() +#endif +{ + s_uart_instance = this; +} + +UartTransport::~UartTransport(void) {} + +void UartTransport::tx_cb(void) +{ +#if !ERPC_THREADS_IS(NONE) + m_txSemaphore.put(); +#else + s_isTransferSendCompleted = true; +#endif +} + +void UartTransport::rx_cb(void) +{ +#if !ERPC_THREADS_IS(NONE) + m_rxSemaphore.put(); +#else + s_isTransferReceiveCompleted = true; +#endif + s_transferReceiveRequireBytes = UART_BUFFER_SIZE; +} + +/* Transfer callback */ +static void TransferCallback(const struct device *dev, void *user_data) +{ + uint32_t size; + uint32_t rx_size; + uint32_t tx_size; + uint8_t *data; + int err; + + if (!uart_irq_update(dev)) + { + return; + } + + if (uart_irq_rx_ready(dev)) + { + do + { + if (ring_buf_space_get(&uart_receive_buf) == 0) + { + /* Error - receive buffer is full */ + } + + size = ring_buf_put_claim(&uart_receive_buf, &data, UART_BUFFER_SIZE); + + /* read until FIFO empty */ + rx_size = uart_fifo_read(dev, data, size); + if (rx_size < 0) + { + /* Error */ + } + + err = ring_buf_put_finish(&uart_receive_buf, rx_size); + if (err != 0) + { + /* This shouldn't happen unless rx_size > size */ + } + + } while (rx_size == size); + + /* Enough bytes was received, call receive callback */ + if (ring_buf_size_get(&uart_receive_buf) >= s_transferReceiveRequireBytes) + { + s_uart_instance->rx_cb(); + } + } + + if (uart_irq_tx_ready(dev) && ring_buf_size_get(&uart_send_buf) > 0) + { + /* read one byte from queue */ + size = ring_buf_get_claim(&uart_send_buf, &data, UART_BUFFER_SIZE); + + /* send it thought UART */ + tx_size = uart_fifo_fill(dev, data, size); + if (tx_size < 0) + { + /* Error */ + } + + err = ring_buf_get_finish(&uart_send_buf, tx_size); + if (err != 0) + { + /* bytes_send exceeds amount of valid data in a ring buffer. */ + } + + if (ring_buf_size_get(&uart_send_buf) == 0) + { + /* no more bytes to send; disable tx interrupt */ + uart_irq_tx_disable(dev); + s_uart_instance->tx_cb(); + } + } +} + +erpc_status_t UartTransport::init(void) +{ + erpc_status_t erpcStatus = kErpcStatus_InitFailed; + + int32_t status = uart_irq_callback_user_data_set(m_dev, TransferCallback, this); + + if (status == 0) + { + uart_irq_rx_enable(m_dev); + erpcStatus = kErpcStatus_Success; + } + + return erpcStatus; +} + +erpc_status_t UartTransport::underlyingReceive(uint8_t *data, uint32_t size) +{ + erpc_status_t erpcStatus = kErpcStatus_Success; + + if (ring_buf_size_get(&uart_receive_buf) < size) + { + s_transferReceiveRequireBytes = size; + +/* wait until the receiving is finished */ +#if !ERPC_THREADS_IS(NONE) + (void)m_rxSemaphore.get(); +#else + s_isTransferReceiveCompleted = false; + while (!s_isTransferReceiveCompleted) + { + } +#endif + } + + /* read data from buffer */ + if (ring_buf_get(&uart_receive_buf, data, size) != size) + { + /* reading error, should not happen */ + erpcStatus = kErpcStatus_ReceiveFailed; + } + + return erpcStatus; +} + +erpc_status_t UartTransport::underlyingSend(const uint8_t *data, uint32_t size) +{ + erpc_status_t erpcStatus = kErpcStatus_SendFailed; + + s_isTransferSendCompleted = false; + + /* fill buffer */ + ring_buf_put(&uart_send_buf, data, size); + + /* enable transport */ + uart_irq_tx_enable(m_dev); + +/* wait until the sending is finished */ +#if !ERPC_THREADS_IS(NONE) + (void)m_txSemaphore.get(); +#else + while (!s_isTransferSendCompleted) + { + } +#endif + + erpcStatus = kErpcStatus_Success; + + return erpcStatus; +} diff --git a/erpc_java/deploy.xml b/erpc_java/deploy.xml index 1adf2193..2d496677 100644 --- a/erpc_java/deploy.xml +++ b/erpc_java/deploy.xml @@ -6,7 +6,7 @@ io.github.embeddedrpc.erpc erpc - 0.1.0 + 1.13.0 eRPC eRPC (Embedded RPC) is an open source Remote Procedure Call (RPC) system for multichip embedded systems diff --git a/erpc_java/pom.xml b/erpc_java/pom.xml index 934b688f..5173cdba 100644 --- a/erpc_java/pom.xml +++ b/erpc_java/pom.xml @@ -6,7 +6,7 @@ io.github.embeddedrpc.erpc erpc - 0.1.0 + 1.13.0 eRPC eRPC (Embedded RPC) is an open source Remote Procedure Call (RPC) system for multichip embedded systems diff --git a/erpc_python/erpc/erpc_version.py b/erpc_python/erpc/erpc_version.py index 3efec812..3e702641 100644 --- a/erpc_python/erpc/erpc_version.py +++ b/erpc_python/erpc/erpc_version.py @@ -1,9 +1,9 @@ #!/usr/bin/env python -# Copyright 2017-2023 NXP +# Copyright 2017-2024 NXP # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # Should be same as in erpc_version.h -ERPC_VERSION = "1.12.0" +ERPC_VERSION = "1.13.0" diff --git a/erpc_python/erpc/transport.py b/erpc_python/erpc/transport.py index cc3b33d2..8b98ca45 100644 --- a/erpc_python/erpc/transport.py +++ b/erpc_python/erpc/transport.py @@ -10,6 +10,8 @@ import struct import socket import threading +from socket import SHUT_RDWR + from .crc16 import Crc16 from .client import RequestError import time @@ -166,7 +168,9 @@ def _serve(self): self._serverSockEventStart.set() def close(self): - self._serverSockEventStart.clear() + if self._isServer: + self._serverSockEventStart.clear() + self._sock.shutdown(SHUT_RDWR) self._sock.close() self._sock = None diff --git a/erpc_python/readme.md b/erpc_python/readme.md index a8f2b06e..57d09477 100644 --- a/erpc_python/readme.md +++ b/erpc_python/readme.md @@ -7,29 +7,27 @@ protocol level. Also, the classes mirror those in the C++ infrastructure. ## Contents -`erpc` - Python package for eRPC infrastructure. +[erpc](erpc) - Python package for eRPC infrastructure. -`setup.py` - setuptools setup script that installs the erpc package. +[setup.py](setup.py) - setuptools setup script that installs the erpc package. -`setup.cfg, README_Pypi.md` - necessary files for the pypi support. +[setup.cfg](setup.cfg), [README_Pypi.md](README_Pypi.md) - necessary files for the pypi support. ## Installation Pip package installer needs to be installed in your Python version. Use following way for Python3 pip installation: ```sh -sudo apt-get install python3-pip -/usr/bin$ sudo rm python -/usr/bin$ sudo ln -s python3 python +sudo apt-get install python3 python3-pip ``` -To install the eRPC Python infrastructure, run the setup.py script like this (based on your system admin rights are required): +To install the eRPC Python infrastructure from pypi: ```sh -python setup.py install +pip install erpc ``` -Alternatively, you may use pip to install the package, like this: +To install the eRPC Python infrastructure from local folder ([erpc/erpc_python](/erpc_python)): ```sh pip install . diff --git a/erpcgen/src/AstNode.cpp b/erpcgen/src/AstNode.cpp index 05b868b7..278487c2 100644 --- a/erpcgen/src/AstNode.cpp +++ b/erpcgen/src/AstNode.cpp @@ -217,7 +217,9 @@ string AstNode::getDescription() const case TOK_UNARY_NEGATE: case TOK_ARRAY: case TOK_UNION_CASE: + { break; + } default: { output += " " + valToString + " "; diff --git a/erpcgen/src/AstWalker.cpp b/erpcgen/src/AstWalker.cpp index 2d898d6c..a473bb46 100644 --- a/erpcgen/src/AstWalker.cpp +++ b/erpcgen/src/AstWalker.cpp @@ -62,49 +62,79 @@ void AstWalker::dispatch(AstNode *node) switch (tok.getToken()) { case TOK_PROGRAM: + { rewrite = handleProgram(node, dir); break; + } case TOK_CHILDREN: + { break; + } case TOK_TYPE: + { rewrite = handleType(node, dir); break; + } case TOK_ENUM: + { rewrite = handleEnum(node, dir); break; + } case TOK_ENUM_MEMBER: + { rewrite = handleEnumMember(node, dir); break; + } case TOK_STRUCT: + { rewrite = handleStruct(node, dir); break; + } case TOK_STRUCT_MEMBER: + { rewrite = handleStructMember(node, dir); break; + } case TOK_UNION: + { rewrite = handleUnion(node, dir); break; + } case TOK_UNION_CASE: + { rewrite = handleUnionCase(node, dir); break; + } case TOK_INTERFACE: + { rewrite = handleInterface(node, dir); break; + } case TOK_FUNCTION: + { rewrite = handleFunction(node, dir); break; + } case TOK_PARAM: + { rewrite = handleParam(node, dir); break; + } case TOK_CONST: + { rewrite = handleConst(node, dir); break; + } case TOK_EXPR: + { rewrite = handleExpr(node, dir); break; + } case TOK_ANNOTATION: + { rewrite = handleAnnotation(node, dir); break; + } case '+': case '-': case '*': @@ -115,12 +145,16 @@ void AstWalker::dispatch(AstNode *node) case '^': case TOK_LSHIFT: case TOK_RSHIFT: + { rewrite = handleBinaryOp(node, dir); break; + } case TOK_UNARY_NEGATE: case '~': + { rewrite = handleUnaryOp(node, dir); break; + } } if (rewrite) diff --git a/erpcgen/src/CGenerator.cpp b/erpcgen/src/CGenerator.cpp index f891a06a..16b86311 100644 --- a/erpcgen/src/CGenerator.cpp +++ b/erpcgen/src/CGenerator.cpp @@ -821,7 +821,9 @@ void CGenerator::makeAliasesTemplateData() break; } default: + { throw internal_error("Only structs or enums are allowed as unnamed types."); + } } } aliases.push_back(aliasInfo); @@ -2268,8 +2270,11 @@ string CGenerator::getTypenameName(DataType *t, const string &name) break; } default: + { throw internal_error(format_string("In getTypenameName: unknown data type: %s value:%d", t->getName().c_str(), t->getDataType())); + break; + } } return returnName; } @@ -2279,35 +2284,65 @@ string CGenerator::getBuiltinTypename(const BuiltinType *t) switch (t->getBuiltinType()) { case BuiltinType::builtin_type_t::kBoolType: + { return "bool"; + } case BuiltinType::builtin_type_t::kInt8Type: + { return "int8_t"; + } case BuiltinType::builtin_type_t::kInt16Type: + { return "int16_t"; + } case BuiltinType::builtin_type_t::kInt32Type: + { return "int32_t"; + } case BuiltinType::builtin_type_t::kInt64Type: + { return "int64_t"; + } case BuiltinType::builtin_type_t::kUInt8Type: + { return "uint8_t"; + } case BuiltinType::builtin_type_t::kUInt16Type: + { return "uint16_t"; + } case BuiltinType::builtin_type_t::kUInt32Type: + { return "uint32_t"; + } case BuiltinType::builtin_type_t::kUInt64Type: + { return "uint64_t"; + } case BuiltinType::builtin_type_t::kFloatType: + { return "float"; + } case BuiltinType::builtin_type_t::kDoubleType: + { return "double"; + } case BuiltinType::builtin_type_t::kStringType: + { return "char *"; + } case BuiltinType::builtin_type_t::kUStringType: + { return "unsigned char*"; + } case BuiltinType::builtin_type_t::kBinaryType: + { return "uint8_t *"; + } default: + { throw internal_error("unknown builtin type"); + } } } @@ -3039,7 +3074,9 @@ bool CGenerator::isNeedCallFree(DataType *dataType) return false; } default: + { return false; + } } } @@ -3422,15 +3459,25 @@ string CGenerator::getDirection(param_direction_t direction) switch (direction) { case param_direction_t::kInDirection: + { return "kInDirection"; + } case param_direction_t::kOutDirection: + { return "kOutDirection"; + } case param_direction_t::kInoutDirection: + { return "kInoutDirection"; + } case param_direction_t::kReturn: + { return "kReturn"; + } default: + { throw semantic_error("Unsupported direction type"); + } } } diff --git a/erpcgen/src/ErpcLexer.cpp b/erpcgen/src/ErpcLexer.cpp index d3763b86..4883fbf3 100644 --- a/erpcgen/src/ErpcLexer.cpp +++ b/erpcgen/src/ErpcLexer.cpp @@ -82,7 +82,9 @@ int ErpcLexer::processStringEscapes(const char *in, char *out) switch (c) { case 0: // end of the string, bail + { break; + } case 'x': { // start of a hex char escape sequence @@ -90,10 +92,14 @@ int ErpcLexer::processStringEscapes(const char *in, char *out) // read high and low nibbles, checking for end of string char hi = *++in; if (hi == 0) + { break; + } char lo = *++in; if (lo == 0) + { break; + } if (isHexDigit(hi) && isHexDigit(lo)) { @@ -111,41 +117,57 @@ int ErpcLexer::processStringEscapes(const char *in, char *out) break; } case 'n': + { *out++ = '\n'; count++; break; + } case 't': + { *out++ = '\t'; count++; break; + } case 'r': + { *out++ = '\r'; count++; break; + } case 'b': + { *out++ = '\b'; count++; break; + } case 'f': + { *out++ = '\f'; count++; break; + } case '0': + { *out++ = '\0'; count++; break; + } default: + { *out++ = c; count++; break; + } } break; } default: + { // copy all other chars directly *out++ = *in++; count++; + } } } diff --git a/erpcgen/src/HexValues.cpp b/erpcgen/src/HexValues.cpp index a1190993..63e5fb58 100644 --- a/erpcgen/src/HexValues.cpp +++ b/erpcgen/src/HexValues.cpp @@ -21,13 +21,21 @@ bool isHexDigit(char c) uint8_t hexCharToInt(char c) { if (c >= '0' && c <= '9') + { return c - '0'; + } else if (c >= 'a' && c <= 'f') + { return c - 'a' + 10; + } else if (c >= 'A' && c <= 'F') + { return c - 'A' + 10; + } else + { return static_cast(-1); + } } //! \param encodedByte Must point to at least two ASCII hex characters. diff --git a/erpcgen/src/HexValues.hpp b/erpcgen/src/HexValues.hpp index 9433504e..63153260 100644 --- a/erpcgen/src/HexValues.hpp +++ b/erpcgen/src/HexValues.hpp @@ -9,7 +9,6 @@ #if !defined(_HexValues_h_) #define _HexValues_h_ -#include #include //! \brief Determines whether \a c is a hex digit character. diff --git a/erpcgen/src/JavaGenerator.cpp b/erpcgen/src/JavaGenerator.cpp index 76d20063..8dcb5344 100644 --- a/erpcgen/src/JavaGenerator.cpp +++ b/erpcgen/src/JavaGenerator.cpp @@ -34,11 +34,8 @@ extern const char *const kJavaInterface; // Code //////////////////////////////////////////////////////////////////////////////// -JavaGenerator::JavaGenerator(InterfaceDefinition *def, const std::string javaPackageName) -: Generator(def, generator_type_t::kJava) -, m_javaPackageName(javaPackageName) -, m_suffixStrip("") -, m_suffixStripSize(0) +JavaGenerator::JavaGenerator(InterfaceDefinition *def, const std::string javaPackageName) : +Generator(def, generator_type_t::kJava), m_javaPackageName(javaPackageName), m_suffixStrip(""), m_suffixStripSize(0) { /* Set copyright rules. */ if (m_def->hasProgramSymbol()) @@ -354,7 +351,7 @@ data_map JavaGenerator::getFunctionTemplateData(Group *group, Function *fn) } string JavaGenerator::getFunctionPrototype(Group *group, FunctionBase *fn, const string &interfaceName, - const string &name, bool insideInterfaceCall) + const string &name, bool insideInterfaceCall) { FunctionType *functionType = dynamic_cast(fn); if (functionType) @@ -385,20 +382,20 @@ string JavaGenerator::getFunctionPrototype(Group *group, FunctionBase *fn, const // Skip data serialization for variables placed as @length value for lists. if (findParamReferencedFromAnn(params, getOutputName(it), LENGTH_ANNOTATION)) { - continue; + continue; } if (!isFirst) { - proto += ", "; - + proto += ", "; } else { - isFirst = false; + isFirst = false; } - if (it->getDirection() == param_direction_t::kOutDirection || it->getDirection() == param_direction_t::kInoutDirection) + if (it->getDirection() == param_direction_t::kOutDirection || + it->getDirection() == param_direction_t::kInoutDirection) { proto += getTypenameName(it->getDataType(), true, true); } @@ -419,17 +416,17 @@ string JavaGenerator::getTypenameName(DataType *t, bool isReference, bool object { string returnName; - - switch (t->getDataType()) { - case DataType::data_type_t::kArrayType: { + case DataType::data_type_t::kArrayType: + { ArrayType *a = dynamic_cast(t); assert(a); returnName = getTypenameName(a->getElementType(), false, false) + "[]"; break; } - case DataType::data_type_t::kBuiltinType: { + case DataType::data_type_t::kBuiltinType: + { assert(nullptr != dynamic_cast(t)); if (objectType) { @@ -442,23 +439,27 @@ string JavaGenerator::getTypenameName(DataType *t, bool isReference, bool object break; } - case DataType::data_type_t::kListType: { + case DataType::data_type_t::kListType: + { const ListType *a = dynamic_cast(t); assert(a); returnName = "List<" + getTypenameName(a->getElementType(), false, true) + ">"; break; } - case DataType::data_type_t::kAliasType: { + case DataType::data_type_t::kAliasType: + { AliasType *aliasType = dynamic_cast(t); return getTypenameName(aliasType->getTrueDataType(), isReference, objectType); } - case DataType::data_type_t::kVoidType: { + case DataType::data_type_t::kVoidType: + { returnName = "void"; break; } case DataType::data_type_t::kUnionType: case DataType::data_type_t::kEnumType: - case DataType::data_type_t::kStructType: { + case DataType::data_type_t::kStructType: + { returnName = getOutputName(t); break; } @@ -638,7 +639,8 @@ data_map JavaGenerator::makeGroupSymbolsTemplateData(Group *group) switch (dataType->getDataType()) { - case DataType::data_type_t::kStructType: { + case DataType::data_type_t::kStructType: + { StructType *structType = dynamic_cast(symbol); if (structType == nullptr) { @@ -662,7 +664,8 @@ data_map JavaGenerator::makeGroupSymbolsTemplateData(Group *group) } break; } - case DataType::data_type_t::kUnionType: { + case DataType::data_type_t::kUnionType: + { UnionType *unionType = dynamic_cast(symbol); if (unionType == nullptr) { @@ -692,7 +695,8 @@ data_map JavaGenerator::makeGroupSymbolsTemplateData(Group *group) } break; } - case DataType::data_type_t::kAliasType: { + case DataType::data_type_t::kAliasType: + { AliasType *aliasType = dynamic_cast(symbol); if (aliasType == nullptr) break; @@ -791,7 +795,7 @@ data_map JavaGenerator::getEncodeDecodeCall(const string &name, DataType *t, Str { static uint8_t listArrayCounter; // Used for creating nested loops variable names data_map templateData; - bool isReference = (isStructMember && structMember->isByref()) || + bool isReference = (isStructMember && structMember->isByref()) || (isFunctionParam && (structMember->getDirection() == param_direction_t::kOutDirection || structMember->getDirection() == param_direction_t::kInoutDirection)); templateData["type"] = getTypeInfo(t, isReference); // Type info about variable @@ -804,14 +808,16 @@ data_map JavaGenerator::getEncodeDecodeCall(const string &name, DataType *t, Str switch (t->getDataType()) { - case DataType::data_type_t::kAliasType: { + case DataType::data_type_t::kAliasType: + { AliasType *aliasType = dynamic_cast(t); assert(aliasType); templateData = getEncodeDecodeCall(name, aliasType->getElementType(), structType, inDataContainer, false, structMember, true, false); break; } - case DataType::data_type_t::kArrayType: { + case DataType::data_type_t::kArrayType: + { ArrayType *arrayType = dynamic_cast(t); assert(arrayType); DataType *elementType = arrayType->getElementType()->getTrueDataType(); @@ -833,20 +839,24 @@ data_map JavaGenerator::getEncodeDecodeCall(const string &name, DataType *t, Str templateData["isElementArrayType"] = elementType->isArray(); break; } - case DataType::data_type_t::kBuiltinType: { + case DataType::data_type_t::kBuiltinType: + { templateData["decode"] = m_templateData["decodeBuiltinType"]; templateData["encode"] = m_templateData["encodeBuiltinType"]; break; } - case DataType::data_type_t::kEnumType: { + case DataType::data_type_t::kEnumType: + { templateData["decode"] = m_templateData["decodeEnumType"]; templateData["encode"] = m_templateData["encodeEnumType"]; break; } - case DataType::data_type_t::kFunctionType: { + case DataType::data_type_t::kFunctionType: + { throw internal_error("Java does not support functions yet."); } - case DataType::data_type_t::kListType: { + case DataType::data_type_t::kListType: + { ListType *listType = dynamic_cast(t); assert(listType); DataType *elementType = listType->getElementType()->getTrueDataType(); @@ -890,15 +900,18 @@ data_map JavaGenerator::getEncodeDecodeCall(const string &name, DataType *t, Str break; } - case DataType::data_type_t::kStructType: { + case DataType::data_type_t::kStructType: + { templateData["decode"] = m_templateData["decodeStructType"]; templateData["encode"] = m_templateData["encodeStructType"]; break; } - case DataType::data_type_t::kUnionType: { + case DataType::data_type_t::kUnionType: + { break; } - default: { + default: + { throw internal_error("unknown member type"); } } @@ -948,40 +961,48 @@ data_map JavaGenerator::getTypeInfo(DataType *t, int isReference, bool inDataCon info["isNonEncapsulatedUnion"] = false; switch (t->getDataType()) { - case DataType::data_type_t::kAliasType: { + case DataType::data_type_t::kAliasType: + { info = getTypeInfo(t->getTrueDataType(), false); break; } - case DataType::data_type_t::kArrayType: { + case DataType::data_type_t::kArrayType: + { // Array type requires the array element count to come after the variable/member name. info["type"] = "array"; break; } - case DataType::data_type_t::kBuiltinType: { + case DataType::data_type_t::kBuiltinType: + { assert(dynamic_cast(t)); info["type"] = getBuiltinTypename(dynamic_cast(t)); info["codecTypeName"] = getBuiltinCodecTypeName(dynamic_cast(t)); break; } - case DataType::data_type_t::kEnumType: { + case DataType::data_type_t::kEnumType: + { info["type"] = "enum"; break; } - case DataType::data_type_t::kFunctionType: { + case DataType::data_type_t::kFunctionType: + { info["type"] = "function"; break; } - case DataType::data_type_t::kListType: { + case DataType::data_type_t::kListType: + { info["type"] = "list"; break; } - case DataType::data_type_t::kStructType: { + case DataType::data_type_t::kStructType: + { info["type"] = "struct"; info["decode"] = m_templateData["decodeStructType"]; info["encode"] = m_templateData["encodeStructType"]; break; } - case DataType::data_type_t::kUnionType: { + case DataType::data_type_t::kUnionType: + { UnionType *unionType = dynamic_cast(t); assert(unionType); info["type"] = "union"; @@ -1102,7 +1123,8 @@ data_map JavaGenerator::getTypeInfo(DataType *t, int isReference, bool inDataCon info["cases"] = unionCases; break; } - case DataType::data_type_t::kVoidType: { + case DataType::data_type_t::kVoidType: + { info["type"] = "void"; break; } diff --git a/erpcgen/src/JavaGenerator.hpp b/erpcgen/src/JavaGenerator.hpp index c07809c5..716399c3 100644 --- a/erpcgen/src/JavaGenerator.hpp +++ b/erpcgen/src/JavaGenerator.hpp @@ -47,9 +47,9 @@ class JavaGenerator : public Generator virtual void generate() override; protected: - std::string m_suffixStrip; //!< String to remove from suffixes of names. - size_t m_suffixStripSize; //!< Length of the suffix filter string. - std::string m_javaPackageName; //!< Used java package. + std::string m_suffixStrip; //!< String to remove from suffixes of names. + size_t m_suffixStripSize; //!< Length of the suffix filter string. + std::string m_javaPackageName; //!< Used java package. /*! * @brief This function prepare helpful functions located in template files. @@ -159,12 +159,12 @@ class JavaGenerator : public Generator std::string getFunctionPrototype(Group *group, FunctionBase *fn, const std::string &interfaceName = "", const std::string &name = "", bool insideInterfaceCall = false) override; - /*! + /*! * @brief This function return typename name base on DataType. If objectType is true, * return builtin object insted of primitive. * * @param[in] t data type. - * @param[in] objectType + * @param[in] objectType * * @return Return data type name. */ @@ -247,7 +247,8 @@ class JavaGenerator : public Generator * TODO */ cpptempl::data_map getEncodeDecodeCall(const std::string &name, DataType *t, StructType *structType, - bool inDataContainer, bool isStructMember, StructMember *structMember, bool needTypeDeclaration, bool isFunctionParam); + bool inDataContainer, bool isStructMember, StructMember *structMember, + bool needTypeDeclaration, bool isFunctionParam); /* * TODO @@ -268,7 +269,7 @@ class JavaGenerator : public Generator /*! * @brief This function return CamelCase string representation for given BuiltinType. - * + * * @param[in] t Builtin type. * * @return String representation for given builtin type. @@ -285,7 +286,7 @@ class JavaGenerator : public Generator */ std::string getBuiltinTypename(const BuiltinType *t); - /*! + /*! * @brief This function return string representation for given BuiltinType as Object type. * * @param[in] t Builtin type. @@ -307,12 +308,12 @@ class JavaGenerator : public Generator }; /*! - * @brief This function creates Group package name. - * - * @param[in] group Group - * - * @return Package name for given group. - */ + * @brief This function creates Group package name. + * + * @param[in] group Group + * + * @return Package name for given group. + */ std::string getGroupPackageName(const Group *group); /*! diff --git a/erpcgen/src/PythonGenerator.cpp b/erpcgen/src/PythonGenerator.cpp index 3c1f581f..680c5e89 100644 --- a/erpcgen/src/PythonGenerator.cpp +++ b/erpcgen/src/PythonGenerator.cpp @@ -237,20 +237,29 @@ data_map PythonGenerator::getFunctionTemplateData(Group *group, Function *fn) switch (dir) { case param_direction_t::kInDirection: + { paramInfo["direction"] = "in"; inParams.push_back(paramInfo); break; + } case param_direction_t::kOutDirection: + { paramInfo["direction"] = "out"; outParams.push_back(paramInfo); break; + } case param_direction_t::kInoutDirection: + { paramInfo["direction"] = "inout"; inParams.push_back(paramInfo); outParams.push_back(paramInfo); break; + } default: + { paramInfo["direction"] = "none"; + break; + } } params.push_back(paramInfo); @@ -516,7 +525,9 @@ data_map PythonGenerator::makeGroupSymbolsTemplateData(Group *group) break; } default: + { break; + } } } } @@ -701,7 +712,7 @@ data_map PythonGenerator::getTypeInfo(DataType *t) { EnumType *enumType = dynamic_cast(it); assert(enumType); - for (auto itMember : enumType->getMembers()) + for (const auto itMember : enumType->getMembers()) { if (unionCase->getCaseName() == itMember->getName()) { @@ -777,7 +788,9 @@ data_map PythonGenerator::getTypeInfo(DataType *t) break; } default: + { throw internal_error("unknown data type"); + } } return info; } @@ -787,33 +800,61 @@ string PythonGenerator::getBuiltinTypename(const BuiltinType *t) switch (t->getBuiltinType()) { case BuiltinType::builtin_type_t::kBoolType: + { return "bool"; + } case BuiltinType::builtin_type_t::kInt8Type: + { return "int8"; + } case BuiltinType::builtin_type_t::kInt16Type: + { return "int16"; + } case BuiltinType::builtin_type_t::kInt32Type: + { return "int32"; + } case BuiltinType::builtin_type_t::kInt64Type: + { return "int64"; + } case BuiltinType::builtin_type_t::kUInt8Type: + { return "uint8"; + } case BuiltinType::builtin_type_t::kUInt16Type: + { return "uint16"; + } case BuiltinType::builtin_type_t::kUInt32Type: + { return "uint32"; + } case BuiltinType::builtin_type_t::kUInt64Type: + { return "uint64"; + } case BuiltinType::builtin_type_t::kFloatType: + { return "float"; + } case BuiltinType::builtin_type_t::kDoubleType: + { return "double"; + } case BuiltinType::builtin_type_t::kStringType: + { return "string"; + } case BuiltinType::builtin_type_t::kBinaryType: + { return "binary"; + } default: + { throw internal_error("unknown builtin type"); + } } } diff --git a/erpcgen/src/SymbolScanner.cpp b/erpcgen/src/SymbolScanner.cpp index c47b5f23..9b752654 100644 --- a/erpcgen/src/SymbolScanner.cpp +++ b/erpcgen/src/SymbolScanner.cpp @@ -406,15 +406,22 @@ AstNode *SymbolScanner::handleBinaryOp(AstNode *node, bottom_up) switch (tok.getToken()) { case '+': + { result = l + r; break; + } case '-': + { result = l - r; break; + } case '*': + { result = l * r; break; + } case '/': + { // Just make the result a zero if div-by-zero. if (r == 0) { @@ -425,7 +432,9 @@ AstNode *SymbolScanner::handleBinaryOp(AstNode *node, bottom_up) result = l / r; } break; + } case '%': + { // Just make the result a zero if div-by-zero. if (r == 0) { @@ -436,23 +445,36 @@ AstNode *SymbolScanner::handleBinaryOp(AstNode *node, bottom_up) result = l % r; } break; + } case '&': + { result = l & r; break; + } case '|': + { result = l | r; break; + } case '^': + { result = l ^ r; break; + } case TOK_LSHIFT: + { result = l << r; break; + } case TOK_RSHIFT: + { result = l >> r; break; + } default: + { throw internal_error("unknown binary operator"); + } } IntegerValue::int_type_t intType; @@ -504,15 +526,22 @@ AstNode *SymbolScanner::handleBinaryOp(AstNode *node, bottom_up) switch (tok.getToken()) { case '+': + { result = l + r; break; + } case '-': + { result = l - r; break; + } case '*': + { result = l * r; break; + } case '/': + { /* Just make the result a zero if div-by-zero. */ if (r == 0) { @@ -523,6 +552,7 @@ AstNode *SymbolScanner::handleBinaryOp(AstNode *node, bottom_up) result = l / r; } break; + } /* Throw semantic error on invalid operators for floats. */ case '%': @@ -531,9 +561,13 @@ AstNode *SymbolScanner::handleBinaryOp(AstNode *node, bottom_up) case '^': case TOK_LSHIFT: case TOK_RSHIFT: + { throw semantic_error(format_string("line %d: invalid operator on float value", tok.getFirstLine())); + } default: + { throw internal_error("unknown binary operator"); + } } resultNode = new AstNode(Token(TOK_FLOAT_LITERAL, new FloatValue(result))); @@ -579,13 +613,19 @@ AstNode *SymbolScanner::handleUnaryOp(AstNode *node, bottom_up) switch (tok.getToken()) { case TOK_UNARY_NEGATE: + { value = (-(int64_t)(value)); break; + } case '~': + { value = ~value; break; + } default: + { throw internal_error("unknown unary operator"); + } } return new AstNode(Token(TOK_INT_LITERAL, new IntegerValue(value, valueInt->getIntType()))); @@ -596,15 +636,21 @@ AstNode *SymbolScanner::handleUnaryOp(AstNode *node, bottom_up) switch (tok.getToken()) { case TOK_UNARY_NEGATE: + { value = -value; return new AstNode(Token(TOK_FLOAT_LITERAL, new FloatValue(value))); + } // It is a semantic error to use the binary invert operator on a float. case '~': + { throw semantic_error(format_string("line %d: invalid operator on float value", tok.getFirstLine())); + } default: + { throw internal_error("unknown unary operator"); + } } } @@ -1116,18 +1162,24 @@ AstNode *SymbolScanner::handleFunction(AstNode *node, top_down) switch (returnTypeToken.getToken()) { case TOK_ONEWAY: + { func->setIsOneway(true); func->setReturnStructMemberType(new StructMember("(return)", new VoidType)); break; + } case TOK_VOID: + { func->setReturnStructMemberType(new StructMember("(return)", new VoidType)); break; + } default: + { DataType *dataType = lookupDataType(returnTypeNode); func->setReturnStructMemberType(new StructMember("(return)", dataType)); break; + } } if (returnTypeToken.getToken() != TOK_ONEWAY) { @@ -1382,19 +1434,26 @@ void SymbolScanner::setParameterDirection(StructMember *param, AstNode *directio switch (directionNode->getToken().getToken()) { case TOK_IN: + { param_direction = param_direction_t::kInDirection; break; + } case TOK_OUT: + { param_direction = param_direction_t::kOutDirection; break; + } case TOK_INOUT: + { param_direction = param_direction_t::kInoutDirection; break; + } default: + { delete param; throw semantic_error(format_string("line %d: expected parameter direction type", directionNode->getToken().getFirstLine())); - break; + } } } else /* if no direction specified, default case is an 'in' variable */ @@ -1474,8 +1533,10 @@ DataType *SymbolScanner::lookupDataType(const AstNode *typeNode) return lookupDataTypeByName(typeNode->getChild(3)->getToken(), &(m_currentStruct->getScope()), false); } default: + { throw internal_error(format_string("unexpected token type %s on line %d", typeToken.getTokenName(), typeToken.getLocation().m_firstLine)); + } } } diff --git a/erpcgen/src/erpcgen.cpp b/erpcgen/src/erpcgen.cpp index e5288c72..fe520d2c 100644 --- a/erpcgen/src/erpcgen.cpp +++ b/erpcgen/src/erpcgen.cpp @@ -171,27 +171,37 @@ class erpcgenTool switch (optchar) { case '?': + { printUsage(options); return 0; + } case 'V': + { printf("%s %s\n%s\n", k_toolName, k_version, k_copyright); return 0; + } case 'o': + { m_outputFilePath = optarg; break; + } case 'v': + { if (m_verboseType != verbose_type_t::kExtraDebug) { m_verboseType = (verbose_type_t)(((int)m_verboseType) + 1); } break; + } case 'I': + { PathSearcher::getGlobalSearcher().addSearchPath(optarg); break; + } case 'g': { @@ -238,9 +248,11 @@ class erpcgenTool } default: + { Log::error("error: unrecognized option\n\n"); printUsage(options); return 0; + } } } @@ -325,15 +337,21 @@ class erpcgenTool switch (m_outputLanguage) { case languages_t::kCLanguage: + { CGenerator(&def).generate(); break; + } case languages_t::kPythonLanguage: + { PythonGenerator(&def).generate(); break; + } case languages_t::kJavaLanguage: + { // TODO: Check java package JavaGenerator(&def, m_javaPackageName).generate(); break; + } } } catch (exception &e) @@ -373,17 +391,25 @@ class erpcgenTool switch (m_verboseType) { case verbose_type_t::kWarning: + { Log::getLogger()->setFilterLevel(Logger::log_level_t::kWarning); break; + } case verbose_type_t::kInfo: + { Log::getLogger()->setFilterLevel(Logger::log_level_t::kInfo); break; + } case verbose_type_t::kDebug: + { Log::getLogger()->setFilterLevel(Logger::log_level_t::kDebug); break; + } case verbose_type_t::kExtraDebug: + { Log::getLogger()->setFilterLevel(Logger::log_level_t::kDebug2); break; + } } } }; diff --git a/erpcgen/src/templates/c_common_header.template b/erpcgen/src/templates/c_common_header.template index 2083bbd2..9e203662 100644 --- a/erpcgen/src/templates/c_common_header.template +++ b/erpcgen/src/templates/c_common_header.template @@ -26,7 +26,6 @@ extern "C" #include #include {% else %} -#include #include #include {% endif %} diff --git a/erpcgen/src/types/Type.cpp b/erpcgen/src/types/Type.cpp index 78ba49f7..748d6a25 100644 --- a/erpcgen/src/types/Type.cpp +++ b/erpcgen/src/types/Type.cpp @@ -488,7 +488,9 @@ DataType *DataType::getTrueContainerDataType() return a->getElementType()->getTrueContainerDataType(); } default: + { return trueDataType; + } } } diff --git a/erpcgen/test/readme.md b/erpcgen/test/readme.md index c63fa4bf..19033d76 100644 --- a/erpcgen/test/readme.md +++ b/erpcgen/test/readme.md @@ -2,10 +2,7 @@ This file documents the parser and output test system for erpcgen. -This test system is built on py.test using its extensive plugin hooks. To run the tests, just run -py.test in `erpc/erpcgen/test/` directory. It's safer to run py.test with parameter source -directory (from erpcgen directory run: "pytest test"). This prevent on windows to execute -boost test in boost folder. +This test system is built on py.test using its extensive plugin hooks. ## Setup @@ -23,7 +20,19 @@ the VisualStudio project. ## Running Run the tests by running the py.test executable. The tests can be run from either the -`erpc/erpcgen/` or `erpc/erpcgen/test/` directories. +[erpc/erpcgen/](/erpcgen) or [erpc/erpcgen/test/](.) directories. The tests can be also run from root folder defining directory with tests as next parameter. + +Run all tests: + +```bash +$ pytest erpcgen/test +``` + +Run one test + +```bash +$ pytest erpcgen/test/test_union_py.yml +``` Use the `--help` option of py.test to see all available command line options. Useful options are `-s` to turn off output capturing and `-v` to list each test case by name as it runs. The `-k` @@ -35,13 +44,12 @@ such as `--ev=3`. Default verbosity is 0. ## Config -The tests use a config file. The standard config is `erpc/erpcgen/test/config.py`. It tries to -figure out the erpcgen executable location based on the OS. If you need to override this, you can -create a `config_local.py` that defines the config variables listed below. +The tests use a config file. The standard config is [erpc/erpcgen/test/config.py](config.py). It tries to figure out the erpcgen executable location based on the OS. If you need to override this, you can create a `config_local.py` that defines the config variables listed below. Config variables: -- `CC` = C/C++ compiler path, defaults to "gcc" +- `CC` = C compiler path, defaults to "gcc" +- `CXX` = C++ compiler path, defaults to "g++" - `ERPCGEN` = absolute path to the erpcgen executable - `RUN_KEEP_COUNT` = number of historical test runs to retain, not including the most recent run @@ -195,7 +203,7 @@ Here, both not pattern searches range from the last matching character of the po also shows a `not_re` pattern that requires a regular expression to not match within the search range. -## Parametrizatio +## Parametrization If the test spec dictionary has a `params` key, then the spec will be parametrized. The `params` key must have a dictionary value with parameter names for keys. Under each of the parameter names diff --git a/erpcsniffer/src/Sniffer.cpp b/erpcsniffer/src/Sniffer.cpp index fd363a92..5e7007b7 100644 --- a/erpcsniffer/src/Sniffer.cpp +++ b/erpcsniffer/src/Sniffer.cpp @@ -690,7 +690,9 @@ string Sniffer::getDataTypeName(DataType *dataType) return "void"; } default: + { return dataType->getName(); + } } } diff --git a/erpcsniffer/src/erpcsniffer.cpp b/erpcsniffer/src/erpcsniffer.cpp index 80b94735..5839084a 100644 --- a/erpcsniffer/src/erpcsniffer.cpp +++ b/erpcsniffer/src/erpcsniffer.cpp @@ -415,17 +415,25 @@ class erpcsnifferTool switch (m_verboseType) { case verbose_type_t::kWarning: + { Log::getLogger()->setFilterLevel(Logger::log_level_t::kWarning); break; + } case verbose_type_t::kInfo: + { Log::getLogger()->setFilterLevel(Logger::log_level_t::kInfo); break; + } case verbose_type_t::kDebug: + { Log::getLogger()->setFilterLevel(Logger::log_level_t::kDebug); break; + } case verbose_type_t::kExtraDebug: + { Log::getLogger()->setFilterLevel(Logger::log_level_t::kDebug2); break; + } } } }; diff --git a/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/client/MatrixMultiplyServiceClient.java b/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/client/MatrixMultiplyServiceClient.java index 15b4d35f..edaa54e0 100644 --- a/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/client/MatrixMultiplyServiceClient.java +++ b/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/client/MatrixMultiplyServiceClient.java @@ -1,5 +1,5 @@ /** - * Generated by erpcgen 1.12.0 on Mon Jan 8 09:33:04 2024. + * Generated by erpcgen 1.13.0 on Mon Apr 22 10:58:07 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/common/Constants.java b/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/common/Constants.java index 6543b0f8..dbdf1e08 100644 --- a/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/common/Constants.java +++ b/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/common/Constants.java @@ -1,5 +1,5 @@ /** - * Generated by erpcgen 1.12.0 on Mon Jan 8 09:33:04 2024. + * Generated by erpcgen 1.13.0 on Mon Apr 22 10:58:07 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/interfaces/IMatrixMultiplyService.java b/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/interfaces/IMatrixMultiplyService.java index 3599a81a..364027c6 100644 --- a/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/interfaces/IMatrixMultiplyService.java +++ b/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/interfaces/IMatrixMultiplyService.java @@ -1,5 +1,5 @@ /** - * Generated by erpcgen 1.12.0 on Mon Jan 8 09:33:04 2024. + * Generated by erpcgen 1.13.0 on Mon Apr 22 10:58:07 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/server/AbstractMatrixMultiplyServiceService.java b/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/server/AbstractMatrixMultiplyServiceService.java index 2312c609..c77dbd1c 100644 --- a/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/server/AbstractMatrixMultiplyServiceService.java +++ b/examples/matrix_multiply_java/src/main/java/io/github/embeddedrpc/erpc/example/erpc_matrix_multiply/server/AbstractMatrixMultiplyServiceService.java @@ -1,5 +1,5 @@ /** - * Generated by erpcgen 1.12.0 on Mon Jan 8 09:33:04 2024. + * Generated by erpcgen 1.13.0 on Mon Apr 22 10:58:07 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/matrix_multiply_tcp_python/readme.md b/examples/matrix_multiply_tcp_python/readme.md index 96f51031..97d34155 100644 --- a/examples/matrix_multiply_tcp_python/readme.md +++ b/examples/matrix_multiply_tcp_python/readme.md @@ -1,38 +1,45 @@ # Overview + This example demonstrates usage of eRPC between two PC's or boards (e.g. i.MX) with Python using TCP transport layer. One side acts like a server and the second as a client. When client starts, it generates two random matrixes and sends them to the server. Server then performs matrix multiplication and sends the result matrix back to the client. Client then prints the result matrix. Example can be ran on Personal computer or on boards with Python installed, e.g. i.MX (i.MX7SD, i.MX6SX, etc.) -# eRPC documentation -eRPC is open-source project stored on github: https://github.com/EmbeddedRPC/erpc -eRPC documentation can be also found in: https://github.com/EmbeddedRPC/erpc/wiki +## eRPC documentation + +- eRPC is open-source project stored on github: [https://github.com/EmbeddedRPC/erpc](https://github.com/EmbeddedRPC/erpc) +- eRPC documentation can be also found in: [https://github.com/EmbeddedRPC/erpc/wiki](https://github.com/EmbeddedRPC/erpc/wiki) + +## Prerequisites -# Prerequisites - Python 3.6+ -# eRPC installation\ -1. run `python setup.py install` in folder `erpc/erpc_python/` +## eRPC installation + +1. run `python setup.py install` in folder [erpc/erpc_python/](/erpc_python) 2. `pip install erpc`: only major eRPC versions are available through pypi -# Example files -- `matrix_multiply.py`: main example file -- `service/erpc_matrix_multiply.erpc`: eRPC IDL file for example -- `service/erpc_matrix_multiply/`: eRPC output shim code generated from IDL file +## Example files + +- [matrix_multiply.py](matrix_multiply.py): main example file +- [service/erpc_matrix_multiply.erpc](service/erpc_matrix_multiply.erpc): eRPC IDL file for example +- [service/erpc_matrix_multiply](service/erpc_matrix_multiply): eRPC output shim code generated from IDL file + +## Running the example -# Running the example -- Run `matrix_multiply.py` with `-s` (or `--server`) parameter to run server -- Run `matrix_multiply.py` with `-c` (or `--client`) parameter to run client +- Run [matrix_multiply.py](matrix_multiply.py) with `-s` (or `--server`) parameter to run server +- Run [matrix_multiply.py](matrix_multiply.py) with `-c` (or `--client`) parameter to run client - Both server and client has to have specified host and port with `-t` (`--host`) and `-p` (`--port`) parameters. By default is host set as localhost and port as 40. -## Example: -``` +### Example + +```bash python matrix_multiply.py --server --host 192.168.1.10 --port 40 python matrix_multiply.py --client --host 192.168.1.10 --port 40 ``` The log below shows the output of the *eRPC Matrix Multiply* example in the terminal window: -``` +```bash $ python matrix_multiply.py --server eRPC Matrix Multiply TCP example Server created on localhost:40 @@ -64,8 +71,9 @@ Result matrix 2055 1290 0680 0721 1848 3147 2226 3742 3531 3585 1147 1988 2731 2047 2535 +``` - +```bash $ python matrix_multiply.py --client eRPC Matrix Multiply TCP example Client connecting to a host on localhost:40 diff --git a/examples/matrix_multiply_tcp_python/service/__init__.py b/examples/matrix_multiply_tcp_python/service/__init__.py index b3fea60e..3fd87830 100644 --- a/examples/matrix_multiply_tcp_python/service/__init__.py +++ b/examples/matrix_multiply_tcp_python/service/__init__.py @@ -5,7 +5,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -# Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. +# Generated by erpcgen 1.13.0 on Thu Apr 18 09:56:46 2024. # # AUTOGENERATED - DO NOT EDIT # diff --git a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/__init__.py b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/__init__.py index 360de229..54db5dbd 100644 --- a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/__init__.py +++ b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/__init__.py @@ -5,7 +5,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -# Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. +# Generated by erpcgen 1.13.0 on Thu Apr 18 09:56:46 2024. # # AUTOGENERATED - DO NOT EDIT # @@ -15,8 +15,8 @@ version = erpc_version.ERPC_VERSION except ImportError: version = "unknown" -if version != "1.12.0": - raise ValueError("The generated shim code version (1.12.0) is different to the rest of eRPC code (%s). \ +if version != "1.13.0": + raise ValueError("The generated shim code version (1.13.0) is different to the rest of eRPC code (%s). \ Install newer version by running \"python setup.py install\" in folder erpc/erpc_python/." % repr(version)) from . import common diff --git a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/client.py b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/client.py index 098618db..1d8ae6f7 100644 --- a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/client.py +++ b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/client.py @@ -5,7 +5,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -# Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. +# Generated by erpcgen 1.13.0 on Thu Apr 18 09:56:46 2024. # # AUTOGENERATED - DO NOT EDIT # diff --git a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/common.py b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/common.py index a4ede601..16e235fb 100644 --- a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/common.py +++ b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/common.py @@ -5,7 +5,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -# Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. +# Generated by erpcgen 1.13.0 on Thu Apr 18 09:56:46 2024. # # AUTOGENERATED - DO NOT EDIT # diff --git a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/interface.py b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/interface.py index b0d25311..04ea34e5 100644 --- a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/interface.py +++ b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/interface.py @@ -5,7 +5,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -# Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. +# Generated by erpcgen 1.13.0 on Thu Apr 18 09:56:46 2024. # # AUTOGENERATED - DO NOT EDIT # diff --git a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/server.py b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/server.py index 7fa1adc6..b8c807de 100644 --- a/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/server.py +++ b/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/server.py @@ -5,7 +5,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -# Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. +# Generated by erpcgen 1.13.0 on Thu Apr 18 09:56:46 2024. # # AUTOGENERATED - DO NOT EDIT # diff --git a/examples/zephyr/matrix_multiply_mbox/CMakeLists.txt b/examples/zephyr/matrix_multiply_mbox/CMakeLists.txt new file mode 100644 index 00000000..d8aed058 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/CMakeLists.txt @@ -0,0 +1,47 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/../remote/zephyr) + +if(("${BOARD}" STREQUAL "mimxrt1170_evkb_cm7") OR + ("${BOARD}" STREQUAL "mimxrt1170_evk_cm7") OR + ("${BOARD}" STREQUAL "mimxrt1160_evk_cm7")) + message(STATUS "${BOARD} compile as Main in this sample") +else() + message(FATAL_ERROR "${BOARD} is not supported for this sample") +endif() + +project(matrix_multiply_mbox) + +enable_language(C CXX) + +if(CONFIG_INCLUDE_REMOTE_DIR) + target_include_directories(zephyr_interface + INTERFACE ${REMOTE_ZEPHYR_DIR}/include/public) +endif() + +target_include_directories(app PRIVATE + ${PROJECT_SOURCE_DIR}/ + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/service +) + +target_sources(app PRIVATE + ${PROJECT_SOURCE_DIR}/src/main.cpp + ${PROJECT_SOURCE_DIR}/src/erpc_error_handler.cpp + + # Generated shim code + ${PROJECT_SOURCE_DIR}/src/service/c_erpc_matrix_multiply_client.cpp + ${PROJECT_SOURCE_DIR}/src/service/erpc_matrix_multiply_client.cpp + ${PROJECT_SOURCE_DIR}/src/service/erpc_matrix_multiply_interface.cpp +) + +# Same for erpc library and erpc_config.h +target_include_directories(erpc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/examples/zephyr/matrix_multiply_mbox/Kconfig b/examples/zephyr/matrix_multiply_mbox/Kconfig new file mode 100644 index 00000000..8f708489 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/Kconfig @@ -0,0 +1,13 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +source "Kconfig.zephyr" + +config INCLUDE_REMOTE_DIR + bool "Include remote core header directory" + help + Include remote build header files. Can be used if primary image + needs to be aware of size or base address of secondary image diff --git a/examples/zephyr/matrix_multiply_mbox/Kconfig.sysbuild b/examples/zephyr/matrix_multiply_mbox/Kconfig.sysbuild new file mode 100644 index 00000000..6ae8dbda --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +source "share/sysbuild/Kconfig" + +config REMOTE_BOARD +string + default "mimxrt1170_evkb_cm4" if $(BOARD) = "mimxrt1170_evkb_cm7" + default "mimxrt1170_evk_cm4" if $(BOARD) = "mimxrt1170_evk_cm7" + default "mimxrt1160_evk_cm4" if $(BOARD) = "mimxrt1160_evk_cm7" diff --git a/examples/zephyr/matrix_multiply_mbox/README.rst b/examples/zephyr/matrix_multiply_mbox/README.rst new file mode 100644 index 00000000..6f06a59a --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/README.rst @@ -0,0 +1,97 @@ +.. _matrix_multiply_mbox: + +Matrix multiply MBOX +########### + +The eRPC Matrix multiply MBOX sample that can be used with: :ref:`supported board `. + + +The Multicore eRPC Matrix Multiply project is a simple demonstration program that uses Zephyr OS and +the Multicore SDK to show how to implement the Remote Procedure Call between cores of the multicore +system. The primary core (eRPC client) releases the secondary core (eRPC server) from the reset and +then the erpcMatrixMultiply() eRPC call is issued to let the secondary core to perform the +multiplication of two randomly generated matrices. The original matrices and the result matrix is +printed out to the serial console by the primary core. MBOX eRPC transport layer is used in +this example application. + +Shared memory usage +This multicore example uses the MBOX for data exchange.The MBOX chanells are defined in `board/.overlay`. + +eRPC documentation +eRPC specific files are stored in: middleware\multicore\erpc +eRPC documentation is stored in: middleware\multicore\erpc\doc +eRPC is open-source project stored on github: https://github.com/EmbeddedRPC/erpc +eRPC documentation can be also found in: http://embeddedrpc.github.io + +Building and Running +******************** + +This application can be built and executed on Supported Multi Core boards as follows: + +Building the application for mimxrt1160_evk_cm7 +*********************************************** + +.. zephyr-app-commands:: + :zephyr-app: samples/matrix_multiply_rpmsglite + :board: mimxrt1160_evk_cm7 + :goals: debug + :west-args: --sysbuild + +Building the application for mimxrt1170_evk_cm7 +*********************************************** + +.. zephyr-app-commands:: + :zephyr-app: samples/matrix_multiply_rpmsglite + :board: mimxrt1170_evk_cm7 + :goals: debug + :west-args: --sysbuild + +Building the application for mimxrt1170_evkb_cm7 +*********************************************** + +.. zephyr-app-commands:: + :zephyr-app: samples/matrix_multiply_rpmsglite + :board: mimxrt1170_evkb_cm7 + :goals: debug + :west-args: --sysbuild + +Sample Output +============= + +Open a serial terminal (minicom, putty, etc.) and connect the board with the +following settings: + +- Speed: 115200 +- Data: 8 bits +- Parity: None +- Stop bits: 1 + +Reset the board and the following message will appear on the corresponding +serial port: + +.. code-block:: console + + Matrix #1 + 21 33 37 37 9 + 23 45 43 0 32 + 38 44 8 15 36 + 18 18 38 44 16 + 22 23 0 38 7 + + Matrix #2 + 11 23 27 45 11 + 7 19 23 24 6 + 32 26 49 43 16 + 22 48 36 34 41 + 27 20 32 31 11 + + eRPC request is sent to the server + + Result matrix + 2703 4028 4759 4865 2637 + 2808 3142 4787 4956 1563 + 2284 3358 4122 4736 1821 + 2940 4176 4858 4868 2894 + 1428 2907 2715 3051 2015 + + ... \ No newline at end of file diff --git a/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1160_evk_cm7.conf b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1160_evk_cm7.conf new file mode 100644 index 00000000..78b67f1f --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1160_evk_cm7.conf @@ -0,0 +1,3 @@ +CONFIG_MBOX_NXP_IMX_MU=y +CONFIG_INCLUDE_REMOTE_DIR=y +CONFIG_SECOND_CORE_MCUX=y \ No newline at end of file diff --git a/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1160_evk_cm7.overlay b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1160_evk_cm7.overlay new file mode 100644 index 00000000..01c6edf4 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1160_evk_cm7.overlay @@ -0,0 +1,29 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + /* Delete ipc chosen property where old IPM mailbox driver bellow is + * configured. + */ + /delete-property/ zephyr,ipc; + }; + + soc { + /* Delete IPM Driver node nxp,imx-mu */ + /delete-node/ mailbox@40c48000; + + /* Attach MBOX driver to MU Unit */ + mbox:mbox@40c48000 { + compatible = "nxp,mbox-imx-mu"; + reg = <0x40c48000 0x4000>; + interrupts = <118 0>; + rx-channels = <4>; + #mbox-cells = <1>; + status = "okay"; + }; + }; +}; \ No newline at end of file diff --git a/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evk_cm7.conf b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evk_cm7.conf new file mode 100644 index 00000000..583b4950 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evk_cm7.conf @@ -0,0 +1,3 @@ +CONFIG_MBOX_NXP_IMX_MU=y +CONFIG_INCLUDE_REMOTE_DIR=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evk_cm7.overlay b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evk_cm7.overlay new file mode 100644 index 00000000..f6388ee7 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evk_cm7.overlay @@ -0,0 +1,29 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + /* Delete ipc chosen property where old IPM mailbox driver bellow is + * configured. + */ + /delete-property/ zephyr,ipc; + }; + + soc { + /* Delete IPM Driver node nxp,imx-mu */ + /delete-node/ mailbox@40c48000; + + /* Attach MBOX driver to MU Unit */ + mbox:mbox@40c48000 { + compatible = "nxp,mbox-imx-mu"; + reg = <0x40c48000 0x4000>; + interrupts = <118 0>; + rx-channels = <4>; + #mbox-cells = <1>; + status = "okay"; + }; + }; +}; diff --git a/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evkb_cm7.conf b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evkb_cm7.conf new file mode 100644 index 00000000..0dfb100e --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evkb_cm7.conf @@ -0,0 +1,3 @@ +CONFIG_MBOX_NXP_IMX_MU=y +CONFIG_SECOND_CORE_MCUX=y +CONFIG_INCLUDE_REMOTE_DIR=y diff --git a/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evkb_cm7.overlay b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evkb_cm7.overlay new file mode 100644 index 00000000..f6388ee7 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/boards/mimxrt1170_evkb_cm7.overlay @@ -0,0 +1,29 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + /* Delete ipc chosen property where old IPM mailbox driver bellow is + * configured. + */ + /delete-property/ zephyr,ipc; + }; + + soc { + /* Delete IPM Driver node nxp,imx-mu */ + /delete-node/ mailbox@40c48000; + + /* Attach MBOX driver to MU Unit */ + mbox:mbox@40c48000 { + compatible = "nxp,mbox-imx-mu"; + reg = <0x40c48000 0x4000>; + interrupts = <118 0>; + rx-channels = <4>; + #mbox-cells = <1>; + status = "okay"; + }; + }; +}; diff --git a/examples/zephyr/matrix_multiply_mbox/erpc_config.h b/examples/zephyr/matrix_multiply_mbox/erpc_config.h new file mode 100644 index 00000000..6076fd48 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/erpc_config.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2021 NXP + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ERPC_CONFIG_H_ +#define _ERPC_CONFIG_H_ + +/*! + * @addtogroup config + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// Declarations +//////////////////////////////////////////////////////////////////////////////// + +//! @name Threading model options +//@{ +#define ERPC_ALLOCATION_POLICY_DYNAMIC (0U) //!< Dynamic allocation policy +#define ERPC_ALLOCATION_POLICY_STATIC (1U) //!< Static allocation policy + +#define ERPC_THREADS_NONE (0U) //!< No threads. +#define ERPC_THREADS_PTHREADS (1U) //!< POSIX pthreads. +#define ERPC_THREADS_FREERTOS (2U) //!< FreeRTOS. +#define ERPC_THREADS_ZEPHYR (3U) //!< ZEPHYR. +#define ERPC_THREADS_MBED (4U) //!< Mbed OS +#define ERPC_THREADS_WIN32 (5U) //!< WIN32 +#define ERPC_THREADS_THREADX (6U) //!< THREADX + +#define ERPC_NOEXCEPT_DISABLED (0U) //!< Disabling noexcept feature. +#define ERPC_NOEXCEPT_ENABLED (1U) //!< Enabling noexcept feature. + +#define ERPC_NESTED_CALLS_DISABLED (0U) //!< No nested calls support. +#define ERPC_NESTED_CALLS_ENABLED (1U) //!< Nested calls support. + +#define ERPC_NESTED_CALLS_DETECTION_DISABLED (0U) //!< Nested calls detection disabled. +#define ERPC_NESTED_CALLS_DETECTION_ENABLED (1U) //!< Nested calls detection enabled. + +#define ERPC_MESSAGE_LOGGING_DISABLED (0U) //!< Trace functions disabled. +#define ERPC_MESSAGE_LOGGING_ENABLED (1U) //!< Trace functions enabled. + +#define ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED (0U) //!< Do not use MCMGR for MU ISR management. +#define ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED (1U) //!< Use MCMGR for MU ISR management. + +#define ERPC_PRE_POST_ACTION_DISABLED (0U) //!< Pre post shim callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_ENABLED (1U) //!< Pre post shim callback functions enabled. + +#define ERPC_PRE_POST_ACTION_DEFAULT_DISABLED (0U) //!< Pre post shim default callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_DEFAULT_ENABLED (1U) //!< Pre post shim default callback functions enabled. +//@} + +//! @name Configuration options +//@{ + +//! @def ERPC_ALLOCATION_POLICY +//! +//! @brief Choose which allocation policy should be used. +//! +//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used. +//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used. +//! +//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is +//! supported by compiler. Uncomment comment bellow to use static allocation policy. In case of static implementation +//! user need consider another values to set (ERPC_CODEC_COUNT, ERPC_MESSAGE_LOGGERS_COUNT, +//! ERPC_CLIENTS_THREADS_AMOUNT). +// #define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC) + +//! @def ERPC_CODEC_COUNT +//! +//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one +//! thread per each then 2, ... Default value 2. +// #define ERPC_CODEC_COUNT (2U) + +//! @def ERPC_MESSAGE_LOGGERS_COUNT +//! +//! @brief Set amount of message loggers objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. +//! For example if client or server is used in one thread then 1. If both are used in one thread per each then 2, ... +//! For arbitrated client 1 is enough. +//! Default value 0 (May not be used). +// #define ERPC_MESSAGE_LOGGERS_COUNT (0U) + +//! @def ERPC_CLIENTS_THREADS_AMOUNT +//! +//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. Default value 1 (Most of current cases). +// #define ERPC_CLIENTS_THREADS_AMOUNT (1U) + +//! @def ERPC_THREADS +//! +//! @brief Select threading model. +//! +//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC. +//! +//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads. +//! FreeRTOS can be detected when building with compilers that support __has_include(). +//! Otherwise, the default is no threading. +#define ERPC_THREADS (ERPC_THREADS_NONE) + +//! @def ERPC_DEFAULT_BUFFER_SIZE +//! +//! Uncomment to change the size of buffers allocated by one of MessageBufferFactory. +//! (@ref client_setup and @ref server_setup). The default size is set to 256. +//! For RPMsg transport layer, ERPC_DEFAULT_BUFFER_SIZE must be 2^n - 16. +#define ERPC_DEFAULT_BUFFER_SIZE (4096U) + +//! @def ERPC_DEFAULT_BUFFERS_COUNT +//! +//! Uncomment to change the count of buffers allocated by one of statically allocated messages. +//! Default value is set to 2. +//#define ERPC_DEFAULT_BUFFERS_COUNT (2U) + +//! @def ERPC_NOEXCEPT +//! +//! @brief Disable/enable noexcept support. +//! +//! Uncomment for using noexcept feature. +//#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED) + +//! @def ERPC_NESTED_CALLS +//! +//! Default set to ERPC_NESTED_CALLS_DISABLED. Uncomment when callbacks, or other eRPC +//! functions are called from server implementation of another eRPC call. Nested functions +//! need to be marked as @nested in IDL. +//#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_ENABLED) + +//! @def ERPC_NESTED_CALLS_DETECTION +//! +//! Default set to ERPC_NESTED_CALLS_DETECTION_ENABLED when NDEBUG macro is presented. +//! This serve for locating nested calls in code. Nested calls are calls where inside eRPC function +//! on server side is called another eRPC function (like callbacks). Code need be a bit changed +//! to support nested calls. See ERPC_NESTED_CALLS macro. +//#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED) + +//! @def ERPC_MESSAGE_LOGGING +//! +//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base +//! printing messages, or sending data to another system for data analysis. Default set to +//! ERPC_MESSAGE_LOGGING_DISABLED. +//! +//! Uncomment for using logging feature. +//#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_ENABLED) + +//! @def ERPC_TRANSPORT_MU_USE_MCMGR +//! +//! @brief MU transport layer configuration. +//! +//! Set to one of the @c ERPC_TRANSPORT_MU_USE_MCMGR_x macros to configure the MCMGR usage in MU transport layer. +//! +//! MU transport layer could leverage the Multicore Manager (MCMGR) component for Inter-Core +//! interrupts / MU interrupts management or the Inter-Core interrupts can be managed by itself (MUX_IRQHandler +//! overloading). By default, ERPC_TRANSPORT_MU_USE_MCMGR is set to ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED when mcmgr.h +//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be +//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget +//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the +//! erpc_mu_transport.h for additional MU settings. +//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED +//@} + +//! @def ERPC_PRE_POST_ACTION +//! +//! Enable eRPC pre and post callback functions shim code. Take look into "erpc_pre_post_action.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DISABLED. +//! +//! Uncomment for using pre post callback feature. +//#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_ENABLED) + +//! @def ERPC_PRE_POST_ACTION_DEFAULT +//! +//! Enable eRPC pre and post default callback functions. Take look into "erpc_setup_extensions.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DEFAULT_DISABLED. +//! +//! Uncomment for using pre post default callback feature. +//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED) + +/*! @} */ +#endif // _ERPC_CONFIG_H_ +//////////////////////////////////////////////////////////////////////////////// +// EOF +//////////////////////////////////////////////////////////////////////////////// diff --git a/examples/zephyr/matrix_multiply_mbox/prj.conf b/examples/zephyr/matrix_multiply_mbox/prj.conf new file mode 100644 index 00000000..c42a45e0 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/prj.conf @@ -0,0 +1,18 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP20=y +CONFIG_NEWLIB_LIBC=y +CONFIG_GLIBCXX_LIBCPP=y + +# Compiler +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_NO_OPTIMIZATIONS=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_MBOX=y + +# MBOX +CONFIG_MBOX=y + diff --git a/examples/zephyr/matrix_multiply_mbox/remote/CMakeLists.txt b/examples/zephyr/matrix_multiply_mbox/remote/CMakeLists.txt new file mode 100644 index 00000000..35d431a0 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/CMakeLists.txt @@ -0,0 +1,45 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +if(("${BOARD}" STREQUAL "mimxrt1170_evkb_cm4") OR + ("${BOARD}" STREQUAL "mimxrt1170_evk_cm4") OR + ("${BOARD}" STREQUAL "mimxrt1160_evk_cm4")) + message(STATUS "${BOARD} compile as remote in this sample") +else() + message(FATAL_ERROR "${BOARD} is not supported for this sample") +endif() + +project(remote) + +message(STATUS "${BOARD} compiles as remote in this sample") + +target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) + +enable_language(C CXX) + +target_include_directories(app PRIVATE + ${PROJECT_SOURCE_DIR}/.. + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/service +) + +target_sources(app PRIVATE + # Main files + ${PROJECT_SOURCE_DIR}/src/main.cpp + ${PROJECT_SOURCE_DIR}/src/erpc_error_handler.cpp + + # Generated shim code + ${PROJECT_SOURCE_DIR}/src/service/c_erpc_matrix_multiply_server.cpp + ${PROJECT_SOURCE_DIR}/src/service/erpc_matrix_multiply_server.cpp + ${PROJECT_SOURCE_DIR}/src/service/erpc_matrix_multiply_interface.cpp +) + +# Same for erpc library and erpc_config.h +target_include_directories(erpc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) \ No newline at end of file diff --git a/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1160_evk_cm4.conf b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1160_evk_cm4.conf new file mode 100644 index 00000000..af787c38 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1160_evk_cm4.conf @@ -0,0 +1,4 @@ +CONFIG_MBOX_NXP_IMX_MU=y +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y \ No newline at end of file diff --git a/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1160_evk_cm4.overlay b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1160_evk_cm4.overlay new file mode 100644 index 00000000..3b0e39f8 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1160_evk_cm4.overlay @@ -0,0 +1,48 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart1; + zephyr,shell-uart = &lpuart1; + + /* Delete ipc chosen property where old IPM mailbox driver bellow is + * configured. + */ + /delete-property/ zephyr,ipc; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + + /* Delete IPM Driver node nxp,imx-mu */ + /delete-node/ mailbox@40c4c000; + + /* Attach MBOX driver to MU Unit */ + mbox:mbox@40c4c000 { + compatible = "nxp,mbox-imx-mu"; + reg = <0x40c4c000 0x4000>; + interrupts = <118 0>; + rx-channels = <4>; + #mbox-cells = <1>; + status = "okay"; + }; + }; +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; \ No newline at end of file diff --git a/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evk_cm4.conf b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evk_cm4.conf new file mode 100644 index 00000000..0d36a72a --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evk_cm4.conf @@ -0,0 +1,4 @@ +CONFIG_MBOX_NXP_IMX_MU=y +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evk_cm4.overlay b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evk_cm4.overlay new file mode 100644 index 00000000..9cf09274 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evk_cm4.overlay @@ -0,0 +1,48 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart1; + zephyr,shell-uart = &lpuart1; + + /* Delete ipc chosen property where old IPM mailbox driver bellow is + * configured. + */ + /delete-property/ zephyr,ipc; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + + /* Delete IPM Driver node nxp,imx-mu */ + /delete-node/ mailbox@40c4c000; + + /* Attach MBOX driver to MU Unit */ + mbox:mbox@40c4c000 { + compatible = "nxp,mbox-imx-mu"; + reg = <0x40c4c000 0x4000>; + interrupts = <118 0>; + rx-channels = <4>; + #mbox-cells = <1>; + status = "okay"; + }; + }; +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; diff --git a/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evkb_cm4.conf b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evkb_cm4.conf new file mode 100644 index 00000000..0d36a72a --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evkb_cm4.conf @@ -0,0 +1,4 @@ +CONFIG_MBOX_NXP_IMX_MU=y +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evkb_cm4.overlay b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evkb_cm4.overlay new file mode 100644 index 00000000..56337d14 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/boards/mimxrt1170_evkb_cm4.overlay @@ -0,0 +1,49 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart1; + zephyr,shell-uart = &lpuart1; + + /* Delete ipc chosen property where old IPM mailbox driver bellow is + * configured. + */ + /delete-property/ zephyr,ipc; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + + /* Delete IPM Driver node nxp,imx-mu */ + /delete-node/ mailbox@40c4c000; + + /* Attach MBOX driver to MU Unit */ + mbox:mbox@40c4c000 { + compatible = "nxp,mbox-imx-mu"; + reg = <0x40c4c000 0x4000>; + interrupts = <118 0>; + rx-channels = <4>; + #mbox-cells = <1>; + status = "okay"; + }; + }; + +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; diff --git a/examples/zephyr/matrix_multiply_mbox/remote/prj.conf b/examples/zephyr/matrix_multiply_mbox/remote/prj.conf new file mode 100644 index 00000000..705181c7 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/prj.conf @@ -0,0 +1,19 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP20=y +CONFIG_NEWLIB_LIBC=y +CONFIG_GLIBCXX_LIBCPP=y + +# Compiler +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_NO_OPTIMIZATIONS=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_MBOX=y + +# MBOX +CONFIG_MBOX=y + +CONFIG_STDOUT_CONSOLE=n diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/erpc_error_handler.cpp b/examples/zephyr/matrix_multiply_mbox/remote/src/erpc_error_handler.cpp new file mode 100644 index 00000000..8be36267 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/erpc_error_handler.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "erpc_error_handler.h" +#include + +//////////////////////////////////////////////////////////////////////////////// +// Variables +//////////////////////////////////////////////////////////////////////////////// + +extern bool g_erpc_error_occurred; +bool g_erpc_error_occurred = false; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +void erpc_error_handler(erpc_status_t err, uint32_t functionID) +{ + switch (err) + { + case kErpcStatus_Fail: + printk("\r\nGeneric failure."); + break; + + case kErpcStatus_InvalidArgument: + printk("\r\nArgument is an invalid value."); + break; + + case kErpcStatus_Timeout: + printk("\r\nOperated timed out."); + break; + + case kErpcStatus_InvalidMessageVersion: + printk("\r\nMessage header contains an unknown version."); + break; + + case kErpcStatus_ExpectedReply: + printk("\r\nExpected a reply message but got another message type."); + break; + + case kErpcStatus_CrcCheckFailed: + printk("\r\nMessage is corrupted."); + break; + + case kErpcStatus_BufferOverrun: + printk("\r\nAttempt to read or write past the end of a buffer."); + break; + + case kErpcStatus_UnknownName: + printk("\r\nCould not find host with given name."); + break; + + case kErpcStatus_ConnectionFailure: + printk("\r\nFailed to connect to host."); + break; + + case kErpcStatus_ConnectionClosed: + printk("\r\nConnected closed by peer."); + break; + + case kErpcStatus_MemoryError: + printk("\r\nMemory allocation error."); + break; + + case kErpcStatus_ServerIsDown: + printk("\r\nServer is stopped."); + break; + + case kErpcStatus_InitFailed: + printk("\r\nTransport layer initialization failed."); + break; + + case kErpcStatus_ReceiveFailed: + printk("\r\nFailed to receive data."); + break; + + case kErpcStatus_SendFailed: + printk("\r\nFailed to send data."); + break; + + /* no error occurred */ + case kErpcStatus_Success: + return; + + /* unhandled error */ + default: + printk("\r\nUnhandled error occurred."); + break; + } + + /* When error occurred on client side. */ + if (functionID != 0) + { + printk("Function id '%u'.", (unsigned int)functionID); + } + printk("\r\n"); + + /* error occurred */ + g_erpc_error_occurred = true; +} diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/erpc_error_handler.h b/examples/zephyr/matrix_multiply_mbox/remote/src/erpc_error_handler.h new file mode 100644 index 00000000..faf32559 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/erpc_error_handler.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2022 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _EMBEDDED_RPC__ERROR_HANDLER_H_ +#define _EMBEDDED_RPC__ERROR_HANDLER_H_ + +#include "erpc_common.h" +#include + +/*! + * @addtogroup error_handler + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// API +//////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +//! @name Error handler +//@{ + +/*! + * @brief This function handles eRPC errors. + * + * This function prints a description of occurred error and sets bool variable g_erpc_error_occurred which is used for + * determining if error occurred in user application on client side. + */ +void erpc_error_handler(erpc_status_t err, uint32_t functionID); + +//@} + +#ifdef __cplusplus +} +#endif + +/*! @} */ +#endif // _EMBEDDED_RPC__ERROR_HANDLER_H_ diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/main.cpp b/examples/zephyr/matrix_multiply_mbox/remote/src/main.cpp new file mode 100644 index 00000000..270ea40b --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/main.cpp @@ -0,0 +1,134 @@ +/* + * Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include + +#include "erpc_server_setup.h" +#include "erpc_mbox_zephyr_transport.hpp" +#include "erpc_error_handler.h" + + +#include "erpc_matrix_multiply_common.h" +#include "c_erpc_matrix_multiply_server.h" + +/******************************************************************************* + * Definitions + ******************************************************************************/ +#define TX_ID (0) +#define RX_ID (1) + +/******************************************************************************* + * Prototypes + ******************************************************************************/ + +/******************************************************************************* + * Code + ******************************************************************************/ + +/*! + * @brief erpcMatrixMultiply function implementation. + * + * This is the implementation of the erpcMatrixMultiply function called by the primary core. + * + * @param matrix1 First matrix + * @param matrix2 Second matrix + * @param result_matrix Result matrix + */ +void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) +{ + int32_t i, j, k; + + /* Clear the result matrix */ + for (i = 0; i < matrix_size; ++i) + { + for (j = 0; j < matrix_size; ++j) + { + result_matrix[i][j] = 0; + } + } + + /* Multiply two matrices */ + for (i = 0; i < matrix_size; ++i) + { + for (j = 0; j < matrix_size; ++j) + { + for (k = 0; k < matrix_size; ++k) + { + result_matrix[i][j] += matrix1[i][k] * matrix2[k][j]; + } + } + } +} + +/*! + * @brief Main function + */ +int main(void) +{ + struct mbox_channel tx_channel; + struct mbox_channel rx_channel; + const struct device *dev; + + erpc_transport_t transport; + erpc_server_t server; + + dev = DEVICE_DT_GET(DT_NODELABEL(mbox)); + printk("REMOTE: MTU %d\n", mbox_mtu_get(dev)); + + + /* MBOX transport layer initialization */ + mbox_init_channel(&tx_channel, dev, TX_ID); + mbox_init_channel(&rx_channel, dev, RX_ID); + + transport = erpc_transport_zephyr_mbox_init((void *)dev, (void *)&tx_channel, (void *)&rx_channel); + + /* MessageBufferFactory initialization */ + erpc_mbf_t message_buffer_factory; + message_buffer_factory = erpc_mbf_dynamic_init(); + + /* eRPC server side initialization */ + server = erpc_server_init(transport, message_buffer_factory); + + /* adding the service to the server */ + erpc_service_t service = create_MatrixMultiplyService_service(); + erpc_add_service_to_server(server, service); + + for (;;) + { + /* process message */ + erpc_status_t status = erpc_server_poll(server); + + /* handle error status */ + if (status != (erpc_status_t)kErpcStatus_Success) + { + /* print error description */ + erpc_error_handler(status, 0); + + /* removing the service from the server */ + erpc_remove_service_from_server(server, service); + destroy_MatrixMultiplyService_service(service); + + /* stop erpc server */ + erpc_server_stop(server); + + /* print error description */ + erpc_server_deinit(server); + + /* exit program loop */ + break; + } + + /* do other tasks */ + int32_t i; + for (i = 0; i < 10000; i++) + { + } + } + for (;;) + { + } +} diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/c_erpc_matrix_multiply_server.cpp b/examples/zephyr/matrix_multiply_mbox/remote/src/service/c_erpc_matrix_multiply_server.cpp new file mode 100644 index 00000000..d65660ce --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/c_erpc_matrix_multiply_server.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#include +#include "c_erpc_matrix_multiply_server.h" +#include "erpc_matrix_multiply_server.hpp" +#include "erpc_manually_constructed.hpp" + +using namespace erpc; +using namespace std; +using namespace erpcShim; + + +class MatrixMultiplyService_server: public MatrixMultiplyService_interface +{ + public: + virtual ~MatrixMultiplyService_server() {}; + + + void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) + { + ::erpcMatrixMultiply(matrix1, matrix2, result_matrix); + } +}; + +ERPC_MANUALLY_CONSTRUCTED_STATIC(MatrixMultiplyService_service, s_MatrixMultiplyService_service); +ERPC_MANUALLY_CONSTRUCTED_STATIC(MatrixMultiplyService_server, s_MatrixMultiplyService_server); + +erpc_service_t create_MatrixMultiplyService_service(void) +{ + erpc_service_t service; + +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + service = new (nothrow) MatrixMultiplyService_service(new (nothrow)MatrixMultiplyService_server()); +#else + if (s_MatrixMultiplyService_service.isUsed()) + { + service = NULL; + } + else + { + s_MatrixMultiplyService_server.construct(); + s_MatrixMultiplyService_service.construct(s_MatrixMultiplyService_server.get()); + service = s_MatrixMultiplyService_service.get(); + } +#endif + + return service; +} + +void destroy_MatrixMultiplyService_service(erpc_service_t service) +{ +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + if (service) + { + delete (MatrixMultiplyService_server *)(((MatrixMultiplyService_service *)service)->getHandler()); + delete (MatrixMultiplyService_service *)service; + } +#else + (void)service; + erpc_assert(service == s_MatrixMultiplyService_service.get()); + s_MatrixMultiplyService_service.destroy(); + s_MatrixMultiplyService_server.destroy(); +#endif +} + diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/c_erpc_matrix_multiply_server.h b/examples/zephyr/matrix_multiply_mbox/remote/src/service/c_erpc_matrix_multiply_server.h new file mode 100644 index 00000000..b7e7815d --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/c_erpc_matrix_multiply_server.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_c_erpc_matrix_multiply_server_h_) +#define _c_erpc_matrix_multiply_server_h_ + +#include "erpc_matrix_multiply_common.h" + +#if defined(__cplusplus) +extern "C" +{ +#endif + +typedef void * erpc_service_t; + +#if !defined(ERPC_FUNCTIONS_DEFINITIONS) +#define ERPC_FUNCTIONS_DEFINITIONS + + +/*! @brief MatrixMultiplyService identifiers */ +enum _MatrixMultiplyService_ids +{ + kMatrixMultiplyService_service_id = 1, + kMatrixMultiplyService_erpcMatrixMultiply_id = 1, +}; + +//! @name MatrixMultiplyService +//@{ +void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix); +//@} + + +#endif // ERPC_FUNCTIONS_DEFINITIONS + +/*! @brief Return MatrixMultiplyService_service service object. */ +erpc_service_t create_MatrixMultiplyService_service(void); + +/*! @brief Destroy MatrixMultiplyService_service service object. */ +void destroy_MatrixMultiplyService_service(erpc_service_t service); + + +#if defined(__cplusplus) +} +#endif + +#endif // _c_erpc_matrix_multiply_server_h_ diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply.erpc b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply.erpc new file mode 100644 index 00000000..bfcece34 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply.erpc @@ -0,0 +1,24 @@ +//Copyright below will be added into all generated files. +/*! + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +program erpc_matrix_multiply + +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +const int32 matrix_size = 5; + +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +type Matrix = int32[matrix_size][matrix_size]; + +interface MatrixMultiplyService { + erpcMatrixMultiply(in Matrix matrix1, in Matrix matrix2, out Matrix result_matrix) -> void +} diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_common.h b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_common.h new file mode 100644 index 00000000..5015f99a --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_common.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_common_h_) +#define _erpc_matrix_multiply_common_h_ + + +#if defined(__cplusplus) +extern "C" +{ +#endif +#include +#include +#include + +#include "erpc_version.h" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +#if !defined(ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY) +#define ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +// Aliases data types declarations +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +typedef int32_t Matrix[5][5]; + +// Constant variable declarations +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +extern const int32_t matrix_size; + +#endif // ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +#if defined(__cplusplus) +} +#endif + +#endif // _erpc_matrix_multiply_common_h_ diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_common.hpp b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_common.hpp new file mode 100644 index 00000000..56efc4ad --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_common.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_common_hpp_) +#define _erpc_matrix_multiply_common_hpp_ + + +#include +#include + +#include "erpc_version.h" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +#if !defined(ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY) +#define ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +// Aliases data types declarations +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +typedef int32_t Matrix[5][5]; + +// Constant variable declarations +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +extern const int32_t matrix_size; + +#endif // ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + + +#endif // _erpc_matrix_multiply_common_hpp_ diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_interface.cpp b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_interface.cpp new file mode 100644 index 00000000..ceb050fe --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_interface.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#include "erpc_matrix_multiply_interface.hpp" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +using namespace std; +using namespace erpcShim; + +MatrixMultiplyService_interface::~MatrixMultiplyService_interface(void) +{ +} diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_interface.hpp b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_interface.hpp new file mode 100644 index 00000000..e4426378 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_interface.hpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_interface_hpp_) +#define _erpc_matrix_multiply_interface_hpp_ + +#include "erpc_matrix_multiply_common.hpp" + +namespace erpcShim +{ + + +// Abstract base class for MatrixMultiplyService +class MatrixMultiplyService_interface +{ + public: + static const uint8_t m_serviceId = 1; + static const uint8_t m_erpcMatrixMultiplyId = 1; + + virtual ~MatrixMultiplyService_interface(void); + + virtual void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) = 0; +private: +}; +} // erpcShim + + +#endif // _erpc_matrix_multiply_interface_hpp_ diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_server.cpp b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_server.cpp new file mode 100644 index 00000000..a190dcfa --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_server.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#include "erpc_matrix_multiply_server.hpp" +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC +#include +#include "erpc_port.h" +#endif +#include "erpc_manually_constructed.hpp" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + +using namespace erpc; +using namespace std; +using namespace erpcShim; + +#if ERPC_NESTED_CALLS_DETECTION +extern bool nestingDetection; +#endif + + + +// Constant variable definitions +#if defined(__MINGW32__) +__declspec( selectany ) +#else +#pragma weak matrix_size +#endif +extern const int32_t matrix_size = 5; + + +MatrixMultiplyService_service::MatrixMultiplyService_service(MatrixMultiplyService_interface *_MatrixMultiplyService_interface) + : erpc::Service(MatrixMultiplyService_interface::m_serviceId) + , m_handler(_MatrixMultiplyService_interface) +{ +} + +MatrixMultiplyService_service::~MatrixMultiplyService_service() +{ +} + +// return service interface handler. +MatrixMultiplyService_interface* MatrixMultiplyService_service::getHandler(void) +{ + return m_handler; +} + +// Call the correct server shim based on method unique ID. +erpc_status_t MatrixMultiplyService_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory, Transport * transport) +{ + erpc_status_t erpcStatus; + switch (methodId) + { + case MatrixMultiplyService_interface::m_erpcMatrixMultiplyId: + { + erpcStatus = erpcMatrixMultiply_shim(codec, messageFactory, transport, sequence); + break; + } + + default: + { + erpcStatus = kErpcStatus_InvalidArgument; + break; + } + } + + return erpcStatus; +} + +// Server shim for erpcMatrixMultiply of MatrixMultiplyService interface. +erpc_status_t MatrixMultiplyService_service::erpcMatrixMultiply_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence) +{ + erpc_status_t err = kErpcStatus_Success; + + Matrix matrix1; + Matrix matrix2; + Matrix result_matrix; + + // startReadMessage() was already called before this shim was invoked. + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->read(matrix1[arrayCount0][arrayCount1]); + } + } + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->read(matrix2[arrayCount0][arrayCount1]); + } + } + + err = codec->getStatus(); + if (err == kErpcStatus_Success) + { + // Invoke the actual served function. +#if ERPC_NESTED_CALLS_DETECTION + nestingDetection = true; +#endif + m_handler->erpcMatrixMultiply(matrix1, matrix2, result_matrix); +#if ERPC_NESTED_CALLS_DETECTION + nestingDetection = false; +#endif + + // preparing MessageBuffer for serializing data + err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize()); + } + + if (err == kErpcStatus_Success) + { + // preparing codec for serializing data + codec->reset(transport->reserveHeaderSize()); + + // Build response message. + codec->startWriteMessage(message_type_t::kReplyMessage, MatrixMultiplyService_interface::m_serviceId, MatrixMultiplyService_interface::m_erpcMatrixMultiplyId, sequence); + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->write(result_matrix[arrayCount0][arrayCount1]); + } + } + + err = codec->getStatus(); + } + + return err; +} diff --git a/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_server.hpp b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_server.hpp new file mode 100644 index 00000000..9a5efd0a --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/remote/src/service/erpc_matrix_multiply_server.hpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_server_hpp_) +#define _erpc_matrix_multiply_server_hpp_ + +#include "erpc_matrix_multiply_interface.hpp" + +#include "erpc_server.hpp" +#include "erpc_codec.hpp" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +namespace erpcShim +{ + +/*! + * @brief Service subclass for MatrixMultiplyService. + */ +class MatrixMultiplyService_service : public erpc::Service +{ +public: + MatrixMultiplyService_service(MatrixMultiplyService_interface *_MatrixMultiplyService_interface); + + virtual ~MatrixMultiplyService_service(); + + /*! @brief return service interface handler. */ + MatrixMultiplyService_interface* getHandler(void); + + /*! @brief Call the correct server shim based on method unique ID. */ + virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport); + +private: + MatrixMultiplyService_interface *m_handler; + /*! @brief Server shim for erpcMatrixMultiply of MatrixMultiplyService interface. */ + erpc_status_t erpcMatrixMultiply_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence); +}; + +} // erpcShim + + +#endif // _erpc_matrix_multiply_server_hpp_ diff --git a/examples/zephyr/matrix_multiply_mbox/sample.yaml b/examples/zephyr/matrix_multiply_mbox/sample.yaml new file mode 100644 index 00000000..10e90eb7 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/sample.yaml @@ -0,0 +1,6 @@ +sample: + description: eRPC Matrix multiplication using MBOX transport layer + name: eRPC MBOX Matrix multiplication +common: + sysbuild: true + tags: mbox diff --git a/examples/zephyr/matrix_multiply_mbox/src/erpc_error_handler.cpp b/examples/zephyr/matrix_multiply_mbox/src/erpc_error_handler.cpp new file mode 100644 index 00000000..8be36267 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/erpc_error_handler.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "erpc_error_handler.h" +#include + +//////////////////////////////////////////////////////////////////////////////// +// Variables +//////////////////////////////////////////////////////////////////////////////// + +extern bool g_erpc_error_occurred; +bool g_erpc_error_occurred = false; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +void erpc_error_handler(erpc_status_t err, uint32_t functionID) +{ + switch (err) + { + case kErpcStatus_Fail: + printk("\r\nGeneric failure."); + break; + + case kErpcStatus_InvalidArgument: + printk("\r\nArgument is an invalid value."); + break; + + case kErpcStatus_Timeout: + printk("\r\nOperated timed out."); + break; + + case kErpcStatus_InvalidMessageVersion: + printk("\r\nMessage header contains an unknown version."); + break; + + case kErpcStatus_ExpectedReply: + printk("\r\nExpected a reply message but got another message type."); + break; + + case kErpcStatus_CrcCheckFailed: + printk("\r\nMessage is corrupted."); + break; + + case kErpcStatus_BufferOverrun: + printk("\r\nAttempt to read or write past the end of a buffer."); + break; + + case kErpcStatus_UnknownName: + printk("\r\nCould not find host with given name."); + break; + + case kErpcStatus_ConnectionFailure: + printk("\r\nFailed to connect to host."); + break; + + case kErpcStatus_ConnectionClosed: + printk("\r\nConnected closed by peer."); + break; + + case kErpcStatus_MemoryError: + printk("\r\nMemory allocation error."); + break; + + case kErpcStatus_ServerIsDown: + printk("\r\nServer is stopped."); + break; + + case kErpcStatus_InitFailed: + printk("\r\nTransport layer initialization failed."); + break; + + case kErpcStatus_ReceiveFailed: + printk("\r\nFailed to receive data."); + break; + + case kErpcStatus_SendFailed: + printk("\r\nFailed to send data."); + break; + + /* no error occurred */ + case kErpcStatus_Success: + return; + + /* unhandled error */ + default: + printk("\r\nUnhandled error occurred."); + break; + } + + /* When error occurred on client side. */ + if (functionID != 0) + { + printk("Function id '%u'.", (unsigned int)functionID); + } + printk("\r\n"); + + /* error occurred */ + g_erpc_error_occurred = true; +} diff --git a/examples/zephyr/matrix_multiply_mbox/src/erpc_error_handler.h b/examples/zephyr/matrix_multiply_mbox/src/erpc_error_handler.h new file mode 100644 index 00000000..faf32559 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/erpc_error_handler.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2022 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _EMBEDDED_RPC__ERROR_HANDLER_H_ +#define _EMBEDDED_RPC__ERROR_HANDLER_H_ + +#include "erpc_common.h" +#include + +/*! + * @addtogroup error_handler + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// API +//////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +//! @name Error handler +//@{ + +/*! + * @brief This function handles eRPC errors. + * + * This function prints a description of occurred error and sets bool variable g_erpc_error_occurred which is used for + * determining if error occurred in user application on client side. + */ +void erpc_error_handler(erpc_status_t err, uint32_t functionID); + +//@} + +#ifdef __cplusplus +} +#endif + +/*! @} */ +#endif // _EMBEDDED_RPC__ERROR_HANDLER_H_ diff --git a/examples/zephyr/matrix_multiply_mbox/src/main.cpp b/examples/zephyr/matrix_multiply_mbox/src/main.cpp new file mode 100644 index 00000000..4c267d46 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/main.cpp @@ -0,0 +1,152 @@ +/* + * Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include +#include + +#include "erpc_client_setup.h" +#include "erpc_mbox_zephyr_transport.hpp" +#include "erpc_error_handler.h" + +#include "c_erpc_matrix_multiply_client.h" +#include "erpc_matrix_multiply_common.h" + + + +/******************************************************************************* + * Definitions + ******************************************************************************/ +#define MATRIX_ITEM_MAX_VALUE (50) +#define APP_ERPC_READY_EVENT_DATA (1U) + +#define TX_ID (1) +#define RX_ID (0) + +/******************************************************************************* + * Variables + ******************************************************************************/ +extern bool g_erpc_error_occurred; + +/******************************************************************************* + * Prototypes + ******************************************************************************/ + +/******************************************************************************* + * Code + ******************************************************************************/ + +/*! + * @brief Fill matrices by random values + */ +static void fill_matrices(Matrix matrix1_ptr, Matrix matrix2_ptr) +{ + int32_t a, b; + + /* Fill both matrices by random values */ + for (a = 0; a < matrix_size; ++a) + { + for (b = 0; b < matrix_size; ++b) + { + matrix1_ptr[a][b] = rand() % MATRIX_ITEM_MAX_VALUE; + matrix2_ptr[a][b] = rand() % MATRIX_ITEM_MAX_VALUE; + } + } +} + +/*! + * @brief Printing a matrix to the console + */ +static void print_matrix(Matrix matrix_ptr) +{ + int32_t a, b; + + for (a = 0; a < matrix_size; ++a) + { + for (b = 0; b < matrix_size; ++b) + { + printk("%4i ", matrix_ptr[a][b]); + } + printk("\r\n"); + } +} + +int main(void) +{ + struct mbox_channel tx_channel; + struct mbox_channel rx_channel; + const struct device *dev; + + erpc_transport_t transport; + erpc_client_t client; + + Matrix matrix1 = { 0 }, matrix2 = { 0 }, result_matrix = { 0 }; + + dev = DEVICE_DT_GET(DT_NODELABEL(mbox)); + + /* MBOX transport layer initialization */ + + mbox_init_channel(&tx_channel, dev, TX_ID); + mbox_init_channel(&rx_channel, dev, RX_ID); + + transport = erpc_transport_zephyr_mbox_init((void *)dev, (void *)&tx_channel, (void *)&rx_channel); + + /* MessageBufferFactory initialization */ + erpc_mbf_t message_buffer_factory; + message_buffer_factory = erpc_mbf_dynamic_init(); + + /* eRPC client side initialization */ + client = erpc_client_init(transport, message_buffer_factory); + initMatrixMultiplyService_client(client); + + /* Set default error handler */ + erpc_client_set_error_handler(client, erpc_error_handler); + + /* Fill both matrices by random values */ + fill_matrices(matrix1, matrix2); + + /* Print both matrices on the console */ + printk("\r\nMatrix #1"); + printk("\r\n=========\r\n"); + print_matrix(matrix1); + + printk("\r\nMatrix #2"); + printk("\r\n=========\r\n"); + print_matrix(matrix2); + + for (;;) + { + printk("\r\neRPC request is sent to the server\r\n"); + + erpcMatrixMultiply(matrix1, matrix2, result_matrix); + + /* Check if some error occurred in eRPC */ + if (g_erpc_error_occurred) + { + /* Exit program loop */ + break; + } + + printk("\r\nResult matrix"); + printk("\r\n=============\r\n"); + print_matrix(result_matrix); + + k_sleep(K_MSEC(1000)); + + /* Fill both matrices by random values */ + fill_matrices(matrix1, matrix2); + + /* Print both matrices on the console */ + printk("\r\nMatrix #1"); + printk("\r\n=========\r\n"); + print_matrix(matrix1); + + printk("\r\nMatrix #2"); + printk("\r\n=========\r\n"); + print_matrix(matrix2); + } + for (;;) + { + } +} diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/c_erpc_matrix_multiply_client.cpp b/examples/zephyr/matrix_multiply_mbox/src/service/c_erpc_matrix_multiply_client.cpp new file mode 100644 index 00000000..a20696f5 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/c_erpc_matrix_multiply_client.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#include "c_erpc_matrix_multiply_client.h" +#include "erpc_matrix_multiply_client.hpp" +#include "erpc_manually_constructed.hpp" + +using namespace erpc; +using namespace std; +using namespace erpcShim; + + +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC +MatrixMultiplyService_client *s_MatrixMultiplyService_client = nullptr; +#else +ERPC_MANUALLY_CONSTRUCTED_STATIC(MatrixMultiplyService_client, s_MatrixMultiplyService_client); +#endif + +void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) +{ + s_MatrixMultiplyService_client->erpcMatrixMultiply(matrix1, matrix2, result_matrix); +} + +void initMatrixMultiplyService_client(erpc_client_t client) +{ +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + erpc_assert(s_MatrixMultiplyService_client == nullptr); + s_MatrixMultiplyService_client = new MatrixMultiplyService_client(reinterpret_cast(client)); +#else + erpc_assert(!s_MatrixMultiplyService_client.isUsed()); + s_MatrixMultiplyService_client.construct(reinterpret_cast(client)); +#endif +} + +void deinitMatrixMultiplyService_client(void) +{ +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + if (s_MatrixMultiplyService_client != nullptr) + { + delete s_MatrixMultiplyService_client; + s_MatrixMultiplyService_client = nullptr; + } +#else + s_MatrixMultiplyService_client.destroy(); +#endif +} diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/c_erpc_matrix_multiply_client.h b/examples/zephyr/matrix_multiply_mbox/src/service/c_erpc_matrix_multiply_client.h new file mode 100644 index 00000000..7fc9a163 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/c_erpc_matrix_multiply_client.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_c_erpc_matrix_multiply_client_h_) +#define _c_erpc_matrix_multiply_client_h_ + +#include "erpc_matrix_multiply_common.h" +#include "erpc_client_manager.h" + +#if defined(__cplusplus) +extern "C" +{ +#endif + +#if !defined(ERPC_FUNCTIONS_DEFINITIONS) +#define ERPC_FUNCTIONS_DEFINITIONS + + +/*! @brief MatrixMultiplyService identifiers */ +enum _MatrixMultiplyService_ids +{ + kMatrixMultiplyService_service_id = 1, + kMatrixMultiplyService_erpcMatrixMultiply_id = 1, +}; + +//! @name MatrixMultiplyService +//@{ +void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix); +//@} + +#endif // ERPC_FUNCTIONS_DEFINITIONS + +void initMatrixMultiplyService_client(erpc_client_t client); + +void deinitMatrixMultiplyService_client(void); + +#if defined(__cplusplus) +} +#endif + +#endif // _c_erpc_matrix_multiply_client_h_ diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply.erpc b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply.erpc new file mode 100644 index 00000000..bfcece34 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply.erpc @@ -0,0 +1,24 @@ +//Copyright below will be added into all generated files. +/*! + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +program erpc_matrix_multiply + +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +const int32 matrix_size = 5; + +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +type Matrix = int32[matrix_size][matrix_size]; + +interface MatrixMultiplyService { + erpcMatrixMultiply(in Matrix matrix1, in Matrix matrix2, out Matrix result_matrix) -> void +} diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_client.cpp b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_client.cpp new file mode 100644 index 00000000..bc890132 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_client.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC +#include "erpc_port.h" +#endif +#include "erpc_codec.hpp" +#include "erpc_matrix_multiply_client.hpp" +#include "erpc_manually_constructed.hpp" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + +using namespace erpc; +using namespace std; +using namespace erpcShim; + + +// Constant variable definitions +#if defined(__MINGW32__) +__declspec( selectany ) +#else +#pragma weak matrix_size +#endif +extern const int32_t matrix_size = 5; + + + +MatrixMultiplyService_client::MatrixMultiplyService_client(ClientManager *manager) +:m_clientManager(manager) +{ +} + +MatrixMultiplyService_client::~MatrixMultiplyService_client() +{ +} + +// MatrixMultiplyService interface erpcMatrixMultiply function client shim. +void MatrixMultiplyService_client::erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) +{ + erpc_status_t err = kErpcStatus_Success; + + +#if ERPC_PRE_POST_ACTION + pre_post_action_cb preCB = m_clientManager->getPreCB(); + if (preCB) + { + preCB(); + } +#endif + + // Get a new request. + RequestContext request = m_clientManager->createRequest(false); + + // Encode the request. + Codec * codec = request.getCodec(); + + if (codec == NULL) + { + err = kErpcStatus_MemoryError; + } + else + { + codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_erpcMatrixMultiplyId, request.getSequence()); + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->write(matrix1[arrayCount0][arrayCount1]); + } + } + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->write(matrix2[arrayCount0][arrayCount1]); + } + } + + // Send message to server + // Codec status is checked inside this function. + m_clientManager->performRequest(request); + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->read(result_matrix[arrayCount0][arrayCount1]); + } + } + + err = codec->getStatus(); + } + + // Dispose of the request. + m_clientManager->releaseRequest(request); + + // Invoke error handler callback function + m_clientManager->callErrorHandler(err, m_erpcMatrixMultiplyId); + +#if ERPC_PRE_POST_ACTION + pre_post_action_cb postCB = m_clientManager->getPostCB(); + if (postCB) + { + postCB(); + } +#endif + + + return; +} diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_client.hpp b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_client.hpp new file mode 100644 index 00000000..9f9b7bb5 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_client.hpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_client_hpp_) +#define _erpc_matrix_multiply_client_hpp_ + +#include "erpc_matrix_multiply_interface.hpp" + +#include "erpc_client_manager.h" + +namespace erpcShim +{ + +class MatrixMultiplyService_client: public MatrixMultiplyService_interface +{ + public: + MatrixMultiplyService_client(erpc::ClientManager *manager); + + virtual ~MatrixMultiplyService_client(); + + virtual void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix); + + protected: + erpc::ClientManager *m_clientManager; +}; + +} // erpcShim + + +#endif // _erpc_matrix_multiply_client_hpp_ diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_common.h b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_common.h new file mode 100644 index 00000000..5015f99a --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_common.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_common_h_) +#define _erpc_matrix_multiply_common_h_ + + +#if defined(__cplusplus) +extern "C" +{ +#endif +#include +#include +#include + +#include "erpc_version.h" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +#if !defined(ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY) +#define ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +// Aliases data types declarations +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +typedef int32_t Matrix[5][5]; + +// Constant variable declarations +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +extern const int32_t matrix_size; + +#endif // ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +#if defined(__cplusplus) +} +#endif + +#endif // _erpc_matrix_multiply_common_h_ diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_common.hpp b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_common.hpp new file mode 100644 index 00000000..56efc4ad --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_common.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_common_hpp_) +#define _erpc_matrix_multiply_common_hpp_ + + +#include +#include + +#include "erpc_version.h" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +#if !defined(ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY) +#define ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +// Aliases data types declarations +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +typedef int32_t Matrix[5][5]; + +// Constant variable declarations +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +extern const int32_t matrix_size; + +#endif // ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + + +#endif // _erpc_matrix_multiply_common_hpp_ diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_interface.cpp b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_interface.cpp new file mode 100644 index 00000000..ceb050fe --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_interface.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#include "erpc_matrix_multiply_interface.hpp" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +using namespace std; +using namespace erpcShim; + +MatrixMultiplyService_interface::~MatrixMultiplyService_interface(void) +{ +} diff --git a/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_interface.hpp b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_interface.hpp new file mode 100644 index 00000000..e4426378 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/src/service/erpc_matrix_multiply_interface.hpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_interface_hpp_) +#define _erpc_matrix_multiply_interface_hpp_ + +#include "erpc_matrix_multiply_common.hpp" + +namespace erpcShim +{ + + +// Abstract base class for MatrixMultiplyService +class MatrixMultiplyService_interface +{ + public: + static const uint8_t m_serviceId = 1; + static const uint8_t m_erpcMatrixMultiplyId = 1; + + virtual ~MatrixMultiplyService_interface(void); + + virtual void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) = 0; +private: +}; +} // erpcShim + + +#endif // _erpc_matrix_multiply_interface_hpp_ diff --git a/examples/zephyr/matrix_multiply_mbox/sysbuild.cmake b/examples/zephyr/matrix_multiply_mbox/sysbuild.cmake new file mode 100644 index 00000000..f6fb8146 --- /dev/null +++ b/examples/zephyr/matrix_multiply_mbox/sysbuild.cmake @@ -0,0 +1,34 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +if("${SB_CONFIG_REMOTE_BOARD}" STREQUAL "") + message(FATAL_ERROR + "Target ${BOARD} not supported for this sample. " + "There is no remote board selected in Kconfig.sysbuild") +endif() + +set(REMOTE_APP remote) + +ExternalZephyrProject_Add( + APPLICATION ${REMOTE_APP} + SOURCE_DIR ${APP_DIR}/${REMOTE_APP} + BOARD ${SB_CONFIG_REMOTE_BOARD} +) + +native_simulator_set_child_images(${DEFAULT_IMAGE} ${REMOTE_APP}) + +native_simulator_set_final_executable(${DEFAULT_IMAGE}) + +if ("${BOARD}" STREQUAL "mimxrt1170_evkb_cm7" OR + "${BOARD}" STREQUAL "mimxrt1170_evk_cm7" OR + "${BOARD}" STREQUAL "mimxrt1160_evk_cm7" + ) + # For these NXP boards the main core application is dependent on + # 'zephyr_image_info.h' generated by remote application. + + # Let's build the remote application first + add_dependencies(${DEFAULT_IMAGE} ${REMOTE_APP}) +endif() \ No newline at end of file diff --git a/examples/zephyr/matrix_multiply_rpmsglite/CMakeLists.txt b/examples/zephyr/matrix_multiply_rpmsglite/CMakeLists.txt index ef3edcef..62b2971f 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/CMakeLists.txt +++ b/examples/zephyr/matrix_multiply_rpmsglite/CMakeLists.txt @@ -1,4 +1,8 @@ -# SPDX-License-Identifier: Apache-2.0 +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# cmake_minimum_required(VERSION 3.20.0) diff --git a/examples/zephyr/matrix_multiply_rpmsglite/Kconfig b/examples/zephyr/matrix_multiply_rpmsglite/Kconfig index 3837c49b..8f708489 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/Kconfig +++ b/examples/zephyr/matrix_multiply_rpmsglite/Kconfig @@ -1,6 +1,8 @@ -# Copyright 2023 NXP # -# SPDX-License-Identifier: Apache-2.0 +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# source "Kconfig.zephyr" diff --git a/examples/zephyr/matrix_multiply_rpmsglite/Kconfig.sysbuild b/examples/zephyr/matrix_multiply_rpmsglite/Kconfig.sysbuild index 0ff689dd..150379c2 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/Kconfig.sysbuild +++ b/examples/zephyr/matrix_multiply_rpmsglite/Kconfig.sysbuild @@ -1,6 +1,8 @@ -# Copyright 2023 NXP # -# SPDX-License-Identifier: Apache-2.0 +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# source "share/sysbuild/Kconfig" diff --git a/examples/zephyr/matrix_multiply_rpmsglite/boards/lpcxpresso54114_m4.overlay b/examples/zephyr/matrix_multiply_rpmsglite/boards/lpcxpresso54114_m4.overlay index e061dcc4..9b1024d6 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/boards/lpcxpresso54114_m4.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/boards/lpcxpresso54114_m4.overlay @@ -1,8 +1,7 @@ /* - * Copyright (c) 2019 Linaro Limited - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ / { diff --git a/examples/zephyr/matrix_multiply_rpmsglite/boards/lpcxpresso55s69_cpu0.overlay b/examples/zephyr/matrix_multiply_rpmsglite/boards/lpcxpresso55s69_cpu0.overlay index 270eb0e7..c0696468 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/boards/lpcxpresso55s69_cpu0.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/boards/lpcxpresso55s69_cpu0.overlay @@ -1,8 +1,7 @@ /* - * Copyright (c) 2019 Linaro Limited - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ / { diff --git a/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1160_evk_cm7.overlay b/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1160_evk_cm7.overlay index 584538a1..3bf2b0dc 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1160_evk_cm7.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1160_evk_cm7.overlay @@ -1,7 +1,7 @@ /* - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evk_cm7.overlay b/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evk_cm7.overlay index 584538a1..3bf2b0dc 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evk_cm7.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evk_cm7.overlay @@ -1,7 +1,7 @@ /* - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evkb_cm7.conf b/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evkb_cm7.conf index ae8dba8c..630a1933 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evkb_cm7.conf +++ b/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evkb_cm7.conf @@ -1,7 +1,2 @@ -# -# Copyright 2023, NXP -# -# SPDX-License-Identifier: Apache-2.0 -# CONFIG_INCLUDE_REMOTE_DIR=y CONFIG_SECOND_CORE_MCUX=y diff --git a/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evkb_cm7.overlay b/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evkb_cm7.overlay index 584538a1..3bf2b0dc 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evkb_cm7.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/boards/mimxrt1170_evkb_cm7.overlay @@ -1,7 +1,7 @@ /* - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/CMakeLists.txt b/examples/zephyr/matrix_multiply_rpmsglite/remote/CMakeLists.txt index 16ed61d7..6793ca58 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/CMakeLists.txt +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/CMakeLists.txt @@ -1,4 +1,8 @@ -# SPDX-License-Identifier: Apache-2.0 +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# cmake_minimum_required(VERSION 3.20.0) diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/lpcxpresso54114_m0.overlay b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/lpcxpresso54114_m0.overlay index e061dcc4..9b1024d6 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/lpcxpresso54114_m0.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/lpcxpresso54114_m0.overlay @@ -1,8 +1,7 @@ /* - * Copyright (c) 2019 Linaro Limited - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ / { diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/lpcxpresso55s69_cpu1.overlay b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/lpcxpresso55s69_cpu1.overlay index 270eb0e7..c0696468 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/lpcxpresso55s69_cpu1.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/lpcxpresso55s69_cpu1.overlay @@ -1,8 +1,7 @@ /* - * Copyright (c) 2019 Linaro Limited - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ / { diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1160_evk_cm4.overlay b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1160_evk_cm4.overlay index 83589d7e..ab57a613 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1160_evk_cm4.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1160_evk_cm4.overlay @@ -1,7 +1,7 @@ /* - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evk_cm4.overlay b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evk_cm4.overlay index 83589d7e..ab57a613 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evk_cm4.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evk_cm4.overlay @@ -1,7 +1,7 @@ /* - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evkb_cm4.conf b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evkb_cm4.conf index 7b43b448..4dfc4a60 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evkb_cm4.conf +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evkb_cm4.conf @@ -1,8 +1,3 @@ -# -# Copyright 2023, NXP -# -# SPDX-License-Identifier: Apache-2.0 -# CONFIG_BUILD_OUTPUT_INFO_HEADER=y CONFIG_BUILD_OUTPUT_HEX=y CONFIG_SECOND_CORE_MCUX=y diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evkb_cm4.overlay b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evkb_cm4.overlay index b9c0439c..65fb71ff 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evkb_cm4.overlay +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/boards/mimxrt1170_evkb_cm4.overlay @@ -1,7 +1,7 @@ /* - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/c_erpc_matrix_multiply_server.cpp b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/c_erpc_matrix_multiply_server.cpp index afb98cb3..d65660ce 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/c_erpc_matrix_multiply_server.cpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/c_erpc_matrix_multiply_server.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/c_erpc_matrix_multiply_server.h b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/c_erpc_matrix_multiply_server.h index d312e8d3..b7e7815d 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/c_erpc_matrix_multiply_server.h +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/c_erpc_matrix_multiply_server.h @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_common.h b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_common.h index fdbd0c7a..5015f99a 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_common.h +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_common.h @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -27,7 +27,7 @@ extern "C" #include "erpc_version.h" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_common.hpp b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_common.hpp index d1b16374..56efc4ad 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_common.hpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_common.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -17,13 +17,12 @@ #define _erpc_matrix_multiply_common_hpp_ -#include #include #include #include "erpc_version.h" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_interface.cpp b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_interface.cpp index e50f033c..ceb050fe 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_interface.cpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_interface.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -15,7 +15,7 @@ #include "erpc_matrix_multiply_interface.hpp" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_interface.hpp b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_interface.hpp index b2be5a90..e4426378 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_interface.hpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_interface.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_server.cpp b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_server.cpp index d6c97a33..a190dcfa 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_server.cpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_server.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -20,7 +20,7 @@ #endif #include "erpc_manually_constructed.hpp" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_server.hpp b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_server.hpp index ad1f17f2..9a5efd0a 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_server.hpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/remote/src/service/erpc_matrix_multiply_server.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -21,7 +21,7 @@ #include "erpc_server.hpp" #include "erpc_codec.hpp" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/src/service/c_erpc_matrix_multiply_client.cpp b/examples/zephyr/matrix_multiply_rpmsglite/src/service/c_erpc_matrix_multiply_client.cpp index af77c961..a20696f5 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/src/service/c_erpc_matrix_multiply_client.cpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/src/service/c_erpc_matrix_multiply_client.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_rpmsglite/src/service/c_erpc_matrix_multiply_client.h b/examples/zephyr/matrix_multiply_rpmsglite/src/service/c_erpc_matrix_multiply_client.h index 8966a5c4..7fc9a163 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/src/service/c_erpc_matrix_multiply_client.h +++ b/examples/zephyr/matrix_multiply_rpmsglite/src/service/c_erpc_matrix_multiply_client.h @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_client.cpp b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_client.cpp index 329c4b43..bc890132 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_client.cpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_client.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -20,7 +20,7 @@ #include "erpc_matrix_multiply_client.hpp" #include "erpc_manually_constructed.hpp" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_client.hpp b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_client.hpp index b8b81101..9f9b7bb5 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_client.hpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_client.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_common.h b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_common.h index fdbd0c7a..5015f99a 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_common.h +++ b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_common.h @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -27,7 +27,7 @@ extern "C" #include "erpc_version.h" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_common.hpp b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_common.hpp index d1b16374..56efc4ad 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_common.hpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_common.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -17,13 +17,12 @@ #define _erpc_matrix_multiply_common_hpp_ -#include #include #include #include "erpc_version.h" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_interface.cpp b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_interface.cpp index e50f033c..ceb050fe 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_interface.cpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_interface.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -15,7 +15,7 @@ #include "erpc_matrix_multiply_interface.hpp" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_interface.hpp b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_interface.hpp index b2be5a90..e4426378 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_interface.hpp +++ b/examples/zephyr/matrix_multiply_rpmsglite/src/service/erpc_matrix_multiply_interface.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:39 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_rpmsglite/sysbuild.cmake b/examples/zephyr/matrix_multiply_rpmsglite/sysbuild.cmake index 255b8358..573177b7 100644 --- a/examples/zephyr/matrix_multiply_rpmsglite/sysbuild.cmake +++ b/examples/zephyr/matrix_multiply_rpmsglite/sysbuild.cmake @@ -1,6 +1,8 @@ -# Copyright 2023 NXP # -# SPDX-License-Identifier: Apache-2.0 +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# # Add external project ExternalZephyrProject_Add( diff --git a/examples/zephyr/matrix_multiply_tcp/CMakeLists.txt b/examples/zephyr/matrix_multiply_tcp/CMakeLists.txt new file mode 100644 index 00000000..87eb5813 --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/CMakeLists.txt @@ -0,0 +1,24 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(erpc_matrix_multiply_example C CXX) + +target_sources(app PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/erpc_error_handler.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/service/c_erpc_matrix_multiply_server.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/service/erpc_matrix_multiply_interface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/service/erpc_matrix_multiply_server.cpp + ) + +target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) +target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/service) + +target_include_directories(erpc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) diff --git a/examples/zephyr/matrix_multiply_tcp/README.rst b/examples/zephyr/matrix_multiply_tcp/README.rst new file mode 100644 index 00000000..749b7afe --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/README.rst @@ -0,0 +1,115 @@ +.. _matrix_multiply_tcp: + +Matrix multiply TCP +################### + +This example demonstrates usage of eRPC between PC and board using the Zephyr OS and the TCP +transport layer. Board acts like a server and the PC as client. When client starts, it generates +two random matrixes and sends them to server. Server then performs matrix multiplication and sends +result data back to client. Result matrix is then printed on the PC side. + +eRPC documentation +eRPC specific files are stored in: middleware\\multicore\\erpc +eRPC documentation is stored in: middleware\\multicore\\erpc\\doc +eRPC is open-source project stored on github: https://github.com/EmbeddedRPC/erpc +eRPC documentation can be also found in: http://embeddedrpc.github.io + +PC Side Setup (Python) +********************** + +1. Make sure you have Python installed on your PC +2. Install serial module by executing following command in command line: "python -m pip install pyserial" +3. Install eRPC module to Python by executing setup.py located in: middleware\\multicore\\erpc\\erpc_python - "python setup.py install" + +Run erpc\\examples\\matrix_multiply_tcp_python\\matrix_multiply.py as client + +usage: matrix_multiply.py [-h] [-c] [-s] [-t HOST] [-p PORT] [-S SERIAL] [-B BAUD] + +eRPC Matrix Multiply example + +options: + -h, --help show this help message and exit + -c, --client Run client + -s, --server Run server + -t HOST, --host HOST Host IP address (default value is localhost) + -p PORT, --port PORT Port (default value is 40) + -S SERIAL, --serial SERIAL + Serial device (default value is None) + -B BAUD, --baud BAUD Baud (default value is 115200) + +Example: +======== +To run PC side as a client with a board connected as a server to COM3 execute: + +.. code-block:: bash + + matrix_multiply.py --client --host 192.0.2.1 --port 12345 + + +Building and Running +******************** + +This application can be built and executed as follows: + + +Building the application for mimxrt1060_evk +******************************************* + +.. zephyr-app-commands:: + :zephyr-app: samples/matrix_multiply_tcp + :board: mimxrt1060_evk + :goals: debug + +Building the application for mimxrt1160_evk_cm7 +*********************************************** + +.. zephyr-app-commands:: + :zephyr-app: samples/matrix_multiply_uart + :board: mimxrt1160_evk_cm7 + :goals: debug + +Sample Output +============= + +Open a serial terminal (minicom, putty, etc.) and connect the board with the +following settings: + +- Speed: 115200 +- Data: 8 bits +- Parity: None +- Stop bits: 1 + +Reset the board and the following message will appear on the corresponding +serial port: + +.. code-block:: console + + eRPC Matrix Multiply TCP example + Transport: serial=COM14 baudrate=115200 + Matrix #1 + ========= + 8 2 1 3 1 + 9 4 7 6 0 + 3 8 5 9 8 + 2 8 7 3 7 + 7 8 3 6 3 + + Matrix #1 + ========= + 1 9 5 7 8 + 2 4 8 3 9 + 9 1 8 3 0 + 7 6 3 4 2 + 4 4 8 7 8 + + eRPC request is sent to the server + + Matrix result + ========= + 46 103 81 84 96 + 122 140 151 120 120 + 159 150 210 152 178 + 130 103 195 120 150 + 104 146 165 127 164 + + Press Enter to initiate the next matrix multiplication or 'q' to quit diff --git a/examples/zephyr/matrix_multiply_tcp/prj.conf b/examples/zephyr/matrix_multiply_tcp/prj.conf new file mode 100644 index 00000000..c0cb6aef --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/prj.conf @@ -0,0 +1,56 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP20=y +CONFIG_GLIBCXX_LIBCPP=y +CONFIG_NEWLIB_LIBC=y + +# POSIX +CONFIG_POSIX_API=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_TCP=y + +# Networking config +CONFIG_NETWORKING=y +CONFIG_NET_TCP=y +CONFIG_NET_SOCKETS=y + +# Network address config +CONFIG_NET_CONFIG_SETTINGS=y +CONFIG_NET_CONFIG_NEED_IPV4=y +CONFIG_NET_CONFIG_NEED_IPV6=n +CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1" + +# Threads +CONFIG_THREAD_CUSTOM_DATA=y +CONFIG_DYNAMIC_THREAD=y +CONFIG_DYNAMIC_THREAD_POOL_SIZE=1 +CONFIG_DYNAMIC_THREAD_STACK_SIZE=8192 + +# Compiler +CONFIG_HEAP_MEM_POOL_SIZE=16384 + +#CONFIG_NO_OPTIMIZATIONS=y + +# reguired only if CONFIG_NO_OPTIMIZATIONS is enabled +#CONFIG_MAIN_STACK_SIZE=16384 +#CONFIG_ISR_STACK_SIZE=4096 +#CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192 +#CONFIG_NET_MGMT_EVENT_STACK_SIZE=4096 +#CONFIG_NET_TCP_WORKQ_STACK_SIZE=1024 + +# does not work - eth_mcux.c:90 +CONFIG_NET_RX_STACK_SIZE=16384 + +# Debug +#CONFIG_LOG=y +#CONFIG_LOG_MODE_IMMEDIATE=y +#CONFIG_LOG_OVERRIDE_LEVEL=3 +#CONFIG_NET_LOG=y + +#CONFIG_THREAD_ANALYZER=y +#CONFIG_THREAD_ANALYZER_USE_PRINTK=y +#CONFIG_THREAD_ANALYZER_AUTO=y +#CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5 +#CONFIG_THREAD_NAME=y diff --git a/examples/zephyr/matrix_multiply_tcp/sample.yaml b/examples/zephyr/matrix_multiply_tcp/sample.yaml new file mode 100644 index 00000000..49859405 --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/sample.yaml @@ -0,0 +1,3 @@ +sample: + description: eRPC TCP Matrix multiplication + name: eRPC Matrix TCP multiplication diff --git a/examples/zephyr/matrix_multiply_tcp/src/erpc_config.h b/examples/zephyr/matrix_multiply_tcp/src/erpc_config.h new file mode 100644 index 00000000..3f03735a --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/erpc_config.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2021 NXP + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ERPC_CONFIG_H_ +#define _ERPC_CONFIG_H_ + +/*! + * @addtogroup config + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// Declarations +//////////////////////////////////////////////////////////////////////////////// + +//! @name Threading model options +//@{ +#define ERPC_ALLOCATION_POLICY_DYNAMIC (0U) //!< Dynamic allocation policy +#define ERPC_ALLOCATION_POLICY_STATIC (1U) //!< Static allocation policy + +#define ERPC_THREADS_NONE (0U) //!< No threads. +#define ERPC_THREADS_PTHREADS (1U) //!< POSIX pthreads. +#define ERPC_THREADS_FREERTOS (2U) //!< FreeRTOS. +#define ERPC_THREADS_ZEPHYR (3U) //!< ZEPHYR. +#define ERPC_THREADS_MBED (4U) //!< Mbed OS +#define ERPC_THREADS_WIN32 (5U) //!< WIN32 +#define ERPC_THREADS_THREADX (6U) //!< THREADX + +#define ERPC_NOEXCEPT_DISABLED (0U) //!< Disabling noexcept feature. +#define ERPC_NOEXCEPT_ENABLED (1U) //!< Enabling noexcept feature. + +#define ERPC_NESTED_CALLS_DISABLED (0U) //!< No nested calls support. +#define ERPC_NESTED_CALLS_ENABLED (1U) //!< Nested calls support. + +#define ERPC_NESTED_CALLS_DETECTION_DISABLED (0U) //!< Nested calls detection disabled. +#define ERPC_NESTED_CALLS_DETECTION_ENABLED (1U) //!< Nested calls detection enabled. + +#define ERPC_MESSAGE_LOGGING_DISABLED (0U) //!< Trace functions disabled. +#define ERPC_MESSAGE_LOGGING_ENABLED (1U) //!< Trace functions enabled. + +#define ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED (0U) //!< Do not use MCMGR for MU ISR management. +#define ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED (1U) //!< Use MCMGR for MU ISR management. + +#define ERPC_PRE_POST_ACTION_DISABLED (0U) //!< Pre post shim callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_ENABLED (1U) //!< Pre post shim callback functions enabled. + +#define ERPC_PRE_POST_ACTION_DEFAULT_DISABLED (0U) //!< Pre post shim default callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_DEFAULT_ENABLED (1U) //!< Pre post shim default callback functions enabled. +//@} + +//! @name Configuration options +//@{ + +//! @def ERPC_ALLOCATION_POLICY +//! +//! @brief Choose which allocation policy should be used. +//! +//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used. +//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used. +//! +//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is +//! supported by compiler. Uncomment comment bellow to use static allocation policy. In case of static implementation +//! user need consider another values to set (ERPC_CODEC_COUNT, ERPC_MESSAGE_LOGGERS_COUNT, +//! ERPC_CLIENTS_THREADS_AMOUNT). +// #define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC) + +//! @def ERPC_CODEC_COUNT +//! +//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one +//! thread per each then 2, ... Default value 2. +// #define ERPC_CODEC_COUNT (2U) + +//! @def ERPC_MESSAGE_LOGGERS_COUNT +//! +//! @brief Set amount of message loggers objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. +//! For example if client or server is used in one thread then 1. If both are used in one thread per each then 2, ... +//! For arbitrated client 1 is enough. +//! Default value 0 (May not be used). +// #define ERPC_MESSAGE_LOGGERS_COUNT (0U) + +//! @def ERPC_CLIENTS_THREADS_AMOUNT +//! +//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. Default value 1 (Most of current cases). +// #define ERPC_CLIENTS_THREADS_AMOUNT (1U) + +//! @def ERPC_THREADS +//! +//! @brief Select threading model. +//! +//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC. +//! +//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads. +//! FreeRTOS can be detected when building with compilers that support __has_include(). +//! Otherwise, the default is no threading. +#define ERPC_THREADS (ERPC_THREADS_PTHREADS) + +//! @def ERPC_DEFAULT_BUFFER_SIZE +//! +//! Uncomment to change the size of buffers allocated by one of MessageBufferFactory. +//! (@ref client_setup and @ref server_setup). The default size is set to 256. +//! For RPMsg transport layer, ERPC_DEFAULT_BUFFER_SIZE must be 2^n - 16. +#define ERPC_DEFAULT_BUFFER_SIZE (4096U) + +//! @def ERPC_DEFAULT_BUFFERS_COUNT +//! +//! Uncomment to change the count of buffers allocated by one of statically allocated messages. +//! Default value is set to 2. +//#define ERPC_DEFAULT_BUFFERS_COUNT (2U) + +//! @def ERPC_NOEXCEPT +//! +//! @brief Disable/enable noexcept support. +//! +//! Uncomment for using noexcept feature. +//#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED) + +//! @def ERPC_NESTED_CALLS +//! +//! Default set to ERPC_NESTED_CALLS_DISABLED. Uncomment when callbacks, or other eRPC +//! functions are called from server implementation of another eRPC call. Nested functions +//! need to be marked as @nested in IDL. +//#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_ENABLED) + +//! @def ERPC_NESTED_CALLS_DETECTION +//! +//! Default set to ERPC_NESTED_CALLS_DETECTION_ENABLED when NDEBUG macro is presented. +//! This serve for locating nested calls in code. Nested calls are calls where inside eRPC function +//! on server side is called another eRPC function (like callbacks). Code need be a bit changed +//! to support nested calls. See ERPC_NESTED_CALLS macro. +//#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED) + +//! @def ERPC_MESSAGE_LOGGING +//! +//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base +//! printing messages, or sending data to another system for data analysis. Default set to +//! ERPC_MESSAGE_LOGGING_DISABLED. +//! +//! Uncomment for using logging feature. +//#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_ENABLED) + +//! @def ERPC_TRANSPORT_MU_USE_MCMGR +//! +//! @brief MU transport layer configuration. +//! +//! Set to one of the @c ERPC_TRANSPORT_MU_USE_MCMGR_x macros to configure the MCMGR usage in MU transport layer. +//! +//! MU transport layer could leverage the Multicore Manager (MCMGR) component for Inter-Core +//! interrupts / MU interrupts management or the Inter-Core interrupts can be managed by itself (MUX_IRQHandler +//! overloading). By default, ERPC_TRANSPORT_MU_USE_MCMGR is set to ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED when mcmgr.h +//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be +//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget +//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the +//! erpc_mu_transport.h for additional MU settings. +//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED +//@} + +//! @def ERPC_PRE_POST_ACTION +//! +//! Enable eRPC pre and post callback functions shim code. Take look into "erpc_pre_post_action.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DISABLED. +//! +//! Uncomment for using pre post callback feature. +//#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_ENABLED) + +//! @def ERPC_PRE_POST_ACTION_DEFAULT +//! +//! Enable eRPC pre and post default callback functions. Take look into "erpc_setup_extensions.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DEFAULT_DISABLED. +//! +//! Uncomment for using pre post default callback feature. +//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED) + +/*! @} */ +#endif // _ERPC_CONFIG_H_ +//////////////////////////////////////////////////////////////////////////////// +// EOF +//////////////////////////////////////////////////////////////////////////////// diff --git a/examples/zephyr/matrix_multiply_tcp/src/erpc_error_handler.cpp b/examples/zephyr/matrix_multiply_tcp/src/erpc_error_handler.cpp new file mode 100644 index 00000000..8be36267 --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/erpc_error_handler.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2017 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "erpc_error_handler.h" +#include + +//////////////////////////////////////////////////////////////////////////////// +// Variables +//////////////////////////////////////////////////////////////////////////////// + +extern bool g_erpc_error_occurred; +bool g_erpc_error_occurred = false; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +void erpc_error_handler(erpc_status_t err, uint32_t functionID) +{ + switch (err) + { + case kErpcStatus_Fail: + printk("\r\nGeneric failure."); + break; + + case kErpcStatus_InvalidArgument: + printk("\r\nArgument is an invalid value."); + break; + + case kErpcStatus_Timeout: + printk("\r\nOperated timed out."); + break; + + case kErpcStatus_InvalidMessageVersion: + printk("\r\nMessage header contains an unknown version."); + break; + + case kErpcStatus_ExpectedReply: + printk("\r\nExpected a reply message but got another message type."); + break; + + case kErpcStatus_CrcCheckFailed: + printk("\r\nMessage is corrupted."); + break; + + case kErpcStatus_BufferOverrun: + printk("\r\nAttempt to read or write past the end of a buffer."); + break; + + case kErpcStatus_UnknownName: + printk("\r\nCould not find host with given name."); + break; + + case kErpcStatus_ConnectionFailure: + printk("\r\nFailed to connect to host."); + break; + + case kErpcStatus_ConnectionClosed: + printk("\r\nConnected closed by peer."); + break; + + case kErpcStatus_MemoryError: + printk("\r\nMemory allocation error."); + break; + + case kErpcStatus_ServerIsDown: + printk("\r\nServer is stopped."); + break; + + case kErpcStatus_InitFailed: + printk("\r\nTransport layer initialization failed."); + break; + + case kErpcStatus_ReceiveFailed: + printk("\r\nFailed to receive data."); + break; + + case kErpcStatus_SendFailed: + printk("\r\nFailed to send data."); + break; + + /* no error occurred */ + case kErpcStatus_Success: + return; + + /* unhandled error */ + default: + printk("\r\nUnhandled error occurred."); + break; + } + + /* When error occurred on client side. */ + if (functionID != 0) + { + printk("Function id '%u'.", (unsigned int)functionID); + } + printk("\r\n"); + + /* error occurred */ + g_erpc_error_occurred = true; +} diff --git a/examples/zephyr/matrix_multiply_tcp/src/erpc_error_handler.h b/examples/zephyr/matrix_multiply_tcp/src/erpc_error_handler.h new file mode 100644 index 00000000..faf32559 --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/erpc_error_handler.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2022 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _EMBEDDED_RPC__ERROR_HANDLER_H_ +#define _EMBEDDED_RPC__ERROR_HANDLER_H_ + +#include "erpc_common.h" +#include + +/*! + * @addtogroup error_handler + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// API +//////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +//! @name Error handler +//@{ + +/*! + * @brief This function handles eRPC errors. + * + * This function prints a description of occurred error and sets bool variable g_erpc_error_occurred which is used for + * determining if error occurred in user application on client side. + */ +void erpc_error_handler(erpc_status_t err, uint32_t functionID); + +//@} + +#ifdef __cplusplus +} +#endif + +/*! @} */ +#endif // _EMBEDDED_RPC__ERROR_HANDLER_H_ diff --git a/examples/zephyr/matrix_multiply_tcp/src/main.cpp b/examples/zephyr/matrix_multiply_tcp/src/main.cpp new file mode 100644 index 00000000..3a53e7ee --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/main.cpp @@ -0,0 +1,119 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#include "erpc_server_setup.h" +#include "c_erpc_matrix_multiply_server.h" +#include "erpc_matrix_multiply_common.h" +#include "erpc_error_handler.h" +#include "erpc_transport_setup.h" + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +/******************************************************************************* + * Variables + ******************************************************************************/ +erpc_server_t server; + +/******************************************************************************* + * Prototypes + ******************************************************************************/ + +/******************************************************************************* + * Code + ******************************************************************************/ + +/*! + * @brief erpcMatrixMultiply function implementation. + * + * This is the implementation of the erpcMatrixMultiply function called by the primary core. + * + * @param matrix1 First matrix + * @param matrix2 Second matrix + * @param result_matrix Result matrix + */ +void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) +{ + int32_t i, j, k; + + /* Clear the result matrix */ + for (i = 0; i < matrix_size; ++i) + { + for (j = 0; j < matrix_size; ++j) + { + result_matrix[i][j] = 0; + } + } + + /* Multiply two matrices */ + for (i = 0; i < matrix_size; ++i) + { + for (j = 0; j < matrix_size; ++j) + { + for (k = 0; k < matrix_size; ++k) + { + result_matrix[i][j] += matrix1[i][k] * matrix2[k][j]; + } + } + } +} + +int main(void) +{ + /* TCP transport layer initialization */ + erpc_transport_t transport; + transport = erpc_transport_tcp_init("localhost", 12345, true); + + /* MessageBufferFactory initialization */ + erpc_mbf_t message_buffer_factory; + message_buffer_factory = erpc_mbf_dynamic_init(); + + /* eRPC server side initialization */ + server = erpc_server_init(transport, message_buffer_factory); + + /* adding the service to the server */ + erpc_service_t service = create_MatrixMultiplyService_service(); + erpc_add_service_to_server(server, service); + + for (;;) + { + /* process message */ + erpc_status_t status = erpc_server_poll(server); + + /* handle error status */ + if (status != (erpc_status_t)kErpcStatus_Success) + { + /* print error description */ + erpc_error_handler(status, 0); + + /* removing the service from the server */ + erpc_remove_service_from_server(server, service); + destroy_MatrixMultiplyService_service(service); + + /* stop erpc server */ + erpc_server_stop(server); + + /* print error description */ + erpc_server_deinit(server); + + /* exit program loop */ + break; + } + + /* do other tasks */ + int32_t i; + for (i = 0; i < 10000; i++) + { + } + } + + for (;;) + { + } +} diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/c_erpc_matrix_multiply_server.cpp b/examples/zephyr/matrix_multiply_tcp/src/service/c_erpc_matrix_multiply_server.cpp new file mode 100644 index 00000000..d19c4a8b --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/c_erpc_matrix_multiply_server.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#include +#include "c_erpc_matrix_multiply_server.h" +#include "erpc_matrix_multiply_server.hpp" +#include "erpc_manually_constructed.hpp" + +using namespace erpc; +using namespace std; +using namespace erpcShim; + + +class MatrixMultiplyService_server: public MatrixMultiplyService_interface +{ + public: + virtual ~MatrixMultiplyService_server() {}; + + + void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) + { + ::erpcMatrixMultiply(matrix1, matrix2, result_matrix); + } +}; + +ERPC_MANUALLY_CONSTRUCTED_STATIC(MatrixMultiplyService_service, s_MatrixMultiplyService_service); +ERPC_MANUALLY_CONSTRUCTED_STATIC(MatrixMultiplyService_server, s_MatrixMultiplyService_server); + +erpc_service_t create_MatrixMultiplyService_service(void) +{ + erpc_service_t service; + +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + service = new (nothrow) MatrixMultiplyService_service(new (nothrow)MatrixMultiplyService_server()); +#else + if (s_MatrixMultiplyService_service.isUsed()) + { + service = NULL; + } + else + { + s_MatrixMultiplyService_server.construct(); + s_MatrixMultiplyService_service.construct(s_MatrixMultiplyService_server.get()); + service = s_MatrixMultiplyService_service.get(); + } +#endif + + return service; +} + +void destroy_MatrixMultiplyService_service(erpc_service_t service) +{ +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC + if (service) + { + delete (MatrixMultiplyService_server *)(((MatrixMultiplyService_service *)service)->getHandler()); + delete (MatrixMultiplyService_service *)service; + } +#else + (void)service; + erpc_assert(service == s_MatrixMultiplyService_service.get()); + s_MatrixMultiplyService_service.destroy(); + s_MatrixMultiplyService_server.destroy(); +#endif +} + diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/c_erpc_matrix_multiply_server.h b/examples/zephyr/matrix_multiply_tcp/src/service/c_erpc_matrix_multiply_server.h new file mode 100644 index 00000000..e1f168bf --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/c_erpc_matrix_multiply_server.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_c_erpc_matrix_multiply_server_h_) +#define _c_erpc_matrix_multiply_server_h_ + +#include "erpc_matrix_multiply_common.h" + +#if defined(__cplusplus) +extern "C" +{ +#endif + +typedef void * erpc_service_t; + +#if !defined(ERPC_FUNCTIONS_DEFINITIONS) +#define ERPC_FUNCTIONS_DEFINITIONS + + +/*! @brief MatrixMultiplyService identifiers */ +enum _MatrixMultiplyService_ids +{ + kMatrixMultiplyService_service_id = 1, + kMatrixMultiplyService_erpcMatrixMultiply_id = 1, +}; + +//! @name MatrixMultiplyService +//@{ +void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix); +//@} + + +#endif // ERPC_FUNCTIONS_DEFINITIONS + +/*! @brief Return MatrixMultiplyService_service service object. */ +erpc_service_t create_MatrixMultiplyService_service(void); + +/*! @brief Destroy MatrixMultiplyService_service service object. */ +void destroy_MatrixMultiplyService_service(erpc_service_t service); + + +#if defined(__cplusplus) +} +#endif + +#endif // _c_erpc_matrix_multiply_server_h_ diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply.erpc b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply.erpc new file mode 100644 index 00000000..bfcece34 --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply.erpc @@ -0,0 +1,24 @@ +//Copyright below will be added into all generated files. +/*! + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +program erpc_matrix_multiply + +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +const int32 matrix_size = 5; + +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +type Matrix = int32[matrix_size][matrix_size]; + +interface MatrixMultiplyService { + erpcMatrixMultiply(in Matrix matrix1, in Matrix matrix2, out Matrix result_matrix) -> void +} diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_common.h b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_common.h new file mode 100644 index 00000000..6050df24 --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_common.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_common_h_) +#define _erpc_matrix_multiply_common_h_ + + +#if defined(__cplusplus) +extern "C" +{ +#endif +#include +#include +#include + +#include "erpc_version.h" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +#if !defined(ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY) +#define ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +// Aliases data types declarations +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +typedef int32_t Matrix[5][5]; + +// Constant variable declarations +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +extern const int32_t matrix_size; + +#endif // ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +#if defined(__cplusplus) +} +#endif + +#endif // _erpc_matrix_multiply_common_h_ diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_common.hpp b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_common.hpp new file mode 100644 index 00000000..3dfef510 --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_common.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_common_hpp_) +#define _erpc_matrix_multiply_common_hpp_ + + +#include +#include + +#include "erpc_version.h" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +#if !defined(ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY) +#define ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + +// Aliases data types declarations +/*! This is the matrix array type. The dimension has to be the same as the + matrix size const. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +typedef int32_t Matrix[5][5]; + +// Constant variable declarations +/*! This const defines the matrix size. The value has to be the same as the + Matrix array dimension. Do not forget to re-generate the erpc code once the + matrix size is changed in the erpc file */ +extern const int32_t matrix_size; + +#endif // ERPC_TYPE_DEFINITIONS_ERPC_MATRIX_MULTIPLY + + +#endif // _erpc_matrix_multiply_common_hpp_ diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_interface.cpp b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_interface.cpp new file mode 100644 index 00000000..0aa9af0a --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_interface.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#include "erpc_matrix_multiply_interface.hpp" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +using namespace std; +using namespace erpcShim; + +MatrixMultiplyService_interface::~MatrixMultiplyService_interface(void) +{ +} diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_interface.hpp b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_interface.hpp new file mode 100644 index 00000000..99b264cf --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_interface.hpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_interface_hpp_) +#define _erpc_matrix_multiply_interface_hpp_ + +#include "erpc_matrix_multiply_common.hpp" + +namespace erpcShim +{ + + +// Abstract base class for MatrixMultiplyService +class MatrixMultiplyService_interface +{ + public: + static const uint8_t m_serviceId = 1; + static const uint8_t m_erpcMatrixMultiplyId = 1; + + virtual ~MatrixMultiplyService_interface(void); + + virtual void erpcMatrixMultiply(Matrix matrix1, Matrix matrix2, Matrix result_matrix) = 0; +private: +}; +} // erpcShim + + +#endif // _erpc_matrix_multiply_interface_hpp_ diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_server.cpp b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_server.cpp new file mode 100644 index 00000000..a76721da --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_server.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#include "erpc_matrix_multiply_server.hpp" +#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC +#include +#include "erpc_port.h" +#endif +#include "erpc_manually_constructed.hpp" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + +using namespace erpc; +using namespace std; +using namespace erpcShim; + +#if ERPC_NESTED_CALLS_DETECTION +extern bool nestingDetection; +#endif + + + +// Constant variable definitions +#if defined(__MINGW32__) +__declspec( selectany ) +#else +#pragma weak matrix_size +#endif +extern const int32_t matrix_size = 5; + + +MatrixMultiplyService_service::MatrixMultiplyService_service(MatrixMultiplyService_interface *_MatrixMultiplyService_interface) + : erpc::Service(MatrixMultiplyService_interface::m_serviceId) + , m_handler(_MatrixMultiplyService_interface) +{ +} + +MatrixMultiplyService_service::~MatrixMultiplyService_service() +{ +} + +// return service interface handler. +MatrixMultiplyService_interface* MatrixMultiplyService_service::getHandler(void) +{ + return m_handler; +} + +// Call the correct server shim based on method unique ID. +erpc_status_t MatrixMultiplyService_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory, Transport * transport) +{ + erpc_status_t erpcStatus; + switch (methodId) + { + case MatrixMultiplyService_interface::m_erpcMatrixMultiplyId: + { + erpcStatus = erpcMatrixMultiply_shim(codec, messageFactory, transport, sequence); + break; + } + + default: + { + erpcStatus = kErpcStatus_InvalidArgument; + break; + } + } + + return erpcStatus; +} + +// Server shim for erpcMatrixMultiply of MatrixMultiplyService interface. +erpc_status_t MatrixMultiplyService_service::erpcMatrixMultiply_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence) +{ + erpc_status_t err = kErpcStatus_Success; + + Matrix matrix1; + Matrix matrix2; + Matrix result_matrix; + + // startReadMessage() was already called before this shim was invoked. + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->read(matrix1[arrayCount0][arrayCount1]); + } + } + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->read(matrix2[arrayCount0][arrayCount1]); + } + } + + err = codec->getStatus(); + if (err == kErpcStatus_Success) + { + // Invoke the actual served function. +#if ERPC_NESTED_CALLS_DETECTION + nestingDetection = true; +#endif + m_handler->erpcMatrixMultiply(matrix1, matrix2, result_matrix); +#if ERPC_NESTED_CALLS_DETECTION + nestingDetection = false; +#endif + + // preparing MessageBuffer for serializing data + err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize()); + } + + if (err == kErpcStatus_Success) + { + // preparing codec for serializing data + codec->reset(transport->reserveHeaderSize()); + + // Build response message. + codec->startWriteMessage(message_type_t::kReplyMessage, MatrixMultiplyService_interface::m_serviceId, MatrixMultiplyService_interface::m_erpcMatrixMultiplyId, sequence); + + for (uint32_t arrayCount0 = 0U; arrayCount0 < 5U; ++arrayCount0) + { + for (uint32_t arrayCount1 = 0U; arrayCount1 < 5U; ++arrayCount1) + { + codec->write(result_matrix[arrayCount0][arrayCount1]); + } + } + + err = codec->getStatus(); + } + + return err; +} diff --git a/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_server.hpp b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_server.hpp new file mode 100644 index 00000000..c8e5a724 --- /dev/null +++ b/examples/zephyr/matrix_multiply_tcp/src/service/erpc_matrix_multiply_server.hpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014-2016, Freescale Semiconductor, Inc. + * Copyright 2016 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. + * + * AUTOGENERATED - DO NOT EDIT + */ + + +#if !defined(_erpc_matrix_multiply_server_hpp_) +#define _erpc_matrix_multiply_server_hpp_ + +#include "erpc_matrix_multiply_interface.hpp" + +#include "erpc_server.hpp" +#include "erpc_codec.hpp" + +#if 11300 != ERPC_VERSION_NUMBER +#error "The generated shim code version is different to the rest of eRPC code." +#endif + + +namespace erpcShim +{ + +/*! + * @brief Service subclass for MatrixMultiplyService. + */ +class MatrixMultiplyService_service : public erpc::Service +{ +public: + MatrixMultiplyService_service(MatrixMultiplyService_interface *_MatrixMultiplyService_interface); + + virtual ~MatrixMultiplyService_service(); + + /*! @brief return service interface handler. */ + MatrixMultiplyService_interface* getHandler(void); + + /*! @brief Call the correct server shim based on method unique ID. */ + virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport); + +private: + MatrixMultiplyService_interface *m_handler; + /*! @brief Server shim for erpcMatrixMultiply of MatrixMultiplyService interface. */ + erpc_status_t erpcMatrixMultiply_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence); +}; + +} // erpcShim + + +#endif // _erpc_matrix_multiply_server_hpp_ diff --git a/examples/zephyr/matrix_multiply_uart/src/service/c_erpc_matrix_multiply_server.cpp b/examples/zephyr/matrix_multiply_uart/src/service/c_erpc_matrix_multiply_server.cpp index afb98cb3..d19c4a8b 100644 --- a/examples/zephyr/matrix_multiply_uart/src/service/c_erpc_matrix_multiply_server.cpp +++ b/examples/zephyr/matrix_multiply_uart/src/service/c_erpc_matrix_multiply_server.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_uart/src/service/c_erpc_matrix_multiply_server.h b/examples/zephyr/matrix_multiply_uart/src/service/c_erpc_matrix_multiply_server.h index d312e8d3..e1f168bf 100644 --- a/examples/zephyr/matrix_multiply_uart/src/service/c_erpc_matrix_multiply_server.h +++ b/examples/zephyr/matrix_multiply_uart/src/service/c_erpc_matrix_multiply_server.h @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_common.h b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_common.h index fdbd0c7a..6050df24 100644 --- a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_common.h +++ b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_common.h @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -27,7 +27,7 @@ extern "C" #include "erpc_version.h" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_common.hpp b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_common.hpp index d1b16374..3dfef510 100644 --- a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_common.hpp +++ b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_common.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -17,13 +17,12 @@ #define _erpc_matrix_multiply_common_hpp_ -#include #include #include #include "erpc_version.h" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_interface.cpp b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_interface.cpp index e50f033c..0aa9af0a 100644 --- a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_interface.cpp +++ b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_interface.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -15,7 +15,7 @@ #include "erpc_matrix_multiply_interface.hpp" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_interface.hpp b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_interface.hpp index b2be5a90..99b264cf 100644 --- a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_interface.hpp +++ b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_interface.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. * * AUTOGENERATED - DO NOT EDIT */ diff --git a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_server.cpp b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_server.cpp index d6c97a33..a76721da 100644 --- a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_server.cpp +++ b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_server.cpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -20,7 +20,7 @@ #endif #include "erpc_manually_constructed.hpp" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_server.hpp b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_server.hpp index ad1f17f2..c8e5a724 100644 --- a/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_server.hpp +++ b/examples/zephyr/matrix_multiply_uart/src/service/erpc_matrix_multiply_server.hpp @@ -7,7 +7,7 @@ */ /* - * Generated by erpcgen 1.12.0 on Wed Oct 25 10:00:57 2023. + * Generated by erpcgen 1.13.0 on Thu Apr 18 09:59:40 2024. * * AUTOGENERATED - DO NOT EDIT */ @@ -21,7 +21,7 @@ #include "erpc_server.hpp" #include "erpc_codec.hpp" -#if 11200 != ERPC_VERSION_NUMBER +#if 11300 != ERPC_VERSION_NUMBER #error "The generated shim code version is different to the rest of eRPC code." #endif diff --git a/test/common/gtest/gtest.cpp b/test/common/gtest/gtest.cpp index 4a7fc663..d6aed525 100644 --- a/test/common/gtest/gtest.cpp +++ b/test/common/gtest/gtest.cpp @@ -5390,7 +5390,7 @@ class ScopedPrematureExitFile { ~ScopedPrematureExitFile() { if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') { - remove(premature_exit_filepath_); + // remove(premature_exit_filepath_); } } @@ -9600,7 +9600,7 @@ class CapturedStream { } ~CapturedStream() { - remove(filename_.c_str()); + // remove(filename_.c_str()); } std::string GetCapturedString() { diff --git a/test/common/gtest/gtest.h b/test/common/gtest/gtest.h index ef9a6231..df1bd334 100644 --- a/test/common/gtest/gtest.h +++ b/test/common/gtest/gtest.h @@ -3393,29 +3393,54 @@ inline bool IsDir(const StatStruct& st) { # endif // GTEST_OS_WINDOWS_MOBILE #elif GTEST_OS_BARE_METAL - typedef struct { int x; } StatStruct; -#if not defined(__ARMCC_VERSION) +#if not defined(__ARMCC_VERSION) && not defined(__ZEPHYR__) inline int FileNo(FILE* file) { return fileno(file); } #else inline int FileNo(FILE* file) { return -1; } #endif inline int IsATTY(int fd) { return 0; } inline int Stat(const char* path, StatStruct* buf) { return -1; } +#if not defined(__ZEPHYR__) inline int StrCaseCmp(const char* s1, const char* s2) { return strcasecmp(s1, s2); } -#if not defined(__ARMCC_VERSION) +#else +inline int StrCaseCmp(const char* s1, const char* s2) +{ + const char *ch1 = (const char *)s1; + const char *ch2 = (const char *)s2; + + while (tolower(*ch1) == tolower(*ch2++)) { + if (*ch1++ == '\0') { + return (0); + } + } + + return (tolower(*ch1) - tolower(*--ch2)); +} +#endif +#if not defined(__ARMCC_VERSION) && not defined(__ZEPHYR__) inline char* StrDup(const char* src) { return strdup(src); } #else -inline char* StrDup(const char* src) { return (NULL); } +inline char* StrDup(const char* src) { + size_t len; + char *copy; + + len = strlen(src) + 1; + if ((copy = (char *)malloc(len)) == NULL) { + return (NULL); + } + + memcpy(copy, src, len); + return (copy); +} #endif inline int RmDir(const char* dir) { return -1; } inline bool IsDir(const StatStruct& st) { return false; } #else - typedef struct stat StatStruct; inline int FileNo(FILE* file) { return fileno(file); } diff --git a/test/common/unit_test_arbitrator_app1.cpp b/test/common/unit_test_arbitrator_app1.cpp index 87043b0c..9577aedc 100644 --- a/test/common/unit_test_arbitrator_app1.cpp +++ b/test/common/unit_test_arbitrator_app1.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2016, Freescale Semiconductor, Inc. - * Copyright 2016 - 2023 NXP + * Copyright 2016 - 2024 NXP * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -90,7 +90,7 @@ void runClient(void *arg) // wait until ERPC first (client) app will announce that it is ready. while (waitClient == 0) { - Thread::sleep(10); + Thread::sleep(10000); } // wait until ERPC first (client) app will announce ready to quit state @@ -98,7 +98,7 @@ void runClient(void *arg) { isTestPassing = testClient(); { - Thread::sleep(10); + Thread::sleep(10000); Mutex::Guard lock(waitQuitMutex); if (waitQuit != 0 || isTestPassing != 0 || stopTest != 0) { @@ -110,7 +110,7 @@ void runClient(void *arg) while (true) { - Thread::sleep(10); + Thread::sleep(100000); Mutex::Guard lock(waitQuitMutex); if (waitQuit != 0) { diff --git a/test/common/unit_test_zephyr_rpmsg_lite_arbitrator_client.cpp b/test/common/unit_test_zephyr_rpmsg_lite_arbitrator_client.cpp new file mode 100644 index 00000000..876fae6d --- /dev/null +++ b/test/common/unit_test_zephyr_rpmsg_lite_arbitrator_client.cpp @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016 - 2023 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include + +#include "erpc_arbitrated_client_setup.h" +#include "erpc_mbf_setup.h" +#include "erpc_server_setup.h" +#include "erpc_transport_setup.h" +#include "erpc_threading.h" + +// #include "FreeRTOS.h" +// #include "semphr.h" +// #include "task.h" + +#include "c_test_firstInterface_client.h" +#include "c_test_secondInterface_server.h" +#include "gtest.h" +#include "unit_test.h" +#include "unit_test_wrapped.h" + +#include "rpmsg_lite.h" + +// #ifdef UNITY_DUMP_RESULTS +// #include "corn_g_test.h" +// #endif + +using namespace erpc; +using namespace std; + +#define APP_ERPC_READY_EVENT_DATA (1) +#define RPMSG_LITE_LINK_ID (0) + +Mutex waitQuitMutex; +Thread g_initThread("runInit"); +Thread g_serverThread("runServer"); +Thread g_clientThread("runClient"); + +K_THREAD_STACK_DEFINE(stack_init, 256 * 4); +K_THREAD_STACK_DEFINE(stack_server, 1536 * 8); +K_THREAD_STACK_DEFINE(stack_client, 1536 * 8); + +volatile int waitQuit = 0; +volatile uint16_t eRPCReadyEventData = 0; +extern const uint32_t erpc_generated_crc; +erpc_service_t service = NULL; +erpc_server_t server; + +struct k_poll_signal signalClient; +struct k_poll_signal signalServer; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// +/*! + * @brief eRPC server side ready event handler + */ +static void eRPCReadyEventHandler(uint16_t eventData, void *context) +{ + eRPCReadyEventData = eventData; +} + +void increaseWaitQuit() +{ + Mutex::Guard lock(waitQuitMutex); + waitQuit++; +} + +void runServer(void *arg) +{ + struct k_poll_event events[1] = { + K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &signalServer) + }; + k_poll(events, 1, K_FOREVER); + + erpc_status_t err; + err = erpc_server_run(server); + increaseWaitQuit(); + + if (err != kErpcStatus_Success) + { + printk("Server error: %d\r\n", err); + } + + k_thread_suspend(k_current_get()); +} + +void runClient(void *arg) +{ + struct k_poll_event events[1] = { + K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &signalClient), + }; + k_poll(events, 1, K_FOREVER); + + // send to ERPC second (server) app message that this app is ready. + whenReady(); + + __attribute__((unused)) int i; + i = RUN_ALL_TESTS(); + + // wait until ERPC second (server) app will announce ready to quit state. + while (true) + { + Mutex::Guard lock(waitQuitMutex); + if (waitQuit != 0) + { + break; + } + } + + // send to ERPC second (server) app ready to quit state + quitFirstInterfaceServer(); + + increaseWaitQuit(); + + k_thread_suspend(k_current_get()); +} + +void runInit(void *arg) +{ + erpc_transport_t transportClient; + erpc_transport_t transportServer; + + // RPMsg-Lite transport layer initialization + transportClient = erpc_transport_rpmsg_lite_rtos_master_init(100, 101, RPMSG_LITE_LINK_ID); + + if (transportClient == NULL) + { + // error in initialization of transport layer + printk("Transport layer initialization failed\r\n"); + while (1) + { + } + } + + // MessageBufferFactory initialization + erpc_mbf_t message_buffer_factory; + erpc_client_t client; + + message_buffer_factory = erpc_mbf_rpmsg_init(transportClient); + + // eRPC client side initialization + client = erpc_arbitrated_client_init(transportClient, message_buffer_factory, &transportServer); + initInterfaces(client); + + // eRPC server side initialization + server = erpc_server_init(transportServer, message_buffer_factory); + + erpc_arbitrated_client_set_crc(client, erpc_generated_crc); + + // adding server to client for nested calls. + erpc_arbitrated_client_set_server(client, server); + erpc_arbitrated_client_set_server_thread_id(client, (void *)g_serverThread.getThreadId()); + + // adding the service to the server + service = create_SecondInterface_service(); + erpc_add_service_to_server(server, service); + + // unblock server and client task + + k_poll_signal_raise(&signalClient, 0); + k_poll_signal_raise(&signalServer, 0); + + k_thread_suspend(k_current_get()); +} + +class ZephyrPrinter : public ::testing::EmptyTestEventListener +{ + virtual void OnTestCaseStart(const ::testing::TestCase &test_case) + { + printk("[----------] %d %s from %s\n", test_case.test_to_run_count(), + (test_case.test_to_run_count() == 1 ? "test" : "tests"), test_case.name()); + } + + virtual void OnTestStart(const ::testing::TestInfo &test_info) + { + printk("[ RUN ] %s.%s\n", test_info.test_case_name(), test_info.name()); + } + + virtual void OnTestDisabled(const ::testing::TestInfo &test_info) + { + printk("[ DISABLED ] %s.%s\n", test_info.test_case_name(), test_info.name()); + } + + virtual void OnTestPartResult(const ::testing::TestPartResult &test_part_result) + { + if (test_part_result.type() == ::testing::TestPartResult::kSuccess) + { + return; + } + else + { + printk("%s (%d) %s\n%s\n", test_part_result.file_name(), test_part_result.line_number(), + test_part_result.failed() ? "error" : "Success", test_part_result.summary()); + } + } + + virtual void OnTestEnd(const ::testing::TestInfo &test_info) + { + if (test_info.result()->Passed()) + { + printk("[ OK ] "); + } + else + { + printk("[ FAILED ] "); + } + printk("%s.%s\n", test_info.test_case_name(), test_info.name()); + } + + virtual void OnTestCaseEnd(const ::testing::TestCase &test_case) + { + printk("%d %s from %s\n", test_case.test_to_run_count(), + (test_case.test_to_run_count() == 1 ? "test" : "tests"), test_case.name()); + } + + virtual void OnTestProgramEnd(const ::testing::UnitTest &) { printk("[==========] Done running all tests.\r\n"); } +}; + +int main(void) +{ + env_sleep_msec(1000); + int fake_argc = 1; + const auto fake_arg0 = "dummy"; + char *fake_argv0 = const_cast(fake_arg0); + char **fake_argv = &fake_argv0; + ::testing::InitGoogleTest(&fake_argc, fake_argv); + + ::testing::TestEventListeners &listeners = ::testing::UnitTest::GetInstance()->listeners(); + delete listeners.Release(listeners.default_result_printer()); + listeners.Append(new ZephyrPrinter); + + k_poll_signal_init(&signalClient); + k_poll_signal_init(&signalServer); + + g_initThread.init(&runInit, 1, 256 * 4); + g_serverThread.init(&runServer, 2, 1536 * 4); + g_clientThread.init(&runClient, 1, 1536 * 4); + + g_initThread.setStackPointer(stack_init); + g_serverThread.setStackPointer(stack_server); + g_clientThread.setStackPointer(stack_client); + + g_initThread.start(); + g_serverThread.start(); + g_clientThread.start(); + + k_thread_suspend(k_current_get()); +} + +extern "C" { +void quitSecondInterfaceServer() +{ + /* removing the service from the server */ + erpc_remove_service_from_server(server, service); + destroy_SecondInterface_service(service); + + // Stop server part + erpc_server_stop(server); + increaseWaitQuit(); +} +} diff --git a/test/common/unit_test_zephyr_rpmsg_lite_arbitrator_server.cpp b/test/common/unit_test_zephyr_rpmsg_lite_arbitrator_server.cpp new file mode 100644 index 00000000..477e1656 --- /dev/null +++ b/test/common/unit_test_zephyr_rpmsg_lite_arbitrator_server.cpp @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016 - 2024 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#include "erpc_arbitrated_client_setup.h" +#include "erpc_mbf_setup.h" +#include "erpc_server_setup.h" +#include "erpc_transport_setup.h" +#include "erpc_threading.h" + +#include "c_test_firstInterface_server.h" +#include "c_test_secondInterface_client.h" +#include "unit_test.h" +#include "unit_test_wrapped.h" + +#include "rpmsg_lite.h" + +using namespace erpc; + +int testClient(); + +#define APP_ERPC_READY_EVENT_DATA (1) +#define RPMSG_LITE_LINK_ID (0) + +#define SHM_MEM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) +#define SHM_MEM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) + +Mutex waitQuitMutex; +Thread g_initThread("runInit"); +Thread g_serverThread("runServer"); +Thread g_clientThread("runClient"); + +volatile int waitQuit = 0; +volatile int waitClient = 0; +volatile int isTestPassing = 0; +uint32_t startupData; +volatile int stopTest = 0; +extern const uint32_t erpc_generated_crc; +erpc_service_t service = NULL; +erpc_server_t server; + +K_THREAD_STACK_DEFINE(stack_init, 256 * 4); +K_THREAD_STACK_DEFINE(stack_server, 1536 * 4); +K_THREAD_STACK_DEFINE(stack_client, 1536 * 4); + +struct k_poll_signal signalClient; +struct k_poll_signal signalServer; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// +void increaseWaitQuit() +{ + Mutex::Guard lock(waitQuitMutex); + waitQuit++; +} + +void runServer(void *arg) +{ + struct k_poll_event events[1] = { + K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &signalServer), + }; + k_poll(events, 1, K_FOREVER); + + erpc_status_t err; + err = erpc_server_run(server); + increaseWaitQuit(); + + if (err != kErpcStatus_Success) + { + // server error + while (1) + { + } + } + k_thread_suspend(k_current_get()); +} + +void runClient(void *arg) +{ + struct k_poll_event events[1] = { + K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &signalClient), + }; + k_poll(events, 1, K_FOREVER); + + // wait until ERPC first (client) app will announce that it is ready. + while (waitClient == 0) + { + Thread::sleep(10000); + } + + // wait until ERPC first (client) app will announce ready to quit state + while (true) + { + isTestPassing = testClient(); + { + Thread::sleep(10000); + Mutex::Guard lock(waitQuitMutex); + if (waitQuit != 0 || isTestPassing != 0 || stopTest != 0) + { + enableFirstSide(); + break; + } + } + } + + while (true) + { + Thread::sleep(100000); + Mutex::Guard lock(waitQuitMutex); + if (waitQuit != 0) + { + break; + } + } + + // send to ERPC first (client) app ready to quit state + quitSecondInterfaceServer(); + increaseWaitQuit(); + k_thread_suspend(k_current_get()); +} + +static void SignalReady(void) {} + +void runInit(void *arg) +{ + uint32_t *shared_memory = (uint32_t *)SHM_MEM_ADDR; + + erpc_transport_t transportClient; + erpc_transport_t transportServer; + erpc_mbf_t message_buffer_factory; + erpc_client_t client; + + transportClient = erpc_transport_rpmsg_lite_rtos_remote_init(101U, 100U, (void *)(char *)shared_memory, + RPMSG_LITE_LINK_ID, SignalReady, NULL); + // MessageBufferFactory initialization + message_buffer_factory = erpc_mbf_rpmsg_init(transportClient); + + // eRPC client side initialization + client = erpc_arbitrated_client_init(transportClient, message_buffer_factory, &transportServer); + initInterfaces(client); + + // eRPC server side initialization + server = erpc_server_init(transportServer, message_buffer_factory); + + erpc_arbitrated_client_set_crc(client, erpc_generated_crc); + + // adding server to client for nested calls. + erpc_arbitrated_client_set_server(client, server); + erpc_arbitrated_client_set_server_thread_id(client, (void *)g_serverThread.getThreadId()); + + // adding the service to the server + service = create_FirstInterface_service(); + erpc_add_service_to_server(server, service); + + // unblock server and client task + k_poll_signal_raise(&signalClient, 0); + k_poll_signal_raise(&signalServer, 0); + + k_thread_suspend(k_current_get()); +} + +int main(void) +{ + env_sleep_msec(0); + k_poll_signal_init(&signalClient); + k_poll_signal_init(&signalServer); + + g_initThread.init(&runInit, 1, 256 * 4); + g_serverThread.init(&runServer, 3, 1536 * 4); + g_clientThread.init(&runClient, 2, 1536 * 4); + + g_initThread.setStackPointer(stack_init); + g_serverThread.setStackPointer(stack_server); + g_clientThread.setStackPointer(stack_client); + + + g_initThread.start(); + g_serverThread.start(); + g_clientThread.start(); + + k_thread_suspend(k_current_get()); +} + +extern "C" { +void stopSecondSide() +{ + ++stopTest; +} + +int32_t getResultFromSecondSide() +{ + return isTestPassing; +} + +void testCasesAreDone(void) +{ + increaseWaitQuit(); +} + +void quitFirstInterfaceServer() +{ + /* removing the service from the server */ + erpc_remove_service_from_server(server, service); + destroy_FirstInterface_service(service); + + // Stop server part + erpc_server_stop(server); +} + +void whenReady() +{ + waitClient++; +} +} + +int testClient() +{ + int number = 15; + for (int i = 0; i < number; i++) + { + secondSendInt(i + number); + } + for (int i = number - 1; i >= 0; i--) + { + if (i + number != secondReceiveInt()) + { + return -1; + } + } + return 0; +} diff --git a/test/common/unit_test_zephyr_rpmsg_lite_client.cpp b/test/common/unit_test_zephyr_rpmsg_lite_client.cpp new file mode 100644 index 00000000..8b95b9fa --- /dev/null +++ b/test/common/unit_test_zephyr_rpmsg_lite_client.cpp @@ -0,0 +1,133 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#include "rpmsg_lite.h" +#include "erpc_client_setup.h" + +#include "c_test_unit_test_common_client.h" +#include "gtest.h" +#include "gtestListener.hpp" +#include "myAlloc.hpp" +#include "unit_test_wrapped.h" + +// #ifdef UNITY_DUMP_RESULTS +// #include "corn_g_test.h" +// #endif + +using namespace std; + +//////////////////////////////////////////////////////////////////////////////// +// Classes +//////////////////////////////////////////////////////////////////////////////// + +class ZephyrPrinter : public ::testing::EmptyTestEventListener +{ + virtual void OnTestCaseStart(const ::testing::TestCase &test_case) + { + printk("[----------] %d %s from %s\n", test_case.test_to_run_count(), + (test_case.test_to_run_count() == 1 ? "test" : "tests"), test_case.name()); + } + + virtual void OnTestStart(const ::testing::TestInfo &test_info) + { + printk("[ RUN ] %s.%s\n", test_info.test_case_name(), test_info.name()); + } + + virtual void OnTestDisabled(const ::testing::TestInfo &test_info) + { + printk("[ DISABLED ] %s.%s\n", test_info.test_case_name(), test_info.name()); + } + + virtual void OnTestPartResult(const ::testing::TestPartResult &test_part_result) + { + if (test_part_result.type() == ::testing::TestPartResult::kSuccess) + { + return; + } + else + { + printk("%s (%d) %s\n%s\n", test_part_result.file_name(), test_part_result.line_number(), + test_part_result.failed() ? "error" : "Success", test_part_result.summary()); + } + } + + virtual void OnTestEnd(const ::testing::TestInfo &test_info) + { + if (test_info.result()->Passed()) + { + printk("[ OK ] "); + } + else + { + printk("[ FAILED ] "); + } + printk("%s.%s\n", test_info.test_case_name(), test_info.name()); + } + + virtual void OnTestCaseEnd(const ::testing::TestCase &test_case) + { + printk("%d %s from %s\n", test_case.test_to_run_count(), + (test_case.test_to_run_count() == 1 ? "test" : "tests"), test_case.name()); + } + + virtual void OnTestProgramEnd(const ::testing::UnitTest &) { printk("[==========] Done running all tests.\r\n"); } +}; + +using namespace std; + +//////////////////////////////////////////////////////////////////////////////// +// Definitions +//////////////////////////////////////////////////////////////////////////////// + +#define RPMSG_LITE_LINK_ID (0) +int ::MyAlloc::allocated_ = 0; +extern char rpmsg_lite_base[]; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +int main(void) +{ + env_sleep_msec(4000); + + int fake_argc = 1; + const auto fake_arg0 = "dummy"; + char *fake_argv0 = const_cast(fake_arg0); + char **fake_argv = &fake_argv0; + ::testing::InitGoogleTest(&fake_argc, fake_argv); + + ::testing::TestEventListeners &listeners = ::testing::UnitTest::GetInstance()->listeners(); + listeners.Append(new LeakChecker); + + delete listeners.Release(listeners.default_result_printer()); + listeners.Append(new ZephyrPrinter); + + erpc_transport_t transport; + erpc_mbf_t message_buffer_factory; + erpc_client_t client; + + transport = erpc_transport_rpmsg_lite_rtos_master_init(100, 101, RPMSG_LITE_LINK_ID); + message_buffer_factory = erpc_mbf_rpmsg_init(transport); + + client = erpc_client_init(transport, message_buffer_factory); + initInterfaces_common(client); + initInterfaces(client); + + int i = RUN_ALL_TESTS(); + quit(); + + erpc_client_deinit(client); + + return i; +} + +void initInterfaces_common(erpc_client_t client) +{ + initCommon_client(client); +} diff --git a/test/common/unit_test_zephyr_rpmsg_lite_server.cpp b/test/common/unit_test_zephyr_rpmsg_lite_server.cpp new file mode 100644 index 00000000..82f53722 --- /dev/null +++ b/test/common/unit_test_zephyr_rpmsg_lite_server.cpp @@ -0,0 +1,104 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "erpc_mbf_setup.h" +#include "erpc_server_setup.h" +#include "erpc_simple_server.hpp" +#include "erpc_transport_setup.h" + +#include "rpmsg_lite.h" + +#include "c_test_unit_test_common_server.h" +#include "myAlloc.hpp" +#include "unit_test_wrapped.h" + +//////////////////////////////////////////////////////////////////////////////// +// Variables +//////////////////////////////////////////////////////////////////////////////// +#define RPMSG_LITE_LINK_ID (0) + +#define SHM_MEM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) +#define SHM_MEM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) + +int ::MyAlloc::allocated_ = 0; +extern char rpmsg_lite_base[]; +erpc_service_t service_common = NULL; +erpc_server_t server; + + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +static void SignalReady(void) {} + +int main(void) +{ + env_sleep_msec(1000); + uint32_t *shared_memory = (uint32_t *)SHM_MEM_ADDR; + + erpc_transport_t transport; + erpc_mbf_t message_buffer_factory; + + transport = erpc_transport_rpmsg_lite_rtos_remote_init(101U, 100U, (void *)(char *)shared_memory, + RPMSG_LITE_LINK_ID, SignalReady, NULL); + message_buffer_factory = erpc_mbf_rpmsg_init(transport); + + /* Init server */ + server = erpc_server_init(transport, message_buffer_factory); + + /* Add test services. This function call erpc_add_service_to_server for all necessary services. */ + add_services_to_server(server); + + /* Add common service */ + add_common_service(server); + + /* Add run server */ + erpc_server_run(server); + + /* Deinit server */ + erpc_server_deinit(server); + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Server helper functions +//////////////////////////////////////////////////////////////////////////////// + +void add_common_service(erpc_server_t server) +{ + service_common = create_Common_service(); + erpc_add_service_to_server(server, service_common); +} + +void remove_common_services_from_server(erpc_server_t server, erpc_service_t service) +{ + erpc_remove_service_from_server(server, service); + destroy_Common_service(service); +} + +//////////////////////////////////////////////////////////////////////////////// +// Common service implementations here +//////////////////////////////////////////////////////////////////////////////// + +void quit() +{ + /* removing common services from the server */ + remove_common_services_from_server(server, service_common); + + /* removing individual test services from the server */ + remove_services_from_server(server); + + erpc_server_stop(server); +} + +int32_t getServerAllocated() +{ + int result = ::MyAlloc::allocated(); + ::MyAlloc::allocated(0); + return result; +} diff --git a/test/common/unit_test_zephyr_uart_arbitrator_server.cpp b/test/common/unit_test_zephyr_uart_arbitrator_server.cpp new file mode 100644 index 00000000..cae93ef3 --- /dev/null +++ b/test/common/unit_test_zephyr_uart_arbitrator_server.cpp @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016 - 2024 NXP + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#include "erpc_arbitrated_client_setup.h" +#include "erpc_mbf_setup.h" +#include "erpc_server_setup.h" +#include "erpc_transport_setup.h" +#include "erpc_threading.h" + +#include "c_test_firstInterface_server.h" +#include "c_test_secondInterface_client.h" +#include "unit_test.h" +#include "unit_test_wrapped.h" + +using namespace erpc; + +#define UART_DEVICE_NODE DT_CHOSEN(zephyr_console) +static const struct device *const uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE); + +int testClient(); + +Mutex waitQuitMutex; +Thread g_initThread("runInit"); +Thread g_serverThread("runServer"); +Thread g_clientThread("runClient"); + +volatile int waitQuit = 0; +volatile int waitClient = 0; +volatile int isTestPassing = 0; +uint32_t startupData; +volatile int stopTest = 0; +extern const uint32_t erpc_generated_crc; +erpc_service_t service = NULL; +erpc_server_t server; + +K_THREAD_STACK_DEFINE(stack_init, 256 * 4); +K_THREAD_STACK_DEFINE(stack_server, 1536 * 4); +K_THREAD_STACK_DEFINE(stack_client, 1536 * 4); + +struct k_poll_signal signalClient; +struct k_poll_signal signalServer; + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// +void increaseWaitQuit() +{ + Mutex::Guard lock(waitQuitMutex); + waitQuit++; +} + +void runServer(void *arg) +{ + struct k_poll_event events[1] = { + K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &signalServer), + }; + k_poll(events, 1, K_FOREVER); + + erpc_status_t err; + err = erpc_server_run(server); + increaseWaitQuit(); + + if (err != kErpcStatus_Success) + { + // server error + while (1) + { + } + } + k_thread_suspend(k_current_get()); +} + +void runClient(void *arg) +{ + struct k_poll_event events[1] = { + K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &signalClient), + }; + k_poll(events, 1, K_FOREVER); + + // wait until ERPC first (client) app will announce that it is ready. + while (waitClient == 0) + { + Thread::sleep(10000); + } + + // wait until ERPC first (client) app will announce ready to quit state + while (true) + { + isTestPassing = testClient(); + { + Thread::sleep(10000); + Mutex::Guard lock(waitQuitMutex); + if (waitQuit != 0 || isTestPassing != 0 || stopTest != 0) + { + enableFirstSide(); + break; + } + } + } + + while (true) + { + Thread::sleep(100000); + Mutex::Guard lock(waitQuitMutex); + if (waitQuit != 0) + { + break; + } + } + + // send to ERPC first (client) app ready to quit state + quitSecondInterfaceServer(); + increaseWaitQuit(); + k_thread_suspend(k_current_get()); +} + +static void SignalReady(void) {} + +void runInit(void *arg) +{ + if (!device_is_ready(uart_dev)) + { + printk("UART device not found!"); + return; + } + + erpc_transport_t transportClient; + erpc_transport_t transportServer; + erpc_mbf_t message_buffer_factory; + erpc_client_t client; + + transportClient = erpc_transport_zephyr_uart_init((void *)uart_dev); + + // MessageBufferFactory initialization + message_buffer_factory = erpc_mbf_dynamic_init(); + + // eRPC client side initialization + client = erpc_arbitrated_client_init(transportClient, message_buffer_factory, &transportServer); + initInterfaces(client); + + // eRPC server side initialization + server = erpc_server_init(transportServer, message_buffer_factory); + + erpc_arbitrated_client_set_crc(client, erpc_generated_crc); + + // adding server to client for nested calls. + erpc_arbitrated_client_set_server(client, server); + erpc_arbitrated_client_set_server_thread_id(client, (void *)g_serverThread.getThreadId()); + + // adding the service to the server + service = create_FirstInterface_service(); + erpc_add_service_to_server(server, service); + + // unblock server and client task + k_poll_signal_raise(&signalClient, 0); + k_poll_signal_raise(&signalServer, 0); + + k_thread_suspend(k_current_get()); +} + +int main(void) +{ + k_poll_signal_init(&signalClient); + k_poll_signal_init(&signalServer); + + g_initThread.init(&runInit, 1, 256 * 4); + g_serverThread.init(&runServer, 3, 1536 * 4); + g_clientThread.init(&runClient, 2, 1536 * 4); + + g_initThread.setStackPointer(stack_init); + g_serverThread.setStackPointer(stack_server); + g_clientThread.setStackPointer(stack_client); + + + g_initThread.start(); + g_serverThread.start(); + g_clientThread.start(); + + k_thread_suspend(k_current_get()); +} + +extern "C" { +void stopSecondSide() +{ + ++stopTest; +} + +int32_t getResultFromSecondSide() +{ + return isTestPassing; +} + +void testCasesAreDone(void) +{ + increaseWaitQuit(); +} + +void quitFirstInterfaceServer() +{ + /* removing the service from the server */ + erpc_remove_service_from_server(server, service); + destroy_FirstInterface_service(service); + + // Stop server part + erpc_server_stop(server); +} + +void whenReady() +{ + waitClient++; +} +} + +int testClient() +{ + int number = 15; + for (int i = 0; i < number; i++) + { + secondSendInt(i + number); + } + for (int i = number - 1; i >= 0; i--) + { + if (i + number != secondReceiveInt()) + { + return -1; + } + } + return 0; +} diff --git a/test/common/unit_test_zephyr_uart_server.cpp b/test/common/unit_test_zephyr_uart_server.cpp new file mode 100644 index 00000000..2521b0e3 --- /dev/null +++ b/test/common/unit_test_zephyr_uart_server.cpp @@ -0,0 +1,101 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "erpc_mbf_setup.h" +#include "erpc_server_setup.h" +#include "erpc_simple_server.hpp" +#include "erpc_transport_setup.h" +#include "erpc_uart_zephyr_transport.hpp" + +#include "c_test_unit_test_common_server.h" +#include "myAlloc.hpp" +#include "unit_test_wrapped.h" + +//////////////////////////////////////////////////////////////////////////////// +// Variables +//////////////////////////////////////////////////////////////////////////////// +#define UART_DEVICE_NODE DT_CHOSEN(zephyr_console) + +static const struct device *const uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE); + +int ::MyAlloc::allocated_ = 0; +erpc_service_t service_common = NULL; +erpc_server_t server; + + +//////////////////////////////////////////////////////////////////////////////// +// Code +//////////////////////////////////////////////////////////////////////////////// + +int main(void) +{ + if (!device_is_ready(uart_dev)) + { + printk("UART device not found!"); + return -1; + } + + erpc_transport_t transport; + erpc_mbf_t message_buffer_factory; + + transport = erpc_transport_zephyr_uart_init((void *)uart_dev); + message_buffer_factory = erpc_mbf_dynamic_init(); + + /* Init server */ + server = erpc_server_init(transport, message_buffer_factory); + + /* Add test services. This function call erpc_add_service_to_server for all necessary services. */ + add_services_to_server(server); + + /* Add common service */ + add_common_service(server); + + /* Add run server */ + erpc_server_run(server); + + /* Deinit server */ + erpc_server_deinit(server); + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// Server helper functions +//////////////////////////////////////////////////////////////////////////////// + +void add_common_service(erpc_server_t server) +{ + service_common = create_Common_service(); + erpc_add_service_to_server(server, service_common); +} + +void remove_common_services_from_server(erpc_server_t server, erpc_service_t service) +{ + erpc_remove_service_from_server(server, service); + destroy_Common_service(service); +} + +//////////////////////////////////////////////////////////////////////////////// +// Common service implementations here +//////////////////////////////////////////////////////////////////////////////// + +void quit() +{ + /* removing common services from the server */ + remove_common_services_from_server(server, service_common); + + /* removing individual test services from the server */ + remove_services_from_server(server); + + erpc_server_stop(server); +} + +int32_t getServerAllocated() +{ + int result = ::MyAlloc::allocated(); + ::MyAlloc::allocated(0); + return result; +} diff --git a/test/python_impl_tests/scripts/server/runner.py b/test/python_impl_tests/scripts/server/runner.py index b3582696..cd5ce026 100644 --- a/test/python_impl_tests/scripts/server/runner.py +++ b/test/python_impl_tests/scripts/server/runner.py @@ -20,12 +20,19 @@ def __init__(self, name, params, services, constructors): self.client = None self.proc = None self.argParser = self.initParser() - try: - self.args = self.argParser.parse_args() - except: - args = [item for item in sys.argv if (item in ['-c', '-s', '--server', '--client']) or ('=' in item)] + + if '--twister-harness' in sys.argv: + # Filter all unnecessary arguments from Twister + args = [item for item in sys.argv if ('--device-serial' in item or '--device-serial-baud' in item)] + args.append('-c') self.args = self.argParser.parse_args(args) - self.initTest(name, params) + else: + try: + self.args = self.argParser.parse_args() + except: + args = [item for item in sys.argv if (item in ['-c', '-s', '--server', '--client']) or ('=' in item)] + self.args = self.argParser.parse_args(args) + self.initTest(name, params) def initParser(self): # parse cmd parameters @@ -36,6 +43,9 @@ def initParser(self): argParser.add_argument('-p', '--port', default='12345', help='Port (default value is 12345)') argParser.add_argument('-S', '--serial', default=None, help='Serial device (default value is None)') argParser.add_argument('-B', '--baud', default='115200', help='Baud (default value is 115200)') + # Zephyr Twister arguments + argParser.add_argument('--device-serial', default=None, dest='serial') + argParser.add_argument('--device-serial-baud', default='115200', dest='baud', ) return argParser def initTest(self, name, params): diff --git a/test/test_arbitrator/test_arbitrator_client_impl.cpp b/test/test_arbitrator/test_arbitrator_client_impl.cpp index 22839f2b..b4157ae7 100644 --- a/test/test_arbitrator/test_arbitrator_client_impl.cpp +++ b/test/test_arbitrator/test_arbitrator_client_impl.cpp @@ -64,6 +64,7 @@ TEST(test_arbitrator, NestedCallTest) stopSecondSide(); while (!enabled) { + Thread::sleep(1000); }; EXPECT_EQ(nestedCallTest(), nestedCallsCount * 2 - 1); } diff --git a/test/test_lists/test_lists_client_impl.cpp b/test/test_lists/test_lists_client_impl.cpp index f648712a..f6706d65 100644 --- a/test/test_lists/test_lists_client_impl.cpp +++ b/test/test_lists/test_lists_client_impl.cpp @@ -205,14 +205,20 @@ TEST(test_list, SendReceived2Enum) switch (j) { case 0: + { *list_s = red; break; + } case 1: + { *list_s = green; break; + } case 2: + { *list_s = blue; break; + } } ++list_s; } diff --git a/test/test_unions/test_unions_server_impl.cpp b/test/test_unions/test_unions_server_impl.cpp index 8c2140d1..55c2d785 100644 --- a/test/test_unions/test_unions_server_impl.cpp +++ b/test/test_unions/test_unions_server_impl.cpp @@ -87,6 +87,7 @@ gapGenericEvent_t *testGenericCallback(const gapGenericEvent_t *event) case gAdvTxPowerLevelRead_c: default: { + break; } } return newEvent; diff --git a/test/zephyr/README.rst b/test/zephyr/README.rst new file mode 100644 index 00000000..6450fd8a --- /dev/null +++ b/test/zephyr/README.rst @@ -0,0 +1,93 @@ +Zephyr eRPC tests +################# + +This folder contains all the necessary files to test eRPC with Zephyr. +The folder contains two folders for dual core testing - `rpmsglite/` and PC-Board testing via UART - `uart/`. + +To build images for the primary and secondary core, Zephyr requires the use of `sysbuild`. The primary `CMakeLists.txt` is +located in the unit test folder, while the `CMakeLists.txt` for the secondary core is +located in the nested `remote` folder. The `sysbuild.cmake` directs the Zephyr build system to +first build the secondary core and then link it to the primary image. + +Directory structure +******************* + +* **cmake/** CMake files used for building tests +* **rpmsglite/cmake/** CMake files for sysbuild and tests +* **uart/cmake/** CMake files for tests +* **rpmsglite/config/** Configuration files for both cores +* **uart/config/** Configuration files for UART tests +* **rpmsglite/test\_xxx/** Directories with tests. Contains primary and remote CMakeLists.txt, sysbuild.cmake and testcase.yaml +* **uart/test\_xxx/** Directories with tests. Contains CMakeLists.txt and testcase.yaml + +Running tests +************* + +Note: To generate eRPC code, CMake requires `erpcgen` executable to be in Path. +If you have already builded `erpcgen`, add it to the path. Windows: + +.. code-block:: console + + $env:PATH = $env:PATH + ';C:\path\to\erpc\erpcgen\' # Windows + +All tests (RPMSG-Lite and UART) can be executed with Zephyr's Twister: + +.. code-block:: console + + west twister --device-testing --device-serial COM8 -T .\erpc\test\zephyr -p mimxrt1160_evk_cm7 --west-flash --west-runner=jlink + +For executing tests on one core boards (mimxrt1060_evk): + +.. code-block:: console + + west twister --device-testing --device-serial COM8 -T .\erpc\test\zephyr\uart -p mimxrt1060_evkb + +* `--device-testing` Run tests on device +* `--device-serial` Select port where is the device connected +* `-T` Path where Twister looks for test cases (testcase.yaml) +* `-p` Name of the device +* `--west-flash` is required to be able build sysbuild tests. +* `--west-runner` Runner used to flash board + +Test's structure notes +###################### + +Each test suite has it's own `cmake/unit_test.cmake`. Each test has its own folder with a CMakeLists files that include `cmake/unit_test.cmake`, which includes +Zephyr and all necessary variables. These variables can be overridden in the test's CMakeLists file. Finally, the `zephyr/cmake/test.cmake`` file is included. +Ensure that all sources and includes are added to the test when included. If the client is involved, add the gtest as well. + +`cmake/unit_test.cmake` has to define `ERPC_ROOT_DIR`, `ZEPHYR_TEST_CMAKE_DIR` and `ERPC_ROOT_DIR`. +Additionally `TRANSPORT` and `APP_TYPE` has to be specified in test's `CMakeLists.txt` or in `unit_test.cmake` before including `zephyr/cmake/variables.cmake`. + +Variable +******** + +* **RPMSG_LITE_REMOTE_BOARD** Remote board selected based on build board +* **APP_TYPE** CLIENT/SERVER, specified in projects's CMakeLists +* **TRANSPORT** In this case always `zephyr_uart` or `zephyr_rpmsg_lite` +* **TEST_NAME** Name of the test - test_binary, ... +* **TEST_SOURCE_DIR** Source dir of the test implementation +* **TEST_COMMON_DIR** Common dir of the erpc test (`erpc/test/common``) +* **ERPC_NAME** Default `test`, can be overridden +* **ERPC_NAME_APP** Default ERPC_NAME, overridden +* **TEST_OUT_DIR** The binary directory where the test is builded +* **ERPC_OUT_ROOT_DIR** The root directory for the erpc shim code is generation +* **ERPC_OUT_DIR** Name of the directory where shim code is generated (Default: erpc_outputs) +* **TEST_ERPC_OUT_DIR** The directory where the erpc shim code is generated +* **GENERATE_ERPC_IDL_FILES** If FALSE, test.cmake file will not generate the shim code +* **IDL_FILE** IDL file that is used for generating +* **TEST_EXT_SOURCES** External sources that are added to the app +* **TEST_EXT_INCLUDES** External includes that are added to the app + +Files +***** + +* **cmake/test.cmake** Generate shim code, add sources and includes to the target, link Configuration files to erpc and rpmsg_lite +* **cmake/variables.cmake** Set default variables +* **{rpmsglite,uart}/cmake/unit_test.cmake** Main cmake for server and client, includes Zephyr package and variables.cmake +* **rpmsglite/cmake/sysbuild.cmake** Common sysbuild for all test. Has to be included from test's folder in file named **sysbuild.cmake** +* **rpmsglite/cmake/rpmsg_lite.cmake** Used in sysbuild.cmake to determinate remote board +* **{rpmsglite,uart}/test_xxx/testcase.yaml** Define test, so it can be discoverd by Twister +* **{rpmsglite,uart}/test_xxx/CMakeLists.cmake** CMake for the test +* **rpmsglite/test_xxx/sysbuild.cmake** Includes cmake/sysbuild.cmake. Used by Zephyr's sysbuild system +* **rpmsglite/test_xxx/remote/CMakeLists.cmake** CMake for the server \ No newline at end of file diff --git a/test/zephyr/cmake/test.cmake b/test/zephyr/cmake/test.cmake new file mode 100644 index 00000000..b1cda6a7 --- /dev/null +++ b/test/zephyr/cmake/test.cmake @@ -0,0 +1,88 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Generate ERPC shim code and add sources and includes to app target. +# If APP_TYPE is client, also add gtest. Link the config directory to erpc a rpmsg_lite. + +set_ifndef(TEST_ERPC_FILES + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME_APP}_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_unit_test_common_interface.cpp + + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME_APP}_${APP_TYPE}.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_unit_test_common_${APP_TYPE}.cpp + + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME_APP}_${APP_TYPE}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME}_unit_test_common_${APP_TYPE}.cpp +) + +if(GENERATE_ERPC_IDL_FILES) + add_custom_command( + OUTPUT ${TEST_ERPC_FILES} + COMMAND erpcgen -g c -o ${ERPC_OUT_ROOT_DIR} ${IDL_FILE} # TODO: add builded erpcgen if not found in path + WORKING_DIRECTORY ${TEST_SOURCE_DIR} + DEPENDS ${IDL_FILE} + COMMENT "Generating eRPC files from: ${IDL_FILE} to ${ERPC_OUT_ROOT_DIR}" + ) +endif() + +set_ifndef(TEST_SOURCES + ${TEST_COMMON_DIR}/unit_test_${TRANSPORT}_${APP_TYPE}.cpp + ${TEST_SOURCE_DIR}/${TEST_NAME}_${APP_TYPE}_impl.cpp + + ${TEST_ERPC_FILES} + ${TEST_EXT_SOURCES} +) + +set_ifndef(TEST_INCLUDES + ${TEST_ERPC_OUT_DIR} + ${TEST_COMMON_DIR} + ${TEST_SOURCE_DIR} + ${CONFIG_DIR}/ + ${TEST_EXT_INCLUDES} +) + +target_include_directories(app PRIVATE ${TEST_INCLUDES}) +target_sources(app PRIVATE ${TEST_SOURCES}) + +# Include gtest +if(APP_TYPE STREQUAL "client") + target_sources(app + PRIVATE ${TEST_COMMON_DIR}/gtest/gtest.cpp + PRIVATE ${TEST_COMMON_DIR}/gtest/gtimer.c + ) + + target_include_directories(app PUBLIC ${TEST_COMMON_DIR}/gtest/) + + target_compile_definitions(app PUBLIC + GTEST_OS_BARE_METAL=1 + GTEST_HAS_CLONE=0 + GTEST_HAS_EXCEPTIONS=0 + GTEST_HAS_GLOBAL_STRING=0 + GTEST_HAS_GLOBAL_WSTRING=0 + GTEST_HAS_POSIX_RE=0 + GTEST_HAS_PTHREAD=0 + GTEST_HAS_RTTI=0 + GTEST_HAS_STD_WSTRING=1 + GTEST_HAS_TR1_TUPLE=0 + GTEST_HAS_SEH=0 + GTEST_HAS_STREAM_REDIRECTION=0 + GTEST_USE_OWN_TR1_TUPLE=1 + GTEST_LANG_CXX11=1 + GTEST_LINKED_AS_SHARED_LIBRARY=0 + GTEST_CREATE_SHARED_LIBRARY=0 + UNITY_DUMP_RESULTS=1 + ) +endif() + +# Also include this directory into rpmsg_lite library because of project specific include rpsmg_config.h +if(CONFIG_RPMSGLITE) + target_include_directories(rpmsg_lite PRIVATE ${CONFIG_DIR}) +endif() + +# Same for erpc library and erpc_config.h +if(CONFIG_ERPC) + target_include_directories(erpc PRIVATE ${CONFIG_DIR}) +endif() \ No newline at end of file diff --git a/test/zephyr/cmake/variables.cmake b/test/zephyr/cmake/variables.cmake new file mode 100644 index 00000000..70d174ec --- /dev/null +++ b/test/zephyr/cmake/variables.cmake @@ -0,0 +1,27 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Set test implementation directory +set(TEST_SOURCE_DIR ${ERPC_ROOT_DIR}/test/${TEST_NAME}) +set(TEST_COMMON_DIR ${ERPC_ROOT_DIR}/test/common) + +# Set test name +set(ERPC_NAME "test") +set(ERPC_NAME_APP ${ERPC_NAME}) + +# Directory where test is generated +set(TEST_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) + +# Directory where eRPC shim is generated +set(ERPC_OUT_ROOT_DIR ${TEST_OUT_DIR}) +set(ERPC_OUT_DIR erpc_outputs) +set(TEST_ERPC_OUT_DIR ${ERPC_OUT_ROOT_DIR}/${ERPC_OUT_DIR}) + +# Disable/Enable ERPC Shim generation; Source code has to be added to TEST_CLIENT_SOURCES/TEST_SERVER_SOURCES +set(GENERATE_ERPC_IDL_FILES TRUE) + +# IDL file +set(IDL_FILE ${TEST_SOURCE_DIR}/${TEST_NAME}.erpc) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/cmake/rpmsg_lite.cmake b/test/zephyr/rpmsglite/cmake/rpmsg_lite.cmake new file mode 100644 index 00000000..001aaf31 --- /dev/null +++ b/test/zephyr/rpmsglite/cmake/rpmsg_lite.cmake @@ -0,0 +1,29 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Selects the secondary board based on the board set during build. + +message(STATUS "BOARD: ${BOARD}") + +if(BOARD STREQUAL "lpcxpresso54114_m4") + set(RPMSG_LITE_REMOTE_BOARD "lpcxpresso54114_m0") +elseif(BOARD STREQUAL "lpcxpresso55s69_cpu0") + set(RPMSG_LITE_REMOTE_BOARD "lpcxpresso55s69_cpu1") +elseif(BOARD STREQUAL "mps2_an521") + set(RPMSG_LITE_REMOTE_BOARD "mps2_an521_remote") +elseif(BOARD STREQUAL "v2m_musca_b1") + set(RPMSG_LITE_REMOTE_BOARD "v2m_musca_b1_ns") +elseif(BOARD STREQUAL "mimxrt1170_evk_cm7") + set(RPMSG_LITE_REMOTE_BOARD "mimxrt1170_evk_cm4") +elseif(BOARD STREQUAL "mimxrt1160_evk_cm7") + set(RPMSG_LITE_REMOTE_BOARD "mimxrt1160_evk_cm4") +elseif(BOARD STREQUAL "mimxrt1170_evkb_cm7") + set(RPMSG_LITE_REMOTE_BOARD "mimxrt1170_evkb_cm4") +else() + message(FATAL "RMPSG-Lite: Unsupported board.") +endif() + + diff --git a/test/zephyr/rpmsglite/cmake/sysbuild.cmake b/test/zephyr/rpmsglite/cmake/sysbuild.cmake new file mode 100644 index 00000000..4095b9af --- /dev/null +++ b/test/zephyr/rpmsglite/cmake/sysbuild.cmake @@ -0,0 +1,31 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +get_filename_component(CURRENT_DIR_NAME ${APP_DIR} NAME) +set(SERVER ${CURRENT_DIR_NAME}_remote) +set(CLIENT ${CURRENT_DIR_NAME}) + +# Include RPMSG_LITE_REMOTE_BOARD variable base on BOARD +include(${APP_DIR}/../cmake/rpmsg_lite.cmake) + +# Add external project +ExternalZephyrProject_Add( + APPLICATION ${SERVER} + SOURCE_DIR ${APP_DIR}/remote + BOARD ${RPMSG_LITE_REMOTE_BOARD} + ) + +# Add dependencies so that the remote sample will be built first +# This is required because some primary cores need information from the +# remote core's build, such as the output image's LMA +add_dependencies(${CLIENT} ${SERVER}) +sysbuild_add_dependencies(FLASH ${CLIENT} ${SERVER}) +sysbuild_add_dependencies(CONFIGURE ${CLIENT} ${SERVER}) + +if(SB_CONFIG_BOOTLOADER_MCUBOOT) + # Make sure MCUboot is flashed first + sysbuild_add_dependencies(FLASH ${CLIENT} mcuboot) +endif() diff --git a/test/zephyr/rpmsglite/cmake/unit_test.cmake b/test/zephyr/rpmsglite/cmake/unit_test.cmake new file mode 100644 index 00000000..d48888a8 --- /dev/null +++ b/test/zephyr/rpmsglite/cmake/unit_test.cmake @@ -0,0 +1,44 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +set(TRANSPORT "zephyr_rpmsg_lite") + +if((NOT APP_TYPE STREQUAL "client") AND (NOT APP_TYPE STREQUAL "server")) + message(FATAL_ERROR "Unmown APP_TYPE. Set it to the 'client' or 'server'.") +endif() + +if (APP_TYPE STREQUAL "client") + set(KCONFIG_ROOT ${CMAKE_CURRENT_LIST_DIR}/../config/Kconfig) +endif() + +if(NOT DEFINED APPLICATION_CONFIG_DIR) + if (APP_TYPE STREQUAL "client") + set(APPLICATION_CONFIG_DIR ${CMAKE_CURRENT_LIST_DIR}/../config/) + elseif(APP_TYPE STREQUAL "server") + set(APPLICATION_CONFIG_DIR ${CMAKE_CURRENT_LIST_DIR}/../config/remote) + endif() +endif() + +if(NOT DEFINED CONFIG_DIR) + set(CONFIG_DIR ${CMAKE_CURRENT_LIST_DIR}/../config/) +endif() + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +zephyr_get(APP_DIR SYSBUILD GLOBAL) +get_filename_component(TEST_NAME ${APP_DIR} NAME) +set(ERPC_ROOT_DIR ${ZEPHYR_ERPC_MODULE_DIR}) +set(ZEPHYR_TEST_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../cmake) + +# Include test's variables +include(${ZEPHYR_TEST_CMAKE_DIR}/variables.cmake) + +if(CONFIG_INCLUDE_REMOTE_DIR) + target_include_directories(zephyr_interface + INTERFACE + ${CMAKE_CURRENT_BINARY_DIR}/../${TEST_NAME}_remote/zephyr/include/public) +endif() + diff --git a/test/zephyr/rpmsglite/config/Kconfig b/test/zephyr/rpmsglite/config/Kconfig new file mode 100644 index 00000000..defc13a8 --- /dev/null +++ b/test/zephyr/rpmsglite/config/Kconfig @@ -0,0 +1,11 @@ +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause + +source "Kconfig.zephyr" + +config INCLUDE_REMOTE_DIR + bool "Include remote core header directory" + help + Include remote build header files. Can be used if primary image + needs to be aware of size or base address of secondary image diff --git a/test/zephyr/rpmsglite/config/boards/lpcxpresso54114_m4.conf b/test/zephyr/rpmsglite/config/boards/lpcxpresso54114_m4.conf new file mode 100644 index 00000000..60eead5a --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/lpcxpresso54114_m4.conf @@ -0,0 +1,2 @@ +CONFIG_SECOND_CORE_MCUX=y +CONFIG_INCLUDE_REMOTE_DIR=y diff --git a/test/zephyr/rpmsglite/config/boards/lpcxpresso54114_m4.overlay b/test/zephyr/rpmsglite/config/boards/lpcxpresso54114_m4.overlay new file mode 100644 index 00000000..95f16760 --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/lpcxpresso54114_m4.overlay @@ -0,0 +1,20 @@ +/* + * Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + 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/test/zephyr/rpmsglite/config/boards/lpcxpresso55s69_cpu0.conf b/test/zephyr/rpmsglite/config/boards/lpcxpresso55s69_cpu0.conf new file mode 100644 index 00000000..7e6904d5 --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/lpcxpresso55s69_cpu0.conf @@ -0,0 +1 @@ +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/config/boards/lpcxpresso55s69_cpu0.overlay b/test/zephyr/rpmsglite/config/boards/lpcxpresso55s69_cpu0.overlay new file mode 100644 index 00000000..98df6d93 --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/lpcxpresso55s69_cpu0.overlay @@ -0,0 +1,22 @@ +/* + * Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + /* + * shared memory reserved for the inter-processor communication + */ + + zephyr,ipc_shm = &sram4duplicate; + zephyr,ipc = &mailbox0; + }; + + /* This is a duplication of sram4, workaround */ + sram4duplicate: memory@20040000 { + compatible = "mmio-sram"; + reg = <0x20040000 DT_SIZE_K(16)>; + }; +}; diff --git a/test/zephyr/rpmsglite/config/boards/mimxrt1160_evk_cm7.conf b/test/zephyr/rpmsglite/config/boards/mimxrt1160_evk_cm7.conf new file mode 100644 index 00000000..630a1933 --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/mimxrt1160_evk_cm7.conf @@ -0,0 +1,2 @@ +CONFIG_INCLUDE_REMOTE_DIR=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/config/boards/mimxrt1160_evk_cm7.overlay b/test/zephyr/rpmsglite/config/boards/mimxrt1160_evk_cm7.overlay new file mode 100644 index 00000000..3bf2b0dc --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/mimxrt1160_evk_cm7.overlay @@ -0,0 +1,24 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + chosen { + zephyr,ipc_shm = &ocram2_overlay; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set. + */ + ocram2_overlay: memory@202c0000{ + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; diff --git a/test/zephyr/rpmsglite/config/boards/mimxrt1170_evk_cm7.conf b/test/zephyr/rpmsglite/config/boards/mimxrt1170_evk_cm7.conf new file mode 100644 index 00000000..630a1933 --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/mimxrt1170_evk_cm7.conf @@ -0,0 +1,2 @@ +CONFIG_INCLUDE_REMOTE_DIR=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/config/boards/mimxrt1170_evk_cm7.overlay b/test/zephyr/rpmsglite/config/boards/mimxrt1170_evk_cm7.overlay new file mode 100644 index 00000000..3bf2b0dc --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/mimxrt1170_evk_cm7.overlay @@ -0,0 +1,24 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + chosen { + zephyr,ipc_shm = &ocram2_overlay; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set. + */ + ocram2_overlay: memory@202c0000{ + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; diff --git a/test/zephyr/rpmsglite/config/boards/mimxrt1170_evkb_cm7.conf b/test/zephyr/rpmsglite/config/boards/mimxrt1170_evkb_cm7.conf new file mode 100644 index 00000000..ffd841cb --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/mimxrt1170_evkb_cm7.conf @@ -0,0 +1,7 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# +CONFIG_INCLUDE_REMOTE_DIR=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/config/boards/mimxrt1170_evkb_cm7.overlay b/test/zephyr/rpmsglite/config/boards/mimxrt1170_evkb_cm7.overlay new file mode 100644 index 00000000..3bf2b0dc --- /dev/null +++ b/test/zephyr/rpmsglite/config/boards/mimxrt1170_evkb_cm7.overlay @@ -0,0 +1,24 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + chosen { + zephyr,ipc_shm = &ocram2_overlay; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set. + */ + ocram2_overlay: memory@202c0000{ + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; diff --git a/test/zephyr/rpmsglite/config/erpc_config.h b/test/zephyr/rpmsglite/config/erpc_config.h new file mode 100644 index 00000000..20721f71 --- /dev/null +++ b/test/zephyr/rpmsglite/config/erpc_config.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2021 NXP + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ERPC_CONFIG_H_ +#define _ERPC_CONFIG_H_ + +/*! + * @addtogroup config + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// Declarations +//////////////////////////////////////////////////////////////////////////////// + +//! @name Threading model options +//@{ +#define ERPC_ALLOCATION_POLICY_DYNAMIC (0U) //!< Dynamic allocation policy +#define ERPC_ALLOCATION_POLICY_STATIC (1U) //!< Static allocation policy + +#define ERPC_THREADS_NONE (0U) //!< No threads. +#define ERPC_THREADS_PTHREADS (1U) //!< POSIX pthreads. +#define ERPC_THREADS_FREERTOS (2U) //!< FreeRTOS. +#define ERPC_THREADS_ZEPHYR (3U) //!< ZEPHYR. +#define ERPC_THREADS_MBED (4U) //!< Mbed OS +#define ERPC_THREADS_WIN32 (5U) //!< WIN32 +#define ERPC_THREADS_THREADX (6U) //!< THREADX + +#define ERPC_NOEXCEPT_DISABLED (0U) //!< Disabling noexcept feature. +#define ERPC_NOEXCEPT_ENABLED (1U) //!< Enabling noexcept feature. + +#define ERPC_NESTED_CALLS_DISABLED (0U) //!< No nested calls support. +#define ERPC_NESTED_CALLS_ENABLED (1U) //!< Nested calls support. + +#define ERPC_NESTED_CALLS_DETECTION_DISABLED (0U) //!< Nested calls detection disabled. +#define ERPC_NESTED_CALLS_DETECTION_ENABLED (1U) //!< Nested calls detection enabled. + +#define ERPC_MESSAGE_LOGGING_DISABLED (0U) //!< Trace functions disabled. +#define ERPC_MESSAGE_LOGGING_ENABLED (1U) //!< Trace functions enabled. + +#define ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED (0U) //!< Do not use MCMGR for MU ISR management. +#define ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED (1U) //!< Use MCMGR for MU ISR management. + +#define ERPC_PRE_POST_ACTION_DISABLED (0U) //!< Pre post shim callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_ENABLED (1U) //!< Pre post shim callback functions enabled. + +#define ERPC_PRE_POST_ACTION_DEFAULT_DISABLED (0U) //!< Pre post shim default callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_DEFAULT_ENABLED (1U) //!< Pre post shim default callback functions enabled. +//@} + +//! @name Configuration options +//@{ + +//! @def ERPC_ALLOCATION_POLICY +//! +//! @brief Choose which allocation policy should be used. +//! +//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used. +//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used. +//! +//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is supported +//! by compiler. Uncomment comment bellow to use static allocation policy. +//! In case of static implementation user need consider another values to set (ERPC_CODEC_COUNT, +//! ERPC_MESSAGE_LOGGERS_COUNT, ERPC_CLIENTS_THREADS_AMOUNT). +// #define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC) + +//! @def ERPC_CODEC_COUNT +//! +//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one thread per +//! each then 2, ... Default value 2. +// #define ERPC_CODEC_COUNT (2U) + +//! @def ERPC_MESSAGE_LOGGERS_COUNT +//! +//! @brief Set amount of message loggers objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. +//! For example if client or server is used in one thread then 1. If both are used in one thread per each then 2, ... +//! For arbitrated client 1 is enough. +//! Default value 0 (May not be used). +// #define ERPC_MESSAGE_LOGGERS_COUNT (0U) + +//! @def ERPC_CLIENTS_THREADS_AMOUNT +//! +//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to ERPC_ALLOCATION_POLICY_STATIC. +//! Default value 1 (Most of current cases). +// #define ERPC_CLIENTS_THREADS_AMOUNT (1U) + +//! @def ERPC_THREADS +//! +//! @brief Select threading model. +//! +//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC. +//! +//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads. +//! FreeRTOS can be detected when building with compilers that support __has_include(). +//! Otherwise, the default is no threading. +#define ERPC_THREADS (ERPC_THREADS_ZEPHYR) + +//! @def ERPC_DEFAULT_BUFFER_SIZE +//! +//! Uncomment to change the size of buffers allocated by one of MessageBufferFactory. +//! (@ref client_setup and @ref server_setup). The default size is set to 256. +//! For RPMsg transport layer, ERPC_DEFAULT_BUFFER_SIZE must be 2^n - 16. +#define ERPC_DEFAULT_BUFFER_SIZE (496U) + +//! @def ERPC_DEFAULT_BUFFERS_COUNT +//! +//! Uncomment to change the count of buffers allocated by one of statically allocated messages. +//! Default value is set to 2. +//#define ERPC_DEFAULT_BUFFERS_COUNT (2U) + +//! @def ERPC_NOEXCEPT +//! +//! @brief Disable/enable noexcept support. +//! +//! Uncomment for using noexcept feature. +//#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED) + +//! @def ERPC_NESTED_CALLS +//! +//! Default set to ERPC_NESTED_CALLS_DISABLED. Uncomment when callbacks, or other eRPC +//! functions are called from server implementation of another eRPC call. Nested functions +//! need to be marked as @nested in IDL. +//#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_ENABLED) + +//! @def ERPC_NESTED_CALLS_DETECTION +//! +//! Default set to ERPC_NESTED_CALLS_DETECTION_ENABLED when NDEBUG macro is presented. +//! This serve for locating nested calls in code. Nested calls are calls where inside eRPC function +//! on server side is called another eRPC function (like callbacks). Code need be a bit changed +//! to support nested calls. See ERPC_NESTED_CALLS macro. +//#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED) + +//! @def ERPC_MESSAGE_LOGGING +//! +//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base +//! printing messages, or sending data to another system for data analysis. Default set to +//! ERPC_MESSAGE_LOGGING_DISABLED. +//! +//! Uncomment for using logging feature. +//#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_ENABLED) + +//! @def ERPC_TRANSPORT_MU_USE_MCMGR +//! +//! @brief MU transport layer configuration. +//! +//! Set to one of the @c ERPC_TRANSPORT_MU_USE_MCMGR_x macros to configure the MCMGR usage in MU transport layer. +//! +//! MU transport layer could leverage the Multicore Manager (MCMGR) component for Inter-Core +//! interrupts / MU interrupts management or the Inter-Core interrupts can be managed by itself (MUX_IRQHandler +//! overloading). By default, ERPC_TRANSPORT_MU_USE_MCMGR is set to ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED when mcmgr.h +//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be +//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget +//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the +//! erpc_mu_transport.h for additional MU settings. +//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED +//@} + +//! @def ERPC_PRE_POST_ACTION +//! +//! Enable eRPC pre and post callback functions shim code. Take look into "erpc_pre_post_action.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DISABLED. +//! +//! Uncomment for using pre post callback feature. +//#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_ENABLED) + +//! @def ERPC_PRE_POST_ACTION_DEFAULT +//! +//! Enable eRPC pre and post default callback functions. Take look into "erpc_setup_extensions.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DEFAULT_DISABLED. +//! +//! Uncomment for using pre post default callback feature. +//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED) + +/*! @} */ +#endif // _ERPC_CONFIG_H_ +//////////////////////////////////////////////////////////////////////////////// +// EOF +//////////////////////////////////////////////////////////////////////////////// diff --git a/test/zephyr/rpmsglite/config/prj.conf b/test/zephyr/rpmsglite/config/prj.conf new file mode 100644 index 00000000..e9735977 --- /dev/null +++ b/test/zephyr/rpmsglite/config/prj.conf @@ -0,0 +1,37 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP17=y +CONFIG_GLIBCXX_LIBCPP=y + +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=y + +# Compiler +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_NO_OPTIMIZATIONS=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_RPMSG_LITE=y + +# RPMSG Lite +CONFIG_IPM=y +CONFIG_EVENTS=y +CONFIG_PRINTK=y +CONFIG_RPMSGLITE=y +CONFIG_RPMSGLITE_QUEUE=y +CONFIG_RPMSGLITE_NS=y +CONFIG_TIMESLICE_SIZE=1 + +CONFIG_THREAD_CUSTOM_DATA=y +CONFIG_ERPC_ARBITRATED_CLIENT=y +CONFIG_POLL=y + +CONFIG_THREAD_NAME=y +CONFIG_SCHED_CPU_MASK=y +CONFIG_THREAD_ANALYZER=y + +CONFIG_LOG=y +CONFIG_LOG_MODE_IMMEDIATE=y +CONFIG_LOG_OVERRIDE_LEVEL=3 \ No newline at end of file diff --git a/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso54114_m0.conf b/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso54114_m0.conf new file mode 100644 index 00000000..b9e2b072 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso54114_m0.conf @@ -0,0 +1,2 @@ +CONFIG_SECOND_CORE_MCUX=y +CONFIG_BUILD_OUTPUT_HEX=y diff --git a/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso54114_m0.overlay b/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso54114_m0.overlay new file mode 100644 index 00000000..95f16760 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso54114_m0.overlay @@ -0,0 +1,20 @@ +/* + * Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + 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/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso55s69_cpu1.conf b/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso55s69_cpu1.conf new file mode 100644 index 00000000..b9e2b072 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso55s69_cpu1.conf @@ -0,0 +1,2 @@ +CONFIG_SECOND_CORE_MCUX=y +CONFIG_BUILD_OUTPUT_HEX=y diff --git a/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso55s69_cpu1.overlay b/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso55s69_cpu1.overlay new file mode 100644 index 00000000..98df6d93 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/lpcxpresso55s69_cpu1.overlay @@ -0,0 +1,22 @@ +/* + * Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + /* + * shared memory reserved for the inter-processor communication + */ + + zephyr,ipc_shm = &sram4duplicate; + zephyr,ipc = &mailbox0; + }; + + /* This is a duplication of sram4, workaround */ + sram4duplicate: memory@20040000 { + compatible = "mmio-sram"; + reg = <0x20040000 DT_SIZE_K(16)>; + }; +}; diff --git a/test/zephyr/rpmsglite/config/remote/boards/mimxrt1160_evk_cm4.conf b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1160_evk_cm4.conf new file mode 100644 index 00000000..4dfc4a60 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1160_evk_cm4.conf @@ -0,0 +1,3 @@ +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/config/remote/boards/mimxrt1160_evk_cm4.overlay b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1160_evk_cm4.overlay new file mode 100644 index 00000000..ab57a613 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1160_evk_cm4.overlay @@ -0,0 +1,51 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + /* Switch to lpuart2, since primary core uses lpuart1 */ + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart2; + zephyr,shell-uart = &lpuart2; + zephyr,ipc_shm = &ocram2_overlay; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set + */ + ocram2_overlay: memory@202c0000 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; + +/* Enable secondary LPUART */ +&lpuart2 { + status = "okay"; + current-speed = <115200>; +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; diff --git a/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evk_cm4.conf b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evk_cm4.conf new file mode 100644 index 00000000..4dfc4a60 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evk_cm4.conf @@ -0,0 +1,3 @@ +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evk_cm4.overlay b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evk_cm4.overlay new file mode 100644 index 00000000..ab57a613 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evk_cm4.overlay @@ -0,0 +1,51 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + /* Switch to lpuart2, since primary core uses lpuart1 */ + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart2; + zephyr,shell-uart = &lpuart2; + zephyr,ipc_shm = &ocram2_overlay; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set + */ + ocram2_overlay: memory@202c0000 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; + +/* Enable secondary LPUART */ +&lpuart2 { + status = "okay"; + current-speed = <115200>; +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; diff --git a/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evkb_cm4.conf b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evkb_cm4.conf new file mode 100644 index 00000000..ef7b0f83 --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evkb_cm4.conf @@ -0,0 +1,8 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evkb_cm4.overlay b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evkb_cm4.overlay new file mode 100644 index 00000000..65fb71ff --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/boards/mimxrt1170_evkb_cm4.overlay @@ -0,0 +1,51 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + /* Switch to lpuart2, since primary core uses lpuart1 */ + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart1; + zephyr,shell-uart = &lpuart1; + zephyr,ipc_shm = &ocram2_overlay; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set + */ + ocram2_overlay: memory@202c0000 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; + +/* Enable secondary LPUART */ +&lpuart2 { + status = "okay"; + current-speed = <115200>; +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; diff --git a/test/zephyr/rpmsglite/config/remote/prj.conf b/test/zephyr/rpmsglite/config/remote/prj.conf new file mode 100644 index 00000000..5581523e --- /dev/null +++ b/test/zephyr/rpmsglite/config/remote/prj.conf @@ -0,0 +1,33 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP17=y +CONFIG_GLIBCXX_LIBCPP=y + +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=y + +# Compiler +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_NO_OPTIMIZATIONS=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_RPMSG_LITE=y + +# RPMSG Lite +CONFIG_IPM=y +CONFIG_EVENTS=y +CONFIG_PRINTK=y +CONFIG_RPMSGLITE=y +CONFIG_RPMSGLITE_QUEUE=y +CONFIG_RPMSGLITE_NS=y +CONFIG_TIMESLICE_SIZE=1 + +CONFIG_THREAD_CUSTOM_DATA=y +CONFIG_ERPC_ARBITRATED_CLIENT=y +CONFIG_POLL=y + +CONFIG_THREAD_NAME=y +CONFIG_SCHED_CPU_MASK=y +CONFIG_THREAD_ANALYZER=y \ No newline at end of file diff --git a/test/zephyr/rpmsglite/config/rpmsg_config.h b/test/zephyr/rpmsglite/config/rpmsg_config.h new file mode 100644 index 00000000..8d519b6c --- /dev/null +++ b/test/zephyr/rpmsglite/config/rpmsg_config.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014, Mentor Graphics Corporation + * All rights reserved. + * Copyright (c) 2015 Xilinx, Inc. All rights reserved. + * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef RPMSG_CONFIG_H_ +#define RPMSG_CONFIG_H_ + +#include "erpc_config_internal.h" + +/* RPMsg config values */ +/* START { */ +#define RL_MS_PER_INTERVAL (1) + +#define RL_BUFFER_PAYLOAD_SIZE (ERPC_DEFAULT_BUFFER_SIZE) + +#define RL_BUFFER_COUNT (ERPC_DEFAULT_BUFFERS_COUNT) + +#define RL_API_HAS_ZEROCOPY (1) + +#define RL_USE_STATIC_API (1) + +#define RL_USE_MCMGR_IPC_ISR_HANDLER (1) + +#define RL_ASSERT(x) \ + do \ + { \ + if (!(x)) \ + while (1) \ + ; \ + } while (0); +/* } END */ + +#endif /* RPMSG_CONFIG_H_ */ diff --git a/test/zephyr/rpmsglite/test_annotations/CMakeLists.txt b/test/zephyr/rpmsglite/test_annotations/CMakeLists.txt new file mode 100644 index 00000000..44c466af --- /dev/null +++ b/test/zephyr/rpmsglite/test_annotations/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(TEST_EXT_SOURCES ${TEST_COMMON_DIR}/addOne.cpp) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_annotations/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_annotations/remote/CMakeLists.txt new file mode 100644 index 00000000..cf2b14f6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_annotations/remote/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_annotations/sysbuild.cmake b/test/zephyr/rpmsglite/test_annotations/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_annotations/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_annotations/testcase.yaml b/test/zephyr/rpmsglite/test_annotations/testcase.yaml new file mode 100644 index 00000000..05a74273 --- /dev/null +++ b/test/zephyr/rpmsglite/test_annotations/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.annotations: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_arbitrator/CMakeLists.txt b/test/zephyr/rpmsglite/test_arbitrator/CMakeLists.txt new file mode 100644 index 00000000..0184d6e0 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +set(APPLICATION_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config) +set(CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +include(${APP_DIR}/common.cmake) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_arbitrator/common.cmake b/test/zephyr/rpmsglite/test_arbitrator/common.cmake new file mode 100644 index 00000000..faad2b46 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/common.cmake @@ -0,0 +1,31 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +if (APP_TYPE STREQUAL "client") + set(APP_TYPE_SECOND "server") +elseif(APP_TYPE STREQUAL "server") +set(APP_TYPE_SECOND "client") +else() + message(FATAL "Unmown APP_TYPE. Set it to the 'client' or 'server'.") +endif() + + +set(TEST_ERPC_FILES + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_firstInterface_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_firstInterface_${APP_TYPE}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME}_firstInterface_${APP_TYPE}.cpp + + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_secondInterface_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_secondInterface_${APP_TYPE_SECOND}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME}_secondInterface_${APP_TYPE_SECOND}.cpp +) + +set(TEST_SOURCES + ${TEST_ERPC_FILES} + + ${TEST_SOURCE_DIR}/${TEST_NAME}_${APP_TYPE}_impl.cpp + ${TEST_COMMON_DIR}/unit_test_${TRANSPORT}_arbitrator_${APP_TYPE}.cpp +) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso54114_m4.conf b/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso54114_m4.conf new file mode 100644 index 00000000..60eead5a --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso54114_m4.conf @@ -0,0 +1,2 @@ +CONFIG_SECOND_CORE_MCUX=y +CONFIG_INCLUDE_REMOTE_DIR=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso54114_m4.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso54114_m4.overlay new file mode 100644 index 00000000..95f16760 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso54114_m4.overlay @@ -0,0 +1,20 @@ +/* + * Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + 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/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso55s69_cpu0.conf b/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso55s69_cpu0.conf new file mode 100644 index 00000000..7e6904d5 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso55s69_cpu0.conf @@ -0,0 +1 @@ +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso55s69_cpu0.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso55s69_cpu0.overlay new file mode 100644 index 00000000..6a2568e2 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/lpcxpresso55s69_cpu0.overlay @@ -0,0 +1,22 @@ +/* +* Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + /* + * shared memory reserved for the inter-processor communication + */ + + zephyr,ipc_shm = &sram4duplicate; + zephyr,ipc = &mailbox0; + }; + + /* This is a duplication of sram4, workaround */ + sram4duplicate: memory@20040000 { + compatible = "mmio-sram"; + reg = <0x20040000 DT_SIZE_K(16)>; + }; +}; diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1160_evk_cm7.conf b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1160_evk_cm7.conf new file mode 100644 index 00000000..630a1933 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1160_evk_cm7.conf @@ -0,0 +1,2 @@ +CONFIG_INCLUDE_REMOTE_DIR=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1160_evk_cm7.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1160_evk_cm7.overlay new file mode 100644 index 00000000..d160db3e --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1160_evk_cm7.overlay @@ -0,0 +1,24 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + chosen { + zephyr,ipc_shm = &ocram2_overlay; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set. + */ + ocram2_overlay: memory@202c0000{ + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(23)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evk_cm7.conf b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evk_cm7.conf new file mode 100644 index 00000000..630a1933 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evk_cm7.conf @@ -0,0 +1,2 @@ +CONFIG_INCLUDE_REMOTE_DIR=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evk_cm7.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evk_cm7.overlay new file mode 100644 index 00000000..d160db3e --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evk_cm7.overlay @@ -0,0 +1,24 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + chosen { + zephyr,ipc_shm = &ocram2_overlay; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set. + */ + ocram2_overlay: memory@202c0000{ + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(23)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evkb_cm7.conf b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evkb_cm7.conf new file mode 100644 index 00000000..ffd841cb --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evkb_cm7.conf @@ -0,0 +1,7 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# +CONFIG_INCLUDE_REMOTE_DIR=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evkb_cm7.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evkb_cm7.overlay new file mode 100644 index 00000000..3bf2b0dc --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/boards/mimxrt1170_evkb_cm7.overlay @@ -0,0 +1,24 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + chosen { + zephyr,ipc_shm = &ocram2_overlay; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set. + */ + ocram2_overlay: memory@202c0000{ + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/erpc_config.h b/test/zephyr/rpmsglite/test_arbitrator/config/erpc_config.h new file mode 100644 index 00000000..89abda4e --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/erpc_config.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2021 NXP + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ERPC_CONFIG_H_ +#define _ERPC_CONFIG_H_ + +/*! + * @addtogroup config + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// Declarations +//////////////////////////////////////////////////////////////////////////////// + +//! @name Threading model options +//@{ +#define ERPC_ALLOCATION_POLICY_DYNAMIC (0U) //!< Dynamic allocation policy +#define ERPC_ALLOCATION_POLICY_STATIC (1U) //!< Static allocation policy + +#define ERPC_THREADS_NONE (0U) //!< No threads. +#define ERPC_THREADS_PTHREADS (1U) //!< POSIX pthreads. +#define ERPC_THREADS_FREERTOS (2U) //!< FreeRTOS. +#define ERPC_THREADS_ZEPHYR (3U) //!< ZEPHYR. +#define ERPC_THREADS_MBED (4U) //!< Mbed OS +#define ERPC_THREADS_WIN32 (5U) //!< WIN32 +#define ERPC_THREADS_THREADX (6U) //!< THREADX + +#define ERPC_NOEXCEPT_DISABLED (0U) //!< Disabling noexcept feature. +#define ERPC_NOEXCEPT_ENABLED (1U) //!< Enabling noexcept feature. + +#define ERPC_NESTED_CALLS_DISABLED (0U) //!< No nested calls support. +#define ERPC_NESTED_CALLS_ENABLED (1U) //!< Nested calls support. + +#define ERPC_NESTED_CALLS_DETECTION_DISABLED (0U) //!< Nested calls detection disabled. +#define ERPC_NESTED_CALLS_DETECTION_ENABLED (1U) //!< Nested calls detection enabled. + +#define ERPC_MESSAGE_LOGGING_DISABLED (0U) //!< Trace functions disabled. +#define ERPC_MESSAGE_LOGGING_ENABLED (1U) //!< Trace functions enabled. + +#define ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED (0U) //!< Do not use MCMGR for MU ISR management. +#define ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED (1U) //!< Use MCMGR for MU ISR management. + +#define ERPC_PRE_POST_ACTION_DISABLED (0U) //!< Pre post shim callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_ENABLED (1U) //!< Pre post shim callback functions enabled. + +#define ERPC_PRE_POST_ACTION_DEFAULT_DISABLED (0U) //!< Pre post shim default callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_DEFAULT_ENABLED (1U) //!< Pre post shim default callback functions enabled. +//@} + +//! @name Configuration options +//@{ + +//! @def ERPC_ALLOCATION_POLICY +//! +//! @brief Choose which allocation policy should be used. +//! +//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used. +//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used. +//! +//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is supported +//! by compiler. Uncomment comment bellow to use static allocation policy. +//! In case of static implementation user need consider another values to set (ERPC_CODEC_COUNT, +//! ERPC_MESSAGE_LOGGERS_COUNT, ERPC_CLIENTS_THREADS_AMOUNT). +// #define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC) + +//! @def ERPC_CODEC_COUNT +//! +//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one thread per +//! each then 2, ... Default value 2. +// #define ERPC_CODEC_COUNT (2U) + +//! @def ERPC_MESSAGE_LOGGERS_COUNT +//! +//! @brief Set amount of message loggers objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. +//! For example if client or server is used in one thread then 1. If both are used in one thread per each then 2, ... +//! For arbitrated client 1 is enough. +//! Default value 0 (May not be used). +// #define ERPC_MESSAGE_LOGGERS_COUNT (0U) + +//! @def ERPC_CLIENTS_THREADS_AMOUNT +//! +//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to ERPC_ALLOCATION_POLICY_STATIC. +//! Default value 1 (Most of current cases). +// #define ERPC_CLIENTS_THREADS_AMOUNT (1U) + +//! @def ERPC_THREADS +//! +//! @brief Select threading model. +//! +//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC. +//! +//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads. +//! FreeRTOS can be detected when building with compilers that support __has_include(). +//! Otherwise, the default is no threading. +#define ERPC_THREADS (ERPC_THREADS_ZEPHYR) + +//! @def ERPC_DEFAULT_BUFFER_SIZE +//! +//! Uncomment to change the size of buffers allocated by one of MessageBufferFactory. +//! (@ref client_setup and @ref server_setup). The default size is set to 256. +//! For RPMsg transport layer, ERPC_DEFAULT_BUFFER_SIZE must be 2^n - 16. +#define ERPC_DEFAULT_BUFFER_SIZE (496U) + +//! @def ERPC_DEFAULT_BUFFERS_COUNT +//! +//! Uncomment to change the count of buffers allocated by one of statically allocated messages. +//! Default value is set to 2. +#define ERPC_DEFAULT_BUFFERS_COUNT (16U) + +//! @def ERPC_NOEXCEPT +//! +//! @brief Disable/enable noexcept support. +//! +//! Uncomment for using noexcept feature. +//#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED) + +//! @def ERPC_NESTED_CALLS +//! +//! Default set to ERPC_NESTED_CALLS_DISABLED. Uncomment when callbacks, or other eRPC +//! functions are called from server implementation of another eRPC call. Nested functions +//! need to be marked as @nested in IDL. +#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_ENABLED) + +//! @def ERPC_NESTED_CALLS_DETECTION +//! +//! Default set to ERPC_NESTED_CALLS_DETECTION_ENABLED when NDEBUG macro is presented. +//! This serve for locating nested calls in code. Nested calls are calls where inside eRPC function +//! on server side is called another eRPC function (like callbacks). Code need be a bit changed +//! to support nested calls. See ERPC_NESTED_CALLS macro. +#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED) + +//! @def ERPC_MESSAGE_LOGGING +//! +//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base +//! printing messages, or sending data to another system for data analysis. Default set to +//! ERPC_MESSAGE_LOGGING_DISABLED. +//! +//! Uncomment for using logging feature. +//#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_ENABLED) + +//! @def ERPC_TRANSPORT_MU_USE_MCMGR +//! +//! @brief MU transport layer configuration. +//! +//! Set to one of the @c ERPC_TRANSPORT_MU_USE_MCMGR_x macros to configure the MCMGR usage in MU transport layer. +//! +//! MU transport layer could leverage the Multicore Manager (MCMGR) component for Inter-Core +//! interrupts / MU interrupts management or the Inter-Core interrupts can be managed by itself (MUX_IRQHandler +//! overloading). By default, ERPC_TRANSPORT_MU_USE_MCMGR is set to ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED when mcmgr.h +//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be +//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget +//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the +//! erpc_mu_transport.h for additional MU settings. +//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED +//@} + +//! @def ERPC_PRE_POST_ACTION +//! +//! Enable eRPC pre and post callback functions shim code. Take look into "erpc_pre_post_action.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DISABLED. +//! +//! Uncomment for using pre post callback feature. +//#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_ENABLED) + +//! @def ERPC_PRE_POST_ACTION_DEFAULT +//! +//! Enable eRPC pre and post default callback functions. Take look into "erpc_setup_extensions.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DEFAULT_DISABLED. +//! +//! Uncomment for using pre post default callback feature. +//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED) + +/*! @} */ +#endif // _ERPC_CONFIG_H_ +//////////////////////////////////////////////////////////////////////////////// +// EOF +//////////////////////////////////////////////////////////////////////////////// diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/prj.conf b/test/zephyr/rpmsglite/test_arbitrator/config/prj.conf new file mode 100644 index 00000000..8ddb841a --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/prj.conf @@ -0,0 +1,37 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP17=y +CONFIG_GLIBCXX_LIBCPP=y + +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=y + +# Compiler +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=32000 +CONFIG_NO_OPTIMIZATIONS=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_RPMSG_LITE=y + +# RPMSG Lite +CONFIG_IPM=y +CONFIG_EVENTS=y +CONFIG_PRINTK=y +CONFIG_RPMSGLITE=y +CONFIG_RPMSGLITE_QUEUE=y +CONFIG_RPMSGLITE_NS=y +CONFIG_TIMESLICE_SIZE=1 + +CONFIG_THREAD_CUSTOM_DATA=y +CONFIG_ERPC_ARBITRATED_CLIENT=y +CONFIG_POLL=y + +CONFIG_THREAD_NAME=y +CONFIG_SCHED_CPU_MASK=y +CONFIG_THREAD_ANALYZER=y + +CONFIG_LOG=y +CONFIG_LOG_MODE_IMMEDIATE=y +CONFIG_LOG_OVERRIDE_LEVEL=3 \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso54114_m0.conf b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso54114_m0.conf new file mode 100644 index 00000000..b9e2b072 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso54114_m0.conf @@ -0,0 +1,2 @@ +CONFIG_SECOND_CORE_MCUX=y +CONFIG_BUILD_OUTPUT_HEX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso54114_m0.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso54114_m0.overlay new file mode 100644 index 00000000..a5515378 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso54114_m0.overlay @@ -0,0 +1,20 @@ +/* +* Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + 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/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso55s69_cpu1.conf b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso55s69_cpu1.conf new file mode 100644 index 00000000..b9e2b072 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso55s69_cpu1.conf @@ -0,0 +1,2 @@ +CONFIG_SECOND_CORE_MCUX=y +CONFIG_BUILD_OUTPUT_HEX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso55s69_cpu1.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso55s69_cpu1.overlay new file mode 100644 index 00000000..6a2568e2 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/lpcxpresso55s69_cpu1.overlay @@ -0,0 +1,22 @@ +/* +* Copyright 2023 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/ { + chosen { + /* + * shared memory reserved for the inter-processor communication + */ + + zephyr,ipc_shm = &sram4duplicate; + zephyr,ipc = &mailbox0; + }; + + /* This is a duplication of sram4, workaround */ + sram4duplicate: memory@20040000 { + compatible = "mmio-sram"; + reg = <0x20040000 DT_SIZE_K(16)>; + }; +}; diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1160_evk_cm4.conf b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1160_evk_cm4.conf new file mode 100644 index 00000000..4dfc4a60 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1160_evk_cm4.conf @@ -0,0 +1,3 @@ +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1160_evk_cm4.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1160_evk_cm4.overlay new file mode 100644 index 00000000..9cb7c67a --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1160_evk_cm4.overlay @@ -0,0 +1,51 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + /* Switch to lpuart2, since primary core uses lpuart1 */ + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart2; + zephyr,shell-uart = &lpuart2; + zephyr,ipc_shm = &ocram2_overlay; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set + */ + ocram2_overlay: memory@202c0000 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(23)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; + +/* Enable secondary LPUART */ +&lpuart2 { + status = "okay"; + current-speed = <115200>; +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evk_cm4.conf b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evk_cm4.conf new file mode 100644 index 00000000..4dfc4a60 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evk_cm4.conf @@ -0,0 +1,3 @@ +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evk_cm4.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evk_cm4.overlay new file mode 100644 index 00000000..ab57a613 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evk_cm4.overlay @@ -0,0 +1,51 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + /* Switch to lpuart2, since primary core uses lpuart1 */ + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart2; + zephyr,shell-uart = &lpuart2; + zephyr,ipc_shm = &ocram2_overlay; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set + */ + ocram2_overlay: memory@202c0000 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; + +/* Enable secondary LPUART */ +&lpuart2 { + status = "okay"; + current-speed = <115200>; +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evkb_cm4.conf b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evkb_cm4.conf new file mode 100644 index 00000000..ef7b0f83 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evkb_cm4.conf @@ -0,0 +1,8 @@ +# +# Copyright 2023-2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# +CONFIG_BUILD_OUTPUT_INFO_HEADER=y +CONFIG_BUILD_OUTPUT_HEX=y +CONFIG_SECOND_CORE_MCUX=y diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evkb_cm4.overlay b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evkb_cm4.overlay new file mode 100644 index 00000000..65fb71ff --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/boards/mimxrt1170_evkb_cm4.overlay @@ -0,0 +1,51 @@ +/* + * Copyright 2023-2024 NXP + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +/ { + /* Switch to lpuart2, since primary core uses lpuart1 */ + chosen { + zephyr,flash = &ocram; + zephyr,console = &lpuart1; + zephyr,shell-uart = &lpuart1; + zephyr,ipc_shm = &ocram2_overlay; + }; + + soc { + /delete-node/ gpt@400f0000; + + /* Replace GPT2 with another GPT kernel timer */ + gpt2_hw_timer:gpt@400f0000 { + compatible = "nxp,gpt-hw-timer"; + reg = <0x400f0000 0x4000>; + interrupts = <120 0>; + status = "okay"; + }; + }; + + /* OpenAMP fails with full 512K OCRAM2 memory region as shared memory. + * Define a subset of the OCRAM2 region for demo to use + * Note that shared memory must have specific MPU attributes set + */ + ocram2_overlay: memory@202c0000 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x202c0000 DT_SIZE_K(16)>; + zephyr,memory-region="OCRAM2_OVERLAY"; + zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>; + }; +}; + +/* Enable secondary LPUART */ +&lpuart2 { + status = "okay"; + current-speed = <115200>; +}; + +/* Disable primary GPT timer */ +&gpt_hw_timer { + status = "disabled"; +}; diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/remote/prj.conf b/test/zephyr/rpmsglite/test_arbitrator/config/remote/prj.conf new file mode 100644 index 00000000..5581523e --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/remote/prj.conf @@ -0,0 +1,33 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP17=y +CONFIG_GLIBCXX_LIBCPP=y + +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=y + +# Compiler +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_NO_OPTIMIZATIONS=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_RPMSG_LITE=y + +# RPMSG Lite +CONFIG_IPM=y +CONFIG_EVENTS=y +CONFIG_PRINTK=y +CONFIG_RPMSGLITE=y +CONFIG_RPMSGLITE_QUEUE=y +CONFIG_RPMSGLITE_NS=y +CONFIG_TIMESLICE_SIZE=1 + +CONFIG_THREAD_CUSTOM_DATA=y +CONFIG_ERPC_ARBITRATED_CLIENT=y +CONFIG_POLL=y + +CONFIG_THREAD_NAME=y +CONFIG_SCHED_CPU_MASK=y +CONFIG_THREAD_ANALYZER=y \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_arbitrator/config/rpmsg_config.h b/test/zephyr/rpmsglite/test_arbitrator/config/rpmsg_config.h new file mode 100644 index 00000000..f5f0f565 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/config/rpmsg_config.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, Mentor Graphics Corporation + * All rights reserved. + * Copyright (c) 2015 Xilinx, Inc. All rights reserved. + * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef RPMSG_CONFIG_H_ +#define RPMSG_CONFIG_H_ + +#include "erpc_config_internal.h" + +/* RPMsg config values */ +/* START { */ +#define RL_MS_PER_INTERVAL (1) + +#define RL_BUFFER_PAYLOAD_SIZE (ERPC_DEFAULT_BUFFER_SIZE) + +#define RL_BUFFER_COUNT (ERPC_DEFAULT_BUFFERS_COUNT) + +#define RL_API_HAS_ZEROCOPY (1) + +#define RL_USE_STATIC_API (0) + +#define RL_USE_MCMGR_IPC_ISR_HANDLER (1) + +// #define SH_MEM_TOTAL_SIZE (22527) + +#define RL_ASSERT(x) \ + do \ + { \ + if (!(x)) \ + while (1) \ + ; \ + } while (0); +/* } END */ + +#endif /* RPMSG_CONFIG_H_ */ diff --git a/test/zephyr/rpmsglite/test_arbitrator/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_arbitrator/remote/CMakeLists.txt new file mode 100644 index 00000000..ea4ac692 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/remote/CMakeLists.txt @@ -0,0 +1,21 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +set(APPLICATION_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../config/remote) +set(CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../config) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +include(${APP_DIR}/common.cmake) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_arbitrator/sysbuild.cmake b/test/zephyr/rpmsglite/test_arbitrator/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_arbitrator/testcase.yaml b/test/zephyr/rpmsglite/test_arbitrator/testcase.yaml new file mode 100644 index 00000000..333a18f0 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arbitrator/testcase.yaml @@ -0,0 +1,7 @@ +tests: + erpc.rpmsglite.arbitrator: + sysbuild: true + harness: gtest + timeout: 60 + extra_configs: + - CONFIG_THREAD_CUSTOM_DATA=y \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_arrays/CMakeLists.txt b/test/zephyr/rpmsglite/test_arrays/CMakeLists.txt new file mode 100644 index 00000000..e34d1b16 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arrays/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(TEST_ERPC_OUT_DIR ${ERPC_OUT_ROOT_DIR}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_arrays/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_arrays/remote/CMakeLists.txt new file mode 100644 index 00000000..5d6ced00 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arrays/remote/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(TEST_ERPC_OUT_DIR ${ERPC_OUT_ROOT_DIR}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_arrays/sysbuild.cmake b/test/zephyr/rpmsglite/test_arrays/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_arrays/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_arrays/testcase.yaml b/test/zephyr/rpmsglite/test_arrays/testcase.yaml new file mode 100644 index 00000000..ab0e77dd --- /dev/null +++ b/test/zephyr/rpmsglite/test_arrays/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.arrays: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_binary/CMakeLists.txt b/test/zephyr/rpmsglite/test_binary/CMakeLists.txt new file mode 100644 index 00000000..bbe6011e --- /dev/null +++ b/test/zephyr/rpmsglite/test_binary/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_binary/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_binary/remote/CMakeLists.txt new file mode 100644 index 00000000..cf2b14f6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_binary/remote/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_binary/sysbuild.cmake b/test/zephyr/rpmsglite/test_binary/sysbuild.cmake new file mode 100644 index 00000000..2dd3cfbf --- /dev/null +++ b/test/zephyr/rpmsglite/test_binary/sysbuild.cmake @@ -0,0 +1,6 @@ +# Copyright 2023 NXP +# +# SPDX-License-Identifier: BSD-3-Clause + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_binary/testcase.yaml b/test/zephyr/rpmsglite/test_binary/testcase.yaml new file mode 100644 index 00000000..13be47b3 --- /dev/null +++ b/test/zephyr/rpmsglite/test_binary/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.binary: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_builtin/CMakeLists.txt b/test/zephyr/rpmsglite/test_builtin/CMakeLists.txt new file mode 100644 index 00000000..bbe6011e --- /dev/null +++ b/test/zephyr/rpmsglite/test_builtin/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_builtin/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_builtin/remote/CMakeLists.txt new file mode 100644 index 00000000..cf2b14f6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_builtin/remote/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_builtin/sysbuild.cmake b/test/zephyr/rpmsglite/test_builtin/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_builtin/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_builtin/testcase.yaml b/test/zephyr/rpmsglite/test_builtin/testcase.yaml new file mode 100644 index 00000000..7843ee55 --- /dev/null +++ b/test/zephyr/rpmsglite/test_builtin/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.builtin: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_callbacks/CMakeLists.txt b/test/zephyr/rpmsglite/test_callbacks/CMakeLists.txt new file mode 100644 index 00000000..459e1532 --- /dev/null +++ b/test/zephyr/rpmsglite/test_callbacks/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +include(${APP_DIR}/common.cmake) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_callbacks/common.cmake b/test/zephyr/rpmsglite/test_callbacks/common.cmake new file mode 100644 index 00000000..357e1424 --- /dev/null +++ b/test/zephyr/rpmsglite/test_callbacks/common.cmake @@ -0,0 +1,27 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +set(ERPC_NAME_APP test_core0) + +# Define required IDL files +set(TEST_ERPC_FILES + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME_APP}_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME_APP}_${APP_TYPE}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME_APP}_${APP_TYPE}.cpp + + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_core1_interface.cpp + + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_unit_test_common_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_unit_test_common_${APP_TYPE}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME}_unit_test_common_${APP_TYPE}.cpp +) + +set(TEST_SOURCES + ${TEST_ERPC_FILES} + + ${TEST_SOURCE_DIR}/${TEST_NAME}_${APP_TYPE}_impl.cpp + ${TEST_COMMON_DIR}/unit_test_${TRANSPORT}_${APP_TYPE}.cpp +) diff --git a/test/zephyr/rpmsglite/test_callbacks/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_callbacks/remote/CMakeLists.txt new file mode 100644 index 00000000..3eb433bc --- /dev/null +++ b/test/zephyr/rpmsglite/test_callbacks/remote/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +include(${APP_DIR}/common.cmake) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_callbacks/sysbuild.cmake b/test/zephyr/rpmsglite/test_callbacks/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_callbacks/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_callbacks/testcase.yaml b/test/zephyr/rpmsglite/test_callbacks/testcase.yaml new file mode 100644 index 00000000..0d380c4b --- /dev/null +++ b/test/zephyr/rpmsglite/test_callbacks/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.callbacks: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_const/CMakeLists.txt b/test/zephyr/rpmsglite/test_const/CMakeLists.txt new file mode 100644 index 00000000..bbe6011e --- /dev/null +++ b/test/zephyr/rpmsglite/test_const/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_const/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_const/remote/CMakeLists.txt new file mode 100644 index 00000000..cf2b14f6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_const/remote/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_const/sysbuild.cmake b/test/zephyr/rpmsglite/test_const/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_const/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_const/testcase.yaml b/test/zephyr/rpmsglite/test_const/testcase.yaml new file mode 100644 index 00000000..635452f1 --- /dev/null +++ b/test/zephyr/rpmsglite/test_const/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.const: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_enums/CMakeLists.txt b/test/zephyr/rpmsglite/test_enums/CMakeLists.txt new file mode 100644 index 00000000..bbe6011e --- /dev/null +++ b/test/zephyr/rpmsglite/test_enums/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_enums/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_enums/remote/CMakeLists.txt new file mode 100644 index 00000000..cf2b14f6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_enums/remote/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_enums/sysbuild.cmake b/test/zephyr/rpmsglite/test_enums/sysbuild.cmake new file mode 100644 index 00000000..d368ee08 --- /dev/null +++ b/test/zephyr/rpmsglite/test_enums/sysbuild.cmake @@ -0,0 +1,7 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_enums/testcase.yaml b/test/zephyr/rpmsglite/test_enums/testcase.yaml new file mode 100644 index 00000000..2722cbd6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_enums/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.enums: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_lists/CMakeLists.txt b/test/zephyr/rpmsglite/test_lists/CMakeLists.txt new file mode 100644 index 00000000..bbe6011e --- /dev/null +++ b/test/zephyr/rpmsglite/test_lists/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_lists/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_lists/remote/CMakeLists.txt new file mode 100644 index 00000000..cf2b14f6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_lists/remote/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_lists/sysbuild.cmake b/test/zephyr/rpmsglite/test_lists/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_lists/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_lists/testcase.yaml b/test/zephyr/rpmsglite/test_lists/testcase.yaml new file mode 100644 index 00000000..a00b9900 --- /dev/null +++ b/test/zephyr/rpmsglite/test_lists/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.lists: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_shared/CMakeLists.txt b/test/zephyr/rpmsglite/test_shared/CMakeLists.txt new file mode 100644 index 00000000..7139fa3f --- /dev/null +++ b/test/zephyr/rpmsglite/test_shared/CMakeLists.txt @@ -0,0 +1,20 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_shared/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_shared/remote/CMakeLists.txt new file mode 100644 index 00000000..cf2b14f6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_shared/remote/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_shared/sysbuild.cmake b/test/zephyr/rpmsglite/test_shared/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_shared/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_shared/testcase.yaml b/test/zephyr/rpmsglite/test_shared/testcase.yaml new file mode 100644 index 00000000..08652f12 --- /dev/null +++ b/test/zephyr/rpmsglite/test_shared/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.shared: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_struct/CMakeLists.txt b/test/zephyr/rpmsglite/test_struct/CMakeLists.txt new file mode 100644 index 00000000..913b04c6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_struct/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(ERPC_NAME_APP test_ArithmeticService) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_struct/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_struct/remote/CMakeLists.txt new file mode 100644 index 00000000..fec4abe0 --- /dev/null +++ b/test/zephyr/rpmsglite/test_struct/remote/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(ERPC_NAME_APP test_ArithmeticService) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_struct/sysbuild.cmake b/test/zephyr/rpmsglite/test_struct/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_struct/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_struct/testcase.yaml b/test/zephyr/rpmsglite/test_struct/testcase.yaml new file mode 100644 index 00000000..01420599 --- /dev/null +++ b/test/zephyr/rpmsglite/test_struct/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.struct: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_typedef/CMakeLists.txt b/test/zephyr/rpmsglite/test_typedef/CMakeLists.txt new file mode 100644 index 00000000..bbe6011e --- /dev/null +++ b/test/zephyr/rpmsglite/test_typedef/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_typedef/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_typedef/remote/CMakeLists.txt new file mode 100644 index 00000000..cf2b14f6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_typedef/remote/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_typedef/sysbuild.cmake b/test/zephyr/rpmsglite/test_typedef/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_typedef/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_typedef/testcase.yaml b/test/zephyr/rpmsglite/test_typedef/testcase.yaml new file mode 100644 index 00000000..4c2a7225 --- /dev/null +++ b/test/zephyr/rpmsglite/test_typedef/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.typedef: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_unions/CMakeLists.txt b/test/zephyr/rpmsglite/test_unions/CMakeLists.txt new file mode 100644 index 00000000..1ae87bd6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_unions/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "client") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(ERPC_NAME test) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_unions/remote/CMakeLists.txt b/test/zephyr/rpmsglite/test_unions/remote/CMakeLists.txt new file mode 100644 index 00000000..9b36f6b6 --- /dev/null +++ b/test/zephyr/rpmsglite/test_unions/remote/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +# Zephyr +set(APP_TYPE "server") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(ERPC_NAME test) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/rpmsglite/test_unions/sysbuild.cmake b/test/zephyr/rpmsglite/test_unions/sysbuild.cmake new file mode 100644 index 00000000..e140b251 --- /dev/null +++ b/test/zephyr/rpmsglite/test_unions/sysbuild.cmake @@ -0,0 +1,8 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Include sysbuild cmake, that is same for all tests +include(${APP_DIR}/../cmake/sysbuild.cmake) \ No newline at end of file diff --git a/test/zephyr/rpmsglite/test_unions/testcase.yaml b/test/zephyr/rpmsglite/test_unions/testcase.yaml new file mode 100644 index 00000000..5da3cdb0 --- /dev/null +++ b/test/zephyr/rpmsglite/test_unions/testcase.yaml @@ -0,0 +1,4 @@ +tests: + erpc.rpmsglite.unions: + sysbuild: true + harness: gtest \ No newline at end of file diff --git a/test/zephyr/uart/cmake/unit_test.cmake b/test/zephyr/uart/cmake/unit_test.cmake new file mode 100644 index 00000000..17f62aed --- /dev/null +++ b/test/zephyr/uart/cmake/unit_test.cmake @@ -0,0 +1,29 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# App type and transport +set(APP_TYPE "server") +set(TRANSPORT "zephyr_uart") + +# Zephyr APPLICATION_CONFIG_DIR and CONFIG_DIR +if(NOT DEFINED APPLICATION_CONFIG_DIR) + set(APPLICATION_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../config) +endif() + +if(NOT DEFINED CONFIG_DIR) + set(CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../config) +endif() + +# Include zephyr +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +# Common variables +get_filename_component(TEST_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(ERPC_ROOT_DIR ${ZEPHYR_ERPC_MODULE_DIR}) +set(ZEPHYR_TEST_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../cmake) + +# Include test's variables +include(${ZEPHYR_TEST_CMAKE_DIR}/variables.cmake) \ No newline at end of file diff --git a/test/zephyr/uart/config/erpc_config.h b/test/zephyr/uart/config/erpc_config.h new file mode 100644 index 00000000..9b3417ce --- /dev/null +++ b/test/zephyr/uart/config/erpc_config.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2021 NXP + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ERPC_CONFIG_H_ +#define _ERPC_CONFIG_H_ + +/*! + * @addtogroup config + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// Declarations +//////////////////////////////////////////////////////////////////////////////// + +//! @name Threading model options +//@{ +#define ERPC_ALLOCATION_POLICY_DYNAMIC (0U) //!< Dynamic allocation policy +#define ERPC_ALLOCATION_POLICY_STATIC (1U) //!< Static allocation policy + +#define ERPC_THREADS_NONE (0U) //!< No threads. +#define ERPC_THREADS_PTHREADS (1U) //!< POSIX pthreads. +#define ERPC_THREADS_FREERTOS (2U) //!< FreeRTOS. +#define ERPC_THREADS_ZEPHYR (3U) //!< ZEPHYR. +#define ERPC_THREADS_MBED (4U) //!< Mbed OS +#define ERPC_THREADS_WIN32 (5U) //!< WIN32 +#define ERPC_THREADS_THREADX (6U) //!< THREADX + +#define ERPC_NOEXCEPT_DISABLED (0U) //!< Disabling noexcept feature. +#define ERPC_NOEXCEPT_ENABLED (1U) //!< Enabling noexcept feature. + +#define ERPC_NESTED_CALLS_DISABLED (0U) //!< No nested calls support. +#define ERPC_NESTED_CALLS_ENABLED (1U) //!< Nested calls support. + +#define ERPC_NESTED_CALLS_DETECTION_DISABLED (0U) //!< Nested calls detection disabled. +#define ERPC_NESTED_CALLS_DETECTION_ENABLED (1U) //!< Nested calls detection enabled. + +#define ERPC_MESSAGE_LOGGING_DISABLED (0U) //!< Trace functions disabled. +#define ERPC_MESSAGE_LOGGING_ENABLED (1U) //!< Trace functions enabled. + +#define ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED (0U) //!< Do not use MCMGR for MU ISR management. +#define ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED (1U) //!< Use MCMGR for MU ISR management. + +#define ERPC_PRE_POST_ACTION_DISABLED (0U) //!< Pre post shim callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_ENABLED (1U) //!< Pre post shim callback functions enabled. + +#define ERPC_PRE_POST_ACTION_DEFAULT_DISABLED (0U) //!< Pre post shim default callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_DEFAULT_ENABLED (1U) //!< Pre post shim default callback functions enabled. +//@} + +//! @name Configuration options +//@{ + +//! @def ERPC_ALLOCATION_POLICY +//! +//! @brief Choose which allocation policy should be used. +//! +//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used. +//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used. +//! +//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is supported +//! by compiler. Uncomment comment bellow to use static allocation policy. +//! In case of static implementation user need consider another values to set (ERPC_CODEC_COUNT, +//! ERPC_MESSAGE_LOGGERS_COUNT, ERPC_CLIENTS_THREADS_AMOUNT). +#define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_DYNAMIC) + +//! @def ERPC_CODEC_COUNT +//! +//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one thread per +//! each then 2, ... Default value 2. +#define ERPC_CODEC_COUNT (2U) + +//! @def ERPC_MESSAGE_LOGGERS_COUNT +//! +//! @brief Set amount of message loggers objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. +//! For example if client or server is used in one thread then 1. If both are used in one thread per each then 2, ... +//! For arbitrated client 1 is enough. +//! Default value 0 (May not be used). +#define ERPC_MESSAGE_LOGGERS_COUNT (0U) + +//! @def ERPC_CLIENTS_THREADS_AMOUNT +//! +//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to ERPC_ALLOCATION_POLICY_STATIC. +//! Default value 1 (Most of current cases). +#define ERPC_CLIENTS_THREADS_AMOUNT (1U) + +//! @def ERPC_THREADS +//! +//! @brief Select threading model. +//! +//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC. +//! +//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads. +//! FreeRTOS can be detected when building with compilers that support __has_include(). +//! Otherwise, the default is no threading. +#define ERPC_THREADS (ERPC_THREADS_ZEPHYR) + +//! @def ERPC_DEFAULT_BUFFER_SIZE +//! +//! Uncomment to change the size of buffers allocated by one of MessageBufferFactory. +//! (@ref client_setup and @ref server_setup). The default size is set to 256. +//! For RPMsg transport layer, ERPC_DEFAULT_BUFFER_SIZE must be 2^n - 16. +#define ERPC_DEFAULT_BUFFER_SIZE (512U) + +//! @def ERPC_DEFAULT_BUFFERS_COUNT +//! +//! Uncomment to change the count of buffers allocated by one of statically allocated messages. +//! Default value is set to 2. +//#define ERPC_DEFAULT_BUFFERS_COUNT (2U) + +//! @def ERPC_NOEXCEPT +//! +//! @brief Disable/enable noexcept support. +//! +//! Uncomment for using noexcept feature. +//#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED) + +//! @def ERPC_NESTED_CALLS +//! +//! Default set to ERPC_NESTED_CALLS_DISABLED. Uncomment when callbacks, or other eRPC +//! functions are called from server implementation of another eRPC call. Nested functions +//! need to be marked as @nested in IDL. +//#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_ENABLED) + +//! @def ERPC_NESTED_CALLS_DETECTION +//! +//! Default set to ERPC_NESTED_CALLS_DETECTION_ENABLED when NDEBUG macro is presented. +//! This serve for locating nested calls in code. Nested calls are calls where inside eRPC function +//! on server side is called another eRPC function (like callbacks). Code need be a bit changed +//! to support nested calls. See ERPC_NESTED_CALLS macro. +//#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED) + +//! @def ERPC_MESSAGE_LOGGING +//! +//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base +//! printing messages, or sending data to another system for data analysis. Default set to +//! ERPC_MESSAGE_LOGGING_DISABLED. +//! +//! Uncomment for using logging feature. +//#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_ENABLED) + +//! @def ERPC_TRANSPORT_MU_USE_MCMGR +//! +//! @brief MU transport layer configuration. +//! +//! Set to one of the @c ERPC_TRANSPORT_MU_USE_MCMGR_x macros to configure the MCMGR usage in MU transport layer. +//! +//! MU transport layer could leverage the Multicore Manager (MCMGR) component for Inter-Core +//! interrupts / MU interrupts management or the Inter-Core interrupts can be managed by itself (MUX_IRQHandler +//! overloading). By default, ERPC_TRANSPORT_MU_USE_MCMGR is set to ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED when mcmgr.h +//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be +//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget +//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the +//! erpc_mu_transport.h for additional MU settings. +//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED +//@} + +//! @def ERPC_PRE_POST_ACTION +//! +//! Enable eRPC pre and post callback functions shim code. Take look into "erpc_pre_post_action.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DISABLED. +//! +//! Uncomment for using pre post callback feature. +//#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_ENABLED) + +//! @def ERPC_PRE_POST_ACTION_DEFAULT +//! +//! Enable eRPC pre and post default callback functions. Take look into "erpc_setup_extensions.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DEFAULT_DISABLED. +//! +//! Uncomment for using pre post default callback feature. +//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED) + +/*! @} */ +#endif // _ERPC_CONFIG_H_ +//////////////////////////////////////////////////////////////////////////////// +// EOF +//////////////////////////////////////////////////////////////////////////////// diff --git a/test/zephyr/uart/config/prj.conf b/test/zephyr/uart/config/prj.conf new file mode 100644 index 00000000..1b222af7 --- /dev/null +++ b/test/zephyr/uart/config/prj.conf @@ -0,0 +1,28 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP17=y +CONFIG_GLIBCXX_LIBCPP=y + +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=y + +# Compiler +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_NO_OPTIMIZATIONS=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_UART=y + +# UART +CONFIG_CONSOLE=n +CONFIG_UART_CONSOLE=n + +CONFIG_THREAD_NAME=y +CONFIG_SCHED_CPU_MASK=y +CONFIG_THREAD_ANALYZER=y + +CONFIG_LOG=y +CONFIG_LOG_MODE_IMMEDIATE=y +CONFIG_LOG_OVERRIDE_LEVEL=3 \ No newline at end of file diff --git a/test/zephyr/uart/test_annotations/CMakeLists.txt b/test/zephyr/uart/test_annotations/CMakeLists.txt new file mode 100644 index 00000000..6d25c45d --- /dev/null +++ b/test/zephyr/uart/test_annotations/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(TEST_EXT_SOURCES ${TEST_COMMON_DIR}/addOne.cpp) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_annotations/testcase.yaml b/test/zephyr/uart/test_annotations/testcase.yaml new file mode 100644 index 00000000..7605e0a7 --- /dev/null +++ b/test/zephyr/uart/test_annotations/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.annotations: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_annotations/test_annotations.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_arbitrator/CMakeLists.txt b/test/zephyr/uart/test_arbitrator/CMakeLists.txt new file mode 100644 index 00000000..4b148562 --- /dev/null +++ b/test/zephyr/uart/test_arbitrator/CMakeLists.txt @@ -0,0 +1,35 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +set(APPLICATION_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config) +set(CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/config) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(APP_TYPE_SECOND "client") + +set(TEST_ERPC_FILES + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_firstInterface_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_firstInterface_${APP_TYPE}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME}_firstInterface_${APP_TYPE}.cpp + + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_secondInterface_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_secondInterface_${APP_TYPE_SECOND}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME}_secondInterface_${APP_TYPE_SECOND}.cpp +) + +set(TEST_SOURCES + ${TEST_ERPC_FILES} + + ${TEST_SOURCE_DIR}/${TEST_NAME}_${APP_TYPE}_impl.cpp + ${TEST_COMMON_DIR}/unit_test_${TRANSPORT}_arbitrator_${APP_TYPE}.cpp +) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_arbitrator/config/erpc_config.h b/test/zephyr/uart/test_arbitrator/config/erpc_config.h new file mode 100644 index 00000000..ef8a0073 --- /dev/null +++ b/test/zephyr/uart/test_arbitrator/config/erpc_config.h @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2020 NXP + * Copyright 2020-2021 ACRIOS Systems s.r.o. + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ERPC_CONFIG_H_ +#define _ERPC_CONFIG_H_ + +/*! + * @addtogroup config + * @{ + * @file + */ + +//////////////////////////////////////////////////////////////////////////////// +// Declarations +//////////////////////////////////////////////////////////////////////////////// + +//! @name Threading model options +//@{ +#define ERPC_ALLOCATION_POLICY_DYNAMIC (0U) //!< Dynamic allocation policy +#define ERPC_ALLOCATION_POLICY_STATIC (1U) //!< Static allocation policy + +#define ERPC_THREADS_NONE (0U) //!< No threads. +#define ERPC_THREADS_PTHREADS (1U) //!< POSIX pthreads. +#define ERPC_THREADS_FREERTOS (2U) //!< FreeRTOS. +#define ERPC_THREADS_ZEPHYR (3U) //!< ZEPHYR. +#define ERPC_THREADS_MBED (4U) //!< Mbed OS +#define ERPC_THREADS_WIN32 (5U) //!< WIN32 +#define ERPC_THREADS_THREADX (6U) //!< THREADX + +#define ERPC_NOEXCEPT_DISABLED (0U) //!< Disabling noexcept feature. +#define ERPC_NOEXCEPT_ENABLED (1U) //!< Enabling noexcept feature. + +#define ERPC_NESTED_CALLS_DISABLED (0U) //!< No nested calls support. +#define ERPC_NESTED_CALLS_ENABLED (1U) //!< Nested calls support. + +#define ERPC_NESTED_CALLS_DETECTION_DISABLED (0U) //!< Nested calls detection disabled. +#define ERPC_NESTED_CALLS_DETECTION_ENABLED (1U) //!< Nested calls detection enabled. + +#define ERPC_MESSAGE_LOGGING_DISABLED (0U) //!< Trace functions disabled. +#define ERPC_MESSAGE_LOGGING_ENABLED (1U) //!< Trace functions enabled. + +#define ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED (0U) //!< Do not use MCMGR for MU ISR management. +#define ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED (1U) //!< Use MCMGR for MU ISR management. + +#define ERPC_PRE_POST_ACTION_DISABLED (0U) //!< Pre post shim callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_ENABLED (1U) //!< Pre post shim callback functions enabled. + +#define ERPC_PRE_POST_ACTION_DEFAULT_DISABLED (0U) //!< Pre post shim default callbacks functions disabled. +#define ERPC_PRE_POST_ACTION_DEFAULT_ENABLED (1U) //!< Pre post shim default callback functions enabled. +//@} + +//! @name Configuration options +//@{ + +//! @def ERPC_ALLOCATION_POLICY +//! +//! @brief Choose which allocation policy should be used. +//! +//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used. +//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used. +//! +//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is +//! supported by compiler. Uncomment comment bellow to use static allocation policy. In case of static implementation +//! user need consider another values to set (ERPC_CODEC_COUNT, ERPC_MESSAGE_LOGGERS_COUNT, +//! ERPC_CLIENTS_THREADS_AMOUNT). +#define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_DYNAMIC) + +//! @def ERPC_CODEC_COUNT +//! +//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one +//! thread per each then 2, ... Default value 2. +#define ERPC_CODEC_COUNT (2U) + +//! @def ERPC_MESSAGE_LOGGERS_COUNT +//! +//! @brief Set amount of message loggers objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. +//! For example if client or server is used in one thread then 1. If both are used in one thread per each then 2, ... +//! For arbitrated client 1 is enough. +//! Default value 0 (May not be used). +#define ERPC_MESSAGE_LOGGERS_COUNT (0U) + +//! @def ERPC_CLIENTS_THREADS_AMOUNT +//! +//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to +//! ERPC_ALLOCATION_POLICY_STATIC. Default value 1 (Most of current cases). +#define ERPC_CLIENTS_THREADS_AMOUNT (1U) + +//! @def ERPC_THREADS +//! +//! @brief Select threading model. +//! +//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC. +//! +//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads. +//! FreeRTOS can be detected when building with compilers that support __has_include(). +//! Otherwise, the default is no threading. +#define ERPC_THREADS (ERPC_THREADS_ZEPHYR) + +//! @def ERPC_DEFAULT_BUFFER_SIZE +//! +//! Uncomment to change the size of buffers allocated by one of MessageBufferFactory. +//! (@ref client_setup and @ref server_setup). The default size is set to 256. +//! For RPMsg transport layer, ERPC_DEFAULT_BUFFER_SIZE must be 2^n - 16. +#define ERPC_DEFAULT_BUFFER_SIZE (512U) + +//! @def ERPC_DEFAULT_BUFFERS_COUNT +//! +//! Uncomment to change the count of buffers allocated by one of statically allocated messages. +//! Default value is set to 2. +//#define ERPC_DEFAULT_BUFFERS_COUNT (2U) + +//! @def ERPC_NOEXCEPT +//! +//! @brief Disable/enable noexcept support. +//! +//! Uncomment for using noexcept feature. +//#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED) + +//! @def ERPC_NESTED_CALLS +//! +//! Default set to ERPC_NESTED_CALLS_DISABLED. Uncomment when callbacks, or other eRPC +//! functions are called from server implementation of another eRPC call. Nested functions +//! need to be marked as @nested in IDL. +#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_ENABLED) + +//! @def ERPC_NESTED_CALLS_DETECTION +//! +//! Default set to ERPC_NESTED_CALLS_DETECTION_ENABLED when NDEBUG macro is presented. +//! This serve for locating nested calls in code. Nested calls are calls where inside eRPC function +//! on server side is called another eRPC function (like callbacks). Code need be a bit changed +//! to support nested calls. See ERPC_NESTED_CALLS macro. +//#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED) + +//! @def ERPC_MESSAGE_LOGGING +//! +//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base +//! printing messages, or sending data to another system for data analysis. Default set to +//! ERPC_MESSAGE_LOGGING_DISABLED. +//! +//! Uncomment for using logging feature. +//#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_ENABLED) + +//! @def ERPC_TRANSPORT_MU_USE_MCMGR +//! +//! @brief MU transport layer configuration. +//! +//! Set to one of the @c ERPC_TRANSPORT_MU_USE_MCMGR_x macros to configure the MCMGR usage in MU transport layer. +//! +//! MU transport layer could leverage the Multicore Manager (MCMGR) component for Inter-Core +//! interrupts / MU interrupts management or the Inter-Core interrupts can be managed by itself (MUX_IRQHandler +//! overloading). By default, ERPC_TRANSPORT_MU_USE_MCMGR is set to ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED when mcmgr.h +//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be +//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget +//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the +//! erpc_mu_transport.h for additional MU settings. +//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED +//@} + +//! @def ERPC_PRE_POST_ACTION +//! +//! Enable eRPC pre and post callback functions shim code. Take look into "erpc_pre_post_action.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DISABLED. +//! +//! Uncomment for using pre post callback feature. +//#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_ENABLED) + +//! @def ERPC_PRE_POST_ACTION_DEFAULT +//! +//! Enable eRPC pre and post default callback functions. Take look into "erpc_setup_extensions.h". Can be used for +//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DEFAULT_DISABLED. +//! +//! Uncomment for using pre post default callback feature. +//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED) + +//! @name Assert function definition +//@{ +//! User custom asser defition. Include header file if needed before bellow line. If assert is not enabled, default will +//! be used. +// #define erpc_assert(condition) +//@} + +//! @def ENDIANES_HEADER +//! +//! Include header file that controls the communication endianness +//! +//! Uncomment for example behaviour for endianness agnostic with: +//! 1. communication in little endian. +//! 2. current processor is big endian. +//! 3. pointer size is 32 bit. +//! 4. float+double scheme not defined, so throws assert if passes. +//! #define ERPC_PROCESSOR_ENDIANNESS_LITTLE 0 +//! #define ERPC_COMMUNICATION_LITTLE 1 +//! #define ERPC_POINTER_SIZE_16 0 +//! #define ERPC_POINTER_SIZE_32 1 +//! #define ERPC_POINTER_SIZE_64 0 +//! #define ENDIANNESS_HEADER "erpc_endianness_agnostic_example.h" + +/*! @} */ +#endif // _ERPC_CONFIG_H_ +//////////////////////////////////////////////////////////////////////////////// +// EOF +//////////////////////////////////////////////////////////////////////////////// diff --git a/test/zephyr/uart/test_arbitrator/config/prj.conf b/test/zephyr/uart/test_arbitrator/config/prj.conf new file mode 100644 index 00000000..d27a67b3 --- /dev/null +++ b/test/zephyr/uart/test_arbitrator/config/prj.conf @@ -0,0 +1,32 @@ +# C++ Language Support +CONFIG_CPP=y +CONFIG_STD_CPP17=y +CONFIG_GLIBCXX_LIBCPP=y + +CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=y + +# Compiler +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_NO_OPTIMIZATIONS=y + +# eRPC +CONFIG_ERPC=y +CONFIG_ERPC_TRANSPORT_UART=y + +# UART +CONFIG_CONSOLE=n +CONFIG_UART_CONSOLE=n + +CONFIG_THREAD_CUSTOM_DATA=y +CONFIG_ERPC_ARBITRATED_CLIENT=y +CONFIG_POLL=y + +CONFIG_THREAD_NAME=y +CONFIG_SCHED_CPU_MASK=y +CONFIG_THREAD_ANALYZER=y + +CONFIG_LOG=y +CONFIG_LOG_MODE_IMMEDIATE=y +CONFIG_LOG_OVERRIDE_LEVEL=3 \ No newline at end of file diff --git a/test/zephyr/uart/test_arbitrator/testcase.yaml b/test/zephyr/uart/test_arbitrator/testcase.yaml new file mode 100644 index 00000000..dda0c3b9 --- /dev/null +++ b/test/zephyr/uart/test_arbitrator/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.arbitrator: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_arbitrator/test_arbitrator.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_arrays/CMakeLists.txt b/test/zephyr/uart/test_arrays/CMakeLists.txt new file mode 100644 index 00000000..5e072377 --- /dev/null +++ b/test/zephyr/uart/test_arrays/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(TEST_ERPC_OUT_DIR ${ERPC_OUT_ROOT_DIR}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_arrays/testcase.yaml b/test/zephyr/uart/test_arrays/testcase.yaml new file mode 100644 index 00000000..585c5610 --- /dev/null +++ b/test/zephyr/uart/test_arrays/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.arrays: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_arrays/test_arrays.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_binary/CMakeLists.txt b/test/zephyr/uart/test_binary/CMakeLists.txt new file mode 100644 index 00000000..c6297d38 --- /dev/null +++ b/test/zephyr/uart/test_binary/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_binary/testcase.yaml b/test/zephyr/uart/test_binary/testcase.yaml new file mode 100644 index 00000000..f8771ff1 --- /dev/null +++ b/test/zephyr/uart/test_binary/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.binary: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_binary/test_binary.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_builtin/CMakeLists.txt b/test/zephyr/uart/test_builtin/CMakeLists.txt new file mode 100644 index 00000000..c6297d38 --- /dev/null +++ b/test/zephyr/uart/test_builtin/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_builtin/testcase.yaml b/test/zephyr/uart/test_builtin/testcase.yaml new file mode 100644 index 00000000..6d37074e --- /dev/null +++ b/test/zephyr/uart/test_builtin/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.builtin: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_builtin/test_builtin.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_callbacks/CMakeLists.txt b/test/zephyr/uart/test_callbacks/CMakeLists.txt new file mode 100644 index 00000000..a8fdb43a --- /dev/null +++ b/test/zephyr/uart/test_callbacks/CMakeLists.txt @@ -0,0 +1,39 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(ERPC_NAME_APP test_core0) + +# Define required IDL files +set(TEST_ERPC_FILES + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME_APP}_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME_APP}_${APP_TYPE}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME_APP}_${APP_TYPE}.cpp + + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_core1_interface.cpp + + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_unit_test_common_interface.cpp + ${TEST_ERPC_OUT_DIR}/${ERPC_NAME}_unit_test_common_${APP_TYPE}.cpp + ${TEST_ERPC_OUT_DIR}/c_${ERPC_NAME}_unit_test_common_${APP_TYPE}.cpp +) + +set(TEST_SOURCES + ${TEST_ERPC_FILES} + + ${TEST_SOURCE_DIR}/${TEST_NAME}_${APP_TYPE}_impl.cpp + ${TEST_COMMON_DIR}/unit_test_${TRANSPORT}_${APP_TYPE}.cpp +) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_callbacks/testcase.yaml b/test/zephyr/uart/test_callbacks/testcase.yaml new file mode 100644 index 00000000..bd5e1765 --- /dev/null +++ b/test/zephyr/uart/test_callbacks/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.callbacks: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_callbacks/test_callbacks.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_const/CMakeLists.txt b/test/zephyr/uart/test_const/CMakeLists.txt new file mode 100644 index 00000000..c6297d38 --- /dev/null +++ b/test/zephyr/uart/test_const/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_const/testcase.yaml b/test/zephyr/uart/test_const/testcase.yaml new file mode 100644 index 00000000..e2f1498f --- /dev/null +++ b/test/zephyr/uart/test_const/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.const: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_const/test_const.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_enums/CMakeLists.txt b/test/zephyr/uart/test_enums/CMakeLists.txt new file mode 100644 index 00000000..c6297d38 --- /dev/null +++ b/test/zephyr/uart/test_enums/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_enums/testcase.yaml b/test/zephyr/uart/test_enums/testcase.yaml new file mode 100644 index 00000000..bd953912 --- /dev/null +++ b/test/zephyr/uart/test_enums/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.enums: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_enums/test_enums.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_lists/CMakeLists.txt b/test/zephyr/uart/test_lists/CMakeLists.txt new file mode 100644 index 00000000..c6297d38 --- /dev/null +++ b/test/zephyr/uart/test_lists/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_lists/testcase.yaml b/test/zephyr/uart/test_lists/testcase.yaml new file mode 100644 index 00000000..c53f86fc --- /dev/null +++ b/test/zephyr/uart/test_lists/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.lists: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_lists/test_lists.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_shared/CMakeLists.txt b/test/zephyr/uart/test_shared/CMakeLists.txt new file mode 100644 index 00000000..c6297d38 --- /dev/null +++ b/test/zephyr/uart/test_shared/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_shared/testcase.yaml b/test/zephyr/uart/test_shared/testcase.yaml new file mode 100644 index 00000000..00e2227f --- /dev/null +++ b/test/zephyr/uart/test_shared/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.shared: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_shared/test_shared.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_struct/CMakeLists.txt b/test/zephyr/uart/test_struct/CMakeLists.txt new file mode 100644 index 00000000..5584b67d --- /dev/null +++ b/test/zephyr/uart/test_struct/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(ERPC_NAME_APP test_ArithmeticService) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_struct/testcase.yaml b/test/zephyr/uart/test_struct/testcase.yaml new file mode 100644 index 00000000..f944b548 --- /dev/null +++ b/test/zephyr/uart/test_struct/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.struct: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_struct/test_atest_structrrays.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_typedef/CMakeLists.txt b/test/zephyr/uart/test_typedef/CMakeLists.txt new file mode 100644 index 00000000..c6297d38 --- /dev/null +++ b/test/zephyr/uart/test_typedef/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_typedef/testcase.yaml b/test/zephyr/uart/test_typedef/testcase.yaml new file mode 100644 index 00000000..aed6d2bf --- /dev/null +++ b/test/zephyr/uart/test_typedef/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.typedef: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_typedef/test_typedef.py" \ No newline at end of file diff --git a/test/zephyr/uart/test_unions/CMakeLists.txt b/test/zephyr/uart/test_unions/CMakeLists.txt new file mode 100644 index 00000000..53266d3e --- /dev/null +++ b/test/zephyr/uart/test_unions/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# Copyright 2024 NXP +# +# SPDX-License-Identifier: BSD-3-Clause +# + +cmake_minimum_required(VERSION 3.20.0) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/unit_test.cmake) +project(${APP_TYPE}) + +set(ERPC_NAME test) + +# Include test +include(${ZEPHYR_TEST_CMAKE_DIR}/test.cmake) diff --git a/test/zephyr/uart/test_unions/testcase.yaml b/test/zephyr/uart/test_unions/testcase.yaml new file mode 100644 index 00000000..a847573c --- /dev/null +++ b/test/zephyr/uart/test_unions/testcase.yaml @@ -0,0 +1,8 @@ +tests: + erpc.uart.unions: + harness: pytest + tags: + - pytest + harness_config: + pytest_root: + - "../../../python_impl_tests/scripts/test_unions/test_unions.py" \ No newline at end of file diff --git a/utilities/styles/VSC/vsc-extension-quickstart.md b/utilities/styles/VSC/vsc-extension-quickstart.md index ea360ba6..9e338f3b 100644 --- a/utilities/styles/VSC/vsc-extension-quickstart.md +++ b/utilities/styles/VSC/vsc-extension-quickstart.md @@ -3,13 +3,13 @@ ## What's in the folder * This folder contains all of the files necessary for your extension. -* `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. -* `syntaxes/erpc.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization. -* `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets. +* [package.json](package.json) - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. +* [syntaxes/erpc.tmLanguage.json](syntaxes/erpc.tmLanguage.json) - this is the Text mate grammar file that is used for tokenization. +* [language-configuration.json](language-configuration.json) - this is the language configuration, defining the tokens that are used for comments and brackets. ## Get up and running straight away -* Make sure the language configuration settings in `language-configuration.json` are accurate. +* Make sure the language configuration settings in [language-configuration.json](language-configuration.json) are accurate. * Press `F5` to open a new window with your extension loaded. * Create a new file with a file name suffix matching your language. * Verify that syntax highlighting works and that the language configuration settings are working. diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 59d52d0e..6e5b755e 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2023 NXP +# Copyright 2023-2024 NXP # # SPDX-License-Identifier: BSD-3-Clause # @@ -54,6 +54,21 @@ if (CONFIG_ERPC) ${ERPC_DIR}/setup/erpc_setup_uart_zephyr.cpp ) + # Optional TCP transport + zephyr_library_sources_ifdef( + CONFIG_ERPC_TRANSPORT_TCP + ${ERPC_DIR}/transports/erpc_tcp_transport.cpp + ${ERPC_DIR}/setup/erpc_setup_tcp.cpp + ${ERPC_DIR}/port/erpc_threading_pthreads.cpp # Required for POSIX threading + ) + + # Optional MBOX transport + zephyr_library_sources_ifdef( + CONFIG_ERPC_TRANSPORT_MBOX + ${ERPC_DIR}/transports/erpc_mbox_zephyr_transport.cpp + ${ERPC_DIR}/setup/erpc_setup_mbox_zephyr.cpp + ) + # Optional RPMSG-LITE transport zephyr_library_sources_ifdef( CONFIG_ERPC_TRANSPORT_RPMSG_LITE diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 810bd062..2dd28d4d 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -1,5 +1,5 @@ # -# Copyright 2023 NXP +# Copyright 2023-2024 NXP # # SPDX-License-Identifier: BSD-3-Clause # @@ -31,12 +31,24 @@ config ERPC_TRANSPORT_UART select SERIAL select UART_INTERRUPT_DRIVEN +config ERPC_TRANSPORT_TCP + bool "Enable eRPC TCP transport" + help + When enabled, eRPC will include TCP transport layer. This layer use Zephyr POSIX. + config ERPC_TRANSPORT_RPMSG_LITE bool "Enable eRPC rpsmg-lite transport" help When enabled, eRPC will include rpsmg-lite transport layer. depends on RPMSGLITE +config ERPC_TRANSPORT_MBOX + bool "Enable eRPC Zephyr MBOX transport" + help + When enabled, eRPC will include Zephyr MBOX transport layer. + select RING_BUFFER + + config ERPC_ARBITRATED_CLIENT bool "Enable eRPC arbitrated client" help