WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Manage wifi (RPi3) with NetworkManager  (Read 6326 times)

Offline derjan

  • Newbie
  • *
  • Posts: 9
Manage wifi (RPi3) with NetworkManager
« on: February 13, 2018, 08:57:40 AM »
I'm trying to build a headless Raspberry Pi 3 with wired, wifi, and 3G network access that configures itself automatically based on what's available. Obviously, wired > wifi > 3G. Out of the box it doesn't even recognise when I pull the network cable (ifconfig still shows the DHCP IP address) so I guess I need some kind of network manager which monitors the connections and updates IP addresses, routes, and nameservers.

After installing firmware-rpi3-wireless, wifi, and networkmanager and adding /usr/local/etc/init.d/dbus restart and /usr/local/etc/init.d/networkmanager start to /opt/bootlocal.sh networkmanager seems to manage the wired connection out of the box.

However, I can't get it to manage the wifi connection. Using the wifi.sh script I can connect to my wireless network, and nmcli r shows WIFI enabled. But nmcli d says the wifi status is unavailable, nmcli d wifi list is empty and nmcli d wifi rescan fails with Error: Scanning not allowed while unavailable or activating..

There is an error message in /var/log/messages saying:

Code: [Select]
daemon.warn NetworkManager[1448]: <warn>  [1518538553.0895] supplicant: failed to acquire wpa_supplicant proxy: Wi-Fi and 802.1x will not be available (Error calling StartServiceByName for fi.w1.wpa_supplicant1: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ExecFailed: Failed to execute program fi.w1.wpa_supplicant1: Permission denied)

Does anyone know how to fix this?

Offline lotte67890

  • Newbie
  • *
  • Posts: 15
Re: Manage wifi (RPi3) with NetworkManager
« Reply #1 on: February 13, 2018, 09:18:28 AM »
You need to create a profile for networkmanager to handle your wifi connection:

nmcli con add type wifi con-name MyWifiNetwork ifname wlan0 ip4 192.168.1.50/24 gw4 192.168.1.1

If you search around the internet you will find a lot of examples... e.g. for dhcp configuration.... Also I assume you may run nmcli with sudo

L

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Manage wifi (RPi3) with NetworkManager
« Reply #2 on: February 13, 2018, 09:56:30 AM »
However, I can't get it to manage the wifi connection. Using the wifi.sh script I can connect to my wireless network, and nmcli r shows WIFI enabled. But nmcli d says the wifi status is unavailable, nmcli d wifi list is empty and nmcli d wifi rescan fails with Error: Scanning not allowed while unavailable or activating..

Don't load the wifi extension - this will load the non-dbus wpa_supplicant extension, which will mess things up.

See below (about 2/3 of the way down the thread) on how to connect to wifi with nmcli:

http://forum.tinycorelinux.net/index.php/topic,21685.0.html

Offline derjan

  • Newbie
  • *
  • Posts: 9
Re: Manage wifi (RPi3) with NetworkManager
« Reply #3 on: February 14, 2018, 05:55:24 AM »
Thanks for the reply, but not installing the wifi extension doesn't change the unavailability of wifi. I re-flashed the SD card with piCore 9.0.3 and installed only the firmware-rpi3-wireless and networkmanager extensions. Same error message in /var/log/messages, and I can't bring the wifi interface up with nmcli.

Adding a connection with nmcli c add type wifi ssid MySSID ifname wlan0 works, but nmcli c up wifi-wlan0 fails with Error: Connection activation failed: No suitable device found for this connection..

nmcli d show wlan0 says that GENERAL.STATE: 20 (unavailable).
nmcli c show wifi-wlan0 says that connection.interface-name: wlan0 but nmcli c show only shows -- for the wifi-wlan0 device.

These are the lines from /var/log/messages:

