Multicore client application
The “Matrix multiply” eRPC client project is located in the following folder:
<MCUXpressoSDK_install_dir>/boards/evkmimxrt1170/multicore_examples/erpc_matrix_multiply_rpmsg/cm7/iar/
Project files for the eRPC client have the _cm7
suffix.
Client 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 the following folders:
<MCUXpressoSDK_install_dir>/devices/<device>
<MCUXpressoSDK_install_dir>/boards/<board_name>/multicore_examples/<example_name>/
|
|
Parent topic:Multicore client application
Client 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.
Two files,
erpc_client_manager.h
anderpc_client_manager.cpp
, are used for managing the client-side application. The main purpose of the client files is to create, perform, and release eRPC requests.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.erpc_common.h
file is used for common eRPC definitions, typedefs, and enums.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.hpp
anderpc_message_buffer.cpp
.erpc_transport.hpp
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 of erpc_malloc() and erpc_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.
erpc_client_setup.h
anderpc_client_setup.cpp
files needs to be added into the “Matrix multiply” example project to demonstrate the use of C-wrapped functions in this example.erpc_transport_setup.h
anderpc_setup_rpmsg_lite_master.cpp
files needs to be added into the project in order to allow C-wrapped function for transport layer setup.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 needs to be added into the client project.
|
|
Parent topic:Multicore client application
Client 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 client application
Client user code
The client’s user code is stored in the main_core0.c file, located in the following folder:
<MCUXpressoSDK_install_dir>/boards/evkmimxrt1170/multicore_example/erpc_matrix_multiply_rpmsg/cm7
The main_core0.c
file contains the code for target board and eRPC initialization.
After initialization, the secondary core is released from reset.
When the secondary core is ready, the primary core initializes two matrix variables.
The erpcMatrixMultiply eRPC function is called to issue the eRPC request and get the result.
It is possible to write the application-specific eRPC error handler. The eRPC error handler of the matrix multiply application is implemented in erpc_error_handler.h
and erpc_error_handler.cpp
files.
The matrix multiplication can be issued repeatedly, when pressing a software board button.
The eRPC-relevant code is captured in the following code snippet:
...
extern bool g_erpc_error_occurred;
...
/* Declare matrix arrays */
Matrix matrix1 = {0}, matrix2 = {0}, result_matrix = {0};
...
/* RPMsg-Lite transport layer initialization */
erpc_transport_t transport;
transport = erpc_transport_rpmsg_lite_master_init(src, dst,
ERPC_TRANSPORT_RPMSG_LITE_LINK_ID);
...
/* MessageBufferFactory initialization */
erpc_mbf_t message_buffer_factory;
message_buffer_factory = erpc_mbf_rpmsg_init(transport);
...
/* eRPC client side initialization */
erpc_client_t client;
client = erpc_client_init(transport, message_buffer_factory);
...
/* Set default error handler */
erpc_client_set_error_handler(client, erpc_error_handler);
...
while (1)
{
/* Invoke the erpcMatrixMultiply function */
erpcMatrixMultiply(matrix1, matrix2, result_matrix);
...
/* Check if some error occured in eRPC */
if (g_erpc_error_occurred)
{
/* Exit program loop */
break;
}
...
}
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 following folder:
<MCUXpressoSDK_install_dir>/boards/evkmimxrt1170/multicore_examples/erpc_matrix_multiply_rpmsg
|
|
Parent topic:Multicore client application
Parent topic:Create an eRPC application