2

Just flashed a card with Raspbian Buster Lite on a Raspberry Pi 2, and ssh'd into it using an ethernet cable. raspi-config/wpa_cli can't communicate with wpa_supplicant (there's no /var/run/wpa_supplicant control interface).

At the end of the post I explain a workaround, but it's not permanent.

Here's some debugging information,

pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15:58 GMT 2020 armv7l GNU/Linux
pi@raspberrypi:~ $ ps aux | grep wpa
root       289  0.0  0.4  10740  3976 ?        Ss   may02   0:00 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
pi         915  0.0  0.0   7356   496 pts/0    S+   00:00   0:00 grep --color=auto wpa
pi@raspberrypi:~ $ sudo systemctl status wpa_supplicant.service 
● wpa_supplicant.service - WPA supplicant
   Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-05-04 02:04:51 -03; 2min 50s ago
 Main PID: 602 (wpa_supplicant)
    Tasks: 1 (limit: 2200)
   Memory: 496.0K
   CGroup: /system.slice/wpa_supplicant.service
           └─602 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant

may 04 02:04:51 raspberrypi systemd[1]: Starting WPA supplicant...
may 04 02:04:51 raspberrypi systemd[1]: Started WPA supplicant.
may 04 02:04:51 raspberrypi wpa_supplicant[602]: Successfully initialized wpa_supplicant

pi@raspberrypi:~ $ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
    ssid="****"
    psk="****"
}

As you can see, I've only edited the config with network's ssid/psk after failing at raspi-config.

Here's my usb wifi adapter / driver,

pi@raspberrypi:~ $ sudo lsusb -v

Bus 001 Device 004: ID 0bda:8179 Realtek Semiconductor Corp. RTL8188EUS 802.11n Wireless Network Adapter
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x8179 RTL8188EUS 802.11n Wireless Network Adapter
  bcdDevice            0.00
  iManufacturer           1 Realtek
  iProduct                2 802.11n NIC
  iSerial                 3 00E04C0001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0027
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled
pi@raspberrypi:~ $ ip addr show wlan0
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 18:a6:f7:1d:36:90 brd ff:ff:ff:ff:ff:ff
pi@raspberrypi:~ $ cat /var/log/syslog
...
May  3 00:04:04 raspberrypi kernel: [    8.225728] r8188eu: module is from the staging directory, the quality is unknown, you have been warned.
May  3 00:04:04 raspberrypi kernel: [    8.324223] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_D_CUT_1T1R_RomVer(0)
May  3 00:04:04 raspberrypi kernel: [    8.362213] usbcore: registered new interface driver r8188eu
May  3 00:04:04 raspberrypi kernel: [   10.939312] random: crng init done
May  3 00:04:04 raspberrypi kernel: [   10.939336] random: 7 urandom warning(s) missed due to ratelimiting
May  3 00:04:04 raspberrypi kernel: [   11.394678] 8021q: 802.1Q VLAN Support v1.8
May  3 00:04:04 raspberrypi systemd[1]: Started triggerhappy global hotkey daemon.
May  3 00:04:04 raspberrypi systemd[1]: Started System Logging Service.
May  3 00:04:05 raspberrypi avahi-daemon[288]: Successfully called chroot().
May  3 00:04:05 raspberrypi avahi-daemon[288]: Successfully dropped remaining capabilities.
May  3 00:04:05 raspberrypi avahi-daemon[288]: No service file found in /etc/avahi/services.
May  3 00:04:05 raspberrypi avahi-daemon[288]: Network interface enumeration completed.
May  3 00:04:05 raspberrypi avahi-daemon[288]: Server startup complete. Host name is raspberrypi.local. Local service cookie is 2935413426.
May  3 00:04:05 raspberrypi wpa_supplicant[307]: Successfully initialized wpa_supplicant
May  3 00:04:05 raspberrypi systemd[1]: Started Login Service.
May  3 00:04:05 raspberrypi systemd[1]: Started Avahi mDNS/DNS-SD Stack.
May  3 00:04:05 raspberrypi systemd[1]: Started WPA supplicant.
May  3 00:04:05 raspberrypi raspi-config[313]: Checking if shift key is held down:Error opening '/dev/input/event*': No such file or directory
May  3 00:04:05 raspberrypi raspi-config[313]:  No. Switching to ondemand scaling governor.
May  3 00:04:05 raspberrypi systemd[1]: Started LSB: Switch to ondemand cpu governor (unless shift key is pressed).
May  3 00:04:05 raspberrypi kernel: [   11.661234] Adding 102396k swap on /var/swap.  Priority:-2 extents:1 across:102396k SSFS
May  3 00:04:05 raspberrypi systemd[1]: Started dphys-swapfile - set up, mount/unmount, and delete a swap file.
May  3 00:04:05 raspberrypi dhcpcd[306]: eth0: waiting for carrier
May  3 00:04:05 raspberrypi kernel: [   11.679881] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
May  3 00:04:05 raspberrypi dhcpcd[306]: wlan0: waiting for carrier
May  3 00:04:05 raspberrypi dhcpcd[306]: eth0: carrier acquired
May  3 00:04:05 raspberrypi kernel: [   12.338131] MAC Address = 18:a6:f7:1d:36:90
May  3 00:04:05 raspberrypi kernel: [   12.341657] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
...

