tomeshnet / prototype-cjdns-pi

Prototype system for mesh networks on single board computers
https://chat.tomesh.net/#/room/#software:tomesh.net
GNU General Public License v3.0
218 stars 42 forks source link

Error when creating ad-hoc interface: command failed: Device or resource busy (-16) #152

Closed suiluj closed 5 years ago

suiluj commented 6 years ago

I get the following error when trying to create an ad-hoc interface:

pi@rpizero1:~ $ set -e
pi@rpizero1:~ $ sudo iw reg set DE
pi@rpizero1:~ $ mesh_dev="wlan0"
pi@rpizero1:~ $ sudo ifconfig $mesh_dev down
pi@rpizero1:~ $ sudo iw $mesh_dev set type ibss
command failed: Device or resource busy (-16)

I am using a Raspberry Pi Zero W(H) with the latest Raspbian Stretch 2018-04-18

Does someone have a solution? I am not sure which process or something is blocking the interface and already tried to stop wpa_supplicant and dhcpcd. But i was not successful.

darkdrgn2k commented 6 years ago

This is using the on board raspberry pi zero wireless correct? or an external one.

I will dig up my rpi zero and try to re-produce it when i have a moment!

suiluj commented 6 years ago

Thank you @darkdrgn2k Yes i am using the internal wifi of the rpi zero w

in my first comment i only tried the commands as shown.

Now i started an installation with the script command: wget https://raw.githubusercontent.com/tomeshnet/prototype-cjdns-pi/master/scripts/install && chmod +x install && WITH_AD_HOC=true WITH_PROMETHEUS_NODE_EXPORTER=true WITH_PROMETHEUS_SERVER=true WITH_GRAFANA=true ./install

first outputs:

pi@rpizero1:~ $ wget https://raw.githubusercontent.com/tomeshnet/prototype-cjdns-pi/master/scripts/install && chmod +x install && WITH_AD_HOC=true WITH_PROMETHEUS_NODE_EXPORTER=true WITH_PROMETHEUS_SERVER=true WITH_GRAFANA=true ./install
--2018-05-06 18:59:25--  https://raw.githubusercontent.com/tomeshnet/prototype-cjdns-pi/master/scripts/install
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.12.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.12.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1403 (1.4K) [text/plain]
Saving to: ‘install.2’

install.2                                         100%[===========================================================================================================>]   1.37K  --.-KB/s    in 0s      

2018-05-06 18:59:25 (3.70 MB/s) - ‘install.2’ saved [1403/1403]

Hit:1 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Hit:2 http://archive.raspberrypi.org/debian stretch InRelease
Reading package lists... Done
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Starting installation on Raspberry Pi Zero (9000c1)...
Configure Mesh Point interface (Y/n)? n
Mesh Point interface configuration will be skipped
Configure Basic Firewall (Y/n)? n
Internet Firewall will be skipped
Configure Internet gateway (Y/n)? Y
Internet gateway will be configured
Install IPFS (Y/n)? n
IPFS installation will be skipped
Configure Hyperboria-compatible Domain Name Servers (Y/n)? n
DNS settings will be skipped
Configure Hyperboria-compatible Network Time Protocol server (Y/n)? n
NTP settings will be skipped
Install non-essential tools useful for network analysis (Y/n)? n
Extra tools will be skipped
Enter the name of your mesh network (default: tomesh): tomesh

ending with an error:

