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/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/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/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_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_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_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/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/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 994cfce5..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 */ @@ -22,7 +22,7 @@ #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 994cfce5..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 */ @@ -22,7 +22,7 @@ #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 994cfce5..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 */ @@ -22,7 +22,7 @@ #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 9b85268b..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) { @@ -253,4 +253,3 @@ int testClient() } return 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/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/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