cjimti / iotwifi

Raspberry Pi (arm) wifi configuration container. Configure and control wifi connectivity with a JSON based REST api.
https://imti.co/iot-wifi/
MIT License
303 stars 124 forks source link

Docker build failing #2

Closed cecchisandrone closed 6 years ago

cecchisandrone commented 6 years ago
  1. Run docker build . -t iotwifi
cjimti commented 6 years ago

@cecchisandrone Thanks for the report. I'll try to reproduce it tonight. Is it possible you are having network trouble?

Are you able to curl -I https://github.com/bhoriuchi/go-bunyan on the pi and get data?

cecchisandrone commented 6 years ago

Yes, just tried it.

Sent from iPhone 8

Il 22 mar 2018, 23:27 +0100, Craig Johnston notifications@github.com, ha scritto:

@cecchisandrone Thanks for the report. I'll try to reproduce it tonight. Is it possible you are having network trouble. Are you able to curl -I https://github.com/bhoriuchi/go-bunyan on the pi and get data? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

cjimti commented 6 years ago

I'll try figure out why the go get command is failing. However I will also update the source in a bit and include the dependencies so go get will not be needed.

cjimti commented 6 years ago

Seems to be working on my development pi. I'm suspecting that it might be docker and it's network. docker build

Can you try docker run --rm -it arm32v7/golang:1.9 /bin/sh -c "go get github.com/bhoriuchi/go-bunyan/bunyan (should simply return without error)

Or shell directly into the container docker run --rm -it arm32v7/golang:1.9 /bin/sh and try go get github.com/bhoriuchi/go-bunyan/bunyan to confirm that go was able to download the package you could ls -l /go/src/github.com/bhoriuchi/go-bunyan and git a directory listing of the package.

I'm going to close this as a bug but will be curious if this is happening to anyone else. Like I said earlier I'll update the source with the dependencies so it won't need go get however the fact that it's not working for you make me think it has something to do with the docker install or network on the pi.

I am also curious about your docker version and pi version. Can you send me the output of these commands.

cat /proc/cpuinfo | grep Revision and docker --version

Thanks!

cjimti commented 6 years ago

@cecchisandrone the build no longer needs to run go get

cecchisandrone commented 6 years ago

@cjimti, build fails again with the same error:

Sending build context to Docker daemon  2.689MB
Step 1/14 : FROM arm32v7/golang:1.9 AS builder
 ---> 1ba8d01a7dcf
Step 2/14 : ENV GOPATH /go
 ---> Using cache
 ---> 25c2f05a12e8
Step 3/14 : WORKDIR /go/src
 ---> Using cache
 ---> 2179870dcc15
Step 4/14 : RUN mkdir -p /go/src/github.com/cjimti/iotwifi
 ---> Running in 88a2d84ba596
The command '/bin/sh -c mkdir -p /go/src/github.com/cjimti/iotwifi' returned a non-zero code: 139

If I run docker run --rm -it arm32v7/golang:1.9 /bin/sh -c "go get github.com/bhoriuchi/go-bunyan/bunyan" I receive return code 139. These are the output of commands you requested:

pi@porterbot:~ $ cat /proc/cpuinfo | grep Revision
Revision        : 0010
pi@porterbot:~ $ docker info
Containers: 4
 Running: 0
 Paused: 0
 Stopped: 4
Images: 24
Server Version: 17.12.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.59+
Operating System: Raspbian GNU/Linux 9 (stretch)
OSType: linux
Architecture: armv6l
CPUs: 1
Total Memory: 244MiB
Name: porterbot
ID: RLWE:WUTC:3OS6:SZJG:QOVF:UV4E:H73C:E2CQ:GHAC:AKM6:E2XN:WVKG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support

Anyway I'm pretty sure that everything is due to Rpi B+ that is ARMv6. This will affect Rpi Zero W as well as they have the same architecture.

cecchisandrone commented 6 years ago

I solved using arm32v6/golang:alpine. No I have HostAPD error due to missing driver: "HOSTAPD GOT: Line 13: invalid/unknown driver 'rtl871xdrv' I have to check better. Anyway if I run your image directly I got:

