nmstoker
Posts: 8
Joined: Tue May 29, 2012 12:47 am

Problem for headless use: Buster Lite starts with Wi-Fi blocked by rfkill

Fri May 01, 2020 11:15 pm

I've recently received two new RPi 4s (4Gb) and went to set them up headless, doing one on day and the next several days later following the same basic pattern. As they are meant to be truly headless (ie I don't plug them into a monitor and ideally would've preferred not to have to go plug in a network cable) I do the usual processes:
  • Setting the host name (in hosts, hostname)
  • Put a file in /boot for ssh
  • Set up wpa_supplicant.conf, crucially with the country code (ie all carefully done following details here)
With both though I am finding that they never come up on the WiFi because rfkill is blocking them. Ought this to be mentioned on the headless configuration page I linked to above?

It's clear that it's rfkill doing this, because when I go plug them into a wired network and ssh on, almost the first thing displayed says it's rfkill:
SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.


Wi-Fi is currently blocked by rfkill.
Use raspi-config to set the country before use.
Now I'm not sure why the message about setting the country before use is coming up, as I carefully set that in wpa_supplicants (and I did double-check that it is definitely meant to be "GB" and not "UK" and that I've done it just like it says on the headless page)

Is there some issue with the order that things are being done in or is the value in wpa_supplicants being ignored because raspi-config has not been run?

To resolve it I have been using sudo rfkill unblock wifi, then rebooting and it works right away then without the network cable when it comes back up (and it doesn't change anything about the wpa_supplicants file, so I'm not convinced it's a problem with that file)

Ideally what I am after is a way that I can set things to ensure that it comes up on first boot. I do change the credentials right away but the risk is limited on my network (and in the past I'd managed to set a non-standard default password by changing the files on the SD card before putting it in, which I would remind myself how to do if I could get the rfkill thing sorted!)

Also would prefer (if possible!) to properly get to the bottom of this, rather than fall back on a hacky solution (ie a script that runs on first boot to trigger rfkill unblock wifi) or resorting to some more involved solution (eg Pi Bakery etc)

Let me know if there's anything other info I should supply or actions to try.

Many thanks,
Neil

jbudd
Posts: 2114
Joined: Mon Dec 16, 2013 10:23 am

Re: Problem for headless use: Buster Lite starts with Wi-Fi blocked by rfkill

Sat May 02, 2020 12:13 am

Can you post the wpa_supplicant.conf file that you are placing in the /boot partition? Change the SSID and password before posting!
Does the file get deleted from /boot when you start the Pi?
Over and out

andrum99
Posts: 2129
Joined: Fri Jul 20, 2012 2:41 pm

Re: Problem for headless use: Buster Lite starts with Wi-Fi blocked by rfkill

Sat May 02, 2020 7:07 am

Use raspi-config to set the wifi country code, as that helpful message is telling you to do. If it already shows the correct country code when you go into raspi-config to change it, set it to another country code, then back to the correct one to make sure it has disabled rfkill. It's obviously got something else that is toggled by that setting in raspi-config, not just inserting the country code into wpa_supplicant.conf.

nmstoker
Posts: 8
Joined: Tue May 29, 2012 12:47 am

Re: Problem for headless use: Buster Lite starts with Wi-Fi blocked by rfkill

Sat May 02, 2020 4:03 pm

Thank you both.

@jbudd, here's the contents of /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
ssid="MY_SSID"
psk="MY_PASSWORD"
}
You asked me to post what was being put into the /boot folder, but that's not quite what I'm doing (sorry if it wasn't clear from my post). I edit the file on the SD card by mounting the necessary partition on my computer before putting it into the RPi, so I am accessing the actual file within /etc/wpa_supplicant/ (unlike with the ssh situation where it is indeed a file placed in /boot)

@andrum99 - I'll have a go with that idea of yours to switch the country code to something else and back shortly and report back. (I've got several more SD Cards I'm due to prep; incidentally thats why I'm trying to resolve this rather than just put up with briefly going non-headless each time :-) Plus it might help others)

jbudd
Posts: 2114
Joined: Mon Dec 16, 2013 10:23 am

Re: Problem for headless use: Buster Lite starts with Wi-Fi blocked by rfkill

Sat May 02, 2020 4:14 pm

I don't see any glaring errors in your wpa_supplicant.conf.

you can put wpa_supplicant.conf in /boot, that's how I do it on a Windows pc. I doubt if it makes a difference but worth trying to see.
Over and out

trejan
Posts: 7204
Joined: Tue Jul 02, 2019 2:28 pm

Re: Problem for headless use: Buster Lite starts with Wi-Fi blocked by rfkill

Sat May 02, 2020 4:32 pm

nmstoker wrote:
Fri May 01, 2020 11:15 pm
[*]Set up wpa_supplicant.conf, crucially with the country code (ie all carefully done following details here)
If you put wpa_supplicant.conf into /boot then raspberrypi-net-mods.service will copy it to the correct location and then run rfkill unblock for you.

If you want to directly alter the rfkill state then it is kept in /var/lib/systemd/rfkill

nmstoker
Posts: 8
Joined: Tue May 29, 2012 12:47 am

Re: Problem for headless use: Buster Lite starts with Wi-Fi blocked by rfkill

Sat May 02, 2020 5:19 pm

Oops! Thanks trejan. Re-reading I now realise that I had skipped the part about where the file should be put, since I knew where it was from previously doing this countless times this way in the past. My mistake! Sounds like this should work for me now.

Return to “Troubleshooting”