Library of the PRU (Libpruio)

I just studied your last image in more detail and found out that you tried to compile the src/c_examples/pruss_toggle.c code. It compiles, but doesn’t link

/usr/bin/ld: cannot find -libpruio

This will be fixed once you execute

sudo ldconfig

and even in that case the executable wouldn’t run, since the uio_pruss driver is not loaded on your system

initialisation failed (failed opening prussdrv library)

In order to give some hints here, I need to know your kernel version.

And:
you started an out-of-source build. Why not continue? Execute

make pruss_toggle_c

in the build folder and find the resulting executable at src/c_examples/pruss_toggle_c. Note: that example needs pinmuxing, it’ best to build and install the lkm first.

Perhaps you want to start with more easy examples (ie 1 or analyse), and care about pinmuxing later.

Regards

Well my friend I was trying the first example 1.c but gave this error:
root@beaglebone:/home/debian/libpruio/build/src/c_examples# ls
1 1.c CMakeFiles cmake_install.cmake Makefile
root@beaglebone:/home/debian/libpruio/build/src/c_examples# ./1
Segmentation fault

I don’t know why my friend, I veryfied the uio_pruss driver root@beaglebone:/home/debian/libpruio/build/src/c_examples# lsmod | grep uio
uio_pdrv_genirq 16384 0
uio 20480 1 uio_pdrv_genirq
root@beaglebone:/home/debian/libpruio/build/src/c_examples# ls -l /dev/uio*
-rw-r–r-- 1 root root 0 May 17 00:42 /dev/uio5
root@beaglebone:/home/debian/libpruio/build/src/c_examples#

Rony Vargas

I did the following the commands:
root@beaglebone:/home/debian/libpruio/src/c_examples# dpkg -l | grep uio
ii libpruio 0.6.6 armhf PRUSS driver for BB A/D-IO
ii libpruio-bas 0.6.6 armhf PRUSS driver for BB A/D-IO
ii libpruio-bin 0.6.6 armhf PRUSS driver for BB A/D-IO
ii libpruio-dev 0.6.6 armhf PRUSS driver for BB A/D-IO
ii libpruio-doc 0.6.6 all HTML-documentation for libpruio-dev packages
ii libpruio-modules-4.19.94-ti-r42 1buster armhf libpruio modules
ii python-pruio 0.6.6 armhf PRUSS driver for BB A/D-IO
root@beaglebone:/home/debian/libpruio/src/c_examples# lsmod | grep uio
uio_pruss 16384 0
uio_pdrv_genirq 16384 0
uio 20480 2 uio_pruss,uio_pdrv_genirq
root@beaglebone:/home/debian/libpruio/src/c_examples# ls -l /dev/uio*
-rw-r–r-- 1 root root 0 May 17 12:30 /dev/uio5
root@beaglebone:/home/debian/libpruio/src/c_examples#

Why are you still working as root in the source tree?

The uio_pruss driver didn’t load (the ls command should give 8 /dev/uio[0-7] entries). Check

dmesg | grep uio

Regards

PS
Is 4.19.94 your kernel version?

Yes is 4.19.94 kernel version my friend

That’s fine. (Here I run libpruio on exactly that version.)

Please post the output from dmesg grep uio.

Regards

PS
You’re running in to a further issue: the libpruio-0-6-6.deb package installed a binary in /usr/lib and executed ldconfig for that binary. Now you’re working in the source tree and installed a second binary in /usr/local/lib. The linker won’t find that binary (and all its customization). Instead the linker binds all compiled executable against the (unchanged) /usr/lib/libpruio.so binary.

So it’s good to make your mind: either packages or building from source.

it doesn’t show nothing in the output my friend @DTJF

Ok, the lkm isn’t loaded.

But more important: make the uio_pruss driver working! Your output from lsmod | grep uio is OK, but ls /dev/uio* must show 8 interrupt files [0-7], like