net/Benchmark.c:191 TODO(cjd): this will fail with a different encoding scheme
wire/PFChan.h:288 * TODO(cjd): This doesn't cover all control message types yet.
benc/serialization/json/JsonBencSerializer.c:331 FIXME(gerard): silently skipping anything we don't understand
client/Configurator.c:573 * FIXME(sdg): moving noforks after setuser might make nproc <- 0,0 work
admin/angel/Core.c:81 TODO(cjd): we need to begin detecting MTU and informing the OS properly!
memory/Allocator.c:246 TODO(cjd): make this optional.
./interface/tuntap/test/TUNInterface_ipv4_root_test.c:59 TODO(cjd): fix TUNConfigurator_addIp4Address() for Illumos, BSD.
dht/dhtcore/NodeStore.h:160 * FIXME(arceliar): Documentation is out of date
./tunnel/test/IpTunnel_test.c:389 Allocator_free(alloc); //TODO(cjd): This is caused by an allocator bug.
./test/Beacon_test.c:16 TODO(cjd): Subnode beacon testing
net/InterfaceController.c:865 TODO(cjd): eps are created in 3 places, there should be a factory function.
switch/SwitchCore.c:19 TODO(cjd): Get rid of NumberCompress so we can set encodingScheme at runtime.
switch/SwitchCore.c:224 TODO(cjd): hmm should we return an error packet?
interface/tuntap/NDPServer.c:128 TODO(cjdns, Kubuxu): Filtering basing on cjdns network and tunnels.
dht/dhtcore/NodeStore.c:669 TODO(cjd): This does not depend on nodeStore or alter the link, consider moving to Node.c
dht/dhtcore/NodeStore.c:900 FIXME(arceliar,cjd): linking every node with 0 link cost, this can't be right.
dht/dhtcore/NodeStore.c:1213 TODO(arceliar): protect keyspace, evict the worst bestParent instead?
dht/dhtcore/NodeStore.c:1293 TODO(arceliar) the 1023 here is pretty arbitrary...
dht/dhtcore/NodeStore.c:1295 TODO(arceliar): is this safe?
dht/dhtcore/NodeStore.c:1523 TODO(cjd): this could return ~0
dht/dhtcore/NodeStore.c:1543 TODO(cjd): this has been the source of assert failures and we might be sweeping
dht/dhtcore/NodeStore.c:1644 TODO(cjd): Schlameil the painter
dht/dhtcore/NodeStore.c:2036 FIXME(arceliar): calcNextCost is guessing what the cost would stabilize to
dht/dhtcore/NodeStore.c:2055 TODO(cjd): What we really should be doing here is storing this link in a
dht/DHTModuleRegistry.c:64 TODO(cjd): Call a debugger with all unhandlable messages?
memory/BufferAllocator.c:25 * TODO(cjd): addOnFreeJob adds a job which is only run when the root allocator is freed
dht/dhtcore/Janitor.c:240 FIXME(arceliar): Probably need stronger requirements than this.
dht/dhtcore/Janitor.c:399 FIXME(arceliar): This target probably isn't optimal.
dht/dhtcore/RouterModule.c:85 * TODO(cjd): ---
subnode/ReachabilityAnnouncer.c:366 TODO(cjd): else if the peer is dropped...
subnode/ReachabilityAnnouncer.c:525 TODO(cjd): This implies a risk of oscillation wherein there is always a tiny bit of
Failed to build cjdns.
Total build time: 1638222ms.
cp: cannot stat '/opt/cjdns/cjdroute': No such file or directory
pi@rpizero1:~ $ 

My primary goal is to create an ad-hoc network. The other parts would be bonus.

Iw dev show the wlan0 interface still as managed:

pi@rpizero1:~ $ iw dev
phy#0
    Unnamed/non-netdev interface
        wdev 0x2
        addr 3e:b8:35:40:8d:0e
        type P2P-device
        txpower 31.00 dBm
    Interface wlan0
        ifindex 3
        wdev 0x1
        addr b8:27:eb:7d:5c:14
        type managed
        channel 1 (2412 MHz), width: 20 MHz, center1: 2412 MHz
        txpower 31.00 dBm
pi@rpizero1:~ $ 
darkdrgn2k commented 6 years ago

I was able to replicate your issue with AdHoc. Seems it may be a driver/firmware issue:

[ 48.960444] brcmfmac: brcmf_cfg80211_change_iface: iface validation failed: err=-16

I tried rpi upgrade but that didn't help either I will dig deeper into this but I also created an issue in the firmware repo for raspberry pi

As for the script/compile

Seems Raspberry Pi Zero may be suffering from the same compile issue as the Pi 3.

Trying a few permutations to see if i can fix it stay tuned :)

darkdrgn2k commented 6 years ago

I have modified the compile for Zero to use same method we used in the raspberry pi 3 issue seems to compile fine.

When installing make sure you add TAG_PROTOTYPE_CJDNS_PI=v0.2.1 IE wget https://raw.githubusercontent.com/tomeshnet/prototype-cjdns-pi/master/scripts/install && chmod +x install && WITH_AD_HOC=true WITH_PROMETHEUS_NODE_EXPORTER=true WITH_PROMETHEUS_SERVER=true WITH_GRAFANA=true TAG_PROTOTYPE_CJDNS_PI=v0.2.1 ./install

NOTE the raspberry pi zero runs an overclocked Raspberry Pi 1 processor chip. You can probably get 10-13Mbps out of it running CJDNS

