GregMefford / blinkchain

Nerves project to use Elixir to drive NeoPixels from a Raspberry Pi
MIT License
71 stars 27 forks source link

Fake WS281x driver is compiled on Raspberry Pi #17

Closed schrockwell closed 5 years ago

schrockwell commented 5 years ago

I have a Raspberry Pi running plain old Raspbian Jessie, with Erlang and Elixir installed per the directions on the Elixir site. In other words, no Nerves is involved here.

When compiling a mix project that uses Blinkchain on the Pi, the rpi_ws281x driver application is compiled in "fake" mode, and it does not communicate with the NeoPixels at all.

The problem is due to these lines in the Makefile - it is expecting the environment variable $CROSSCOMPILE to be defined:

ifeq ($(CROSSCOMPILE),)
# Host testing build
CFLAGS += -DDEBUG
SRC = src/rpi_ws281x.c src/fake_ws2811.c
endif
ifneq ($(CROSSCOMPILE),)
# Normal build
SRC = src/rpi_ws281x.c src/rpi_ws281x/dma.c src/rpi_ws281x/mailbox.c \
    src/rpi_ws281x/mailbox.c src/rpi_ws281x/pwm.c src/rpi_ws281x/rpihw.c \
    src/rpi_ws281x/pcm.c src/rpi_ws281x/ws2811.c
endif

My hacky solution was:

mix deps.clean blinkchain
CROSSCOMPILE=1 mix compile
GregMefford commented 5 years ago

As of blinkchain v1.0.0, when you compile outside of the normal Nerves firmware workflow, it shows a warning message like this:

Makefile:53: No cross-compiler detected. Building Blinkchain native code in test mode.
Makefile:53: If you were intending to build in normal mode e.g. directly on a Raspberry Pi,
Makefile:53: you can force it by running `CROSS_COMPILE=true mix compile`
schrockwell commented 5 years ago

Great! Thanks for addressing this!