1. Introduction[edit source]
As explain In "How_to_exchange_buffers_with_the_Cortex-M_co-processor", the rpmsg protocol can not be adapted to exchange buffers between the cortexes. In this case it is recommended to implement the indirect buffer exchange mode":
- create extra buffers to store the data,
- use rpmsg to transmit reference to these buffers to the remote processor.
This article gives an example of mechanism that shall be put in place to exchange indirect buffers between a main processor and a coprocessor.
2. architecture overview[edit source]
This 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
- On Cortex-M: Application as to implement the "rpmsg-sdb-channel" rpmsg service to exchange the buffer information. 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 implements mechanisms to:
- allocate large buffers in DDR memory
- implement RPMsg service to share buffer with the remote processor.
- send event to Linux Application when buffers are available
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 interface to allocate and manage the shared buffers.
- open/close: gete/release file descriptor.
fd= open('/dev/rpmsg_sdb'); close(fd);
- mmap: allocate and map memoryioctrl
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 to communicate 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)