Skip to content

Instantly share code, notes, and snippets.

@linux4life798
Last active May 4, 2024 20:28
Show Gist options
  • Save linux4life798/952d2164faab3fc0323924aa24e1b367 to your computer and use it in GitHub Desktop.
Save linux4life798/952d2164faab3fc0323924aa24e1b367 to your computer and use it in GitHub Desktop.

Manually Fix WIFI 6E Issue

sudo dpkg-divert --rename --add /usr/lib/firmware/mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
sudo dpkg-divert --rename --add /usr/lib/firmware/mediatek/WIFI_RAM_CODE_MT7922_1.bin
dpkg-divert --list
#pushd ~/src/linux-firmware/mediatek
#git checkout -f 0a18a7292a66532633d9586521f0b954c68a9fbc

pushd ~/Downloads
# We are using tag version 20240410 instead of version 0a18a7292a66532633d9586521f0b954c68a9fbc requested by Framework.
# The version they specified doesn't work reliably.
wget https://gitlab.com/kernel-firmware/linux-firmware/-/raw/20240410/mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
wget https://gitlab.com/kernel-firmware/linux-firmware/-/raw/20240410/mediatek/WIFI_RAM_CODE_MT7922_1.bin

for bin in WIFI_MT7922_patch_mcu_1_1_hdr.bin WIFI_RAM_CODE_MT7922_1.bin; do
	cat $bin | sudo tee /usr/lib/firmware/mediatek/$bin >/dev/null
done
popd

ls -al /usr/lib/firmware/mediatek/WIFI_{MT7922_patch_mcu_1_1_hdr,RAM_CODE_MT7922_1}.bin
# -rw-r--r-- 1 root root 137632 Apr 20 17:00 /usr/lib/firmware/mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
# -rw-r--r-- 1 root root 831860 Apr 20 17:00 /usr/lib/firmware/mediatek/WIFI_RAM_CODE_MT7922_1.bin

md5sum /usr/lib/firmware/mediatek/WIFI_{MT7922_patch_mcu_1_1_hdr,RAM_CODE_MT7922_1}.bin
# 35039ab85bbad3db23a8d5227781b6b9  /usr/lib/firmware/mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
# f647ffe6cf1cc4cd9d164eeb2053a5b4  /usr/lib/firmware/mediatek/WIFI_RAM_CODE_MT7922_1.bin

Undo This Later

sudo rm /usr/lib/firmware/mediatek/WIFI_{MT7922_patch_mcu_1_1_hdr,RAM_CODE_MT7922_1}.bin
sudo dpkg-divert --rename --remove /usr/lib/firmware/mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
sudo dpkg-divert --rename --remove /usr/lib/firmware/mediatek/WIFI_RAM_CODE_MT7922_1.bin

dpkg-divert --list

# You could reinstall if something the fix renaming above fail for some reason, but
# you need to ensure the diversions are removed.
#sudo rm /usr/lib/firmware/mediatek/WIFI_{MT7922_patch_mcu_1_1_hdr,RAM_CODE_MT7922_1}.bin*
#sudo apt install --reinstall firmware-misc-nonfree

Initial Conditions

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux trixie/sid
Release:	n/a
Codename:	trixie

$ dpkg -l firmware-misc-nonfree
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                  Version      Architecture Description
+++-=====================-============-============-=======================================================
ii  firmware-misc-nonfree 20230625-2   all          Binary firmware for various drivers in the Linux kernel
md5sum WIFI_MT7922_patch_mcu_1_1_hdr.bin WIFI_RAM_CODE_MT7922_1.bin
# 27691b6904f8f3dc27d2fb8d2d2961a9  WIFI_MT7922_patch_mcu_1_1_hdr.bin
# f5df1028fc39373eefbf11f8ab2716fd  WIFI_RAM_CODE_MT7922_1.bin

Checkout https://github.com/linux4life798/framework-linux-docs/blob/main/ubuntu-22.04-fw-16.md for the git version.

