26

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, 2023 at 17:50

7 Answers 7

28

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

4
  • 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
  • 1
    But that doesn't just disable the message, it also enables WiFi, which is not what the question is about (and probably not the intention of the OP). Sep 27, 2023 at 8:30
  • and yet, @12431234123412341234123 this answer got more upvotes than any other answer Sep 27, 2023 at 8:48
17

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

9

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

6

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
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.

6
  • 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, 2023 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, 2023 at 10:56
  • 1
    The country code is supposed to go in /etc/default/crda
    – OrangeDog
    Oct 12, 2023 at 9:59
  • @OrangeDog - Use of crda has been deprecated in a few Linux distro's, so YMMV. Particularly if you're reading this in the future.
    – Kingsley
    Oct 12, 2023 at 22:28
2

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.