debian@beaglebone:$ ls -l /dev/uio*
crw-rw---- 1 root pruio 241, 0 Mai 16 20:51 /dev/uio0
crw-rw---- 1 root pruio 241, 1 Mai 16 20:51 /dev/uio1
crw-rw---- 1 root pruio 241, 2 Mai 16 20:51 /dev/uio2
crw-rw---- 1 root pruio 241, 3 Mai 16 20:51 /dev/uio3
crw-rw---- 1 root pruio 241, 4 Mai 16 20:51 /dev/uio4
crw-rw---- 1 root pruio 241, 5 Mai 16 20:51 /dev/uio5
crw-rw---- 1 root pruio 241, 6 Mai 16 20:51 /dev/uio6
crw-rw---- 1 root pruio 241, 7 Mai 16 20:51 /dev/uio7

First check if the right modules are loaded

ls /sys/firmware/devicetree/base/chosen/overlays

Perhaps you’ve to blacklist the rproc driver … I don’t know.

Note: that’s not an libpruio issue. Instead it’s a LINUX-boot issue.

Here my friend @DTJF, when you refer the blacklist is the sudo nano /etc/apt/sources.list to include rproc driver.

debian@beaglebone:/$ ls -l /dev/uio*
ls: cannot access ‘/dev/uio*’: No such file or directory
debian@beaglebone:/$ ls /sys/firmware/devicetree/base/chosen/overlays
AM335X-PRU-RPROC-4-19-TI-00A0 BB-BONE-eMMC1-01-00A0.bb.org-overlays name
BB-ADC-00A0.bb.org-overlays M-BB-BBG-00A0.bb.org-overlays
debian@beaglebone:/$

No, that’s for the package manager.

Your /boot/uEnv.txt file loads the RPROC driver. uio_pruss cannot work! You’ve to fix this.

Regards

Just for further help, here’s the context of a minimal /boot/uEnv.txt file I’m using on a similar kernel version

#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
uname_r=4.19.142-bone56

enable_uboot_overlays=1
disable_uboot_overlay_emmc=1
#disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
disable_uboot_overlay_adc=1
uboot_overlay_pru=AM335X-PRU-UIO-00A0.dtbo
cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet video=HDMI-A-1:800x480@60e

Regards

Here my friend @DTJF, I did the command nano /boot/uEnv.txt and it showed me this:

#Docs: Beagleboard:U-boot partitioning layout 2.0 - eLinux.org

uname_r=4.19.94-ti-r42
#uuid=
#dtb=

###U-Boot Overlays###
###Documentation: Beagleboard:BeagleBoneBlack Debian - eLinux.org
###Master Enable
enable_uboot_overlays=1

###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/.dtbo
#uboot_overlay_addr1=/lib/firmware/.dtbo
#uboot_overlay_addr2=/lib/firmware/.dtbo
#uboot_overlay_addr3=/lib/firmware/.dtbo

###Additional custom capes
#uboot_overlay_addr4=/lib/firmware/.dtbo
#uboot_overlay_addr5=/lib/firmware/.dtbo
#uboot_overlay_addr6=/lib/firmware/.dtbo
#uboot_overlay_addr7=/lib/firmware/.dtbo

###Custom Cape
#dtb_overlay=/lib/firmware/.dtbo

###Disable auto loading of virtual capes (emmc/video/wireless/adc)
#disable_uboot_overlay_emmc=1
#disable_uboot_overlay_video=1
#uboot_overlay_addr6=/lib/firmware/.dtbo
#uboot_overlay_addr7=/lib/firmware/.dtbo

###Custom Cape
#dtb_overlay=/lib/firmware/.dtbo

###Disable auto loading of virtual capes (emmc/video/wireless/adc)
#disable_uboot_overlay_emmc=1
#disable_uboot_overlay_video=1
#disable_uboot_overlay_audio=1
#disable_uboot_overlay_wireless=1
#disable_uboot_overlay_adc=1

###PRUSS OPTIONS
###pru_rproc (4.14.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_rproc (4.19.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
###pru_uio (4.14.x-ti, 4.19.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo

###Cape Universal Enable
enable_uboot_cape_universal=1

###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###U-Boot fdt tweaks… (60000 = 384KB)
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###

cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100$

#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=10$

##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh

Replace that file content by

#Docs: [Beagleboard:U-boot partitioning layout 2.0 - eLinux.org](http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0)

uname_r=4.19.94-ti-r42
enable_uboot_overlays=1

