libpruio (fast and easy D/A - I/O)

Scratch that, the problem occurs repetively.
After a random while the network over USB disappears and connecting to the wifi does not let me reconnect to the cloud9 ide.
I got the startup error again, but the problems occurs even if the error isn’t there.

Message from syslogd@beaglebone at Mar 21 18:33:07 …
kernel:[ 412.210610] Internal error: : 1008 [#1] PREEMPT THUMB2

kernel:[ 412.326905] Process irq/118-wl18xx (pid: 1474, stack limit = 0xdc57a210)

kernel:[ 412.333632] Stack: (0xdc57bce0 to 0xdc57c000)

kernel:[ 412.338012] bce0: c100cb70 c1004088 00000000 18000000 c011eea1 c011eea1 db53b22c c011dbb7

kernel:[ 412.346227] bd00: c100a758 00000000 c110c6bc 23d5fe02 00000000 c100cb70 00000000 c110c6bc

kernel:[ 412.354440] bd20: 18000000 c011ddb9 c1004088 c011e12d c100cb70 c100cb70 000c0013 dc28a400

kernel:[ 412.362653] bd40: 00000000 c011e133 dc28a880 00000001 00000000 c011ee6f dc286010 00000000

kernel:[ 412.370867] bd60: 00000000 c011eeb1 00000000 dc286010 00000000 c05f46f5 dc569a00 dc286010

kernel:[ 412.379082] bd80: ffffe000 00208040 00000000 c011eea1 c1004088 db53b22c 00000000 c05f47ef

kernel:[ 412.387296] bda0: dc286010 c101dc80 dc246010 c05f42a1 dc57bdb0 dc57bdb0 00000000 dc57bdbc

kernel:[ 412.395531] bdc0: dc57bdbc 23d5fe02 dc57be0c dc286010 00000004 400c0013 00000002 dc57a000

kernel:[ 412.403743] bde0: c1004088 c05f4581 400c0013 db53b000 00000001 c07174db db53b22c ffffe000

kernel:[ 412.411959] be00: 00000000 dc569a00 c0147bb9 00000100 00000200 23d5fe02 00000000 db5cbc00

kernel:[ 412.420172] be20: c1004088 0001fffc db218c10 00000004 daf1e840 00000000 bf92f171 bf92f1a3

kernel:[ 412.428387] be40: dad87088 c013b5d3 20000000 00000000 c1004088 23d5fe02 dad86d00 c1004088

kernel:[ 412.436602] be60: c101dc80 00000000 00006d90 bf99b680 00000001 bf9860d3 00000000 00000000

kernel:[ 412.444816] be80: 00000000 dc57be84 dc57be84 23d5fe02 c1017a90 dad86d00 dad86d38 dad86ec8

kernel:[ 412.453031] bea0: 1c800000 c1004088 c0165a39 dc518e58 dad86d00 bf97b761 00000000 c0146683

kernel:[ 412.461245] bec0: dc57bed8 c0146683 00000002 bf99b680 02213071 00000001 db42b400 23d5fe02

kernel:[ 412.469459] bee0: c1017a90 c1004088 dad86ec8 c1004088 00000000 c013b6ad 400c0013 dc57bf08

kernel:[ 412.477673] bf00: c0165a39 23d5fe02 c094366b dad86d00 dad86d38 dad86ec8 1c800000 c1004088

kernel:[ 412.485888] bf20: c0165a39 dc518e58 dc11bdf8 bf97becf bf97bdfd dc5183c0 daa1d600 daa1d600

kernel:[ 412.494102] bf40: c0165911 c0165925 dc5183c0 dc57a000 daa1d600 c0165b17 00000000 00000000

kernel:[ 412.502318] bf60: c0165999 23d5fe02 c0165a39 dc518e40 00000000 dc518980 dc57a000 dc5183c0

kernel:[ 412.510533] bf80: c0165a39 c013fe1f dc57a000 dc518980 c013fd45 00000000 00000000 00000000

kernel:[ 412.518746] bfa0: 00000000 00000000 00000000 c0106a59 00000000 00000000 00000000 00000000

kernel:[ 412.526960] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

kernel:[ 412.535174] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000

kernel:[ 412.697028] Code: 6d6a fa12 f383 d1ec (681b) 07da

Any idea why this would happen?

I have encountered some issues with analog input and libpruio. Last week, I had a working version of some code that is a modification of rb_file.

When I run it (or any of the examples) now, I get a Bus error. I am not sure what I did to cause this.

I changed some systemd services that I have calling my code, and I increased the amount of samples my rb_file code is recording.

It doesn’t seem like either of these should have affected libpruio.

debian@beaglebone:/boot$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[24f2e3495113a63c2dcc2c0bdc0d7660b54e4e8f]
eeprom:[A335BNLTBLA21722EL002623]
model:[TI_AM335x_BeagleBone_Blue]
dogtag:[BeagleBoard.org Debian Image 2018-10-07]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.09-00002-g0b54a51eee]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2018.09-00002-g0b54a51eee]:[location: dd MBR]
kernel:[4.19.28-bone28]
nodejs:[v6.16.0]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/BB-I2C1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=/lib/firmware/BB-W1-BLUE-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr6=/lib/firmware/libpruio-0A00.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.4.20190123.0-0rcnee0~stretch+20190123]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[librobotcontrol]:[1.0.4-git20190107.0-0rcnee0~stretch+20190108]
pkg:[firmware-ti-connectivity]:[20180825+dfsg-1rcnee1~stretch+20181217]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep remote
[ 0.992529] remoteproc remoteproc0: wkup_m3 is available
[ 1.091092] remoteproc remoteproc0: powering up wkup_m3
[ 1.091113] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[ 1.095377] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru

