UIO PRU driver on Beaglebone AI

Is there a UIO PRU driver for the Beaglebone AI? How do I enable it? I’m trying to be able to talk to the PRUs using hal_pru_generic on the the Beaglebone AI, which does so on the BBB using the uio_pruss module. On the AI I see a uio_pruss_shmem module loaded when looking at /proc/modules, is that the same thing?

I can run the following commands on the AI:

cat /sys/class/uio/uio0/maps/map0/addr
0x4b200000

cat /sys/class/uio/uio0/maps/map0/size
0x00020000

cat /sys/class/uio/uio1/maps/map0/addr
0x4b280000

cat /sys/class/uio/uio1/maps/map0/size
0x00020000

The size on both of those seem small as the PRUSS_INTC region starts at 0x00020000 according to the AM572x Technical Reference Manual on page 418 (and on the Beaglebone Black the PRU uio size is 0x00080000).

Anyway, I’m not very familiar with things at this level, so I may not be phrasing my questions well, but any help is appreciated!

Is there a UIO PRU driver for the Beaglebone AI? How do I enable it? I'm trying to be able to talk to the PRUs using hal_pru_generic on the the Beaglebone AI, which does so on the BBB using the uio_pruss module. On the AI I see a uio_pruss_shmem module loaded when looking at /proc/modules, is that the same thing?

This custom little uio_pruss_shmem driver will go away as a different
existing uio driver can be configured to provide uio shared memory
access without interfering with the remoteproc driver's ability to
load the PRU code.

It is largely the same as the uio_pruss module, but the memory region
shared does not include the control registers needed to load code and
start/stop the processor. That can be done with the remoteproc
mechanisms.

Will this work for you?

BTW, sorry I never got back to you on the pinmux stuff. It keeps
dropping from my plate as I seem to always have something more urgent
to do at any given moment. Can you throw a meeting time on my calendar
if you still need this and we can make it a live working session? The
pinmux thing isn't complicated, but I have to look around in a bunch
of places to gather the right bits.

Thanks Jason! I’ve found enough info on the pinmux to get me by for now. hal_pru_generic and the PRUs seem to be the big blocker at this point. I still need to get my head around the details of hal_pru_generic to know if using remoteproc would work. How do I use remoteproc to run code on the PRU?

Thanks Jason! I’ve found enough info on the pinmux to get me by for now. hal_pru_generic and the PRUs seem to be the big blocker at this point. I still need to get my head around the details of hal_pru_generic to know if using remoteproc would work. How do I use remoteproc to run code on the PRU?

Check out cloud9-examples/BeagleBone/AI/pru at v2020.01 · beagleboard/cloud9-examples · GitHub

PRU start script in the Makefile is at

The hal_pru_generic PRU code is all written in assembly and is compiled down to a .bin file. Copying that bin file to the firmware doesn’t work. On the Beaglebone Black the contents of the bin file are copied to the appropriate address in memory in order to load it onto the PRU. What do I have to do to this bin file in order to be able to copy it to /lib/firmare/am57xx-pru1_1-fw (or one of the other 3 pru options) and then start it with remoteproc?

The PRU code for hal_pru_generic is here: https://github.com/machinekit/machinekit-hal/tree/master/src/hal/drivers/hal_pru_generic

You’ll see a number of .p files and they are assembled using pasm, the source code for which is also in the machinekit repository: https://github.com/machinekit/machinekit-hal/tree/master/src/hal/support/pasm

The copyrights at the top of the pasm source are by TI, so I imagine this was copied from somewhere else. I don’t see a way to compile the pru code down to elf format using pasm, which is what it appears I need in order to use remoteproc. Is there another tool I can use to compile/assemble the .p files? Alternatively, is there another tool I can use to convert the compiled .bin file to an elf file?

The PRU code for hal_pru_generic is here: https://github.com/machinekit/machinekit-hal/tree/master/src/hal/drivers/hal_pru_generic

You’ll see a number of .p files and they are assembled using pasm, the source code for which is also in the machinekit repository: https://github.com/machinekit/machinekit-hal/tree/master/src/hal/support/pasm

The copyrights at the top of the pasm source are by TI, so I imagine this was copied from somewhere else. I don’t see a way to compile the pru code down to elf format using pasm, which is what it appears I need in order to use remoteproc. Is there another tool I can use to compile/assemble the .p files? Alternatively, is there another tool I can use to convert the compiled .bin file to an elf file?

You’ll likely need to convert the syntax to get elf. You can use pru-gcc or clpru (TI).

I’d recommend giving pru-gcc a shot. It is available to run on BeagleBone AI in the Debian package feed.

I’d further recommend just switching to C with inline assembly.

Converting the .p files seems like a bigger effort than I’d like to commit right now. I was able to convert the .bin file to a .elf file using objcopy and ln:
Maybe this will come in handy for someone:
https://github.com/PocketNC/bin2elf

Err, I meant objcopy and ld