For instructions on fixing the bug, look in the appendix at the bottom of the page
So I’m hacking away on the Replicape, trying to figure out why the print stops just after the first layer when run through the PRU. I’m debugging left right and centre when it starts to dawn on me that perhaps the problem is not a part of my code at all.. You know that feeling? Someone else has made a boo boo!
In this case it was the prussdrv that was the culprit. I noticed that it sent more events than what was actually occurring. This bug has been documented before on the TI e2e forum, but there is no official support for BeagleBone so I guess that’s why no one has picked up on it:
http://e2e.ti.com/support/arm/sitara_arm/f/791/t/239735.aspx
The guy who sent in the bug also attached a patch! The PyPRUSS library has now been patched up and so for anyone relying on events from the PRU to pace their work, this should work much better!
In aiding me in the persuit of this bug I have found a couple of good resources. First, the uio_pruss.c source code on line:
http://lxr.free-electrons.com/source/drivers/uio/uio_pruss.c ‘
And secondly a very nice howto on userspace I/O drivers:
http://www.kernel.org/doc/htmldocs/uio-howto.html#custom_kernel_module
The PyPRUSS library has now been updated to include this change. To update, simply go to the PyPRUSS folder and do a
git pull
followed by a
python setyp.py install
Appendix A: Compiling the prussdrv library as a shared object
A precompiled version is available here: libprussdrv.so. It goes in /usr/local/lib/
The PyPRUSS library requires a dynamically linked version of the pruss firmware loader.
This is mostly for documentation purposes, so I can forget about it with a clear conscience. Tkae note that the
git clone git://github.com/beagleboard/am335x_pru_package.git cd am335x_pru_package
Jason Krinder has responded to this bug which is great, but for now it needs to be patched manually:
wget http://e2e.ti.com/cfs-file.ashx/__key/telligent-evolution-components-attachments/00-791-00-00-00-23-97-35/attachments.tar.gz tar -xzf attachments.tar.gz patch -p1 < 0001-Fix-for-duplicated-interrupts-when-interrupts-are-se.patch
Move to the right dir:
cd pru_sw/app_loader/interface/
Then compile:
gcc -I. -Wall -I../include -c -fPIC -O3 -mtune=cortex-a8 -march=armv7-a -shared -o prussdrv.o prussdrv.c
And then link:
gcc -shared -o libprussdrv.so prussdrv.o
Thanks. I’ll take a look and try to apply a fix to the repo as soon as I understand exactly what needs to be fixed.
BTW, you might consider posting issues with that repo at https://github.com/beagleboard/am335x_pru_package/issues in the future.
Jason, great that you will look into this, I will post issues on github if I find any more.
Thanks so much for documenting this; I’d been banging my head against this bug all morning trying to figure out why all my events were doubled. I can’t find the checkin in the pypruss repository, but I’ll try the linked patch to prussdrv.
Phooky, yeah, I spent a lot of time on it as well. If you are using the prussdrv library with C, you have to patch and compile, I only supply a precompiled shared library in .so form in the PyPRUSS repo.
Thanks !
I also mentioned the bug on the BB forum weeks ago but nobody said a bit. I had to workaround it implementing an interrupt counter on the PRUSS and compare it against the event counter on userspace. Userspace counter was exactly the double of the userspace counter.
PRUSS is one of those outstanding features of the Sitara against all its competitors. TI should give a bit more support to the community to leverage the big advantage of the BB and not trying to be a R-Pi on steroids running node.js
Juan, I came across your post yesterday, by chance : ) The PRU is definitely a great value driver for my project at least.
Hi,
First of all, I want to congratulate you for winning Beaglebone Cape Contest!
Actually, I’m so interested in PyPRUSS, I installed it and everything seemed great. After a reboot, executing Ti’s examples worked as expected, I checked your python test script (pypruss_test.py) and it worked as well.
But when it came to test one of your examples (let’s say blinkled.py), python raises SystemError which appears to occur at openning event (0) “pypruss.open(0)”.
After this point, testing “pypruss_test.py” and any of Ti’s examples result into the same error.
Actually, I was observing “/sys/class/uio”, uio0-7 were missed upon the problem had showed up!
So, is it something related to this bug?
BTW, I got this:
[ 1429.589172] ————[ cut here ]————
[ 1429.594207] WARNING: at mm/page_alloc.c:2109 __alloc_pages_nodemask+0xf5/0x3de()
[ 1429.601989] Modules linked in: uio_pruss(+) uio ip_tables x_tables ipv6 [last unloaded: uio]
[ 1429.610961] [] (unwind_backtrace+0×1/0x8c) from [] (warn_slowpath_common+0×33/0×48)
[ 1429.620910] [] (warn_slowpath_common+0×33/0×48) from [] (warn_slowpath_null+0xf/0×10)
[ 1429.631042] [] (warn_slowpath_null+0xf/0×10) from [] (__alloc_pages_nodemask+0xf5/0x3de)
[ 1429.641448] [] (__alloc_pages_nodemask+0xf5/0x3de) from [] (__dma_alloc+0×87/0x1fc)
[ 1429.651397] [] (__dma_alloc+0×87/0x1fc) from [] (dma_alloc_coherent+0×33/0x3c)
[ 1429.660919] [] (dma_alloc_coherent+0×33/0x3c) from [] (pruss_probe+0xa8/0x1b4 [uio_pruss])
[ 1429.671539] [] (pruss_probe+0xa8/0x1b4 [uio_pruss]) from [] (platform_drv_probe+0xd/0xe)
[ 1429.681945] [] (platform_drv_probe+0xd/0xe) from [] (driver_probe_device+0x7f/0×108)
[ 1429.691986] [] (driver_probe_device+0x7f/0×108) from [] (__driver_attach+0×31/0×44)
[ 1429.701904] [] (__driver_attach+0×31/0×44) from [] (bus_for_each_dev+0×29/0×46)
[ 1429.711486] [] (bus_for_each_dev+0×29/0×46) from [] (bus_add_driver+0×69/0×168)
[ 1429.721069] [] (bus_add_driver+0×69/0×168) from [] (driver_register+0×51/0xa2)
[ 1429.730560] [] (driver_register+0×51/0xa2) from [] (pruss_init_module+0×8/0xf [uio_pruss])
[ 1429.741119] [] (pruss_init_module+0×8/0xf [uio_pruss]) from [] (do_one_initcall+0×65/0xf0)
[ 1429.751708] [] (do_one_initcall+0×65/0xf0) from [] (sys_init_module+0xfab/0×1120)
[ 1429.761474] [] (sys_init_module+0xfab/0×1120) from [] (ret_fast_syscall+0×1/0×44)
[ 1429.771209] —[ end trace 7edfbfdac68eac0e ]—
[ 1429.776123] pruss_uio pruss_uio: Could not allocate external memory
Thanks in advance,
Abd
Hi again,
Removing “uio_pruss” module from the kernel and add it again simply fixed it. uio(0-7) showed up, and all of your python scripts and Ti’s examples are working well now!!
I don’t know what just happened but ………. it works (God, how I hate this feeling -_-).
Abd, looking at the source code for the driver,
the error message you are getting from uio_pruss comes from not being able to allocate memory for it.
http://lxr.free-electrons.com/source/drivers/uio/uio_pruss.c
I do not have time to look at this further right now, but I would suggest looking there if you want to fix it yourself.
I see you have been using kernel 3.8 on some projects. Have you gotten the PRUs to work on kernel 3.8? None of the examples in the github work for me, and PyPRUSS fails to as well. I have modprobe’d uio_pruss, and dmesg doesn’t report any errors. I don’t see /dev/uio* but the driver is registered (can see it in /sys.) Running as root, however the drivers failed to open the PRUs.
Nathaniel, I have gotten It to work with 3.8. Not sure what the steps were, but you need to recompile the firmware loader (prussdrv). I also made some modifications to the users space driver to get it to mux the pins right. I will write a post about it soon.
Nathaniel, I’ve updated this page with instructions. Can you try the new version and give your response?
No such luck. It fails to initialize the PRU itself. Same with the examples in the am335x_pru_package github. I get this with PyPRUSS
nathaniel@beaglebot:~/pypruss/examples/blinkled$ sudo modprobe
nathaniel@beaglebot:~/pypruss/examples/blinkled$ lsmod
Module Size Used by
uio_pruss 3597 0
nathaniel@beaglebot:~/pypruss/examples/blinkled$ ls
blinkled.bin blinkled.p blinkled.py Makefile
nathaniel@beaglebot:~/pypruss/examples/blinkled$ python blinkled.py
prussdrv_open open failed
Traceback (most recent call last):
File “blinkled.py”, line 8, in
pypruss.open(0) # Open PRU event 0 which is PRU0_ARM_INTERRUPT
SystemError: error return without exception set
nathaniel@beaglebot:~/pypruss/examples/blinkled$
Nathaniel, can you check to make sure that /dev/uio0 exists?
In pypruss.c,
pypruss_open() calls prussdrv_open() in
prussdrv.c which in turn checks for the existance of /dev/uio*. If this file does not exist, it fails.
Actually, I just rememebered, that I had to do few changes to the library to get it to work with 3.8. Here is a patch: http://hipstercircuits.com/wp-content/uploads/2013/02/0000-change-map-and-size-of-addr.patch_.zip.
But I do not think it helps the above error…
No /dev/uio* files. Should they be create automatically or do i have to make to nodes manually?
They should be created automatically by uio.c from KERNEL/drivers/uio.c. If it fails, you should see an error message during startup. Try a
dmesg | grep uio
and see if you get any messages.
First things first, the pruss unit was disabled in arch/arm/boot/dts/am335x.dtsi. Re-enabled it and now I have my /dev/uio* ports. Examples work fine if they are run as root, otherwise I get a segmentation fault. Seems pretty stupid, but oh well for now I guess.