I've used the answer to this question to enable control of my Raspberry Pi GPIO pins from within a Docker container, which runs Alpine.
$ docker run --device /dev/gpiomem whatever
This works with the Python RPi.GPIO module, but not with wiringPi.
Python and its dependencies takes up about the same space as Alpine itself, so I'd like to use wiringPi to save on install time and SD card space, and to keep things simple.
Running wiringPi v2.46 in Raspbian directly (installed using apt-get install wiringpi
) works fine, and I can successfully configure and trigger digital output pins.
Running wiringPi v2.26 in the Alpine container (installed using apk add wiringpi
) fails when trying to configure a pin:
$ gpio -g mode 26 out
Unable to determine hardware version. I see: Hardware : BCM2835,
- expecting BCM2708 or BCM2709. Please report this to projects@drogon.net
Is there anything I can do to expose the SOC to the container, so that wiringPi recognises it correctly? What else might be required to get this working?
Thanks to larsks for pointing out the difference in version numbers.
Version 2.46 of wiringPi is available for Alpine, but I'd failed to notice it's only in the edge branch of the community repository
To use this version I had to modify the file /etc/apk/repositories
, replacing the existing community entry with the edge version.
Since I'm using Docker, I had to do this as part of the image build process, so I added the following to my Dockerfile:
RUN sed -i "s/v[0-9.]*\/community/edge\/community/" /etc/apk/repositories \
&& apk update && apk add wiringpi