Home Adding Hotstpot/AP mode support for MT7921 on Linux (stock / linux-g14 kernel)
Post
Cancel

Adding Hotstpot/AP mode support for MT7921 on Linux (stock / linux-g14 kernel)

Since the current Linux kernel drivers for MT7921 doesn’t support Monitor mode, I couldn’t enable the wifi hotspot through my Zephyrus G14 on Linux. So I found out that there is a patch available for the drivers which might come out on later Linux kernel releases. If you want, you can wait for the time being or try compiling the kernel with the patch by yourselves.

I will be showing you on how to apply the patch over both the stock and linux-g14 kernel. I’m using Arch Linux on Zephyrus-G14 GA401QH. applying the patch on stock firmware should most probably work for other laptops with MT7921 and could be performed similarly for other distros.

Patching and compiling stock kernel

First you need to copy the link for a stock kernel tarball for which you can go to the following link: kernel.org (I will be showing off commands with v5.17.9)

Then you can use the command to download the kernel tarball:

1
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.17.9.tar.xz

uncompress it

1
tar -xvJf linux-5.17.9.tar.xz

the cd into the directory

1
cd linux-5.17.9

Now for the patch, you can either use pwclient to download the patch and make some required changes (there’s a issue with patching header file causing implications.) or you can manually add the changes mentioned in the patchwork or just download the edited patch file by me.

Install pwclient and download the patch from pwclient if you want to download from patchwork and update the patch yourselves:

1
2
paru -S pwclient
pwclient get 12803979

changes to make:

either manually add the code at the end before #endif of mt7921.h or make a patch to do the following :

int mt7921_mcu_uni_add_beacon_offload(struct mt7921_dev *dev,
      struct ieee80211_hw *hw,
      struct ieee80211_vif *vif,
      bool enable);

file location: /drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h

after making changes or using edited patch, you can apply the patch using:

1
patch -Np1 < v2-mt76-mt7921-Add-AP-mode-support.patch

later on for how to compile and copy the kernel to the boot folder, you can follow this guide available on youtube (this can also help you in starting process):

Patching and compiling Linux-G14 kernel (Arch Build System):

The procedure here is a bit different since we will be using the arch build system and not the traditional method.

To download the linux-g14 kernel and to switch to v5.17 branch:

1
2
3
git clone https://gitlab.com/dragonn/linux-g14.git
cd linux-g14/
git checkout remotes/origin/5.17

Download the edited patch : link

edit PKGBUILD file, add the the patch file’s entire name (with extension) in quotes into the source list(array) just like other patch files.

screenshot

modified PKGBUILD (the patch might get added into the custom kernel, so checkout)

after making the change, run the following commands to compile and install the kernel:

1
2
3
updpkgsums
makepkg -s --skippgpcheck
sudo pacman -U linux-g14-headers-5.17.arch1-1-x86_64.pkg.tar.zst linux-g14-5.17.arch1-1-x86_64.pkg.tar.zst

Make sure to reboot into the newer kernel.

And Here we have the following results:

screenshot

You can use linux-wifi-hotspot for enabling hotspot. refer : Arch-Wiki

screenshot

This post is licensed under CC BY 4.0 by the author.