RemoteProc DDR Access: Transferring images from PRUs to ARM

Hi, I am currently working I hope to use the PRUs to transfer image data from an image sensor to linux on ARM. As I understand it, the best ways to do this are either:

  • Have PRU write directly to physical memory location in DDR and have Linux read from there
  • Use DMA

I figured the former would be easier because DMA on Remoteproc seems like undocumented black magic. However, I cannot find a good place to start to with using DDR between the PRU and linux. I tried allocating memory on the linux side and then passing that pointer to the PRU, but my problem was actually that I could not get linux to give me physical memory instead of virtual memory.

Does anyone have any advise on how to get started with this? A simple tutorial on accessing DDR from the PRUs?

Another note: I know alot of people will just tell me to use UIO since there seem to be examples of this, but I would really prefer to use remoteproc since it is still supported and seeing development. I plan on using PRUs in the future, so I would like to do it the right way.

Thanks!

I asked the same question on TI’s forum a few days ago: Linux/BEAGLEBN: DDR access from PRU. No response so far but I’m keen to know as well!

If you already have some code for passing a pointer to the PRU then this here might be of help to you: https://e2e.ti.com/support/arm/sitara_arm/f/791/t/642081, it explains the mapping … but not so much how to disentangle it.

Yes, if you use UIO, you can make use of the pre-allocated DDR buffers
reserved by the device. If you want to use remoteproc, you need to
somehow carve out a chunk of memory to use. Since it's Linux, there
are lots of ways to do this, but most of them involve kernel code
(since that's where you get access to things like physical memory
addresses).

Probably the easiest thing for you to do is to create a reserved
memory node in the device-tree. This lets you allocate a fairly large
chunk of physically contiguous memory at a fixed memory address
(making it easy to work with, no scatter-gather support required)
prior to Linux launching and cluttering up the physical memory map
with lots of running applications. All you need is a few lines added
to your device-tree file:

https://www.kernel.org/doc/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt

...refer to the "multimedia_reserved" example.

Note that you probably want to add the "no-map" property to your
reserved memory range. This tells Linux the memory cannot be cached,
which is important since you have a non-Linux device (the PRU)
modifying the memory contents. If you don't include the "no-map"
setting, you either need to properly handle cache management and
flushing, or make sure your non-Linux access to the memory is cache
coherent (the PRU can't be made to be cache coherent, but some
hardware accelerators can).