Adding a driver to Linux

UPDATED 23/8/16

Revised instructions using a generic driver downloaded from Github. These instructions were needed for the same wireless adapter but under Xubuntu 16.04 the kernel used was a newer version meaning the manufacturer drivers wouldn’t work.

Firstly install the build headers etc

sudo apt-get install linux-headers-generic build-essential

Next thing is to download a generic package from the internet Github site:
https://github.com/gnab/rtl8812au/archive/master.zip

Unzip the file (choose “Extract here” in Archive Manager) and you will get a folder called rtl8812au-master

cd rtl8812au-master

Then build the driver

make
sudo make install
sudo modprobe 8812au

Then copy the module file to the modules folder

cp 8812au.ko /lib/modules/`uname -r 

Final step is to add it to /etc/modules
nano /etc/modules

Put 8812au onto the last line of the file and then save and quit.

This is coming up as expected. The main problem I am having is the system seems to spend all its time trying to detect a network on the ethernet adapter and consequently seems to run into problems with getting the wireless up or else it tries to access the internet through the non existent ethernet. I am still working to debug this at the time of writing. With a router connected supplying a DHCP address on the ethernet adapter the wireless came up and worked properly.


Original instructions using the manufacturer supplied driver (for matching kernel version 15/6/16

If you have a device driver and it comes with files to build a Linux driver, you may have to do some work to get it to load the driver when Linux starts up. I had this experience recently on testing a new wireless adapter for a desktop computer. The instructions supplied with the device were basically incomplete insofar as they only got you to the command needed to load the driver for the current session. The sequence needed to get the driver to load automatically on subsequent sessions was absent.

Let’s go back right to the beginning of what was needed to build this driver and have it loaded on startup. Since most of these commands need to be run as root, first thing to do is to change to root by using the su command.

Then we need to ensure build-essential is installed:

apt install build-essential

This ensures we have things like the Linux header files and the gcc compiler available for use.
Next was to copy the tar.gz file supplied by the manufacturer to the Downloads folder and then extract it with tar xfvz command sequence.
Then change into the directory it created to hold the extracted files.
Build the driver by executing
make

Test the resulting .ko file using insmod:
insmod 8821au.ko

At this point the driver is loaded into memory for only the current session. Since I wanted the driver to load in each session at startup I have to copy that 8821au.ko file to the right folder:
cp 8821au.ko /lib/modules/`uname -r`

The last bit of the command is a clever expansion that will ensure you go into the folder that corresponds to your current kernel version. Note that we aren’t using single quote marks, we are using backtick characters (the key to the left of 1 on most keyboards).
If you then use depmod it should come back with no errors
depmod -a

then use modprobe to ensure it will load
modprobe 8821au

(the .ko extension can be left off for modprobe)
Then use lsmod to check it is loaded.
Final step is to add it to /etc/modules
nano /etc/modules

Put 8821au onto the last line of the file and then save and quit.
Then restart the computer as the last test step.

In testing the system it was able to hotplug this USB wireless adapter with no issues (as it should be able to with a USB) so that is a good result.


Posted

in

by

Tags: