1. Introduction[edit source]
As explain In "How_to_exchange_buffers_with_the_Cortex-M_co-processor", the rpmsg protocol can not be enough efdficient to directly exchange large buffers between the Cortexes. In this case it is recommended to implement the indirect buffer exchange mode":
- Create specific buffers to store the data to exchange,
- use RPMsg to exchange reference to these buffers with the remote processor.
This article gives an example of mechanism that can be put in place to exchange indirect buffers between a main processor and a coprocessor.
2. Architecture overview[edit source]
This architecture example is relying on a the rpmsg_sdb linux driver.
- On Cortex-A:
- The rpmsg_sdb driver implements on Linux side the service allocate and share buffers with the Cortex-M
- the Linux Application directly access to the mmapped buffers.
- On Cortex-M:
- Application has to implement the "rpmsg-sdb-channel" rpmsg service to manage the buffer information.
- a DMA can be used to transfer data to/from DDR.
For example, refer to How_to_exchange_big_data_between_Cortex-M4_and_Cortex-A7 article.
3. rpmsg_sdb driver[edit source]
The RPMsg shared data buffer driver example in in charge of:
- allocating large buffers in DDR memory and mmap them for an application usage.
- implementing the RPMsg service to share buffer with the remote processor.
- send event to Linux Application when buffers are available ( on RPMsg related message reception)
3.1. Configuration[edit source]
3.1.1. Kernel configuration[edit source]
No kernel configuration is needed. The rpmsg_sdb Linux driver is proposed as module and can be installed thanks to the associated Yocto recipe.
3.1.2. Device tree[edit source]
No device tree device tree declaration is needed. The rpmsg_sdb driver is registered as a rpmsg driver. it is probed when the remote processor creates the "rpmsg-sdb-channel" service
3.2. How to use[edit source]
3.2.1. User space interface[edit source]
The rpmsg_sdb driver exposes a "/dev/rpmsg_sdb" sysfs that offers an interface to allocate and manage the shared buffers.
- open/close: get/release file descriptor.
fd= open('/dev/rpmsg_sdb'); close(fd);
- mmap: allocate and map memories
buff0_id = mmap(size,fd); buff1_id = mmap(size,fd);
- ioctrl
- RPMSG_SDB_IOCTL_SET_EFD
- register event for a buffer
ioctrl(fd, RPMSG_SDB_IOCTL_SET_EFD, buff0_id, eventfd);
- RPMSG_SDB_IOCTL_GET_DATA_SIZE
- get the size of a buffer
ioctrl(fd, RPMSG_SDB_IOCTL_GET_DATA_SIZE, buff0_id, eventfd);
3.2.2. RPMsg messaging[edit source]
The RPMsg protocol is used for the communication with the Cortex-M:
- Information on buffer allocated and mmaped is sent to the Cortex-M.
- The message is structured in a string with following format: "BxAyyyyyyyyLzzzzzzzz"
- x: buffer index,
- yyyyyyyy: address of the buffer in DDR ( 32 bits format),
- zzzzzzzz: length of the buffer (32 bits format)
- Buffer filled event received from the Cortex-M:
- When the Cortex-M4 has filled a buffer it can inform the Linux Application by sending a RPMsg with following string Format : "BxLzzzzzzzz"'.
- x: buffer index,
- zzzzzzzz: length of the buffer (32 bits format)
- On this message reception the rpmsg_sdb driver send an event to application ( if an event is associated to the buffer).