"... and no one shall work for money, and no one shall work for fame; But each for the joy of the working, and each, in his separate star, shall draw the thing as he sees it, for the god of things as they are"

-Kipling

 

Enabling the UIO Drivers on the Beaglebone Black

Summary

There are two mechanisms available to load programs into the Programmable Realtime Units (PRU's) on the Beaglebone Black. You can use UIO which accepts only a simple binary image or you can use RProc which uses compiled ELF binaries. Earlier versions of the Beaglebone Black operating system only supported UIO and the drivers for this subsystem were enabled by default. Later versions of the Beaglebone Black operating system enable only RProc by default although the UIO system is capable of being enabled.

If you use the PRU C Compiler to generate the executable intended for the PRU, the output will be an ELF binary and you will need to use RRroc to load it into the PRU. If you use the PASM Assembler for the PRU you just get a simple binary and you will need to use the UIO system to load it. Ultimately, of course, the PRU just runs a binary image with a very simple instruction set and both of these tools produce such a binary. However, the ELF executable has a header which needs to be stripped off first and only the RProc system is able to do that.

Note that, at the time of the writing of this page (Dec 2018), the BBBCSIO interface library for C# and Mono on the Beaglebone Black can only load binaries via the UIO system.

Determine if the UIO Driver is Present

If a UIO Driver suitable for loading the PRU's is operational on the Beaglebone Black, you should be able to see files named uio* in the /dev directory and you should also be to observe the presence of the uio_pruss driver in the output of the lsmod command. The code below shows the results from the two commands when the UIO driver is not present.

root@beaglebone:/home/devuser# ls /dev/uio*
ls: cannot access '/dev/uio*': No such file or directory

root@beaglebone:/home/devuser# lsmod | grep uio
uio_pdrv_genirq        16384  0
uio                    20480  1 uio_pdrv_genirq

Enable the UIO Driver

Both the RProc and UIO are present on later versions of the Beaglebone Black operating system and their enabled or disabled state is controlled by lines in the /boot/uEnv.txt file. If you look in the uEnv.txt file you will see a section which looks like ...

###PRUSS OPTIONS
###pru_rproc (4.4.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo
###pru_rproc (4.14.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_uio (4.4.x-ti, 4.14.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
... note that rproc is enabled by default. To enable UIO just comment out the line referencing ...RPROC... and uncomment the one referencing ...UIO... as shown below.
###PRUSS OPTIONS
###pru_rproc (4.4.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo
###pru_rproc (4.14.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_uio (4.4.x-ti, 4.14.x-ti & mainline/bone kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
You will need to reboot. Changes made in the uEnv.txt file only take effect at boot time.

The UIO Driver Should Now be Present

After the reboot completes, the UIO subsystem should be detectable. The code below shows the results from the two test commands when the UIO driver is present.

root@beaglebone:/home/devuser#  ls /dev/uio*
/dev/uio0  /dev/uio2  /dev/uio4  /dev/uio6
/dev/uio1  /dev/uio3  /dev/uio5  /dev/uio7

root@beaglebone:/home/devuser# lsmod | grep uio
uio_pruss              16384  0
uio_pdrv_genirq        16384  0
uio                    20480  2 uio_pruss,uio_pdrv_genirq

Some Other Considerations

During the development of the RProc mechanism and improvements to the uEnv.txt boot process, things got a little complicated. If you dig around on the Internet for advice about enabling the UIO subsystem you may come across pages that discuss topics like Blacklisting the RProc Drivers as a necessary part of re-enabling UIO. That sort of thing was necessary at one time but now things have settled a quite bit and have been simpliied. The only operation needed to enable UIO on recent versions of the Beaglebone Black operating system is to edit the uEnv.txt file. Just comment out the ...RPROC... line and uncomment the ...UIO... line and reboot. You should be good to go from that point on.

License

The contents of this web page are provided "as is" without any warranty of any kind and without any claim to accuracy. Please be aware that the information provided may be out-of-date, incomplete, erroneous or simply unsuitable for your purposes. Any use you make of the information is entirely at your discretion and any consequences of that use are entirely your responsibility. All source code is provided under the terms of the MIT License.