Code: [Select]
... daemon.info NetworkManager[1106]: <info>  [12.8484] device (wlan0): driver supports Access Point (AP) mode
... daemon.info NetworkManager[1106]: <info>  [12.8559] manager: (wlan0): new 802.11 WiFi device (/org/freedesktop/NetworkManager/Devices/2)
... daemon.info NetworkManager[1106]: <info>  [12.8643] device (wlan0): state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
... daemon.info NetworkManager[1106]: <info>  [13.4262] device (wlan0): set-hw-addr: set MAC address to XX:XX:XX:XX:XX:XX (scanning)
... daemon.warn NetworkManager[1106]: <warn>  [13.4908] supplicant: failed to acquire wpa_supplicant proxy: Wi-Fi and 802.1x will not be available (Error calling StartServiceByName for fi.w1.wpa_supplicant1: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ExecFailed: Failed to execute program fi.w1.wpa_supplicant1: Permission denied)

Is there anything else preventing nmcli from managing the wifi device?

Offline lotte67890

  • Newbie
  • *
  • Posts: 15
Re: Manage wifi (RPi3) with NetworkManager
« Reply #4 on: February 14, 2018, 09:25:43 AM »
You may try to also start dbus...

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Manage wifi (RPi3) with NetworkManager
« Reply #5 on: February 15, 2018, 12:30:58 AM »
Thanks for the reply, but not installing the wifi extension doesn't change the unavailability of wifi.

As mentioned, it's not an issue of the wifi extension per se - the problem is that networkmanager depends on the wpa_supplicant-dbus extension whereas wifi depends on the wpa_supplicant extension.

If you load both networkmanager and wifi, you will have the wpa_supplicant and wpa_supplicant-dbus extensions loaded on top of each other and it will not be obvious if either of them works properly.

In addition, if you are going to use networkmanager, you need to use it to manage all of your network connections, you cannot have it starting wpa_supplicant instances via dbus and the wifi extension starting wpa_supplicant instances directly without running the risk of conflicting commands.

Here's what works for me:
Code: [Select]
$ tce-load -i firmware_iwlwifi-7260
$ tce-load -i networkmanager
$ sudo /usr/local/etc/init.d/dbus start
$ sudo /usr/local/etc/init.d/networkmanager start
$ nmcli d wifi list
*  SSID           MODE   CHAN  RATE       SIGNAL  BARS  SECURITY 
   juanitonet   Infra  8     54 Mbit/s  72      ***   WPA2     
   ane      Infra  6     54 Mbit/s  62      ***   WPA1 WPA2
   AliNetwork Infra  6     54 Mbit/s  57      ***   WEP       
   juanitonet   Infra  48  54 Mbit/s  54      **     WPA2     
 ...
$ nmcli d wifi connect juanitonet password ********
Device 'wlan0' successfully activated with '6ccf90b1-7dfb-4acf-a83d-b3db54c37c9b'.

Offline derjan

  • Newbie
  • *
  • Posts: 9
Re: Manage wifi (RPi3) with NetworkManager
« Reply #6 on: February 15, 2018, 05:49:48 AM »
Yes, I understand, that's why I set up a new SD card and did not install the wifi.tcz extension (which mentions wpa_supplicant in it's description), only the firmware-rpi3-wireless.tcz (which contains lib/firmware/brcm/brcmfmac43430-sdio.bin) and networkmanager extensions. So there shouldn't be a dbus incompatible wpa_supplicant version installed. ls /usr/local/tce.installed/ only lists wpa_supplicant-dbus and no other wpa_supplicant.

Without the firmware, the wireless interface isn't found/listed. Or is the Raspberry Pi wireless firmware also incompatible with wpa_supplicant via dbus? Then what's the alternative?

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Manage wifi (RPi3) with NetworkManager
« Reply #7 on: February 15, 2018, 06:07:08 AM »
firmware-rpi3-wireless is the extension you need, but it needs to be loaded before wireless-KERNEL for the firmware to be loaded properly - you can check using "dmesg | tail -20" or similar.

You can use "tce-status -i" to check if networkmanager and all of it's recursive dependencies are loaded, see:

http://tinycorelinux.net/9.x/armv7/tcz/networkmanager.tcz.tree