{"hostname":"porterbot","level":30,"msg":"Starting IoT Wifi...","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:57.794Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HTTP Listening on 8080","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:57.814Z","v":0}
{"hostname":"porterbot","level":30,"msg":"Loading IoT Wifi...","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:57.816Z","v":0}
{"hostname":"porterbot","level":30,"msg":"Starting Hostapd.","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:57.822Z","v":0}
{"hostname":"porterbot","level":30,"msg":"Hostapd CFG: interface=uap0\nssid=iot-wifi-cfg-3\nhw_mode=g\nchannel=6\nmacaddr_acl=0\nauth_algs=1\nignore_broadcast_ssid=0\nwpa=2\nwpa_passphrase=iotwifipass\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP\nrsn_pairwise=CCMP\nhw_mode=g","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.057Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: random: Trying to read entropy from /dev/random","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.152Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: Configuration file: /dev/stdin","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.164Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: Could not read interface uap0 flags: No such device","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.221Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: nl80211: Driver does not support authentication/association or connect commands","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.229Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: nl80211: deinit ifname=uap0 disabled_11b_rates=0","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.239Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: nl80211: Remove monitor interface: refcount=0","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.254Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: netlink: Operstate: ifindex=0 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.26Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: Could not read interface uap0 flags: No such device","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.281Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: nl80211: Set mode ifindex 0 iftype 2 (STATION)","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.289Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: nl80211: Failed to set interface 0 to mode 2: -19 (No such device)","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.295Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: nl80211 driver initialization failed.","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.301Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: hostapd_interface_deinit_free(0xb6fa6010)","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.307Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: hostapd_interface_deinit_free: num_bss=1 conf-\u003enum_bss=1","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.311Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: hostapd_interface_deinit(0xb6fa6010)","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.313Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: uap0: interface state UNINITIALIZED-\u003eDISABLED","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.314Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: hostapd_bss_deinit: deinit bss uap0","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.32Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: uap0: AP-DISABLED ","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.321Z","v":0}
{"hostname":"porterbot","level":30,"msg":"Hostapd DISABLED","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.323Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: hostapd_cleanup(hapd=0xb6fa6500 (uap0))","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.331Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: hostapd_free_hapd_data: Interface uap0 wasn't started","name":"iotwifi","pid":0,"time":"2018-03-23T09:11:58.336Z","v":0}
{"hostname":"porterbot","level":20,"msg":"ProcessCmd got wpa_supplicant","name":"iotwifi","pid":0,"time":"2018-03-23T09:12:08.346Z","v":0}
panic: interface conversion: interface {} is *exec.ExitError, not string

goroutine 5 [running]:
github.com/cjimti/iotwifi/vendor/github.com/bhoriuchi/go-bunyan/bunyan.(*bunyanLog).sprintf(0x10a3ad2c, 0x10d5a280, 0x1, 0x1, 0x10d76610, 0x0)
        /go/src/github.com/cjimti/iotwifi/vendor/github.com/bhoriuchi/go-bunyan/bunyan/log.go:28 +0x98
github.com/cjimti/iotwifi/vendor/github.com/bhoriuchi/go-bunyan/bunyan.(*bunyanLog).write(0x10a3ad2c, 0x2a1de7, 0x6, 0x2a1a70, 0x5, 0x2a2125, 0x7, 0x2dba20, 0x10a0c108, 0x0, ...)
        /go/src/github.com/cjimti/iotwifi/vendor/github.com/bhoriuchi/go-bunyan/bunyan/log.go:80 +0xc94
github.com/cjimti/iotwifi/vendor/github.com/bhoriuchi/go-bunyan/bunyan.(*Logger).Fatal(0x10a79740, 0x10d5a280, 0x1, 0x1)
        /go/src/github.com/cjimti/iotwifi/vendor/github.com/bhoriuchi/go-bunyan/bunyan/logger.go:126 +0x114
github.com/cjimti/iotwifi/iotwifi.(*WpaCfg).ScanNetworks(0x10a79740, 0x1, 0x2a1a70, 0x5)
        /go/src/github.com/cjimti/iotwifi/iotwifi/wpacfg.go:259 +0xe4