darkdrgn2k commented 6 years ago

I think this may be a bug in the new Raspbian release.

Try this base image from 2018-03-13

https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2018-03-14/2018-03-13-raspbian-stretch-lite.zip

nuke-web3 commented 5 years ago

I am actively trying to get: 2x Pi3b+ , 1x 3B , and possibly a few Zeros on an ad-hoc wireless network. (as internal radios don't do mesh point. :-1: )

https://github.com/althea-mesh/althea_rs/issues/248

Will I need that TAG_PROTOTYPE_CJDNS_PI=v0.2.1 for all devices? Or just the zeros?

nuke-web3 commented 5 years ago

On RPi 3B :

$ WITH_AD_HOC=true WITH_PROMETHEUS_NODE_EXPORTER=true WITH_PROMETHEUS_SERVER=true WITH_GRAFANA=true TAG_PROTOTYPE_CJDNS_PI=v0.2.1 ./install
Hit:1 http://archive.raspberrypi.org/debian stretch InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Hit:3 https://deb.nodesource.com/node_8.x stretch InRelease
Reading package lists... Done
error: pathspec 'v0.2.1' did not match any file(s) known to git.

Also with uninstall / install without that tag I get:

...
ln: failed to create symbolic link '/opt/cjdns/cjdroute': File exists
...
2018-09-04 00:57:14 (1.16 MB/s) - ‘/home/pi/prototype-cjdns-pi/scripts/ipfs/tmp/go-ipfs.tar.gz’ saved [8541559/8541559]

go-ipfs/build-log
go-ipfs/install.sh
go-ipfs/ipfs
go-ipfs/LICENSE
go-ipfs/README.md
Error: failed to take lock at /home/pi/.ipfs: permission denied

Do I need to remove config files to solve this I presume? That is a bug if so? ln issue is independent of this?

with config files removed:

initializing IPFS node at /home/pi/.ipfs
generating 2048-bit RSA keypair...done
peer identity: xxxxx
to get started, enter:

    ipfs cat /ipfs/xxxxx/readme

cp: cannot create regular file '/etc/nginx/site-path-enabled/ipfs-http-gateway.conf': No such file or directory
nuke-web3 commented 5 years ago

Now on a RPi3B with fresh flash to this: https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2018-03-14/2018-03-13-raspbian-stretch-lite.zip

And a clean reinstall with all default values except mesh = N , AP = N , Ad-Hoc = Y:


   _                           _     
  | |_ ___  _ __ ___   ___ ___| |__  
  | __/ _ \| '_ ` _ \ / _ / __| '_ \ 
  | || (_) | | | | | |  __\__ | | | |
   \__\___/|_| |_| |_|\___|___|_| |_|
---------------------------------------
cjdns Service ................ [ACTIVE]
Ad-hoc Interface ........... [INACTIVE]
IPFS Service ................. [ACTIVE]
ScuttleBot Service ........... [ACTIVE]
Prometheus Node Exporter ..... [ACTIVE]
Prometheus Server ............ [ACTIVE]
Grafana ...................... [ACTIVE]
yrd .......................... [ACTIVE]
---------------------------------------
NODE
xxxxx
---------------------------------------
PEERS
---------------------------------------

...
$ ip a
...
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
...

After that - same errors that @suiluj saw in the original iw $mesh_dev set type ibss and iw dev calls.

@darkdrgn2k got some thoughts on where to start? :smile:

darkdrgn2k commented 5 years ago

So it seems that we got the raspberry pi onboard ibss to work.

See bottom of https://github.com/tomeshnet/prototype-cjdns-pi/blob/develop/README.md

suiluj commented 5 years ago

sorry i did not want to close if you're still discussing. i reopen again.

I got it working in a auto start script.

https://github.com/suiluj/pi-adhoc-mqtt-cluster/wiki/Batman-Adv-and-Batctl

The trick is you have to deny interface wlan0:

https://github.com/suiluj/pi-adhoc-mqtt-cluster/wiki/Batman-Adv-and-Batctl#deny-wlan0-and-eth0-interface-to-be-able-to-use-it-as-adhoc-interface-and-bridge-with-the-script-above

darkdrgn2k commented 5 years ago

not exactly sure what you need batman adv

benhylau commented 5 years ago

Is this ticket still relevant? Can we close? @suiluj @darkdrgn2k