RPMSG-lite iMX8 M4 Bare Metal started by linux

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

RPMSG-lite iMX8 M4 Bare Metal started by linux

3,240 Views
zemagi
Contributor II

In my application the M4 firmware is started from linux during init using remoteproc, not from u-boot.

I need to do this becouse I can update the M4 firmware by remote without rebooting the whole board.

In this scenario I need to implement RPMSG form M4_1 to Linux M53s to exchange data between the two cores.

Actually when linux boot the dmsg shows:

[ 0.000000] OF: reserved mem: initialized node vdev0vring0@90000000, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: initialized node vdev0vring1@90008000, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: initialized node vdev1vring0@90010000, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: initialized node vdev1vring1@90018000, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: initialized node vdev0vring0@90100000, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: initialized node vdev0vring1@90108000, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: initialized node vdev1vring0@90110000, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: initialized node vdev1vring1@90118000, compatible id shared-dma-pool

...

[ 0.276966] imx rpmsg driver is registered.
[ 2.083923] imx-rpmsg: probe of 90000000.rpmsg0 failed with error -16
[ 2.090739] imx-rpmsg: probe of 90100000.rpmsg1 failed with error -16

I think becouse M4 is not yet started.

 

Any suggestions?


 

0 Kudos
Reply
5 Replies

3,200 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

I would like to know which Linux version are you working with?
Also, did you use the M4 and the A53 image in the same container?
Have you tried starting the M4 initially and then changing the firmware to see if the same issue is seen?

Saludos,
Aldo.

0 Kudos
Reply

3,193 Views
zemagi
Contributor II

Hello Aldo,


I would like to know which Linux version are you working with?

Linux version 5.4.142


Also, did you use the M4 and the A53 image in the same container?

The boot container is composed by:

  • ATF: bl31-imx8qm.bin
  • SECU: mx8qmb0-ahb-container.bin
  • SCFW: scfw_tcm.bin
  • u-boot: u-boot-spl.bin-imx8qm-var-som-sd + uboot-imx8qm-var-som.bin-sd

the M4 binary is in /boot folder of root fs and start correctly during linux boot.


Have you tried starting the M4 initially and then changing the firmware to see if the same issue is seen?
Not yet, I'll try...

thank you.

3,126 Views
zemagi
Contributor II

I was able to start M4 from u-boot, before linux kernel.

But as soon as kernel boot the M4 hangs.

If I start M4 from linux no hangs happen.

0 Kudos
Reply

2,975 Views
zemagi
Contributor II

After a lot of time I have put again my attentions on that topic.

To get things working I configured u-boot to start CM4 firmware before linux. 

Then if I test the rpmsg using rpmsg_lite_str_echo_rtos from mcuxpresso exmaples the channel is created correctly and now I can get echo messages sent and recived from linux side. 

[ 1.505889] imx-rpmsg 90100000.rpmsg1: assigned reserved memory node vdevbuffer
[ 1.513820] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 1.519928] virtio_rpmsg_bus virtio1: rpmsg host is online
[ 1.519963] virtio_rpmsg_bus virtio1: creating channel rpmsg-virtual-tty-channel-1 addr 0x1f

/sys/bus/rpmsg/devices/virtio1.rpmsg-virtual-tty-channel-1.-1.31 now exists. The result is that from the linux side all things are OK.

unfortunately, if I write the same rpmsg-lite example using a bare metal M4 program, the result is that I'm not able to get channel created and /sys/bus/rpmsg/devices is empty. 

 

[ 1.521733] imx-rpmsg 90100000.rpmsg1: assigned reserved memory node vdevbuffer
[ 1.529666] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 1.535770] virtio_rpmsg_bus virtio1: rpmsg host is online

The bare metal code is the following:

// ------------------------------------------------------------------------    
//  RPMSG Init
// ------------------------------------------------------------------------
    /* Print the initial banner */
    PRINTF("\r\n\r\n----- RPMSG  Test ------\r\n\r\n");    
    int32_t retval;

    PRINTF("rpmsg_lite_remote_init: ");
    my_rpmsg = rpmsg_lite_remote_init((void *)RPMSG_LITE_SHMEM_BASE, RPMSG_LITE_LINK_ID, RL_NO_FLAGS, &rpmsg_ctxt);  
    if (my_rpmsg) PRINTF("Done!\r\n");
        else PRINTF("ERROR rpmsg_lite_remote_init\r\n");

    /* wait for link up */
    PRINTF("rpmsg_lite_wait_for_link_up: ");
    rpmsg_lite_wait_for_link_up(my_rpmsg, RL_BLOCK);
    PRINTF("Done!\r\n");

    /* wait for a while to allow the primary side to bind_ns and register the NS callback */
    //env_sleep_msec(200);

    PRINTF("rpmsg_lite_create_ept: ");    
    my_ept = rpmsg_lite_create_ept(my_rpmsg, LOCAL_EPT_ADDR, my_ept_read_cb, (void *)&has_received, &my_ept_context);
    if (my_ept) PRINTF("Done!\r\n");
        else PRINTF("ERROR rpmsg_lite_create_ept\r\n");

    /* Introduce some delay to avoid NS announce message not being captured by the master side.
       before the nameservice_isr_cb is registered on the master side. */
    env_sleep_msec(4000);

    PRINTF("rpmsg_ns_bind: ");
    my_ns = rpmsg_ns_bind(my_rpmsg, app_nameservice_isr_cb, NULL, &my_ns_context);  
    if (my_ns) PRINTF("Done!\r\n");
        else PRINTF("ERROR rpmsg_ns_bind retval=%d\r\n",retval);

    PRINTF("rpmsg_ns_announce: ");
    retval = rpmsg_ns_announce(my_rpmsg, my_ept, RPMSG_LITE_NS_ANNOUNCE_STRING, RL_NS_CREATE);
    if (retval == RL_SUCCESS) PRINTF("Done!\r\n");
        else PRINTF("ERROR rpmsg_ns_announce retval=%d\r\n",retval);

 

I tried to use rpmsg_ns_bind , but also I comment it out for test. All the #defines are the same as working RTOS example. All calls returns succesfully and rpmsg_lite_wait_for_link_up waits few seconds before succesfully returns. app_nameservice_isr_cb callback is never called.

 

It seems that rpmsg_ns_announce doesn't triggers channel creation, instead wait_for_link_up triggers callback correctly.

 

Any idea?

0 Kudos
Reply

2,942 Views
zemagi
Contributor II

After some investigation I made a mistake on buffer allocation in rpmsg_config.h 

#define RL_BUFFER_COUNT (256U)
 
with the default 2U value don't works.

 

[ 0.277385] imx rpmsg driver is registered.
[ 1.509634] imx-rpmsg 90100000.rpmsg1: assigned reserved memory node vdevbuffer
[ 1.517552] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 1.523645] virtio_rpmsg_bus virtio1: rpmsg host is online
[ 1.529273] virtio_rpmsg_bus virtio1: creating channel rpmsg-virtual-tty-channel-1 addr 0x1f
[ 34.877062] imx_rpmsg_tty virtio1.rpmsg-virtual-tty-channel-1.-1.31: new channel: 0x400 -> 0x1f!
[ 34.877297] Install rpmsg tty driver!

thank you so much,

 

0 Kudos
Reply