Hi CM!

Hello,

I have tried a few implementations, with the number of samples: 30,000 → 300,000 → 600,000. I had no issues with 30,000 or 300,000, as far as I can tell.

I haven’t made any changes to extram_pool_sz, and don’t actually know where the default for this is set. If you could please tell me where that is, I can answer that question.

I also wondered if I should change my uEnv.txt reference from AM335X-PRU-UIO-00A0.dtbo to AM335X-PRU-UIO-4-19-00A0.dtbo, but it was running on the 4.19 kernel previously without issue.

Thanks!

don't use AM335X-PRU-UIO-4-19-00A0.dtbo, it was only used for testing briefly

https://github.com/beagleboard/bb.org-overlays/commit/35dddbc4bec1a61beddfd199601a784745124d3b

Regards,

Are you using error checks (as in the examples)? You didn’t change the extram_pool_sz, so you should get the message “out of memory” for sample amounts (= Adc->ChAz x Adc->Samp) greater than 128 kSamples (= default extram_pool_sz).

You can check the current size of the external memory block in variable PruIo->ESize. A guide for manipulation is in the docs at

http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/ChaMemory.html#SecERam

Regards

In version 0.6.4 some speed optimizations in the ARM code are done. This may lead to race conditions between ARM and PRU in sequences of fast ???->setValue() function calls. The bug is fixed in version 0.6.4b, which I uploaded today. Also the re-muxing in the DTOR is fine again.

Regards

Are you using error checks (as in the examples)? You didn’t change the extram_pool_sz, so you should get the message “out of memory” for sample amounts (= Adc->ChAz x Adc->Samp) greater than 128 kSamples (= default extram_pool_sz).

Yes, I am still using the error checks per the examples. When I run as root I get a bus error, otherwise the error message is:

constructor failed (cannot open /dev/uio5)

Maybe the number of samples is a secondary issue, because I cannot even run any of the examples, e.g. 1 returns a segmentation fault.

This is a LINUX issue. The kernel driver uio_pruss doesn’t load properly. Perhaps it gets listed by lsmod, but it didn’t create the interrupt devices /dev/uio[0-7]. (From user space there is no file /dev/uio5, so opening fails. As root it creates such a device, but without any function. → Don’t use root privileges for development!)

Follow Roberts instruction in this post, in order to provide the necessary debugging informations.

Regards

Follow Roberts instruction in this post, in order to provide the necessary debugging informations.

I have read enough of this board to know that question was coming, so I posted the output of /opt/scripts/tools/version.sh in my initial post. Here it is in case it wasn’t clear:

debian@beaglebone:/boot$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[24f2e3495113a63c2dcc2c0bdc0d7660b54e4e8f]
eeprom:[A335BNLTBLA21722EL002623]
model:[TI_AM335x_BeagleBone_Blue]

dogtag:[BeagleBoard.org Debian Image 2018-10-07]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.09-00002-g0b54a51eee]:[location: dd MBR]

bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2018.09-00002-g0b54a51eee]:[location: dd MBR]
kernel:[4.19.28-bone28]
nodejs:[v6.16.0]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/BB-I2C1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=/lib/firmware/BB-W1-BLUE-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr6=/lib/firmware/libpruio-0A00.dtbo]

uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]

pkg:[bb-cape-overlays]:[4.4.20190123.0-0rcnee0~stretch+20190123]

pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]

pkg:[librobotcontrol]:[1.0.4-git20190107.0-0rcnee0~stretch+20190108]
pkg:[firmware-ti-connectivity]:[20180825+dfsg-1rcnee1~stretch+20181217]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep remote
[ 0.992529] remoteproc remoteproc0: wkup_m3 is available
[ 1.091092] remoteproc remoteproc0: powering up wkup_m3
[ 1.091113] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[ 1.095377] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru

