How to exchange data buffers with the coprocessor

Revision as of 17:59, 4 July 2019 by Registered User

1. Article purpose[edit source]

This article provides information needed to exchange big data between Cortex M4 and Cortex A7.

2. Introduction[edit source]

Virtual UART over RPMSG is a good solution to exchange small/medium amount of data between Cortex M4 and Cortex A7.

Some experiments have demonstrated exchange up to 7MB/s from M4 firmware to user land application.

In situation where more than 7MB/s have to be exchanged, RPMSG is not the solution; in this case transfer by DMA is a must.

DMA will decrease a lot CPU consumption due to copy of data.

But solution based on DMA requires:

  • contiguous memory allocation
  • physical address and size on Cortex M4
  • mmap buffer to let user land application have access to it

A specific Linux driver has to be developed to take care of such constraints.

3. static architecture of big data solution[edit source]

Big data solution is composed of:

  • Linux user land application
  • Linux RPMSG sdb (shared data buffer) driver
  • Linux RPMSG tty driver

4. behavior[edit source]

In order to demonstrate this use case, lets implement a logic analyser running on the STM32MP1 discovery board.

We will use the Arduino connector, to sample the following inputs: PE8..PE12.

A user interface will be available in a web page, running in the application.

The user interface allows to control:

  • the sampling frequency
  • the start / stop of the sampling

The user interface displays statistics of:

  • number of compressed data received by user interface
  • number of uncompressed data decompressed by user interface
  • number of compressed data written by user interface in file system

At startup, the application has to:

  • load Cortex M4 firmware
  • open rpmsg_sdb driver
  • use IOCTL function of rpmsg_sdb driver to allocate and mmap 3 buffers of 1MB in DDR memory.
  • open rpmsg_tty driver

On press on START button, the application sends the sampling command to M4 firmware (including the sampling frequency), and open a "date-time.dat" binary file.

On press on STOP button, or overrun data error, or file system full error, the application sends the stop command to M4 firmware and close the "date-time.dat" binary file.

On event "buffer full" coming from Cortex M4 firmware, the application unpack data, write packed data in "date-time.dat" file, and update statistics information.

Cortex M4 firmware is responsible to:

  • receive and manage DDR buffer information (address and size) in an arry
  • receive sampling command and perform the sampling of PE8..PE12 in SRAM
  • pack sampling data using the 3 upper bits of each data byte to implement a repetition factor
  • transfer packed data to application to DDR buffer thanks to DMA
  • inform application when a buffer of 1MB in DDR is full and roll to next buffer

rpmsg_sdb driver is responsible to:

  • allocate / free buffers in contiguous memory (DDR)
  • send physical address and size of DDR buffer
  • mmap DDR buffers in order to let user land application have access to them

rpmsg_tty driver will be used to communicate (transport commands and events) between Cortex M4 firmware and user land application.

5. data flow[edit source]

File:LA dataflow.png

6. dynamic view[edit source]

File:LA msc.png

7. snapshot view of user interface[edit source]

File:LA snapshot.png