Raspberry Pi Zero 2W periodically disconnects from WiFi

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=25
G_DIETPI_VERSION_RC=1
G_GITBRANCH=‘master’
G_GITOWNER=‘MichaIng’
bullseye 0
Linux DietPi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
arm64
RPi Zero 2 W (aarch64)
5V 1A
Official 16 GB MicroSD (the one in the starter kit)

Additional Information (if applicable)

  • Was the software title installed freshly or updated/migrated? The problem occurs since the first installation
  • Can this issue be replicated on a fresh installation of DietPi? Yes

Steps to reproduce

  1. Install Dietpi
  2. Wait few hours
  3. The board disconnects from wifi

Expected behaviour

The board should remain connected

Actual behaviour

Since first installation, the board connects to wifi, but after few hours it disconnects and the only way to reconnect it is to detach from power supply

Extra details

  • Tried to change power supply (it was attached to the router usb port)
  • Tried to reflash the image
  • The raspberry is close to the router (so no signal issue)
  • Tried to increase the dhcp lease time

Did you already tried to enable Auto Reconnect : [On] within WiFi settings? It will create a service dietpi-wifi-monitor that should check WiFi connection every 10 seconds.

Yeah, I enabled it the other day but it still disconnected. I now have switched log method to make it persistent, I’m going to wait for the next disconnection (in few hours, presumably) and check the logs.

you can reboot your system to test your persistent logs. If it is working, you should see entries from before the reboot.

What file should I read in the /var/log/ folder for reading potential network issues?

By default we log into journalctl. Simply check for timestamp from before reboot

Could be a marginal wifi signal…and/or microwaves being used (my wifi goes wonky when the family microwaves stuff…LOL)

I can’t see any error in the logs. The only weird thing is that I rebooted at around 9:52 am and the logs start at 9:17 am, but the sbc was powered on for many hours before. I started persistent logging yesterday in the afternoon.

The raspberry is at 15 cm from the router, so no poor signal…and I don’t think it’s a microwave problem hahah

ok looks persistent logging is not working. Every hour at the 17th minute, we safe a fake time stamp down to disk. This one is used during boot until real time sync succeeded. Therefore you see 9:17.

can you try following

persistent system logs:

dietpi-software uninstall 103 # uninstalls DIetPi-RAMlog
mkdir /var/log/journal # triggers systemd-journald logs to disk
reboot # required to finalise the RAMlog uninstall

Then you can check system logs via:

journalctl

which will then show as well logs from previous boot sessions. To limit the size, you can additionally e.g. apply the following:

mkdir -p /etc/systemd/journald.conf.d
cat << '_EOF_' > /etc/systemd/journald.conf.d/99-custom.conf
[Journal]
SystemMaxFiles=2
MaxFileSec=7day
_EOF_

This will limit logs to 14 days split across two journal files, so that with rotation you will always have between 7 and 14 days of logs available.

I’ve done everything you said to do. Now I see logs only starting from 10:36am

Ok try to reboot somewhere this evening. It should show logs from 10:36, still. I hope.

It disconnected even before this evening :smiley:

The logs now start from 10:54 am, at that time I edited the stuff you asked me to do. But now some errors are logged, it seems like when it disconnects, something crashes and the system reboots (?)
Where can I dump you the logs?

Should be possible to attach as text file

The errors start around 2:16pm
logs.txt (131.3 KB)

