This work is based off of the work by WANDS. Cheers!
This is modified version of the mainline Linux kernel Ath9k Qualcomm wireless driver. Incorporating changes similar to those found here, only for a more relevant kernel version.
I recommend not using an old distribution such as Ubuntu 14 etc as Ubuntu itself struggles to keep up to date, but an outdated Ubuntu version are hopelessly behind and will probably have problems with a modern kernel on ancient gcc
versions. eg. Ubuntu 14 uses gcc
4.8 which will give a lot of errors with a 5.4+ kernel.
Standard Linux kernel prerequisites are required
sudo pacman -S base-devel ncurses flex bison openssl libelf
sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev
The driver can be built in the kernel source tree or out of the kernel source tree. Below both methods are described.
Either way you will need a copy of the Linux kernel.
git clone https://github.com/torvalds/linux
cd linux
To build the module as part of the kernel you simply need to place the modified driver into the kernel source tree and perform a standard kernel build.
rm drivers/net/wireless/ath/ath9k/*
cp -r $(THIS REPO)/* drivers/net/wireless/ath/ath9k/
or run the patch to patch the changes into the ath9k folder. Please note this should be done from the directory in which the linux
folder is.
patch -sf -p0 < patches/ath9k.patch
You will need to prepare the kernel to run on the target system, this is done through a .config
file and it can be extracted from your existing system.
zcat /proc/config.gz > .config
cp /boot/config-$(uname -r) .config
You will then need to run menuconfig
or try olddefconfig
to synchronize the configs.
make menuconfig
or
make olddefconfig
You must then perform a normal kernel build and a kernel and module install
sudo make -j$(nproc) && sudo make modules_install -j$(nproc) && sudo make install -j$(nproc)
or to build just the ath9k driver
sudo make -j$(nproc) drivers/net/wireless/ath/ath9k/
reboot and check if your new kernel is installed, otherwise continue below.
My test machines run Ubuntu so I will detail the process for an Ubuntu machine. Arch machines are dependent on the bootloader you have chosen and, as such, harder to detail. This example below is for a 5.4 kernel.
Update your initframfs and your grub.
update-initramfs -c -k 5.4
update-grub
Set the kernel as the default for grub by modifying /etc/default/grub
sudo vim /etc/default/grub
Then add the following to the GRUB_DEAFULT
line so that it looks like the following
GRUB_DEAFULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.4"
finally reboot and check the new kernel is being used with uname -r
An out of tree build means that you simply pass the kernel tree into make with the -C
option. This is done using the KDIR
variable, set it appropriately.
As the Ath9k driver has the include structure of a potato it is challenging to build it out of tree as the driver has absolute include paths that traverse higher than the ath9k driver. One solution is to build the entire ath folder or to patch the ath folder to fix up the include fro the ath9k driver. Sorry other ath driver but I have better things to do with my time.
export KDIR=$HOME/linux # Assuming linux was cloned into home
sudo make -C $KDIR M=$KDIR/drivers/net/wireless/ath modules
or if you want to directly install the built module
sudo make -C $KDIR -M $KDIR/drivers/net/wireless/ath modules_install
and reboot.
An old build script I made when testing the WANDS Ubuntu 14 implementation. It should give an outline of the manual process, although the kernel build system should handle this automatically as detailed above.
The Travis CI config (.travis.yml
) also provides the steps necessary.