Unicorn-hat Java port + Pi 2

Hi,

I’m working on a port of unicorn-hat to Java (don’t ask!) and am having some trouble with compiling ws2812. At least that’s where I think I’m at. I appreciate this is a little left-field for the forum, so feel free to say you can’t help ;)

Anyway, I can run the recent Pi 2 fix ok (some examples from the pyhton folder crash for me occasionally but I’m assuming that’s to be expected). However, when I do anything with my hand compiled and JNI linked .so, it crashes. No output.

Can you sense check my SWIG / gcc steps please? I suspect the .so produced isn’t right somehow. I’m basing it all on the Pimoroni mods to ws2812 (including the .i as input into SWIG);

swig -java -package bad.robot.unicorn.neopixel ws2812-RPi.i

gcc -fPIC -c ws2812-RPi.c ws2812-RPi_wrap.c -DPERI_BASE=0x3F000000 -DRPI2 -I/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/include -I/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/include/linux

gcc -shared ws2812-RPi.o ws2812-RPi_wrap.o -o libws2812-RPi.so

The crash report doesn’t reveal much to me but it goes wrong when I try and call show.

# Problematic frame:
# C  [libws2812-RPi.so+0x4d84]  show+0x308

The full log is here.

Any tips welcome!

Everything looks pretty sane- I suspect it’s something in the C library that’s utterly trouncing the Java VM but somehow flies under the radar of Python.

What version of swig are you using, also? I Use swig2.0 to generate bindings.

I’m not at all versed in Java, otherwise I’d give this a shot myself and see if I get similar results. It might also be worth testing on an older Pi, just in case it’s the Pi 2 fixes that are exploding.

Thanks. I used swig 2.0.7 but was thinking of trying with 3. You think it’ll be worth trying on < 2.0.7?

I think I’ll post something on SO for general help debugging the crash report.

Asked a question on SO, see here.

General theme seems to be the C has a bug but I can’t see it or how to narrow it down.

I’m going to try and source a RPi B+ and try it there to.

SOLVED IT! School boy error: I wasn’t initialising the ws2812 driver (init(64))

Ahhhhh! Yeah, I’ve run into that one a few million times :D