Jan 09 14:16:07 DietPi dietpi-wifi-monitor.sh[393]: [ INFO ] DietPi-WiFi_Monitor | Detected wlan0 connection loss. Reconnecting...
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: wlan0: CTRL-EVENT-DISCONNECTED bssid=18:0f:76:79:87:e9 reason=3 locally_generated=1
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=IT
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: nl80211: deinit ifname=p2p-dev-wlan0 disabled_11b_rates=0
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: p2p-dev-wlan0: CTRL-EVENT-TERMINATING
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: wlan0: CTRL-EVENT-TERMINATING
Jan 09 14:16:09 DietPi wpa_supplicant[8962]: Successfully initialized wpa_supplicant
Jan 09 14:16:09 DietPi kernel: brcmfmac: brcmf_cfg80211_set_power_mgmt: power save disabled
Jan 09 14:16:09 DietPi dietpi-wifi-monitor.sh[393]: [  OK  ] DietPi-WiFi_Monitor | Completed
Jan 09 14:16:09 DietPi wpa_supplicant[8965]: wlan0: Trying to associate with SSID 'Infostrada-7987E8_2'
Jan 09 14:16:11 DietPi kernel: ieee80211 phy0: brcmf_fw_crashed: Firmware has halted or crashed
Jan 09 14:16:11 DietPi kernel: ieee80211 phy0: brcmf_fil_cmd_data: bus is down. we have nothing to do.
Jan 09 14:16:11 DietPi kernel: ieee80211 phy0: brcmf_cfg80211_get_tx_power: error (-5)
Jan 09 14:16:11 DietPi wpa_supplicant[8965]: wlan0: CTRL-EVENT-DISCONNECTED bssid=18:0f:76:79:87:e9 reason=3 locally_generated=1
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: nl80211: deinit ifname=p2p-dev-wlan0 disabled_11b_rates=0
Jan 09 14:16:12 DietPi systemd[1]: Stopping ifup for wlan0...
Jan 09 14:16:12 DietPi systemd[1]: Starting Load/Save RF Kill Switch Status...
Jan 09 14:16:12 DietPi kernel: mmc1: card 0001 removed
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: Could not read interface p2p-dev-wlan0 flags: No such device
Jan 09 14:16:12 DietPi systemd[1]: Started Load/Save RF Kill Switch Status.
Jan 09 14:16:12 DietPi kernel: mmc1: queuing unknown CIS tuple 0x63 [cc 09 62 80 02 21 5c c9 89 c1 cc 9e 84 98 00] (15 bytes)
Jan 09 14:16:12 DietPi ifdown[9007]: Cannot find device "wlan0"
Jan 09 14:16:12 DietPi kernel: mmc1: queuing unknown CIS tuple 0xcb [ff d1 1f 00 ff 81 f1 1f 8c 00 23 64 9c bc 0c ff c2 12 4f ff e0 0e 59 06 5f 0a fb 51 1f ff 65 3c 7e 12 e1 14 7f 45 48 ff a1 ff 39 22 00 df 9e] (47 bytes)
Jan 09 14:16:12 DietPi ifdown[9012]: Cannot find device "wlan0"
Jan 09 14:16:12 DietPi kernel: mmc1: queuing unknown CIS tuple 0xa1 [f8 89 93 59 e8 ff 03 e2 01 30 04 ff f3 00 e0 87 93 06 ec 82 6f 22 18 38 77 25 00 40 0c 03 a0 85 a2 f4 59 ff 62 11 73 6d 00 11 8c da 14 97 c3 7f b9 84 05 06 00 39 17 42 6a 0d 21 01 00 a2 34 ce] (194 bytes)
Jan 09 14:16:12 DietPi ifdown[9016]: Device "wlan0" does not exist.
Jan 09 14:16:12 DietPi kernel: mmc1: queuing unknown CIS tuple 0x10 [56 d6 88 97 62 59 00 00 b5 39 03 30 26 2c f8 10 a5 c1 00 74 22 ff ca ff fe fe 53 44 18 8f 17 72 92 88 01 3f 70 2d 99 00 01 2c 8c 73 90 fd 63 ff 6b ed 78 43 10 52 25 a0 00 e1 24 f5 00 00 41 48] (214 bytes)
Jan 09 14:16:12 DietPi ifdown[9020]: Cannot find device "wlan0"
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Jan 09 14:16:12 DietPi ifdown[9038]: command failed: No such device (-19)
Jan 09 14:16:12 DietPi systemd[1]: ifup@wlan0.service: Succeeded.
Jan 09 14:16:12 DietPi systemd[1]: Stopped ifup for wlan0.
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: Could not read interface wlan0 flags: No such device
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: wlan0: CTRL-EVENT-TERMINATING
Jan 09 14:16:17 DietPi systemd[1]: systemd-rfkill.service: Succeeded.

hmm looks like WiFi device died. Found an old RPi GitHub post where user reporting issues with Mesh systems

Interesting part is this:

