I'm also trying to make a hassio addon for the mysensors gateway which is connected on the same raspberry pi 2.
If I run the docker image with --privileged then it runs correctly: it manages to read from the nrf2401, it connects to the MQTT server and publishes incoming messages.
However, if I run the container without --privileged (like hassio does), the mysgw program does not output anything else after:
: Starting gateway...
: Protocol version - 2.2.0
: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0
: TSF:LRT:OK
: TSM:INIT
: TSF:WUR:MS=0
I'm running the container like this:
docker run -it --rm --cap-add SYS_RAWIO --device /dev/mem --device /dev/gpiomem local/mysgw
If I run a strace on the mysgw binary, I see:
bash-4.4# strace mysgw -d 2>&1 | grep open
open("/sys/class/gpio", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
open("/sys/class/gpio/gpiochip0/base", O_RDONLY|O_LARGEFILE) = 4
open("/sys/class/gpio/gpiochip0/ngpio", O_RDONLY|O_LARGEFILE) = 4
open("/sys/class/gpio/gpiochip100/base", O_RDONLY|O_LARGEFILE) = 4
open("/sys/class/gpio/gpiochip100/ngpio", O_RDONLY|O_LARGEFILE) = 4
open("/etc/mysensors.dat", O_RDONLY|O_LARGEFILE) = 3
open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3
open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
open("/etc/mysensors.dat", O_RDONLY|O_LARGEFILE) = 5
open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
open("/proc/cpuinfo", O_RDONLY|O_LARGEFILE) = 5
open("/proc/device-tree/soc/ranges", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
open("/dev/mem", O_RDWR|O_SYNC|O_LARGEFILE) = 5
It looks like it can't open a device which is also described in https://www.mysensors.org/apidocs/group__BCM2835grp.html
It seems to be a symlink to some device in /sys, but this directory is empty somehow.
bash-4.4# ls -al /proc/device-tree
lrwxrwxrwx 1 root root 29 May 7 15:10 /proc/device-tree -> /sys/firmware/devicetree/base
bash-4.4# ls -al /sys/firmware
total 0
drwxrwxrwt 2 root root 40 May 7 15:34 .
dr-xr-xr-x 12 root root 0 May 7 15:34 ..
That's how far I got. Does anyone know how to make this device available within the container without having to use --privileged?