W1-BLUE is a custom dtbo for 1 wire.
libpruio dtbo is probably not actually referencing anything (I think I put it there as a misstep toward troubleshooting this issue)

Another thought I had is that perhaps there is a conflict with librobotcontrol using the PRU when librpuio wants to.

Thank you for your help!

I have read enough of this board to know that question was coming, so I posted the output of /opt/scripts/tools/version.sh in my initial post. Here it is in case it wasn’t clear:

Hopefully Robert finds any hint here …

W1-BLUE is a custom dtbo for 1 wire.
libpruio dtbo is probably not actually referencing anything (I think I put it there as a misstep toward troubleshooting this issue)

Another thought I had is that perhaps there is a conflict with librobotcontrol using the PRU when librpuio wants to.

I don’t know librobotcontrol, but in a first glance it looks like it’s using the rproc driver. It’s impossible to use both, rproc and uio_pruss driver at the same time. libpruio seems to work well on your system, but it’s the LINUX driver loading that fails. Sorry, I cannot help. For libpruio you’ll need a proper uio_pruss driver loading (rproc isn’t fast enough). Check the output of ls -l /dev/uio* , that should list eight entries in case of success. Ask in a librobotcontrol forum if it’s possible to run that library with uio_pruss driver loaded.

Regards

Thank you for the help regarding the driver conflict. I feared that might be the case. I will have to look into running librobotcontrol with uio_pruss, as you suggested.

I also hope that Robert has some insight into my problem.

Also, thank you for your efforts on libpruio. The times I am able to use it, it works well!

librobotcontrol "pru" function calls are tied to remoteproc_pruss (v4.14.x-ti)

What features of librobotcontrol are you using?

Regards,

Hello Robert,

I am using a colleague’s code to read the BeagleBone Blue’s IMU/barometer. He is using some of librobotcontrol in that. To be honest, I don’t know specifically what of librobotcontrol his code is using.

To my understanding, it includes

  • rc/math/kalman.h, filter.h, and quaternion.h
  • rc/time.h, bmp.h, and mpu.h

I am reading through the librobotcontrol source, but it doesn’t look like any of these use the PRU.

I appreciate your insight into this.

You should be fine then, just disable remoteproc_pruss and use
uio_pruss and ignore any of the librobotcontrol pru warnings..

Regards,

You should be fine then, just disable remoteproc_pruss and use
uio_pruss and ignore any of the librobotcontrol pru warnings…

Forgive me if I’m oblivious, what are the steps I take to disable remoteproc_pruss and use uio_pruss?

Do you mean to comment out the PRU-RPROC dtbo files in uEnv.txt, blacklist them in /etc/modprobe.d, or something else entirely?

lsmod shows uio, uio_pdrv_genirq, and uio_pruss already loaded.

When I check the PRU availability, i.e. ls /dev/uio8, it shows uio0-7. All are yellow but uio5.

Thank you,
CM

in /boot/uEnv.txt

only have this one uboot_overlay_pru define enabled:

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

Regards,

Ok, I already have just AM335X-PRU-UIO-00A0.dtbo enabled.

So, if it’s safe to say the issue is not with librobotcontrol, that brings me back to the initial problem.

I cannot run rb_file (or the code I wrote as a modification of it) - getting “constructor failed (cannot open /dev/uio5)”
When I run the example 1 - I get a seg fault.

Any thoughts?

Please post the full output of ls -l /dev/uio*

Do you (your user ID) have write access to that files?

Regards

Please post the full output of ls -l /dev/uio*

Do you (your user ID) have write access to that files?

debian@beaglebone:~/analog$ ls -l /dev/uio*

crw-rw---- 1 root users 240, 0 Nov 3 2016 /dev/uio0

crw-rw---- 1 root users 240, 1 Nov 3 2016 /dev/uio1
crw-rw---- 1 root users 240, 2 Nov 3 2016 /dev/uio2
crw-rw---- 1 root users 240, 3 Nov 3 2016 /dev/uio3
crw-rw---- 1 root users 240, 4 Nov 3 2016 /dev/uio4
-rw-r–r-- 1 root root 0 Mar 29 08:30 /dev/uio5
crw-rw---- 1 root users 240, 6 Nov 3 2016 /dev/uio6
crw-rw---- 1 root users 240, 7 Nov 3 2016 /dev/uio7

When I add write access to /dev/uio5, and run my code (or example 1), I get a Bus error.

/dev/uio5 is listed in white, which means the system doesn’t recognize it as a device, correct?