Log
Jan 09 14:16:07 DietPi dietpi-wifi-monitor.sh[393]: [ INFO ] DietPi-WiFi_Monitor | Detected wlan0 connection loss. Reconnecting...
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: wlan0: CTRL-EVENT-DISCONNECTED bssid=18:0f:76:79:87:e9 reason=3 locally_generated=1
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=IT
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: nl80211: deinit ifname=p2p-dev-wlan0 disabled_11b_rates=0
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: p2p-dev-wlan0: CTRL-EVENT-TERMINATING
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Jan 09 14:16:07 DietPi wpa_supplicant[6641]: wlan0: CTRL-EVENT-TERMINATING
Jan 09 14:16:09 DietPi wpa_supplicant[8962]: Successfully initialized wpa_supplicant
Jan 09 14:16:09 DietPi kernel: brcmfmac: brcmf_cfg80211_set_power_mgmt: power save disabled
Jan 09 14:16:09 DietPi dietpi-wifi-monitor.sh[393]: [  OK  ] DietPi-WiFi_Monitor | Completed
Jan 09 14:16:09 DietPi wpa_supplicant[8965]: wlan0: Trying to associate with SSID 'Infostrada-7987E8_2'
Jan 09 14:16:11 DietPi kernel: ieee80211 phy0: brcmf_fw_crashed: Firmware has halted or crashed
Jan 09 14:16:11 DietPi kernel: ieee80211 phy0: brcmf_fil_cmd_data: bus is down. we have nothing to do.
Jan 09 14:16:11 DietPi kernel: ieee80211 phy0: brcmf_cfg80211_get_tx_power: error (-5)
Jan 09 14:16:11 DietPi wpa_supplicant[8965]: wlan0: CTRL-EVENT-DISCONNECTED bssid=18:0f:76:79:87:e9 reason=3 locally_generated=1
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: nl80211: deinit ifname=p2p-dev-wlan0 disabled_11b_rates=0
Jan 09 14:16:12 DietPi systemd[1]: Stopping ifup for wlan0...
Jan 09 14:16:12 DietPi systemd[1]: Starting Load/Save RF Kill Switch Status...
Jan 09 14:16:12 DietPi kernel: mmc1: card 0001 removed
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: Could not read interface p2p-dev-wlan0 flags: No such device
Jan 09 14:16:12 DietPi systemd[1]: Started Load/Save RF Kill Switch Status.
Jan 09 14:16:12 DietPi kernel: mmc1: queuing unknown CIS tuple 0x63 [cc 09 62 80 02 21 5c c9 89 c1 cc 9e 84 98 00] (15 bytes)
Jan 09 14:16:12 DietPi ifdown[9007]: Cannot find device "wlan0"
Jan 09 14:16:12 DietPi kernel: mmc1: queuing unknown CIS tuple 0xcb [ff d1 1f 00 ff 81 f1 1f 8c 00 23 64 9c bc 0c ff c2 12 4f ff e0 0e 59 06 5f 0a fb 51 1f ff 65 3c 7e 12 e1 14 7f 45 48 ff a1 ff 39 22 00 df 9e] (47 bytes)
Jan 09 14:16:12 DietPi ifdown[9012]: Cannot find device "wlan0"
Jan 09 14:16:12 DietPi kernel: mmc1: queuing unknown CIS tuple 0xa1 [f8 89 93 59 e8 ff 03 e2 01 30 04 ff f3 00 e0 87 93 06 ec 82 6f 22 18 38 77 25 00 40 0c 03 a0 85 a2 f4 59 ff 62 11 73 6d 00 11 8c da 14 97 c3 7f b9 84 05 06 00 39 17 42 6a 0d 21 01 00 a2 34 ce] (194 bytes)
Jan 09 14:16:12 DietPi ifdown[9016]: Device "wlan0" does not exist.
Jan 09 14:16:12 DietPi kernel: mmc1: queuing unknown CIS tuple 0x10 [56 d6 88 97 62 59 00 00 b5 39 03 30 26 2c f8 10 a5 c1 00 74 22 ff ca ff fe fe 53 44 18 8f 17 72 92 88 01 3f 70 2d 99 00 01 2c 8c 73 90 fd 63 ff 6b ed 78 43 10 52 25 a0 00 e1 24 f5 00 00 41 48] (214 bytes)
Jan 09 14:16:12 DietPi ifdown[9020]: Cannot find device "wlan0"
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Jan 09 14:16:12 DietPi ifdown[9038]: command failed: No such device (-19)
Jan 09 14:16:12 DietPi systemd[1]: ifup@wlan0.service: Succeeded.
Jan 09 14:16:12 DietPi systemd[1]: Stopped ifup for wlan0.
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: Could not read interface wlan0 flags: No such device
Jan 09 14:16:12 DietPi wpa_supplicant[8965]: wlan0: CTRL-EVENT-TERMINATING
Jan 09 14:16:17 DietPi systemd[1]: systemd-rfkill.service: Succeeded.
Jan 09 14:16:19 DietPi dietpi-wifi-monitor.sh[393]: [FAILED] DietPi-WiFi_Monitor | WiFi adapter wlan0 has been unplugged. Exiting...
Jan 09 14:16:19 DietPi systemd[1]: dietpi-wifi-monitor.service: Main process exited, code=exited, status=1/FAILURE
Jan 09 14:16:19 DietPi systemd[1]: dietpi-wifi-monitor.service: Failed with result 'exit-code'.
Jan 09 14:16:19 DietPi systemd[1]: dietpi-wifi-monitor.service: Consumed 1min 30.869s CPU time.
Jan 09 14:16:55 DietPi kernel: mmc1: error -22 whilst initialising SDIO card
Jan 09 14:16:55 DietPi kernel: mmc1: queuing unknown CIS tuple 0x63 [cc 09 62 80 02 21 5c c9 89 c1 cc 9e 84 98 00] (15 bytes)
Jan 09 14:16:55 DietPi kernel: mmc1: queuing unknown CIS tuple 0xcb [ff d1 1f 00 ff 81 f1 1f 8c 00 23 64 9c bc 0c ff c2 12 4f ff e0 0e 59 06 5f 0a fb 51 1f ff 65 3c 7e 12 e1 14 7f 45 48 ff a1 ff 39 22 00 df 9e] (47 bytes)
Jan 09 14:16:55 DietPi kernel: mmc1: queuing unknown CIS tuple 0xa1 [f8 89 93 59 e8 ff 03 e2 01 30 04 ff f3 00 e0 87 93 06 ec 82 6f 22 18 38 77 25 00 40 0c 03 a0 85 a2 f4 59 ff 62 11 73 6d 00 11 8c da 14 97 c3 7f b9 84 05 06 00 39 17 42 6a 0d 21 01 00 a2 34 ce] (194 bytes)
Jan 09 14:16:55 DietPi kernel: mmc1: queuing unknown CIS tuple 0x10 [56 d6 88 97 62 59 00 00 b5 39 03 30 26 2c f8 10 a5 c1 00 74 22 ff ca ff fe fe 53 44 18 8f 17 72 92 88 01 3f 70 2d 99 00 01 2c 8c 73 90 fd 63 ff 6b ed 78 43 10 52 25 a0 00 e1 24 f5 00 00 41 48] (214 bytes)
-- Boot d362f8fb60c14843b6140d8fb18a270e --
Jan 09 14:17:01 DietPi kernel: Booting Linux on physical CPU 0x0000000000 [0x410fd034]

reason=3 is "Deauthenticated because sending STA is leaving (or has left) the BSS"
STA stands for station, BSS is basic service set.
Here is even more info about the status codes:
https://aboutcher.co.uk/2012/07/linux-wifi-deauthenticated-reason-codes/

The access point went offline, deauthenticating the client.

So your Pi loses connection for some reason.
I also did some google search, but the reasons vary much. From disabling some wifi features in the router, or not getting a DHCP release, etc pp

I have a main router (the rpi is connected here) and a second router in cascade, but has a different SSID. I also splitted the 2.4 and 5 GHz of the main router, but both with different SSIDs.

I read that it could be a bug in the wifi driver.
This problem occures since day one.

Idk what to do honestly

If it is the driver, not sure what we can do on this as we don’t maintain them. They are the original one from RPI

what you could try is to update to Debian Bookworm to see if it will change anything. But kernel should be same.

Any other possible solution, apart from switching distro? I’ve checked around and seems like someone works around it in the router settings, someone just flashes a different firmware, someone else didn’t solve it… I’m afraid I’ll be in the last group of people