After reading some posts, people seems to have issues with the driver, so tried with wext,

pi@raspberrypi:~ $ sudo pkill wpa_supplicant
pi@raspberrypi:~ $ sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -D wext
Successfully initialized wpa_supplicant
rfkill: Cannot get wiphy information
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument

pi@raspberrypi:~ $ ps aux | grep wpa
root       496  0.2  0.2  10996  2760 ?        Ss   01:58   0:00 wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -D wext

That worked, and wlan0 went up, but I'm not sure how to keep it permanent for reboot, because it's not clear who is responsable for starting wpa_supplicant, dhcpcd hooks (10-wpa_supplicant.conf)? systemd's wpa_supplicant dbus service?

According to ps aux output, it's using the DBus service, and tried adding -Dwext parameter on ExecStart and rebooted but didn't work. It's like the default DBus version doesn't work. Is it expecting NetworkManager to be installed or something?

pi@raspberrypi:~ $ ps aux | grep wpa
root       321  0.2  0.4  10740  3972 ?        Ss   01:56   0:00 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant -Dwext

When running wpa_supplicant using the default nl80211 I get this output,

pi@raspberrypi:~ $ sudo /sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0
Successfully initialized wpa_supplicant
nl80211: Driver does not support authentication/association or connect commands
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
wlan0: Failed to initialize driver interface
  • 3
    I am not sure that what you have listed is significant and fiddling with wpa_supplicant is unnecessary, but one thing is clear - you do not appear to have setup the Pi fully. Depending on what your network supports and the whether the WiFi chip supports it but you have NOT set country code See How to set up networking/WiFi – Milliways May 4 at 6:05
  • For example, you can set up country code using raspi-config, right? I can't even do that because it fails communicating with wpa_supplicant control interface (there's no /var/run/wpa_supplicant created at boot). I had already set country code and rebooted and it doesn't matter, at least for my interface. dhcpcd doesn't seem to start wlan0, whereas starting wpa_supplicant setting wext driver manually does work. – soundblaster May 4 at 13:53
  • 1
    I can't say why raspi-config is not changing the file - I don't use it but put a file called wpa_supplicant.conf in the boot directory and reboot. ls /sys/class/net will show if there is a wireless interface - if not fiddling with other files is futile. – Milliways May 5 at 0:45
2

There are some settings that you always need for a proper configuration. First set option

country=??

outside a network={..} block in /etc/wpa_supplicant/wpa_supplicant.conf and ?? with your country code. If you cannot use raspi-config for doing that, then edit wpa_supplicant.conf.

Then enable WiFi with

rpi ~$ rfkill unblock 0

It is not a good idea to use old background driver wext, even if it seems to work. You may encounter other problems with connections. In /usr/share/doc/wpasupplicant/examples/wpa_supplicant.conf you can find a hint, that background driver nl80211 is the default Linux interface:

Note: ap_scan=2 should not be used with the nl80211 driver interface (the current Linux interface). ap_scan=1 is optimized work working with nl80211. For finding networks using hidden SSID, scan_ssid=1 in the network block can be used with nl80211.

After setting this and your WiFi still doesn't work then you should not touch these settings. Instead look at other issues because these settings are always needed.

