IMX7 RPMSG lite

Do you have any RPMSG-lite implemenation for IMX7 ?

https://nxpmicro.github.io/rpmsg-lite/group__rpmsg__lite.html

It seems lighter than the current RPMSG implementation.

Thanks !

Dear @arnaud_infoteam

We only have the code that we published in our github repository. This is not a full-fledged RpMsg implementation, and as far as I know this should be exactly RpMsg Lite.

Relating the weight: I quickly compared the size of all .c and .h files in the rpmsg folder of iMX7 vs. iMX8QM (NXP calls the folder rpmsg_lite on iMX8):

  • iMX7: 144kB
  • iMX8: 240kB

Regards, Andy

Dear @andy.tx,

Thank you a lot for the quick reply.

It seems to use the implementation from openAMP
https://github.com/OpenAMP/open-amp
https://github.com/OpenAMP/open-amp/wiki/RPMsg-Messaging-Protocol

[upload|iqcHnu6FLj03rqTSzX72SGrZV34=]

In the Cortex-M4 32kB TCM memory is available for data and 32kB for the program.

The current RPMSG implementation needs more than 12 kB (black line in the picture above) heap memory from FreeRTOS. It’s a bit frustrating to have that much memory used for RPMSG.

[upload|9hbqsZvHpvdYIw48T0E9HCq2fAk=]
The picture above illustrate all the malloc done by the RPMSG init.

Thank you a lot. I didn’t need more explanation.

Dear @arnaud_infoteam

Probably the situation is much better than you think. I don’t know the Percepio analyzer, so I might be wrong with interpreting the graphics. But the addresses shown (0x200020A0 …) are all in DRAM, not in TCM.
I also know from my experience with the RpMsg code that all the main RpMsg buffers are in DRAM.

Regards, Andy

Dear @andy.tx

According to the manual the adresses are in the TCM.

According to FreeRTOS manual. It uses a heap memory located in heap_2.c.

The ucHeap table size is defined in FreeRTOSConfig.h with

#define configTOTAL_HEAP_SIZE             ((size_t)(20 * 1024))

You can watch the heap memory available with xPortGetFreeHeapSize() API Function.

I tried to show this, including printf in code. (I use a custom printf, I made on my own). Then, I can watch how much heap memory is available.

void __OCRAM_FUNC IpcFromMizarTask(void *pvParameters)
{
    BaseType_t ret;
    int counter = 0;
    struct rpmsgParam *rpmsgData = pvParameters;
    int result;
    void *rx_buf;
    unsigned long src;
    int len;
    struct ipcFrame currentFrame;
    taskLog("From Mizar task started !");
    taskLog("Heap Memory available %ld",xPortGetFreeHeapSize());
    taskLog("Waiting for RPMSG ...");
    result = rpmsg_rtos_init(RPMSG_REMOTE_CPU_ID, &(rpmsgData->rdev), RPMSG_MASTER,            &(rpmsgData->app_chnl));
    configASSERT(result == 0);

    taskLog("Rpmsg chan [%d --> %d]",
            rpmsgData->app_chnl->src,
            rpmsgData->app_chnl->dst);
    taskLog("Heap Memory available %ld",xPortGetFreeHeapSize());

    while(1)
    {
...

When I run this task initializing the RPMSG. The teminal output shows this:

[    0.000010]           _
[    0.003875]     /\   | |
[    0.007721]    /  \  | | ___ ___  _ __
[    0.011567]   / /\ \ | |/ __/ _ \| '__|
[    0.015413]  / ____ \| | (_| (_) | |
[    0.019259] /_/    \_\_|\___\___/|_|
[    0.022931] v0.3.2-12-ga829fe1-dirty
[    0.026519] Compilation : Jan 16 2020 11:34:40
[    0.031018] Waiting for debug RTT: 0x20005db4
[    0.035389] Heap Memory available 19080
[    0.039321] Init done .. Starting Scheduler ..
[    0.043776] Heap Memory available 16352
[    0.047667] Term Tx task started !
[    0.047648] To Mizar Task started !
[    0.048649] From Mizar task started !
[    0.048659] Heap Memory available 15736
[    0.048671] Waiting for RPMSG ...
[   21.242442] Rpmsg chan [0 --> 1024]
[   21.242457] Heap Memory available 3560

So after the rpmsg init 15736-3560=12176 bytes are used in the heap memory for the RPMSG.

When you change the configTOTAL_HEAP_SIZE value. The bss size also change.

$ size -A release/alcor.elf
release/alcor.elf  :
section                   size         addr
.interrupts                576            0
.text                    29952    536838144
.ARM                         8    536868096
.init_array                  4    536868104
.fini_array                  4    536868108
.ocram_128_1_block       48312      9437184
.ocram_128_2_block        4368      9502720
.shared_ddr3_2_block   1068784   2550136832
.data                      544    536870912
.bss                     29812    536871456
.heap                     1028    536901268
.stack                    1024    536902296
.ARM.attributes             48            0
.comment                    85            0
.debug_line              34679            0
.debug_info             121945            0
.debug_abbrev            22227            0
.debug_aranges            1664            0
.debug_str               10613            0
.debug_loc               13985            0
.debug_ranges             1384            0
.debug_frame              2832            0
.stab                      108            0
.stabstr                   227            0
Total                  1394213

The configTOTAL_HEAP_SIZE reduced to 10*1024

$ size -A release/alcor.elf
release/alcor.elf  :
section                   size         addr
.interrupts                576            0
.text                    29952    536838144
.ARM                         8    536868096
.init_array                  4    536868104
.fini_array                  4    536868108
.ocram_128_1_block       48312      9437184
.ocram_128_2_block        4344      9502720
.shared_ddr3_2_block   1068784   2550136832
.data                      544    536870912
.bss                     19572    536871456
.heap                     1028    536891028
.stack                    1024    536892056
.ARM.attributes             48            0
.comment                    85            0
.debug_line              34679            0
.debug_info             121945            0
.debug_abbrev            22227            0
.debug_aranges            1664            0
.debug_str               10613            0
.debug_loc               13985            0
.debug_ranges             1384            0
.debug_frame              2832            0
.stab                      108            0
.stabstr                   227            0
Total                  1383949

I assume the rpmsg ring buffer are in the DRAM, but the malloc made by the rpmsg init are located in the TCM.

I will try to switch from heap_2.c to heap_5.c

This way I can distribute the freeRTOS heap memory in different memory area. Even the DDR3.

That’s a reason I’m looking forward to seeing Colibri IMX8 at the end of the year to get 128kB TCM memory for data and 128kB for program :smiley:

Best Regards,

Arnaud

Dear @Arnaud
Thank you for that detailed analysis.
Regards, Andy