Skip to content

Commit

Permalink
eRPC updates 01/2023
Browse files Browse the repository at this point in the history
-- MUTransport adaptation to new supported SoCs.
-- Made MUTransport class variables volatile.
-- Add missing setCrc16 and getCrc16 methods into rpmsg transport layers.
-- Adapt rpmsg_lite based transports to changed rpmsg_lite_wait_for_link_up() API parameters.
-- Serialize enums as int32 instead of uint32 in Python.
-- Replace github.com/NXPmicro by github.com/nxp-mcuxpresso.
-- Update license file.
  • Loading branch information
MichalPrincNXP committed Jan 10, 2023
1 parent 89f7d9b commit c4dadea
Show file tree
Hide file tree
Showing 26 changed files with 132 additions and 65 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright 2014-2016 Freescale Semiconductor, Inc.
Copyright 2016-2022 NXP
Copyright 2016-2023 NXP
All rights reserved.

The BSD 3 Clause License
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Supported transports:
* NXP Kinetis SPI and DSPI
* POSIX and Windows serial port
* TCP/IP (mostly for testing)
* [NXP RPMsg-Lite / RPMsg TTY](https://github.com/NXPmicro/rpmsg-lite)
* [NXP RPMsg-Lite / RPMsg TTY](https://github.com/nxp-mcuxpresso/rpmsg-lite)
* SPIdev Linux
* USB CDC
* NXP Messaging Unit
Expand Down Expand Up @@ -102,8 +102,8 @@ To get the board list with multicore support (eRPC included) use filtering based

eRPC examples use the 'erpc_' name prefix.

Another way of getting NXP MCUXpressoSDK eRPC multicore and multiprocessor examples is using the [mcux-sdk](https://github.com/NXPmicro/mcux-sdk) Github repo. Follow the description how to use the West tool
to clone and update the mcuxsdk repo in [readme Overview section](https://github.com/NXPmicro/mcux-sdk#overview). Once done the armgcc eRPC examples can be found in
Another way of getting NXP MCUXpressoSDK eRPC multicore and multiprocessor examples is using the [mcux-sdk](https://github.com/nxp-mcuxpresso/mcux-sdk) Github repo. Follow the description how to use the West tool
to clone and update the mcuxsdk repo in [readme Overview section](https://github.com/nxp-mcuxpresso/mcux-sdk#overview). Once done the armgcc eRPC examples can be found in

mcuxsdk/examples/<board_name>/multicore_examples or in

Expand Down Expand Up @@ -230,4 +230,4 @@ Repository on Github contains two main branches. __Master__ and __develop__. Cod
---
Copyright 2014-2016 Freescale Semiconductor, Inc.

Copyright 2016-2021 NXP
Copyright 2016-2023 NXP
2 changes: 1 addition & 1 deletion doxygen/Doxyfile.erpc
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.1"
PROJECT_NUMBER = "Rev. 1.10.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
Expand Down
2 changes: 1 addition & 1 deletion doxygen/Doxyfile.erpcgen
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.1"
PROJECT_NUMBER = "Rev. 1.10.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
Expand Down
6 changes: 4 additions & 2 deletions erpc_c/infra/erpc_message_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ void MessageBuffer::Cursor::set(MessageBuffer *buffer)

uint8_t &MessageBuffer::Cursor::operator[](int index)
{
erpc_assert(((m_pos + index) >= m_buffer->get()) && ((uint16_t)(m_pos - m_buffer->get()) + index <= m_buffer->getLength()));
erpc_assert(((m_pos + index) >= m_buffer->get()) &&
((uint16_t)(m_pos - m_buffer->get()) + index <= m_buffer->getLength()));

return m_pos[index];
}

const uint8_t &MessageBuffer::Cursor::operator[](int index) const
{
erpc_assert(((m_pos + index) >= m_buffer->get()) && ((uint16_t)(m_pos - m_buffer->get()) + index <= m_buffer->getLength()));
erpc_assert(((m_pos + index) >= m_buffer->get()) &&
((uint16_t)(m_pos - m_buffer->get()) + index <= m_buffer->getLength()));

return m_pos[index];
}
Expand Down
2 changes: 1 addition & 1 deletion erpc_c/infra/erpc_transport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Transport
*
* @return Crc16* Pointer to CRC-16 object containing crc-16 compute function.
*/
virtual Crc16 *getCrc16() { return NULL; }
virtual Crc16 *getCrc16(void) { return NULL; }
};

/*!
Expand Down
4 changes: 2 additions & 2 deletions erpc_c/infra/erpc_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
////////////////////////////////////////////////////////////////////////////////

//! @brief String version of eRPC.
#define ERPC_VERSION "1.9.1"
#define ERPC_VERSION "1.10.0"
//! @brief Integer version of eRPC.
#define ERPC_VERSION_NUMBER 10901
#define ERPC_VERSION_NUMBER 11000

/*! @} */

Expand Down
2 changes: 1 addition & 1 deletion erpc_c/setup/erpc_transport_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void erpc_transport_rpmsg_lite_tty_rtos_deinit(void);
* @brief Create an Linux RPMSG endpoint transport.
*
* This function is using RPMSG endpoints based on this implementation:
* github.com/NXPmicro/rpmsg-sysfs/tree/0aa1817545a765c200b1b2f9b6680a420dcf9171 .
* github.com/nxp-mcuxpresso/rpmsg-sysfs/tree/0aa1817545a765c200b1b2f9b6680a420dcf9171 .
*
* When local/remote address is set to '-1', then default addresses will be used.
* When type is set to '0', then Datagram model will be used, else Stream.
Expand Down
34 changes: 11 additions & 23 deletions erpc_c/transports/erpc_mu_transport.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 NXP
* Copyright 2017-2022 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
Expand Down Expand Up @@ -39,8 +39,7 @@ static MUTransport *s_mu_instance = NULL;
void MUTransport::mu_tx_empty_irq_callback(void)
{
MUTransport *transport = s_mu_instance;
if ((transport != NULL) &&
(0U != (transport->m_muBase->CR & (1UL << (MU_CR_TIEn_SHIFT + MU_TR_COUNT - MU_REG_COUNT)))))
if ((transport != NULL) && MU_IS_TX_EMPTY_FLAG_SET)
{
transport->tx_cb();
}
Expand All @@ -49,8 +48,7 @@ void MUTransport::mu_tx_empty_irq_callback(void)
void MUTransport::mu_rx_full_irq_callback(void)
{
MUTransport *transport = s_mu_instance;
if ((transport != NULL) &&
(0U != (transport->m_muBase->CR & (1UL << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT)))))
if ((transport != NULL) && MU_IS_RX_FULL_FLAG_SET)
{
transport->rx_cb();
}
Expand All @@ -60,27 +58,17 @@ void MUTransport::mu_irq_callback(void)
{
MUTransport *transport = s_mu_instance;
uint32_t flags;
uint32_t rxFlags;
uint32_t txFlags;

flags = MU_GetStatusFlags(transport->m_muBase);

// parse flags of full rx registers
rxFlags = ((flags & MU_SR_RFn_MASK) >> MU_SR_RFn_SHIFT);
rxFlags = (rxFlags >> (MU_RR_COUNT - MU_REG_COUNT));

// parse flags of empty tx registers
txFlags = ((flags & MU_SR_TEn_MASK) >> MU_SR_TEn_SHIFT);
txFlags = (txFlags >> (MU_TR_COUNT - MU_REG_COUNT));

// RECEIVING - rx full flag and rx full irq enabled
if ((rxFlags & 0x1U) && (transport->m_muBase->CR & (1UL << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT))))
if ((flags & MU_SR_RX_MASK) && MU_IS_RX_FULL_FLAG_SET)
{
transport->rx_cb();
}

// TRANSMITTING - tx empty flag and tx empty irq enabled
if ((txFlags & 0x1U) && (transport->m_muBase->CR & (1UL << (MU_CR_TIEn_SHIFT + MU_TR_COUNT - MU_REG_COUNT))))
if ((flags & MU_SR_TX_MASK) && MU_IS_TX_EMPTY_FLAG_SET)
{
transport->tx_cb();
}
Expand Down Expand Up @@ -118,7 +106,7 @@ erpc_status_t MUTransport::init(MU_Type *muBase)

#if !ERPC_THREADS
// enabling the MU rx full irq is necessary only for BM app
MU_EnableInterrupts(m_muBase, (1UL << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT)));
MU_EnableInterrupts(m_muBase, MU_RX_INTR_MASK);
#endif

NVIC_SetPriority(MU_IRQ, MU_IRQ_PRIORITY);
Expand All @@ -135,7 +123,7 @@ void MUTransport::rx_cb(void)
{
// the receive function has not been called yet
// disable MU rx full interrupt
MU_DisableInterrupts(m_muBase, (1UL << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT)));
MU_DisableInterrupts(m_muBase, MU_RX_INTR_MASK);
m_newMessage = true;
}
else
Expand Down Expand Up @@ -166,7 +154,7 @@ void MUTransport::rx_cb(void)
m_rxBuffer = NULL;
#if !ERPC_THREADS_IS(NONE)
// disable MU rx full interrupt in rtos-based blocking implementation
MU_DisableInterrupts(m_muBase, (1UL << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT)));
MU_DisableInterrupts(m_muBase, MU_RX_INTR_MASK);
m_rxSemaphore.putFromISR();
#endif
}
Expand Down Expand Up @@ -195,7 +183,7 @@ void MUTransport::tx_cb(void)
if (m_txCntBytes >= m_txMsgSize)
{
// disable MU tx empty irq from the last tx reg
MU_DisableInterrupts(m_muBase, (1UL << (MU_CR_TIEn_SHIFT + MU_TR_COUNT - MU_REG_COUNT)));
MU_DisableInterrupts(m_muBase, MU_TX_INTR_MASK);

// unblock caller of the send function
m_txBuffer = NULL;
Expand Down Expand Up @@ -224,7 +212,7 @@ erpc_status_t MUTransport::receive(MessageBuffer *message)
m_rxBuffer = (uint32_t *)message->get();

// enable the MU rx full irq
MU_EnableInterrupts(m_muBase, (1UL << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT)));
MU_EnableInterrupts(m_muBase, MU_RX_INTR_MASK);

// wait until the receiving is not complete
#if !ERPC_THREADS_IS(NONE)
Expand Down Expand Up @@ -282,7 +270,7 @@ erpc_status_t MUTransport::send(MessageBuffer *message)
if (m_txCntBytes < m_txMsgSize)
{
// enable MU tx empty irq from the last mu tx reg
MU_EnableInterrupts(m_muBase, (1UL << (MU_CR_TIEn_SHIFT + MU_TR_COUNT - MU_REG_COUNT)));
MU_EnableInterrupts(m_muBase, MU_TX_INTR_MASK);
// wait until the sending is not complete
#if !ERPC_THREADS_IS(NONE)
(void)m_txSemaphore.get();
Expand Down
39 changes: 30 additions & 9 deletions erpc_c/transports/erpc_mu_transport.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 NXP
* Copyright 2017-2022 NXP
* All rights reserved.
*
*
Expand Down Expand Up @@ -47,6 +47,27 @@ extern "C" {
#else
#define MU_REG_COUNT (MU_RR_COUNT) /*!< Count of MU tx/rx registers to be used by this transport layer */
#endif /* ERPC_TRANSPORT_MU_USE_MCMGR */

#if (defined(CPU_MIMXRT1189AVM8A_cm7) || defined(CPU_MIMXRT1189CVM8A_cm7) || defined(CPU_MIMXRT1189CVM8A_cm7) || \
defined(CPU_MIMXRT1189AVM8A_cm33) || defined(CPU_MIMXRT1189CVM8A_cm33) || defined(CPU_MIMXRT1189CVM8A_cm33))
#define MU_TX_SHIFT (1UL << (MU_REG_COUNT - 1U))
#define MU_RX_SHIFT (1UL << (MU_REG_COUNT - 1U))
#define MU_RX_INTR_MASK (MU_RX_INTR(MU_RX_SHIFT))
#define MU_TX_INTR_MASK (MU_TX_INTR(MU_TX_SHIFT))
#define MU_IS_TX_EMPTY_FLAG_SET (0U != (transport->m_muBase->TCR & MU_TX_SHIFT))
#define MU_IS_RX_FULL_FLAG_SET (0U != (transport->m_muBase->RCR & MU_RX_SHIFT))
#define MU_SR_TX_MASK (1UL << (20U + (MU_REG_COUNT - 1U)))
#define MU_SR_RX_MASK (1UL << (24U + (MU_REG_COUNT - 1U)))
#else
#define MU_TX_SHIFT (1UL << (MU_CR_TIEn_SHIFT + MU_TR_COUNT - MU_REG_COUNT))
#define MU_RX_SHIFT (1UL << (MU_CR_RIEn_SHIFT + MU_RR_COUNT - MU_REG_COUNT))
#define MU_RX_INTR_MASK (MU_RX_SHIFT)
#define MU_TX_INTR_MASK (MU_TX_SHIFT)
#define MU_IS_TX_EMPTY_FLAG_SET (0U != (transport->m_muBase->CR & MU_TX_SHIFT))
#define MU_IS_RX_FULL_FLAG_SET (0U != (transport->m_muBase->CR & MU_RX_SHIFT))
#define MU_SR_TX_MASK (1UL << (MU_SR_TEn_SHIFT + MU_TR_COUNT - MU_REG_COUNT))
#define MU_SR_RX_MASK (1UL << (MU_SR_RFn_SHIFT + MU_RR_COUNT - MU_REG_COUNT))
#endif
////////////////////////////////////////////////////////////////////////////////
// Classes
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -176,15 +197,15 @@ class MUTransport : public Transport
*/
void tx_cb(void);

volatile bool m_newMessage; /*!< Flag used in function hasMessage() to inform server by polling function that
message is ready for receiving */
uint32_t m_rxMsgSize; /*!< Size of received message - count of bytes to must be received to complete currently
received message */
uint32_t m_rxCntBytes; /*!< Count of currently received bytes of message */
volatile bool m_newMessage; /*!< Flag used in function hasMessage() to inform server by polling function that
message is ready for receiving */
volatile uint32_t m_rxMsgSize; /*!< Size of received message - count of bytes to must be received to complete
currently received message */
uint32_t m_rxCntBytes; /*!< Count of currently received bytes of message */
uint32_t *volatile m_rxBuffer; /*!< Pointer to buffer to which is copied data from MU registers during receiving */
uint32_t m_txMsgSize; /*!< Size of transmitted message - count of bytes to must be transmitted to send complete
message */
uint32_t m_txCntBytes; /*!< Count of currently received bytes of message */
volatile uint32_t m_txMsgSize; /*!< Size of transmitted message - count of bytes to must be transmitted to send
complete message */
uint32_t m_txCntBytes; /*!< Count of currently received bytes of message */
uint32_t *volatile m_txBuffer; /*!< Pointer to buffer from which is copied data to MU registers during sending */

#if !ERPC_THREADS_IS(NONE)
Expand Down
2 changes: 1 addition & 1 deletion erpc_c/transports/erpc_rpmsg_linux_transport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace erpc {

/*!
* @brief RPMSG Linux transport to send/receive messages through RPMSG endpoints
* based on github.com/NXPmicro/rpmsg-sysfs/tree/0aa1817545a765c200b1b2f9b6680a420dcf9171
* based on github.com/nxp-mcuxpresso/rpmsg-sysfs/tree/0aa1817545a765c200b1b2f9b6680a420dcf9171
* implementation.
* @ingroup rpmsg_linux_transport
*/
Expand Down
14 changes: 13 additions & 1 deletion erpc_c/transports/erpc_rpmsg_lite_rtos_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ RPMsgRTOSTransport::RPMsgRTOSTransport(void)
, m_dst_addr(0)
, m_rpmsg_queue(NULL)
, m_rpmsg_ept(NULL)
, m_crcImpl(NULL)
{
}

Expand Down Expand Up @@ -70,6 +71,17 @@ RPMsgRTOSTransport::~RPMsgRTOSTransport(void)
}
}

void RPMsgRTOSTransport::setCrc16(Crc16 *crcImpl)
{
erpc_assert(crcImpl != NULL);
m_crcImpl = crcImpl;
}

Crc16 *RPMsgRTOSTransport::getCrc16(void)
{
return m_crcImpl;
}

erpc_status_t RPMsgRTOSTransport::init(uint32_t src_addr, uint32_t dst_addr, void *base_address, uint32_t length,
uint32_t rpmsg_link_id)
{
Expand Down Expand Up @@ -166,7 +178,7 @@ erpc_status_t RPMsgRTOSTransport::init(uint32_t src_addr, uint32_t dst_addr, voi
ready_cb();
}

rpmsg_lite_wait_for_link_up(s_rpmsg);
(void)rpmsg_lite_wait_for_link_up(s_rpmsg, RL_BLOCK);

#if RL_USE_STATIC_API
m_rpmsg_queue = rpmsg_queue_create(s_rpmsg, m_queue_stack, &m_queue_context);
Expand Down
17 changes: 16 additions & 1 deletion erpc_c/transports/erpc_rpmsg_lite_rtos_transport.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
* Copyright 2016-2020 NXP
* Copyright 2016-2022 NXP
* All rights reserved.
*
*
Expand All @@ -10,6 +10,7 @@
#ifndef _EMBEDDED_RPC__RPMSG_LITE_RTOS_TRANSPORT_H_
#define _EMBEDDED_RPC__RPMSG_LITE_RTOS_TRANSPORT_H_

#include "erpc_crc16.hpp"
#include "erpc_message_buffer.hpp"
#include "erpc_rpmsg_lite_base_transport.hpp"

Expand Down Expand Up @@ -107,6 +108,19 @@ class RPMsgRTOSTransport : public RPMsgBaseTransport
*/
virtual erpc_status_t send(MessageBuffer *message);

/*!
* @brief This functions sets the CRC-16 implementation.
*
* @param[in] crcImpl Object containing crc-16 compute function.
*/
virtual void setCrc16(Crc16 *crcImpl);

/*!
* @brief This functions gets the CRC-16 object.
*
* @return Crc16* Pointer to CRC-16 object containing crc-16 compute function.
*/
virtual Crc16 *getCrc16(void);
/*!
* @brief Function to check if is message in receive queue and wait for processing.
*
Expand All @@ -123,6 +137,7 @@ class RPMsgRTOSTransport : public RPMsgBaseTransport
uint32_t m_dst_addr; /*!< Destination address used by rpmsg. */
rpmsg_queue_handle m_rpmsg_queue; /*!< Handle of RPMsg queue. */
struct rpmsg_lite_endpoint *m_rpmsg_ept; /*!< Pointer to RPMsg Lite Endpoint structure. */
Crc16 *m_crcImpl; //!< CRC object.
};

} // namespace erpc
Expand Down
14 changes: 13 additions & 1 deletion erpc_c/transports/erpc_rpmsg_lite_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ RPMsgTransport::RPMsgTransport(void)
: RPMsgBaseTransport()
, m_dst_addr(0)
, m_rpmsg_ept(NULL)
, m_crcImpl(NULL)
{
}

Expand Down Expand Up @@ -71,6 +72,17 @@ RPMsgTransport::~RPMsgTransport(void)
}
}

void RPMsgTransport::setCrc16(Crc16 *crcImpl)
{
erpc_assert(crcImpl != NULL);
m_crcImpl = crcImpl;
}

Crc16 *RPMsgTransport::getCrc16(void)
{
return m_crcImpl;
}

erpc_status_t RPMsgTransport::init(uint32_t src_addr, uint32_t dst_addr, void *base_address, uint32_t length,
uint32_t rpmsg_link_id)
{
Expand Down Expand Up @@ -146,7 +158,7 @@ erpc_status_t RPMsgTransport::init(uint32_t src_addr, uint32_t dst_addr, void *b
ready_cb();
}

rpmsg_lite_wait_for_link_up(s_rpmsg);
(void)rpmsg_lite_wait_for_link_up(s_rpmsg, RL_BLOCK);

#if RL_USE_STATIC_API
m_rpmsg_ept = rpmsg_lite_create_ept(s_rpmsg, src_addr, rpmsg_read_cb, this, &m_ept_context);
Expand Down
Loading

0 comments on commit c4dadea

Please sign in to comment.