Update:
After some more digging I was able to reproduce your situation. It seems you do not have dhcpcd running. By default wpa_supplicant is running two times. One time from its package configuration on installation and one time called by dhcpcd. You can check this with:

rpi ~$ systemctl status wpa_supplicant.service
● wpa_supplicant.service - WPA supplicant
   Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-05-05 22:46:15 BST; 18min ago
 Main PID: 511 (wpa_supplicant)
    Tasks: 1 (limit: 4915)
   Memory: 2.7M
   CGroup: /system.slice/wpa_supplicant.service
           └─511 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant

May 05 22:46:15 raspberrypi systemd[1]: Starting WPA supplicant...
May 05 22:46:15 raspberrypi wpa_supplicant[511]: Successfully initialized wpa_supplicant
May 05 22:46:15 raspberrypi systemd[1]: Started WPA supplicant.

This is what you see from the package installation but that does not provide interfaces for management (only option -O for dbus interface). This service is not needed for special Raspbian dhcpcd networking and can be disabled. It only confuses people.

What you do not see is the second wpa_supplicant daemon started by dhcpcd.

rpi ~$ ps aux | grep wpa
root       511  0.0  0.1  10740  4028 ?        Ss   22:46   0:00 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
root       986  0.0  0.0  10984  1972 ?        Ss   23:14   0:00 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,wext
pi        1029  0.0  0.0   7348   584 ttyS0    S+   23:15   0:00 grep --color=auto wpa

Have a look at the CGroup:

rpi ~$ systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/dhcpcd.service.d
           └─wait.conf
   Active: active (running) since Tue 2020-05-05 23:14:14 BST; 3min 48s ago
  Process: 970 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w (code=exited, status=0/SUCCESS)
 Main PID: 1006 (dhcpcd)
    Tasks: 2 (limit: 4915)
   Memory: 1.9M
   CGroup: /system.slice/dhcpcd.service
           ├─ 986 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,wext
           └─1006 /sbin/dhcpcd -q -w

May 05 23:14:13 raspberrypi dhcpcd[970]: eth0: IAID 32:7f:38:91
May 05 23:14:13 raspberrypi dhcpcd[970]: wlan0: waiting for carrier
May 05 23:14:14 raspberrypi dhcpcd[970]: eth0: soliciting an IPv6 router
May 05 23:14:14 raspberrypi dhcpcd[970]: eth0: rebinding lease of 192.168.50.6
May 05 23:14:14 raspberrypi dhcpcd[970]: eth0: leased 192.168.50.6 for 3600 seconds
May 05 23:14:14 raspberrypi dhcpcd[970]: eth0: adding route to 192.168.50.0/24
May 05 23:14:14 raspberrypi dhcpcd[970]: eth0: adding default route via 192.168.50.1
May 05 23:14:14 raspberrypi dhcpcd[970]: forked to background, child pid 1006
May 05 23:14:14 raspberrypi systemd[1]: Started dhcpcd on all interfaces.
May 05 23:14:26 raspberrypi dhcpcd[1006]: eth0: no IPv6 Routers available

So you have to check why your dhcpcd is not running. Maybe you have just to enable and start it with:

rpi ~$ sudo systemctl enable --now dhcpcd.service
| improve this answer | |
  • already tried adding country. I've edited my post with output when using nl80211. wlan0: Failed to initialize driver interface – soundblaster May 5 at 2:13
  • @soundblaster I have updated the answer. – Ingo May 5 at 22:29
  • dhcpcd is running, in fact dhcpcd logs show: control command: dhcpcd --denyinterfaces wlan0. dhcpcd starts, but can't start wlan0, it's not in its CGroups. There's an issue either with the r8188eu driver and my TP-Link wireless adapter, or the ctrl_interface not being found. Neither wpa_cli or raspi-config can't access the ctrl_interface. – soundblaster May 24 at 16:01
  • did a fresh install without modifying any file, I just want to configure WIFI using raspi-config – soundblaster May 24 at 16:03
  • @soundblaster Seems you are mixing up things, very confusing. wlan0 is an interface and has nothing to do with CGroups. /sbin/wpa_supplicant must be shown under CGroups from the output of systemctl status dhcpcd.service. That means that wpa_supplicant is started with a hook script of dhcpcd. Have you checked this? – Ingo May 24 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.