24

I do not want to see the following message when I login to my Pi (5.10.17-v8+ #1403 SMP PREEMPT Mon Feb 22 11:37:54 GMT 2021 aarch64 GNU/Linux):

Wi-Fi is currently blocked by rfkill.
Use raspi-config to set the country before use.

How can I make it so that this message does not show up when I login by SSH?

2
  • 3
    Have a look in /etc/profile.d/wifi-check.sh
    – alin
    Nov 1, 2021 at 22:14
  • A way to do this non-interactively would be nice. I don't mean CLI, I mean by writing to bootfs. Use case: I have a Pi 3A+, no screen, no keyboard. I had to run sudo rfkill unblock wifi (thanks @Kingsley) from the UART interface.
    – Gauthier
    Apr 10 at 17:50

7 Answers 7

26

Run sudo raspi-config and set the wifi country code by going to

5 Localisation Options

Then

L4. WLAN Country

Then select your country code from the list

2
  • 1
    Do you know of a way to do this programmatically? Apr 11, 2021 at 1:32
  • 11
    @GordonFogus - yes - you can use raspi-config non-interactively ... sudo raspi-config nonint do_wifi_country XX - use appropriate value for XX Apr 11, 2021 at 2:58
14

I'm stealing/promoting @Jaromanda X's answer here, as it's a one-liner and avoids having to fumble through the "GUI" to set the Wi-Fi region/country:

sudo raspi-config nonint do_wifi_country XX

XX is country code, you can find your country's code here: https://en.wikipedia.org/wiki/ISO_3166-1

7

I updated a Pi 3b to Bullseye and had this issue. I tried the country code and the urfkill installation and the rfkill unblock command. In the end, I also needed to run

sudo connmanctl enable wifi

This is described at the following: connman unable to connect to wifi: No carrier

5

No matter what I tried the raspi-config always failed with:

Could not communicate with wpa_supplicant

I already had the country code in the /etc/wpa_applicant/wpa_applicant.conf too.

In the end I used the rfkill command to enable it manually.

# rfkill unblock wifi

This seems to preserve the unblocked status, at least through warm-reboots.

Then (with quite a bit more stuffing around) it all worked.

It's a bit of a shame the "out-of-box" configuration scripts can't get this working.

3
  • 1
    You can check this status with rfkill list and you'll see Soft blocked: yes against the device. The unblocked status is saved in a file under /var/lib/systemd/rfkill/ and so survives a cold reboot. The point of this is to prevent unconfigured wifi transmitting on wrong frequencies for the country it's operating in.
    – Ed Randall
    Mar 16, 2022 at 8:02
  • @EdRandall But if the user sets country in wpa_supplicant.conf, shouldn't that give the OS a hint?
    – Gauthier
    Apr 10 at 17:26
  • @Gauthier agree, one would expect so. Seems like a bug that the file under /var/lib/systemd/rfkill/ wins out, but perhaps there are other good reasons that they do it that way.
    – Ed Randall
    Apr 11 at 10:56
4

The easiest way (that I've found) to programmatically make this message go away was to add the following to /boot/config.txt:

dtoverlay=disable-wifi

Yes, this does disable WiFi, but that was not a constraint in the original question (in other words, the question didn't say that disabling WiFi was unacceptable).

While I was at it, I also disabled Bluetooth, since I didn't need that either:

dtoverlay=disable-bt
1
  • Indeed, it's notable that OP is logging in via ssh and therefore has some other kind of networking configured and working.
    – Ed Randall
    Mar 16, 2022 at 8:52
1

I encountered this problem setting up my Pi 4 with the 2021-10-30 version of Bullseye Lite. The howto I followed had a wpa_supplicant.conf file that started with:

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

and when I hooked up via Ethernet, rfkill complained that the country code was invalid. I used raspi-config to "update" it with the same value, and the first three lines came out as:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

The WiFi started working correctly.

When I used the changed sequence on my Pi Zero W, it worked correctly the first time.

Looks like some code in the startup software is fussy about the order in which it finds parameters.

1

You might consider install urfkill, as in:

sudo apt install urfkill
sudo rfkill unblock wifi

That worked for me:

https://raspberrypi.stackexchange.com/a/135176/143070

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