github.com/cjimti/iotwifi/iotwifi.RunWifi(0x2a2125, 0x7, 0x2a1a70, 0x5, 0x2dba20, 0x10a0c108, 0x0, 0x0, 0x0, 0x0, ...)
        /go/src/github.com/cjimti/iotwifi/iotwifi/iotwifi.go:117 +0x250
created by main.main
        /go/src/github.com/cjimti/iotwifi/main.go:45 +0x230
cjimti commented 6 years ago

My image will only run on a pi 3 (arm v7) and using the nl80211 driver (with the onboard wifi). I plan to make another public image for the Pi 2 and allow the interface and driver to be configured but it will be a week or so as I am swamped with work at the moment.

In the output you sent it looks like it is having trouble parsing the config. Did you mount the config? see IOT Wifi Configuration

It was also unable to setup the uap0 interface, this could be due to not running the container with --privileged and --net host. see Docker run

Looks like better error messages are needed on my end. However it is not really intended for a Pi 2 but since I am planning to support the 2 in the future (as well as OrangePi) this helpful, thank you.

cecchisandrone commented 6 years ago

I used the command line you suggest:

docker run --rm --privileged --net host \ -v $(pwd)/wificfg.json:/cfg/wificfg.json \ cjimti/iotwifi

After having edited wificfg.json. It seems that config is parsed correctly but HostAPd fails to run due maybe to a wrong configuration for the USB dongle used.

cjimti commented 6 years ago

@cecchisandrone thanks for the update. Looks like you are running an original Pi Model B+ (I should have looked at the original issue report better). I'll see if I can dig one up around here and also look into supporting more variations.

This looks interesting Hostapd driver for RTL8188{C|CU|CUS} wifi chips.

I'll put out a release soon with the ability specify the driver in the config, in your case driver=rtl871xdrv

cjimti commented 6 years ago

If you want to hard code it in the source for testing you can find where the driver should be specified here and here adding driver=rtl871xdrv to the hostapd configuration.

cecchisandrone commented 6 years ago

Great, I'll give a try. I just tried modifying wpacfg.go. Thanks

cecchisandrone commented 6 years ago

This is the output now:

{"hostname":"porterbot","level":30,"msg":"Starting IoT Wifi...","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.692Z","v":0}
{"hostname":"porterbot","level":30,"msg":"Loading IoT Wifi...","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.705Z","v":0}
{"hostname":"porterbot","level":30,"msg":"Starting Hostapd.","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.708Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HTTP Listening on 8080","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.7Z","v":0}
{"hostname":"porterbot","level":30,"msg":"Hostapd CFG: interface=uap0\nssid=iot-wifi-cfg-3\nhw_mode=g\nchannel=6\nmacaddr_acl=0\nauth_algs=1\nignore_broadcast_ssid=0\nwpa=2\nwpa_passphrase=iotwifipass\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP\nrsn_pairwise=CCMP\ndriver=rtl871xdrv","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.898Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: random: Trying to read entropy from /dev/random","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.955Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: Configuration file: /dev/stdin","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.96Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: Line 13: invalid/unknown driver 'rtl871xdrv'","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.972Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: 1 errors found in configuration file '/dev/stdin'","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.985Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: Failed to set up interface with /dev/stdin","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.986Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: hostapd_init: free iface 0xb6f8d010","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.988Z","v":0}
{"hostname":"porterbot","level":30,"msg":"HOSTAPD GOT: Failed to initialize interface","name":"iotwifi","pid":0,"time":"2018-03-23T17:47:22.989Z","v":0}
cjimti commented 6 years ago

@cecchisandrone yeah invalid/unknown driver 'rtl871xdrv'. need to get rtl871xdrv driver installed.

cjimti commented 6 years ago

...but a rebuild hostapd will also be needed. So I'll take a look at it this weekend. Would be nice to have a version that runs on older Pis.

cecchisandrone commented 6 years ago

Cool, thanks for this. Useless to say how many times in IOT projects this task is done, doing that with your approach is really smart and simple.