Introducing eRPC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Introducing eRPC

Introducing eRPC

This tutorial is introducing the eRPC (embedded remote procedure call) open-source project.

 

The eRPC (Embedded Remote Procedure Call) is a Remote Procedure Call (RPC) system created by NXP. An RPC is a mechanism used to invoke a software routine on a remote system using a simple local function call. The remote system may be any CPU connected by an arbitrary communications channel: a server across a network, another CPU core in a multicore system, and so on. To the client, it is just like calling a function in a library built into the application. The only difference is any latency or unreliability introduced by the communications channel.

 

Important links: 

 

The eRPC is supporting multicore and multiprocessor types of applications. 

 

Where to find eRPC examples

 

  • Plenty of eRPC multicore and multiprocessor examples can be found in NXP MCUXpressoSDK packages. Visit https://mcuxpresso.nxp.com to configure, build and download these packages.
    To get the board list with multicore support (eRPC included) use filtering based on Middleware and search for 'multicore' string. Once the selected package with the multicore middleware is downloaded, see
    <MCUXpressoSDK_install_dir>/boards/<board_name>/multicore_examples for eRPC multicore examples (RPMsg_Lite or Messaging Unit transports used) or
    <MCUXpressoSDK_install_dir>/boards/<board_name>/multiprocessor_examples for eRPC multiprocessor examples (UART or SPI transports used).

    eRPC examples use the 'erpc_' name prefix.

  • Another way of getting NXP MCUXpressoSDK eRPC multicore and multiprocessor examples is using the mcux-sdk Github repo. Follow the description how to use the West tool to clone and update the mcuxsdk repo in readme Overview section. Once done the armgcc eRPC examples can be found in
    mcuxsdk/examples/<board_name>/multicore_examples or in
    mcuxsdk/examples/<board_name>/multiprocessor_examples folders.

    You can use the evkmimxrt1170 as the board_name for instance. Similar to MCUXpressoSDK packages the eRPC examples use the 'erpc_' name prefix.

 

Comments

Could anybody help me with follow ussue?:
I'm using use eRPC demo example from erpc-imx-demos on iMX6COM board.

Starting demo application on M4 side:

"Hardware initialized
eRPC intialized
MatrixMultiply service added"

adding driver in linux:
"root@imx6sxea-com:~# modprobe -v rpmsg_multiept
insmod /lib/modules/4.1.15-2.0.3+geb0b90b/kernel/drivers/rpmsg/rpmsg_multiept.ko"

(Here are not any feedback from the system that rpmsg channel was created and rpmsg folder under sys/class/rpmsg is empty)

Starting appl demo on linux:

Traceback (most recent call last):
File "example.py", line 111, in <module>
transport = erpc.transport.RpmsgTransport()
File "build/bdist.linux-armv7l/egg/erpc/transport.py", line 199, in __init__
File "build/bdist.linux-armv7l/egg/rpmsg/sysfs.py", line 116, in __init__
Exception
Exception TypeError: 'an integer is required' in <bound method RpmsgEndpoint.__del__ of <rpmsg.sysfs.RpmsgEndpoint instance at 0x764bde68>> ignored

P.S.
I've built M4 eRPC demo appl. using cmake and also eclipse.
M4 rpmsg demo appl works fine.

Hi Vadim, 

as you see in other comments, i am trying to answer as soon as possible. But this week (and maybe next) i am busy. 
But from what i see in error you should compare init function in transport.py - class RpmsgTransport

And here erpc-imx-demos/sysfs.py at master · EmbeddedRPC/erpc-imx-demos · GitHub   - class RpmsgEndpoint

Be sure that GitHub - EmbeddedRPC/erpc-imx-demos: eRPC demos for i.MX devices  is up to date and and subrepos are checkout on commits as they are aligned with erpc-imx-demos.

Maybe mareknovak‌ can help better here what is wrong. 
Looks like 

if self.id == -1:
raise Exception()

is returning -1

Hi Vadim,

Please post here: ls /sys/class/rpmsg
it looks like the nameservice was not sent from the M4 (is M4 running with the right firmware?). Because of this, a folder with dynamically announced channel from M4 was not created and therefore python cannot create rpmsg  transport...

Please check your M4 core print-outs.

Regards,
Marek

root@imx6sxea-com:~# ls /sys/class/rpmsg
root@imx6sxea-com:~#

Marek, rpmsg folder is empty.

I'll try to check sources, but as I mentioned RPMSG example works fine.

You need to run M4 app befor the python app.

Dusan, Marek,

finally I successfully started modified eRPC example. But I use C on Linux side and erpc 1.5.0 with 6x parameters rpmsg init function in M4 (Dusan tips at github concerning 6th parameter). Thank you for help. Be ready for new questions)

Hi vadimfilippenko, if you are stilll interested in using python version you can look into this thread adding MPU patch to my kernel - I cannot see the new module · Issue #2 · EmbeddedRPC/erpc-imx-demos ... . At least last two messages from mhanuel26 should be interesting for you because he was able to use python application.

Hi Dusan, Marek, community.

I've made several applications with eRPC,
M4(client)-A9(server) or M4(server)-A9(client) works fine, but I want to use client/server appl on each side.
But now it doesn't work or function from one side only executes 1 time and appl hangs.