To see the diff between the Debian 20230625 version of the firmware and the git version requested by framework, see https://gitlab.com/kernel-firmware/linux-firmware/-/compare/20230625...0a18a7292a66532633d9586521f0b954c68a9fbc .

# Showing the diff between the Debian firmware versions and the framework requested version.

$ git log 20230625...0a18a7292a66532633d9586521f0b954c68a9fbc -- mediatek/|cat
commit 0a18a7292a66532633d9586521f0b954c68a9fbc
Author: Deren Wu <deren.wu@mediatek.com>
Date:   Thu Nov 16 16:18:19 2023 +0800

    linux-firmware: update firmware for MT7921 WiFi device
    
    Update binary firmware for MT7921 WiFi devices
    
    File: mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin
    Version: 20231109190918a
    File: mediatek/WIFI_RAM_CODE_MT7961_1.bin
    Version: 20231109190959
    
    Signed-off-by: Deren Wu <deren.wu@mediatek.com>
    Signed-off-by: Josh Boyer <jwboyer@kernel.org>

commit 5e9fdab57258fadff7e02979de294dbbb51e7a48
Author: Jason Chen <Jason-ch.Chen@mediatek.com>
Date:   Tue Nov 21 16:17:35 2023 +0800

    mediatek: Remove an unused packed library
    
    Internal version: cherry_scp_v2.0.23042-e27728578
    Release version: v2.0.23042
    
    Signed-off-by: Jason Chen <Jason-ch.Chen@mediatek.com>

commit a41fa7c5008809ae360ce0808e378b37b1d6c0f4
Author: Jason Chen <Jason-ch.Chen@mediatek.com>
Date:   Mon Nov 20 16:11:40 2023 +0800

    mediatek: Sync shared memory structure changes
    
    Internal version: cherry_scp_v2.0.23033-543477593
    Release version: v2.0.23033
    
    Signed-off-by: Jason Chen <Jason-ch.Chen@mediatek.com>

commit 6910095b2c6c71ab3af2c0bbe8f1204774a947a9
Author: SkyLake.Huang <skylake.huang@mediatek.com>
Date:   Mon Nov 13 15:58:18 2023 +0800

    linux-firmware: add firmware for mt7988 internal 2.5G ethernet phy
    
    This patch adds firmware file of version 2023/07/28 for mt7988 internal 2.5G
    ethernet phy.
    
    Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>

commit f41d890ac9e3540caf59cbda34be50a6ebef31f3
Author: Yunfei Dong <yunfei.dong@mediatek.com>
Date:   Sat Jul 22 16:04:00 2023 +0800

    mediatek: Update mt8195 SCP firmware to support 10bit mode
    
    Internal version: cherry_scp_v2.0.21961+9474b1930 private-mt-scp:v0.0.127+e00cea1
                      cherry_scp_15268.0.23_07_21 2023-07-21 18:39:41
    Release version: v2.0.21961
    
    Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>

commit 8917650bc36918fb745149eff878488757524d6f
Author: Chris Lu <chris.lu@mediatek.com>
Date:   Thu Jun 29 18:01:21 2023 +0800

    linux-firmware: update firmware for mediatek bluetooth chip (MT7922)
    
    Update binary firmware for MT7922 BT devices.
    
    File: mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin
    Version: 20230627144220
    
    Signed-off-by: Chris Lu <chris.lu@mediatek.com>
    Signed-off-by: Josh Boyer <jwboyer@kernel.org>

commit 7d9af0923a0fb1606a20d666f8e33390ba245663
Author: Deren Wu <deren.wu@mediatek.com>
Date:   Thu Jun 29 17:51:42 2023 +0800

    linux-firmware: update firmware for MT7922 WiFi device
    
    Update binary firmware for MT7922 WiFi devices
    
    File: mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
    Version: 20230627143702a
    File: mediatek/WIFI_RAM_CODE_MT7922_1.bin
    Version: 20230627143946
    
    Signed-off-by: Deren Wu <deren.wu@mediatek.com>
    Signed-off-by: Josh Boyer <jwboyer@kernel.org>
@linux4life798
Copy link
Author

linux4life798 commented Apr 21, 2024

I have this issue with resuming from sleep. It seems to take about 35 seconds to resume from sleep and wake the screen.

At the 35 second mark, I see usb devices and the keyboard backlights flash, like they have been reinitialized, and then I see the display finally turn on. After unlocking, dmesg shows kernel backtraces.

I have tried to enable rtc_cmos.use_acpi_alarm=1 in the kernel command line parameters, like discussed in https://github.com/linux4life798/framework-linux-docs/blob/main/ubuntu-22.04-fw-16.md#suspend-keeps-waking-up-or-fails-to-suspend, but it doesn't make a difference.

@linux4life798
Copy link
Author

Also, this pinned firmware version for the Mediatek MT7922 still doesn't fix the issue with wifi 6e most of the time.

@linux4life798
Copy link
Author

linux4life798 commented Apr 21, 2024

It looks like there has been quite a few more updated to the mediatek firmware, since the 0a18a7292a66532633d9586521f0b954c68a9fbc version.

I'll try the latest tag 20240410:

pushd ~/Downloads
gio trash WIFI_*.bin
wget https://gitlab.com/kernel-firmware/linux-firmware/-/raw/20240410/mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
wget https://gitlab.com/kernel-firmware/linux-firmware/-/raw/20240410/mediatek/WIFI_RAM_CODE_MT7922_1.bin

for bin in WIFI_MT7922_patch_mcu_1_1_hdr.bin WIFI_RAM_CODE_MT7922_1.bin; do
	cat $bin | sudo tee /usr/lib/firmware/mediatek/$bin >/dev/null
done
popd

Results:

  • It connected once.

  • It remained connected or resumed connectivity across sleep and resume.

  • It connected again, after reboot!

  • It connected a third time after shutdown and startup. This seems like the fix. I will update the main tutorial.

  • It connected a fourth time after shutdown and startup.

  • I do need to note that it doesn't seem to be cleanly connected to the AP. It seems like it tries to auth many times, aborts auth citing by local choice (Reason: 3=DEAUTH_LEAVING), but eventually connects.

  • Failed to connect after machine sat idle for a bit and probably went to sleep. Here were the kernel messages:

    [13873.049482] PM: suspend exit
    [13876.040571] wlp1s0: authenticate with ae:4c:a5:ab:cd:ef
    [13876.076204] wlp1s0: send auth to ae:4c:a5:ab:cd:ef (try 1/3)
    [13876.103905] wlp1s0: authenticate with ae:4c:a5:ab:cd:ef
    [13876.112854] wlp1s0: send auth to ae:4c:a5:ab:cd:ef (try 1/3)
    [13879.152341] wlp1s0: send auth to ae:4c:a5:ab:cd:ef (try 2/3)
    [13881.117940] wlp1s0: aborting authentication with ae:4c:a5:ab:cd:ef by local choice (Reason: 3=DEAUTH_LEAVING)
    [13895.414979] wlp1s0: authenticate with ae:4c:a5:ab:cd:ef
    [13896.464028] wlp1s0: send auth to ae:4c:a5:ab:cd:ef (try 1/3)
    [13899.504255] wlp1s0: send auth to ae:4c:a5:ab:cd:ef (try 2/3)
    [13914.460942] wlp1s0: authenticate with ae:4c:a5:ab:cd:ef
    [13915.503836] wlp1s0: send auth to ae:4c:a5:ab:cd:ef (try 1/3)
    [13916.527825] wlp1s0: send auth to ae:4c:a5:ab:cd:ef (try 2/3)
    [13917.551781] wlp1s0: send auth to ae:4c:a5:ab:cd:ef (try 3/3)
    [13917.564573] wlp1s0: authentication with ae:4c:a5:ab:cd:ef timed out
    

@linux4life798
Copy link
Author

This firmware + kernel does not fix the WiFi, BTW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment