In previous post related to the configuration of Linux on MacBookPro14,3 I mentioned, that we have a problem with wifi. In this article, I want to describe how to solve this.

This is just a note, mainly for me, that describes how to fix wifi on Debian with MacBook hardware

Related articles:

Problem

The problem is clear - wifi can discover part(!) of networks (only 2.4GHz), but cannot connect to them.

Workaround - create a fresh hotspot (every time with a new pwd) on the phone and connect to it, after u can reconnect to any wifi.

Solution

The very first thing - we should determine which device has a problem. To do so, we can use lspci with grep command.

I wrote a post some time ago about a great tool grep

My output:

khb@localhost$ ispel | grep Network
03:00,0 Network controller: Broadcom ine, and subsidiaries BCM43602 802,11ac Wireless LAN SOC (rev 02)
khb@localhost$

Now we can see, that problem with the bcm43602 wifi adapter.

Fix

To fix this problem, we should install the correct driver for this device.

sudo apt-get purge bcmwl-kernel-source
sudo apt update
sudo update-pciids
sudo apt install firmware-b43-installer

perform a reboot, and start:

sudo iwconfig wlp3s0 txpower 10dBm

The reason for me is unknown, but with less transmission power, the wifi adapter starts working well… Thanks to iwconfig, it’s easy to do.

To determine name of the your card run iwconfig:

khb@localhost: $ sudo iconfig
lo				no wireless extensions.

wlp3s0
				IEEE 802.11 ESSID: "NAME"
				Mode: Managed Frequency:2.457 GHZ Access Point: 40:3F:8C:B7:B4:24
				Bit Rate=24 Mb/s Tx-Power=31 dBm
				Retry short limit:7
				RTS thr:off
				Fragment thr: off
				Encryption key:off
				Power Management: on
				Link Quality=29/70 Signal level=-81 dBm
				Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
				Tx excessive retries: 198 Invalid misc:0 Missed beacon:0
khb@localhost: ~$

Done.

The problem here is that the last command must be executed after every reboot.

To automate this process, we can create a service that will be executed automatically with root (sudo) after every system starts. systemd will be used for this.

demo



  • create file: sudo touch /opt/netshift.sh

  • edit content: gedit admin:///opt/netshift.sh

  • add command (the last one from the above solution):

#!/bin/sh
sleep 20
iwconfig wlp3s0 txpower 10dBm
exit 0

actual command does not (and must not) contain sudo! That’s because in systemd it already has a root.

  • save and close
  • give execute permission to script sudo chmod u+x /opt/netshift.sh
  • create new systemd service:
sudo touch /etc/systemd/system/netshift.service
  • edit the new service:
gedit admin:///etc/systemd/system/netshift.service
[Unit]
Description=Netshift service
After=network.target

[Service]
ExecStart=/opt/netshift.sh

[Install]
WantedBy=multi-user.target
  • start service
sudo systemctl start netshift
  • enable service so he can be started on boot:
sudo systemctl enable netshift
  • reboot pc, wait 20 sec and wifi should auto-connect to prev network.

  • to remove service:

sudo systemctl stop netshift
sudo systemctl disable netshift
sudo rm -v /opt/netshift.sh
sudo rm -v /etc/systemd/system/netshift.sh

All this tutorial is available thanks to this post

Resources