###Custom Cape (enable later)
#dtb_overlay=/lib/firmware/<your custom overlay here>.dtbo

###Disable auto loading of virtual capes (emmc/video/wireless/adc)
disable_uboot_overlay_emmc=1
#disable_uboot_overlay_video=1
#disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
disable_uboot_overlay_adc=1

###PRUSS OPTIONS
uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo

cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100$

and check for the uio_pruss driver again (after rebooting).

Regards

PS
I don’t trust the TI kernel flavour (and never tried). Perhaps it’s better you switch to the bone-flavour.

Now yes it showed me the uio_pruss driver my friend @DTJF

crw-rw---- 1 root users 241, 0 May 17 16:04 /dev/uio0
crw-rw---- 1 root users 241, 1 May 17 16:04 /dev/uio1
crw-rw---- 1 root users 241, 2 May 17 16:04 /dev/uio2
crw-rw---- 1 root users 241, 3 May 17 16:04 /dev/uio3
crw-rw---- 1 root users 241, 4 May 17 16:04 /dev/uio4
crw-rw---- 1 root users 241, 5 May 17 16:04 /dev/uio5
crw-rw---- 1 root users 241, 6 May 17 16:04 /dev/uio6
crw-rw---- 1 root users 241, 7 May 17 16:04 /dev/uio7

OK, the example 1_c should work now. You can test the version from the libpruio-bin package by executing (in any folder)

1_c

Regards

yes, it is working perfect my friend @DTJF

debian@beaglebone:~/libpruio/src/c_examples$ ./1
0 F3C0 F8D0 88E0 0 0 0 0
FBD0 F3C0 F8D0 88E0 5210 A320 0 0
FBD0 F3C0 F8D0 88E0 5210 A320 C850 0
FBD0 F3C0 F8D0 88E0 5210 A320 C850 0
FBD0 F3C0 F8D0 88E0 5210 A320 C850 0
FBD0 F3C0 F8D0 88E0 5210 A320 C850 EF50
FBD0 F3C0 F8D0 88E0 5210 A320 C850 EF50
FAB0 F3C0 F8D0 88E0 5210 A320 C850 EF50
FAB0 F3C0 F8D0 88E0 5210 A320 C850 EF50
FB30 F3C0 F8D0 88E0 5210 A320 C850 EF50
FB30 F3C0 F8D0 88E0 5210 A320 C850 EF50
FB30 F3C0 F8D0 88E0 5210 A320 C850 EF50
FB30 F3B0 F8D0 88E0 5210 A320 C850 EF50

Congrats!

Now you’ve to make your mind: either working with

  • packeges
  • building from source (GIT repo)

Regards

thank you my friend @DTJF , now if I want to make work the program of the pru_toggle.c , I need to check the nano /boot/dtbs/am335x-bone-common.dtsi?

debian@beaglebone:~/libpruio/src/c_examples$ ls
1 button2.c io_input.c pruss_toggle pwm_cap rb_file.c
1.c button.c performance.c pruss_toggle.c pwm_cap.c sos.c
button CMakeLists.txt pruss_add.c pru_toggle qep.c stepper.c
debian@beaglebone:~/libpruio/src/c_examples$ ./pruss_toggle
P8_11 configuration failed (pinmux missing)
debian@beaglebone:~/libpruio/src/c_examples$

What’s your decision?

The next step is to install the lkm module, so that libpruio has pinmuxing capability (from source code and you need not deal with device tree blobs).

Some more input. There’re three oportunities for the lkm

  1. RCN package
  2. libpruio-lkm package
  3. building from source

Add 1:
You already installed the RCN package, but it doesn’t load the lkm → either manually load the lkm (modprobe) or create a systemctl service that does this at boot-time (the uio_pruss driver must be active before the lkm taints the kernel)

Add 2:
When you install that package a new group gets created named pruio, the systemctl service gets installed and a dkms job cares about a binary up-date in case of a kernel up-date (dependency kernel headers get also installed).

Add 3:
You’ve to manually install the kernel headers package and then execute

make lkm
sudo make lkm-install

to get the steps from 2. In case of each kernel up-date you’ve to re-build / re-install the lkm again.

Regards