I want to check the general structure of the code.
What I do wrong?
Should I use 2 separate FreeRTOS tasks for client and server on M4?


M4

.
.


erpc_transport_t transport = erpc_transport_rpmsg_lite_rtos_remote_init(.....);
erpc_mbf_t message_buffer_factory = erpc_mbf_rpmsg_init(transport);
erpc_server_init(transport, message_buffer_factory);
erpc_add_service_to_server(create_TEST_service());
erpc_arbitrated_client_init(transport, message_buffer_factory);

while (true)
{
erpc_server_poll();
function1(....);
}

A9

.
.


erpc_transport_t transport = erpc_transport_rpmsg_linux_init(......);
erpc_mbf_t message_buffer_factory = erpc_mbf_dynamic_init();
erpc_server_init(transport, message_buffer_factory);
erpc_add_service_to_server(create_TEST_service());
erpc_arbitrated_client_init(transport, message_buffer_factory);

while (true)
{
erpc_server_poll();
function2(....);
}

Hi Vadim,

Generally yes you need two tasks. One for client and one for server. Issue is also that output from erpc_arbitrated_client_init you have to put as a parameter to init server

Hi, Dusan.

It helped. By the way it was mentioned in example in header file.

The function call from A9 works fine and M4 returns data.

But now the issue is when M4 calls function. The error is appears in A9 "Waiting MU transmit buffer empty timeout!
ugh, imx_mu_rpmsg_send() failed: -5". 

After this error data function call doesn't work in another side too: "rpmsg_multiept rpmsg0: virtqueue_add_outbuf failed: -5"

What should I check?

Thank you for your help.

Hi Dusan,

I want to port eRPC over TCP socket.

I ran your example test code(test_arrays) over virtual serial(inside linux) and the response time taken for serial is less than 1ms.

When I ran the same example code over TCP, the response time is taken for TCP is around 90ms.

Is there a way to reduce the latency and increase the performance over TCP as like as serial?

Thanks,

Sasidharan.

Hi sasicsepsg@gmail.com‌,

Maybe you can ask guys on github (in same topic, or create new one). There are at least two guys who where doing something with TCP:
github: GitHub - EmbeddedRPC/erpc: Embedded RPC 

thread1:Server with TCP Transport handling multiple connections · Issue #32 · EmbeddedRPC/erpc · GitHub 

thread2:TCP Example client / server code · Issue #39 · EmbeddedRPC/erpc · GitHub 

Personaly i found this, but i don't know if this is your case and if it will help: linux - Low latency TCP settings on Ubuntu 

Hi Dusan,

Thanks for the quick response.

I could able to achieve better performance(response in microsec) in TCP by disabling the Nagel's algorithm using the below API call on both client and server socket connection.

int result = setsockopt(sock,            /* socket affected */

                        IPPROTO_TCP,     /* set option at TCP level */

                        TCP_NODELAY,     /* name of option */

                        (char *) &flag,  /* the cast is historical cruft */

                        sizeof(int));    /* length of option value */

Reference : TCP_NODELAY: 2018 Best Practices for TCP Optimization | ExtraHop 

Thanks,

Sasidharan.

Hi sasicsepsg@gmail.com‌,

Thank you to let us know. It is funny, i read about this today because of another project :smileygrin:

Hi Dusan,

I am working with Chandini here at Cubic. I just wanted to get extra info about eRPC when called from multiple threads. At the moment we are using a single end point and using this for one off calls that complete before making the next call. Now we'd potentially like to make multiple calls from multiple threads so we're wondering the best way to do this.

In fact with my lack of knowledge here we've tried making other calls concurrently, well we didn't realise we were doing this until there was an issue.

Now we see comms failure error codes coming back from the eRPC.

Can a single end point be used for this i.e. should this be thread safe on the client side?

If not should we use a separate end point for each thread,

or should we be doing something else?

Regards

Lee

Hi lee.baker@cubic.com,

i didn't have big experience in this area. Recently we had to add some mutexes when multiple erpc calls were called from multiple taks. But i like your idea. 

I quickly looked into source code. You need to specify your usecase. But i think it is imx Linux vs Mcore using RPSMG. In this case i think you can add mutexes as we did (which will serialize eRPC calls. you would need add them somewhere in performRequest function). The creating endpoints for each thread sounds good to me, but i see more issues which has to be solved. The smaller solution could looks like: transport init function will initialize more endpoints (based on number of tasks), eRPC rpmsg send/receive function on client side change to use unused undepoint to send and same endpoint for receive messages, eRPC rpmsg receive function on server need wait for message on all endpoints.
I don't know if it is simple task or more complicated for you. But i am affraid that without modification to code you will be not able to have multithread calls.

Hi Dusan,

     

             Has eRPC been ported to NXP MPC5748G ? Is there any example code I can reference?

Best Regards,

Alex

HI cccheng914@gmail.com‌,

I don't know about official usage of eRPC on MPC5748G. Just the remind: eRPC depends on program language, OS, transport layer. There are not board specific files. So if there is used Freertos and C language you almost win, you need just port transport you want to use (if it is not already).

No ratings
Version history
Last update:
‎07-14-2023 05:31 AM
Updated by: