BCM43142 - Wifi unavailable after computer suspends

I've recently switched to Manjaro and I've been having some issues with my wifi. After my computer suspends it stops working, the network manger doesn't display any networks and the only way I can get it to work again is by rebooting. My network card is the Broadcom BCM43142.

Any more info you need please ask and I appreciate any help I get.

It's kind a dirty hack, but if sudo systemctl restart NetworkManager helps after suspend, we can automate this process.

There is tons of information on the forum regarding this issue. Search systemd suspend unit.

How could writing a unit help? I don't know any other ways of reestablishing my wifi connection other than rebooting

i guess you may take a look on this particular post

Resume unit: part

#/etc/systemd/system/network-resume.service
#sudo systemctl enable network-resume.service
#sudo systemctl start network-resume.service
#sudo systemctl status network-resume.service
#sudo systemctl daemon-reload
[Unit]
Description=Network resume service
After=suspend.target
StopWhenUnneeded=yes

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/bin/sleep 10
ExecStart=/usr/bin/modprobe 8812au
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/ip link set wlan0 up
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/systemctl start NetworkManager
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking on'
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi off'
ExecStart=/usr/bin/sleep 2
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi on'

[Install]
WantedBy=suspend.target

If your adapter ID is different than “wlan0” you will need to substitute you own adapter’s ID into the service files. If you are using a different driver module you will also need to substitute it in place of “8812au”.

You can find your adapters driver/module and device identification with the following command:

inxi -n

@treeman do you have particular step where you hanged on?

I don't have anything helpful here but I can only say that I had this problem for over a year and at some point it just were gone on its own. Some system updates or kernel updates or maybe switching to higher kernel fixed it. I don't know but it eventually did.

In that time as a workaround I just set my screen to turn off when lid closes so the computer was never suspending. This wasn't ideal but I got used it.

However, this doesn't mean you should stop looking for the solution.

If you would read the posted links you would understand you can restart your networking without rebooting.

I will give you a hand writing a service, but it would also be better if you read some of the posted links to learn how systemd works.I will need you to post the following info to be able to create a service for you:

hwinfo --netcard --wlan --bluetooth | grep -Ei "model\:|driver\:|status\:|cmd\:|file\:|detected\:" | grep -v "Config Status" 

Try this solution:
https://ubuntuforums.org/showthread.php?t=2314905&p=13555828#post13555828

Worked for me.
You have to know your network card kernel module.

That is the old pre systemd method. It still works, but is not recommended any longer. That method is extremely dated.

1 Like

Here it is:

Model: "Realtek RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller"
  Driver: "r8169"
  Device File: eno1
  Link detected: no
    Driver Status: r8169 is active
    Driver Activation Cmd: "modprobe r8169"
  Model: "Broadcom BCM43142 802.11b/g/n"
  Driver: "wl"
  Device File: wlo1
  Link detected: yes
    Driver Status: wl is active
    Driver Activation Cmd: "modprobe wl"

Thanks for the help :slight_smile:. I've created the units (changed the adapter and module to my own) but the resume unit wasn't successful. It failed to start the Network manager.
Here are the logs: https://pastebin.com/ZzKS2xb8

This service is condensed into only one unit, so it is very easy to create the service.

Combined network restart service unit:

Create the following file with a root text editor:

/etc/systemd/system/network-restart.service

Add the following contents to the file:

#/etc/systemd/system/network-restart.service
#sudo systemctl enable network-restart.service
#sudo systemctl start network-restart.service
#sudo systemctl status network-restart.service
#sudo systemctl daemon-reload

[Unit]
Description=Broadcom WiFi Restart Service 
Before=sleep.target
StopWhenUnneeded=yes

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking off'
ExecStart=/usr/bin/sleep 1
ExecStart=/usr/bin/systemctl stop NetworkManager
ExecStart=/usr/bin/ip link set wlo1 down
ExecStart=/usr/bin/modprobe -r  wl
ExecStop=/usr/bin/sleep 5
ExecStop=/usr/bin/modprobe wl
ExecStop=/usr/bin/sleep 3
ExecStop=/usr/bin/ip link set wlo1 up
ExecStop=/usr/bin/sleep 2
ExecStop=/usr/bin/systemctl start NetworkManager
ExecStop=/usr/bin/sleep 1
ExecStop=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking on'
ExecStop=/usr/bin/sleep 1
ExecStop=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi off'
ExecStop=/usr/bin/sleep 1
ExecStop=/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli r wifi on'

[Install]
WantedBy=sleep.target

The sleep units in the service may be reduced, (or eliminated) if you do not like the delay it creates. Be aware though, that doing so may reduce the reliability of the service.

Once you have created and saved the service file, enable the service:

sudo systemctl enable network-restart.service

Then reboot the computer.

For the benefit of others wishing to adapt this service to their installation (if different than above):

If your adapter's designation is different than “wlo1” you will need to substitute you own adapter’s ID into the service file.

If you are using a different driver module you will also need to substitute it in place of “wl”.

You can find your adapter driver/module(s) and device ID with the following command:

inxi -n
1 Like

Thanks for all the help. I did everything you've said but the unit failed.

As the resume unit from the post referenced by @webcapcha, it failed to start the network manager.
Logs: https://pastebin.com/JqAc6MLp

99% of what you are posting is unrelated. Simply post this output here on the forum.

systemctl status network-restart.service

You must disable/delete the other services you wrote or the services will interfere with each other. Reboot or run sudo systemctl daemon-reload after making any change.

1 Like

Sorry, kind of a newbie here, thought it might've been helpful. Here it is:

● network-restart.service - Broadcom WiFi Restart Service
   Loaded: loaded (/etc/systemd/system/network-restart.service; enabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Wed 2019-05-08 21:43:31 WEST; 10s ago
  Process: 1364 ExecStart=/usr/bin/sudo -u $USER /bin/bash -lc nmcli networking off (code=exited, status=0/SUCCESS)
  Process: 1408 ExecStart=/usr/bin/sleep 1 (code=exited, status=0/SUCCESS)
  Process: 1477 ExecStart=/usr/bin/systemctl stop NetworkManager (code=exited, status=0/SUCCESS)
  Process: 1478 ExecStart=/usr/bin/ip link set wlo1 down (code=exited, status=0/SUCCESS)
  Process: 1479 ExecStart=/usr/bin/modprobe -r wl (code=exited, status=0/SUCCESS)
  Process: 1554 ExecStop=/usr/bin/sleep 5 (code=exited, status=0/SUCCESS)
  Process: 1689 ExecStop=/usr/bin/modprobe wl (code=exited, status=0/SUCCESS)
  Process: 1699 ExecStop=/usr/bin/sleep 3 (code=exited, status=0/SUCCESS)
  Process: 1706 ExecStop=/usr/bin/ip link set wlo1 up (code=exited, status=0/SUCCESS)
  Process: 1707 ExecStop=/usr/bin/sleep 2 (code=exited, status=0/SUCCESS)
  Process: 1708 ExecStop=/usr/bin/systemctl start NetworkManager (code=killed, signal=TERM)
 Main PID: 1479 (code=exited, status=0/SUCCESS)

mai 08 21:41:43 moonrover systemd[1]: Starting Broadcom WiFi Restart Service...
mai 08 21:41:43 moonrover sudo[1364]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/bash -lc nmcli networking off
mai 08 21:41:43 moonrover sudo[1364]: pam_unix(sudo:session): session opened for user root by (uid=0)
mai 08 21:41:43 moonrover sudo[1364]: pam_unix(sudo:session): session closed for user root
mai 08 21:41:44 moonrover systemd[1]: Started Broadcom WiFi Restart Service.
mai 08 21:41:51 moonrover systemd[1]: Stopping Broadcom WiFi Restart Service...
mai 08 21:43:31 moonrover systemd[1]: network-restart.service: Stopping timed out. Terminating.
mai 08 21:43:31 moonrover systemd[1]: network-restart.service: Control process exited, code=killed, status=15/TERM
mai 08 21:43:31 moonrover systemd[1]: network-restart.service: Failed with result 'timeout'.
mai 08 21:43:31 moonrover systemd[1]: Stopped Broadcom WiFi Restart Service.

Try changing this ^^^ to this:

ExecStop=/usr/bin/sleep 5
ExecStopPost=/usr/bin/systemctl start NetworkManager

This is very strange behaviour. I have never seen Network Manager fail to restart in any similar service I have written.

Restart computer after making the changes.

1 Like

Oddly now sometimes the unit succeeds and sometimes it returns error (same one as before with the NM). But i never get my wifi back in both cases.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by Bytemark