Multicore server application
The “Matrix multiply” eRPC server project is located in the following folder:
<MCUXpressoSDK_install_dir>/boards/evkmimxrt1170/multicore_examples/erpc_matrix_multiply_rpmsg/cm4/iar/
The project files for the eRPC server have the _cm4
suffix.
Server project basic source files
The startup files, board-related settings, peripheral drivers, and utilities belong to the basic project source files and form the skeleton of all MCUXpresso SDK applications. These source files are located in:
<MCUXpressoSDK_install_dir>/devices/<device>
<MCUXpressoSDK_install_dir>/boards/<board_name>/multicore_examples/<example_name>/
|
|
Parent topic:Multicore server application
Server infrastructure files
The eRPC infrastructure files are located in the following folder:
<MCUXpressoSDK_install_dir>/middleware/multicore/erpc/erpc_c
The erpc_c folder contains files for creating eRPC client and server applications in the C/C++ language. These files are distributed into subfolders.
The infra subfolder contains C++ infrastructure code used to build server and client applications.
Four files,
erpc_server.hpp
,erpc_server.cpp
,erpc_simple_server.hpp
, anderpc_simple_server.cpp
, are used for running the eRPC server on the server-side applications. The simple server is currently the only implementation of the server, and its role is to catch client requests, identify and call requested functions, and send data back when requested.Three files (
erpc_codec.hpp
,erpc_basic_codec.hpp
, anderpc_basic_codec.cpp
) are used for codecs. Currently, the basic codec is the initial and only implementation of the codecs.The
erpc_common.hpp
file is used for common eRPC definitions, typedefs, and enums.The
erpc_manually_constructed.hpp
file is used for allocating static storage for the used objects.Message buffer files are used for storing serialized data:
erpc_message_buffer.h
anderpc_message_buffer.cpp
.The
erpc_transport.h
file defines the abstract interface for transport layer.
The port subfolder contains the eRPC porting layer to adapt to different environments.
erpc_port.h
file contains definition oferpc_malloc()
anderpc_free()
functions.erpc_port_stdlib.cpp
file ensures adaptation to stdlib.erpc_config_internal.h
internal erpc configuration file.
The setup subfolder contains a set of plain C APIs that wrap the C++ infrastructure, providing client and server init and deinit routines that greatly simplify eRPC usage in C-based projects. No knowledge of C++ is required to use these APIs.
The
erpc_server_setup.h
anderpc_server_setup.cpp
files needs to be added into the “Matrix multiply” example project to demonstrate the use of C-wrapped functions in this example.The
erpc_transport_setup.h
anderpc_setup_rpmsg_lite_remote.cpp
files needs to be added into the project in order to allow the C-wrapped function for transport layer setup.The
erpc_mbf_setup.h
anderpc_setup_mbf_rpmsg.cpp
files needs to be added into the project in order to allow message buffer factory usage.
The transports subfolder contains transport classes for the different methods of communication supported by eRPC. Some transports are applicable only to host PCs, while others are applicable only to embedded or multicore systems. Most transports have corresponding client and server setup functions in the setup folder.
RPMsg-Lite is used as the transport layer for the communication between cores,
erpc_rpmsg_lite_base_transport.hpp
,erpc_rpmsg_lite_transport.hpp
, anderpc_rpmsg_lite_transport.cpp
files need to be added into the server project.
|
|
Parent topic:Multicore server application
Server multicore infrastructure files
Because of the RPMsg-Lite (transport layer), it is also necessary to include RPMsg-Lite related files, which are in the following folder:
<MCUXpressoSDK_install_dir>/middleware/multicore/rpmsg_lite/
The multicore example applications also use the Multicore Manager software library to control the secondary core startup and shutdown. These source files are located in the following folder:
<MCUXpressoSDK_install_dir>/middleware/multicore/mcmgr/
|
|
Parent topic:Multicore server application
Server user code
The server’s user code is stored in the main_core1.c
file, located in the following folder:
<MCUXpressoSDK_install_dir>/boards/evkmimxrt1170/multicore_examples/erpc_matrix_multiply_rpmsg/cm4
The main_core1.c
file contains two functions:
The main() function contains the code for the target board and eRPC server initialization. After the initialization, the matrix multiply service is added and the eRPC server waits for client’s requests in the while loop.
The erpcMatrixMultiply() function is the user implementation of the eRPC function defined in the IDL file.
There is the possibility to write the application-specific eRPC error handler. The eRPC error handler of the matrix multiply application is implemented in the
erpc_error_handler.h
anderpc_error_handler.cpp
files.
The eRPC-relevant code is captured in the following code snippet:
/* erpcMatrixMultiply function user implementation */
void erpcMatrixMultiply(const Matrix *matrix1, const Matrix *matrix2, Matrix *result_matrix)
{
...
}
int main()
{
...
/* RPMsg-Lite transport layer initialization */
erpc_transport_t transport;
transport = erpc_transport_rpmsg_lite_remote_init(src, dst, (void*)startupData,
ERPC_TRANSPORT_RPMSG_LITE_LINK_ID, SignalReady, NULL);
...
/* MessageBufferFactory initialization */
erpc_mbf_t message_buffer_factory;
message_buffer_factory = erpc_mbf_rpmsg_init(transport);
...
/* eRPC server side initialization */
erpc_server_t server;
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);
...
while (1)
{
/* Process eRPC requests */
erpc_status_t status = erpc_server_poll(server);
/* handle error status */
if (status != kErpcStatus_Success)
{
/* print error description */
erpc_error_handler(status, 0);
...
}
...
}
}
Except for the application main file, there are configuration files for the RPMsg-Lite (rpmsg_config.h
) and eRPC (erpc_config.h
), located in the <MCUXpressoSDK_install_dir>/boards/evkmimxrt1170/multicore_examples/ erpc_matrix_multiply_rpmsg folder.
|
|
Parent topic:Multicore server application
Parent topic:Create an eRPC application