pimoroni / unicorn-hat

Python library for Unicorn pHAT and HAT. 32 or 64 blinding ws2812 pixels for your Raspberry Pi
https://shop.pimoroni.com/products/unicorn-hat
MIT License
370 stars 130 forks source link

importing unicornhat hangs #62

Closed ScrumpyJack closed 8 years ago

ScrumpyJack commented 8 years ago

import unicornhat hangs when it gets to:

noepixel.py def begin(self): resp = ws.ws2811_render(self._LEDS)

unicorn:~# python -m pdb /usr/lib/python2.7/site-packages/unicornhat.py
> /usr/lib/python2.7/site-packages/unicornhat.py(1)<module>()
-> from neopixel import *
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(2)<module>()
-> import atexit
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(3)<module>()
-> import colorsys
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(6)<module>()
-> LED_COUNT      = 64      # Number of LED pixels.
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(7)<module>()
-> LED_PIN        = 18      # GPIO pin connected to the pixels (must support PWM!).
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(8)<module>()
-> LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(9)<module>()
-> LED_DMA        = 5       # DMA channel to use for generating signal (try 5)
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(10)<module>()
-> LED_BRIGHTNESS = 128     # Set to 0 for darkest and 255 for brightest
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(11)<module>()
-> LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(13)<module>()
-> ws2812 = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
(Pdb) n
> /usr/lib/python2.7/site-packages/unicornhat.py(14)<module>()
-> ws2812.begin()
(Pdb) n

[process hangs]

where ws2812.begin is import _rpi_ws281x as ws [...] def begin(self): print('ay') resp = ws.ws2811_render(self._LEDS)

_rpi_ws281x.so is build with musl libc

Here is the last bit of an strace

2083  stat64("colorsys", 0xbea91110)    = -1 ENOENT (No such file or directory)
2083  open("colorsys.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
2083  open("colorsysmodule.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
2083  open("colorsys.py", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
2083  open("colorsys.pyc", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
2083  stat64("/usr/lib/python2.7/colorsys", 0xbea91110) = -1 ENOENT (No such file or directory)
2083  open("/usr/lib/python2.7/colorsys.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
2083  open("/usr/lib/python2.7/colorsysmodule.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
2083  open("/usr/lib/python2.7/colorsys.py", O_RDONLY|O_LARGEFILE) = 4
2083  fstat64(4, {st_mode=S_IFREG|0644, st_size=3691, ...}) = 0
2083  open("/usr/lib/python2.7/colorsys.pyc", O_RDONLY|O_LARGEFILE) = 5
2083  readv(5, [{"", 0}, {"\3\363\r\nQ\247QWc\0\0\0\0\0\0\0\0\6\0\0\0@\0\0\0s\177\0\0\0d\0"..., 1024}], 2) = 1024
2083  fstat64(5, {st_mode=S_IFREG|0644, st_size=3975, ...}) = 0
2083  readv(5, [{"?g333333\343?g\354Q\270\36\205\353\321?g{\24\256G\341z\324?g\341z\24"..., 2958}, {"\3\363\r\nQ\247QWc\0\0\0\0\0\0\0\0\6\0\0\0@\0\0\0s\177\0\0\0d\0"..., 1024}], 2) = 2951
2083  readv(5, [{"\0\0\0s?\0\0", 7}, {"\3\363\r\nQ\247QWc\0\0\0\0\0\0\0\0\6\0\0\0@\0\0\0s\177\0\0\0d\0"..., 1024}], 2) = 0
2083  close(5)                          = 0
2083  close(4)                          = 0
2083  ioctl(1, TIOCGWINSZ, {ws_row=51, ws_col=144, ws_xpixel=864, ws_ypixel=663}) = 0
2083  writev(1, [{"ay", 2}, {"\n", 1}], 2) = 3
2083  open("/proc/cpuinfo", O_RDONLY|O_LARGEFILE) = 4
2083  readv(4, [{"", 0}, {"processor\t: 0\nmodel name\t: ARMv6"..., 1024}], 2) = 292
2083  _llseek(4, -27, [265], SEEK_CUR)  = 0
2083  close(4)                          = 0
2083  open("/dev/vcio", O_RDONLY|O_LARGEFILE) = 4
2083  ioctl(4, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x00, 0x04), 0xbea9221c) = 0
2083  ioctl(4, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x00, 0x04), 0xbea92224) = 0
2083  open("/dev/mem", O_RDWR|O_SYNC|O_LARGEFILE) = 5
2083  mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 5, 0xeb51000) = 0xb6f0c000
2083  close(5)                          = 0
2083  open("/dev/mem", O_RDWR|O_SYNC|O_LARGEFILE) = 5
2083  mmap2(NULL, 36, PROT_READ|PROT_WRITE, MAP_SHARED, 5, 0x20007000) = 0xb6f0b000
2083  close(5)                          = 0
2083  open("/dev/mem", O_RDWR|O_SYNC|O_LARGEFILE) = 5
2083  mmap2(NULL, 40, PROT_READ|PROT_WRITE, MAP_SHARED, 5, 0x2020c000) = 0xb6f0a000
2083  close(5)                          = 0
2083  open("/dev/mem", O_RDWR|O_SYNC|O_LARGEFILE) = 5
2083  mmap2(NULL, 180, PROT_READ|PROT_WRITE, MAP_SHARED, 5, 0x20200000) = 0xb6f09000
2083  close(5)                          = 0
2083  open("/dev/mem", O_RDWR|O_SYNC|O_LARGEFILE) = 5
2083  mmap2(NULL, 8, PROT_READ|PROT_WRITE, MAP_SHARED, 5, 0x20101000) = 0xb6f08000
2083  close(5)                          = 0
2083  nanosleep({0, 10000}, 0xbea92298) = 0
2083  nanosleep({0, 10000}, 0xbea92298) = 0
2083  nanosleep({0, 10000}, 0xbea922a8) = 0
2083  --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
2083  getpid()                          = 2083
2083  sigreturn({mask=[]})              = 0
Gadgetoid commented 8 years ago

Unfortunately my knowledge of the magic that powers Unicorn HAT is limited, it's largely borrowed from: https://github.com/richardghirst/rpi_ws281x

But I can try!

What OS is this on?