Hi @chalu,
@henrique.tx Thanks for the answers, I agree with your points here.
@chalu the whole question depends, at the end, on what you need to do and what are your timings requirements.
The RPMSG framework implements an easier way to communicate between the processors, it’s thread-safe, you can write and read, it’s ready to use and etc.
However, the whole framework that will be slower if you just need to share some memory area between the two processors. For example, if you need to write data with the MCU and just read with Linux, a simple code for the MCU could be:
#define SHARED_MEM_ADDRESS 0x8FF00000
void SharedMemTask(void *pvParameters)
{
uint8_t receiveBuff;
uint32_t value = 0;
uint32_t *ddr_shared_mem = (uint32_t*)SHARED_MEM_ADDRESS;
// Print the initial banner
PRINTF("\r\nShared Memory Demo!\n\n\r");
PRINTF("Shared address: 0x%X\n\r",SHARED_MEM_ADDRESS);
PRINTF("Type r to show the contend of shared memory address (0x%X)\n\r",SHARED_MEM_ADDRESS);
PRINTF("Type w to write new value in the shared memory address (0x%X)\n\r",SHARED_MEM_ADDRESS);
PRINTF("\n\rYou can also write and read the shared memory from linux with devmem2 utility:\n\r");
PRINTF("READ: $devmem2 0x%X\n\r",SHARED_MEM_ADDRESS);
PRINTF("WRITE the value of 0xCC: $devmem2 0x%X w 0xCC\n\r",SHARED_MEM_ADDRESS);
PRINTF("-------------------------------------------------------------------------------\n\r");
// write 0xBB in the shared memory address
*ddr_shared_mem=0xBB;
while(1)
{
// First, get character
receiveBuff = GETCHAR();
switch(receiveBuff) {
case 'r' :
PRINTF("\r\n0x%X: 0x%X\n\r",SHARED_MEM_ADDRESS, *ddr_shared_mem);
break;
case 'w' :
PRINTF("\r\nWrite a value for this register (in HEX): \n\r");
SCANF("%X", &value);
PRINTF("\r\nValue: 0x%X \n\r",value);
*ddr_shared_mem = value;
break;
}
}
}
int main(void)
{
// Initialize demo application pins setting and clock setting.
hardware_init();
// Create a demo task which will print the shared memory content.
xTaskCreate(SharedMemTask, "Print Task", configMINIMAL_STACK_SIZE,
NULL, tskIDLE_PRIORITY+1, NULL);
// Start FreeRTOS scheduler.
vTaskStartScheduler();
// Should never reach this point.
while (true);
}
On linux, you reserve the memory address and read from it, as an example:
reserved-memory {
cmddr0@80000000 {
reg = <0x8FF00000 0x100000>;
no-map;
};
};
So, for example, this removes all the overhead from the RPMSG framework but also introduces a lot of issues that you will need to deal with (threads, don’t write at the same time…). This is just a very simple example, not suitable for more complex scenarios.
Best Regards,
Hiago.