Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi 3 B+ wifi does not work until the service is restarted #82462

Open
ertw opened this issue Mar 13, 2020 · 13 comments
Open

Raspberry Pi 3 B+ wifi does not work until the service is restarted #82462

ertw opened this issue Mar 13, 2020 · 13 comments
Labels
0.kind: bug Something is broken 6.topic: hardware 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS

Comments

@ertw
Copy link

ertw commented Mar 13, 2020

Describe the bug
I would like to have my Rasberry Pi connect to wifi without requiring user interaction. I have attempted to configure it using both wpa_supplicant and iwd, and both services are in a failed state on initial login. I have tried wpa_supplicant both with & without connman, and with & without declaratively specifying the connection details of the SSID.

Restarting the service (systemctl restart wpa_supplicant.service or systemctl restart iwd.service) causes the wireless to immediately connect, and systemctl status shows the service in a healthy state.

When I run journalctl -u iwd, I see the following error listed:
NEW_INTERFACE failed: Device or resource busy

To Reproduce
Steps to reproduce the behavior:

  1. Install NixOs 19.09 with kernel 4.19 following the wiki guide
  2. Attempt to configure wifi using network.wireless.enable = true; or network.wireless.iwd.enable = true;

Expected behavior
The pi should connect to wifi, and the wireless service (iwd or wpa_supplicant) should not crash.

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"aarch64-linux"`
 - host os: `Linux 4.19.107, NixOS, 19.09.2201.7d31bbceaa1 (Loris)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.3`
 - channels(root): `"nixos-unstable-20.09pre215947.82b54d49066, nixos-19.09.2201.7d31bbceaa1"`
 - channels(ertw): `"nixpkgs-unstable-20.09pre215991.93ba4ecd586"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@ertw ertw added the 0.kind: bug Something is broken label Mar 13, 2020
@matthewbauer
Copy link
Member

I had to add this to my config for wifi to work:

  boot.extraModprobeConfig = ''
    options cfg80211 ieee80211_regdom="${regDom}"
  '';
  hardware.firmware = [ pkgs.wireless-regdb ];

where regDom is your 2 letter country code (US for the United States).

@veprbl veprbl added 6.topic: hardware 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS labels Mar 13, 2020
@ertw
Copy link
Author

ertw commented Mar 26, 2020

Update: I did try @matthewbauer's suggestion, and I'm not sure whether it helped or not. Now I am sometimes getting connected to wifi, and sometimes not. In the case where it fails to connect to wifi, I see the same NEW_INTERFACE failed: Device or resource busy in systemctl status.

I am also still unable to boot into the latest 5.4 kernel (I reported a separate bug for this), so maybe this is an issue that is been fixed, and is only affecting 4.19?

Is there some way I can configure the systemd unit to always restart? Something like, attempt to start every 5 seconds forever seems like what I'd want regardless in an embedded device where connectivity is critical.

@matthewbauer
Copy link
Member

I think you can do:

systemd.services.iwd.serviceConfig.Restart = "always";

I also have this in my settings, but can't remember if it made a difference:

networking.dhcpcd.extraConfig = "timeout 0";

@ertw
Copy link
Author

ertw commented Mar 26, 2020

Okay, systemd.services.iwd.serviceConfig.Restart = "always"; does seem to solve my problem- the device is now connecting reliably to wifi and I can SSH into it without needing a display.

I'd like to leave this issue open for now though, as there is something causing both iwd and wpa_supplicant to crash on initial startup. Ideally we could discover what this is, and correctly solve for it rather than just restarting the service.

Here is what I believe to be the minimal config for working WLAN on the Raspberry Pi 3 B+:

{ config, pkgs, lib, ... }:
{
  systemd.services.iwd.serviceConfig.Restart = "always";
  hardware = {
    enableRedistributableFirmware = true;
    firmware = [ pkgs.wireless-regdb ];
  };
  networking = {
    useDHCP = false;
    interfaces.wlan0.useDHCP = true;
    networkmanager.wifi.backend = "iwd";
    wireless.iwd.enable = true;
  };
  boot = {
    extraModprobeConfig = ''
      options cfg80211 ieee80211_regdom="US"
    '';
  };
  system = {
    stateVersion = "19.09";
  };
}

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/raspberry-pi-aarch64-connect-to-wifi-automatically/6162/2

@ertw
Copy link
Author

ertw commented Mar 30, 2020

To add to this, the Arch Linux iwd entry specifically calls out issues with the systemd unit failing on startup, which sounds like what I've been running into.

https://wiki.archlinux.org/index.php/Iwd#Systemd_unit_fails_on_startup_due_to_device_not_being_available

@mleonhard
Copy link

My Raspberry Pi 4B was failing to load the wlan0 device. The fix is to add hardware.enableRedistributableFirmware = true;. The full working config is in Robertof/nixos-docker-sd-image-builder#10 (comment)

Shall we close this issue?

@stale
Copy link

stale bot commented Dec 17, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 17, 2020
@bachp
Copy link
Member

bachp commented Nov 28, 2021

This issue seems to be still present. wlan0 doesn't even show up on the Pi 3. The only workaround is to use an older version of firmware-linux.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 28, 2021
alexvorobiev added a commit to alexvorobiev/nixos-pi that referenced this issue Jan 21, 2022
@ratsclub
Copy link
Member

ratsclub commented Feb 2, 2022

@bachp were you able to connect to do it? My wlan0 also won't show up.

@bachp
Copy link
Member

bachp commented Feb 2, 2022

I got it working by following the instructions in #115652 (comment). But there doesn't seem to be a real solution yet.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/raspberry-pi-3-wireless-interface/17576/1

@jqqqqqqqqqq
Copy link
Contributor

@ertw Your typo is carried to the internet example

options cf680211 ieee80211_regdom="US"

it should be cfg80211 instead of cf680211.

Took me a tremedous long time to figure out.

Without fixing this typo, the output below is 00 and I cannot associate with any network

root@nixos ~# cat /sys/module/cfg80211/parameters/ieee80211_regdom
US

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: hardware 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Projects
None yet
Development

No branches or pull requests

8 participants