Unicorn Hat permissions in /tmp


#1

I have begun to setup my Unicorn HAT and I am running the command with sudo from my user account. The HAT will not start and reports permissions errors:

sudo python ./simple.py 
Can't open device file /tmp/mailbox-18282: Permission denied
Can't open device file /tmp/mailbox-18282: Permission denied
Can't open device file /tmp/mailbox-18282: Permission denied
Traceback (most recent call last):
  File "./simple.py", line 3, in <module>
    import unicornhat as UH
  File "/usr/local/lib/python2.7/dist-packages/unicornhat.py", line 13, in <module>
    ws2812.begin()
  File "/usr/local/lib/python2.7/dist-packages/neopixel.py", line 107, in begin
    raise RuntimeError('ws2811_init failed with code {0}'.format(resp))
RuntimeError: ws2811_init failed with code -1
DMA Error: 76cda818

My user is part of the sudo group so I would expect it to work. Any ideas on how I can get it started?


Unicorn HAT no longer working after Raspbian upgrade
#2

Curious. What OS/Pi version is this on?


#3

It is minibian which is essentially a slimmed down raspbian build on the Pi 2.


#4

Some slight progress. I saw a mention in these forums about using exec on /tmp. Running the command:

sudo mount -o remount exec /tmp

causes the python script to run. This change does not persist after a reboot though and from what I can tell it is a security concern allowing executables in /tmp


#5

I have found a possible solution but I am not really sure why it works. Adding:

tmpfs /tmp tmpfs defaults,noatime,nosuid,noexec,size=20%,mode=1777 0 0

to etc/fstab seems to have done the trick. So something about mounting /tmp specifically with these settings makes it work.


#6

Thanks for your feedback. I haven’t used minibian yet, so I’m not familiar with it. I downloaded it ready to test out, but haven’t had a chance to debug yet- good to see you’re hacking away!

I’ve no idea why mounting tmp in that fashion makes it work. Given that it’s setting noexec, the opposite to your previous attempt, you’d think it would have no effect.

I’m no expert when it comes to the gooey internals of Linux, but there’s clearly something miniban is doing differently to Raspbian here.


#7

Okay, it looks like this change might be relevant: https://github.com/richardghirst/rpi_ws281x/pull/2

Specifically: https://github.com/plan44/rpi_ws281x/commit/a8343c773dc2b61187c746b4b250b157646f4adc


#8

Good find. Looks like others are having a similar problem with the library too then.

I am happy enough with my fix for now, I just wish I understood why it made the difference. I was hoping Minibian would be very similar to Raspbian - so far most things have been fine, after all it uses the same packages etc.

On to the next challenge! … getting Node Red to interact with the Unicorn Hat with this: https://github.com/raruston/nodered-mqtt-unicornhat-demo


#9

It’s not a Minibian issue; I’m on Raspbian (wheezy) and I’m getting the same error.
I don’t understand why since I have not updated/upgraded anything…
everything was working fine yesterday but logged in to play with the UnicornHat today and it spit out the same error.

Can't open device file /tmp/mailbox-2571: No such device or address
Can't open device file /tmp/mailbox-2571: No such device or address
Can't open device file /tmp/mailbox-2571: No such device or address
Traceback (most recent call last):
  File "rain.py", line 3, in <module>
    import unicornhat as unicorn
  File "/usr/local/lib/python2.7/dist-packages/unicornhat.py", line 13, in <module>
    ws2812.begin()
  File "/usr/local/lib/python2.7/dist-packages/neopixel.py", line 107, in begin
    raise RuntimeError('ws2811_init failed with code {0}'.format(resp))
RuntimeError: ws2811_init failed with code -1
DMA Error: b6cd4f00

#10

For reference, this is fixed in the updated version of the rpi_ws281x library that drives Unicorn HAT. It should be fixable now by just running:

sudo pip install --upgrade rpi_ws281x