Did you verify that the dbus and networkmanager daemons are running with, for example, "ps aux | grep dbus"
« Last Edit: February 15, 2018, 06:12:23 AM by Juanito »

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Manage wifi (RPi3) with NetworkManager
« Reply #8 on: February 16, 2018, 05:02:58 AM »
Hmm - there's something amiss here. If I modify the wifi extension dep file to use wpa_supplicant-dbus, the RPi3 wifi connects to my ap.

With networkmanager I get this:
Code: [Select]
$ nmcli d status
DEVICE  TYPE      STATE        CONNECTION
eth0    ethernet  connected    eth0       
wlan0   wifi      unavailable  --         
lo      loopback  unmanaged    --

I'll try to fix this in the next couple of days.

Offline derjan

  • Newbie
  • *
  • Posts: 9
Re: Manage wifi (RPi3) with NetworkManager
« Reply #9 on: February 16, 2018, 08:04:57 AM »
Thanks for still looking into this! The networkmanager output is the same on my RPi.

This is the output of tce-status -i – it seems like all the dependencies of networkmanager are installed:
Code: [Select]
bluetooth-4.9.22-piCore-v7
bluez
bzip2-lib
ca-certificates
dbus
dbus-glib
dhcpcd
expat2
firmware-rpi3-wireless
gamin
gcc_libs
glib2
icu
kmaps
libICE
libSM
libX11
libXau
libXdmcp
libbluetooth
libedit
libelf
libgcrypt
libgpg-error
libical
libiw
liblzma
libmbim
libndp
libnl
libqmi
libsoup
libssh2
libudev
libxcb
libxml2
mc
modemmanager
ncurses
networkmanager
nspr
nss
openssh
openssl
pcre
ppp
readline
sbc
sqlite3
wireless-4.9.22-piCore-v7
wireless_tools
wpa_supplicant-dbus

dbus and networkmanager are running:
Code: [Select]
tc@box: ps aux | grep dbus
1122 tc       /usr/local/bin/dbus-daemon --system

tc@box: ps aux | grep -i networkmanager
1126 root     /usr/local/sbin/NetworkManager
1152 root     /usr/local/sbin/dhcpcd -B -K -L -A -G -c /usr/local/lib/NetworkManager/nm-dhcp-helper -4 -h pi-sensor eth0

If I kill the process nmcli just prints: Error: NetworkManager is not running.

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Manage wifi (RPi3) with NetworkManager
« Reply #10 on: February 20, 2018, 09:51:35 PM »
Got it - the permissions on dbus-daemon-launch-helper in the dbus extension were incorrect - dbus re-posted to the piCore 9.x repos.

Now i get:
Code: [Select]
$ tce-load -i firmware-rpi3-wireless
$ tce-load -i wireless-KERNEL
$ dmesg | tail -10
...
[   88.948778] usbcore: registered new interface driver brcmfmac
[   89.053609] brcmfmac: Firmware version = wl0: May 27 2016 00:13:38 version 7.45.41.26 (r640327) FWID 01-df77e4a7

$ tce-load -i networkmanager
$ sudo /usr/local/etc/init.d/dbus start
$ sudo /usr/local/etc/init.d/networkmanager start
Starting Network Manager daemon...

$ nmcli d status
DEVICE  TYPE      STATE         CONNECTION
eth0    ethernet  connected     eth0       
wlan0   wifi      disconnected  --         
lo      loopback  unmanaged     --   
     
$ sudo nmcli d wifi connect juanitonet password ********
Device 'wlan0' successfully activated with 'dad2be7d-73ab-4062-9373-025a23da2f12'.

$ nmcli d status
DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  eth0       
wlan0   wifi      connected  juanitonet     
lo      loopback  unmanaged  -- 

Offline derjan

  • Newbie
  • *
  • Posts: 9
Re: Manage wifi (RPi3) with NetworkManager
« Reply #11 on: March 01, 2018, 12:38:37 AM »
Awesome, everything seems to work perfectly now.