nxp-mcuxpresso / rpmsg-lite

RPMsg implementation for small MCUs
BSD 3-Clause "New" or "Revised" License
238 stars 73 forks source link

Request for help to setup multiple endpoints on 1 RPSMG channel #8

Closed Teletask closed 1 year ago

Teletask commented 4 years ago

Hi

I'm trying to set up the rpmsg communication between the A7 and M4 of IMX7D. I found a rpmsg-lite example at https://github.com/EmbeddedRPC/erpc-imx-demos, was able to make it run and send some data from A7 to the M4.

The example creates only 1 channel and 1 endpoint on the M4 side. I need 2 endpoint on the same channel.

I tinkered with the example in the hope to set up a second endpoint on the same channel. But my change only lead to the creation of a second channel on the A7 side.

my attempt to create a second endpoint: `

    my_rpmsg = rpmsg_lite_remote_init(rpmsg_lite_base, RL_PLATFORM_IMX7D_M4_LINK_ID, RL_NO_FLAGS);
my_queue = rpmsg_queue_create(my_rpmsg);
my_autobus1_queue = rpmsg_queue_create(my_rpmsg);

PRINTF("Waiting for master to get ready...\r\n");

while(!rpmsg_lite_is_link_up(my_rpmsg))
{
    PRINTF(".");
    v00TaskDelay(300);
}
/*  Create the system endpoint                                                                           */
PRINTF("\r\n create system  endpoint\r\n");
system_ept = rpmsg_lite_create_ept(my_rpmsg, SYSTEM_LOCAL_EPT_ADDR, rpmsg_queue_rx_cb, my_queue);
PRINTF("Sending name service announcement to Linux...\r\n");
    rpmsg_ns_announce(my_rpmsg, system_ept, "rpmsg-openamp-demo-channel", RL_NS_CREATE);

/*  Create the AUTOBUS 1 endpoint                                                      */
PRINTF("create autobus_1 endpoint\r\n");
autobus1_ept = rpmsg_lite_create_ept(my_rpmsg, AUTOBUS1_LOCAL_EPT_ADDR, rpmsg_queue_rx_cb,my_autobus1_queue);

PRINTF("Sending name service announcement to Linux...\r\n");
rpmsg_ns_announce(my_rpmsg, autobus1_ept, "rpmsg-openamp-demo-channel", RL_NS_CREATE)

PRINTF("Waiting for any messages from Linux...\r\n");

while(true);

` A snippet of the A7 debug console:

NXP i.MX Release Distro 4.14-sumo pico-imx7 ttymxc4 pico-imx7 login: root root@pico-imx7:~# cd / root@pico-imx7:/# modprobe rpmsg_multiept rpmsg: new channel 0x400 -> 0x1e rpmsg: new channel 0x401 -> 0x1f

Are there any examples or info available on how to setup multiple rpmsg endpoint on 1 channel on the M4 side?

Kind regards Diek

MichalPrincNXP commented 4 years ago

Hello Diek, sorry for late response ... this is more domain of @MarekNovakNXP , Marek could you please help on this? Thanks. Regards Michal

MichalPrincNXP commented 3 years ago

Hello @Teletask , I was hoping @MarekNovakNXP will response, but I am not able to reach him. Anyway, your approach seems to be correct, the M4 code with creation of new endpoint on the same rpmsg_lite instance (channel) looks good, I do not see any problem here. The new channel creation on the A7 side is caused by the second name service announcement sent from the M4 to the A7 core, I think. Linux rpmsg channels correspond to endpoints of rpmsg_lite instance running in baremetal or RTOS-based system. And, once a new name service announcement is received on the Linux side a new rpmsg channel is created. I would try to avoid calling
rpmsg_ns_announce(my_rpmsg, autobus1_ept, "rpmsg-openamp-demo-channel", RL_NS_CREATE) if you are using rpmsg_multiept module. Hope it helps. Regards Michal

siliangZ commented 3 years ago

Hi @Teletask Were you able to solve the problem by following @MichalPrincNXP suggestions? I have the same issue and couldn't solve the problem.

jambamamba commented 3 years ago

I was able to solve this, just make sure you have the same string in all your announcements

rpmsg_ns_announce(my_rpmsg, autobus1_ept, "rpmsg-openamp-demo-channel", RL_NS_CREATE)

Initially I was doing rpmsg-openamp-demo-channel-1, rpmsg-openamp-demo-channel-2, etc. and it didn't like that. But when I used the same string in all the calls. it worked.

siliangZ commented 3 years ago

@jambamamba Thank you so much for your reply. So you could create one device/channel with two endpoints? When I do it like you suggestion(use the same string in the announcement), I find two devices/channels in my linux system. They show up as "rpmsg-openamp-demo-channel-1.0" and "rpmsg-openamp-demo-channel-1.1". Do you think it is related to the rpmsg driver I am using?