SOLVED! This took me weeks!
So itâs not in anyway intuitive or easy or documented 100%. Here is how you compile a module for a custom Linux build and install it:
Requirements:
- Must build on a normal Linux PC/kernel. The redirection of the RT kernel on Navio+ seems to prevent proper version calculation hence the never ending âBad EXE format/symbol version mismatchâ errors if you try. Wasted loads of time with that.
- Forget building on the Raspberry Pi it takes too long. In order to build the relatively small driver (âmoduleâ) you need access to the a copy of the source with the âModule.symversâ file specifically plus the other prepared headers. That means you have to run a âmake modulesâ on the Emlid RT kernel source.
- Follow the instructions on the Emlid LINUX-RT-RPI GitHub repository to download and build the source (and download the cross compiler also used for the driver).
- If using a 64bit development PC make sure you use the 64bit raspbian tools (cross-compiler). It may work on Ubuntu 14 (Linux 3.18) but will fail on Ubuntu 15 (Linux 3.19) with weird âcommand not foundâ errors.
- Download and re-(cross-)compile your driver. Usually this means editing the Makefile, selecting the ARM and Raspberry Pi build options and providing paths to the (Emlid) source and the cross-compiler (Raspbian Tools). There should be instructions with the driver on how to build. The target of the build is a â.koâ file, a Linux module.
Sometimes the original drivers wonât work because theyâre written for older kernel versions with depreciated functions. This is the case currently with the newer 802.11AC models from Edimax, what I was trying to get working. Luckily others have does this work for them, the âgnabâ user on GitHub is one example. Heâs created a ârtl8812auâ repository with fixed source code so all the new AC wireless adapters will work!
Iâm going to write all this up into a detailed article, but for now people wishing to play with the newer WiFi adapters with a Raspberry Pi 2 on the current â3.18.9-rt5-v7+â kernel build (exactly as downloaded from the Emlid web site) can try this driver:
Itâs a ZIP containing two versions of a built 8812au.ko module (driver), one with power saving on and one with those functions disabled (probably what you want for a drone). To install it do the following:
-
Download and extract the ZIP. You only need the 8812au.ko file from the directory named after the configuration you want (âPower Saveâ or âNo Power Saveâ).
-
Copy the file to the SD card of the Raspberry Pi, using the âsudoâ elevation because itâs in a system path (if you have the SD card mounted in another Linux machine you would prefix â/lib/âŚâ with the mount path, e.g. on Ubuntu itâs â/media///â):
sudo cp 8812au.ko /lib/modules/3.18.9-rt5-v7+/kernel/drivers/net/wireless/
sudo chmod 644 /lib/modules/3.18.9-rt5-v7+/kernel/drivers/net/wireless/8812au.ko -
Boot the Raspberry Pi and run the following command to install the driver:
sudo insmod /lib/modules/3.18.9-rt5-v7+/kernel/drivers/net/wireless/8812au.ko
sudo depmod -a $(uname -r) -
Check the driver loaded, you should see 8812au in the list:
lsmod
-
Check the WLAN adapter has initialized:
iwconfig
-
Follow instructions to configure the WLAN0 interface and WPA_SUPPLICANT. Iâm writing an article on that too, but for now you can get a quick start here:
Note: This modified version by GNAB is not perfect. Although it seems to run reliably when configured correctly, when playing with settings you may find a kernel fault occurs and the system locks-up, specifically when editing the âwpa_supplicant.confâ file. To correct this, remove the adapter, power-cycle then correct the configuration before re-inserting it.
One example I found is when configuring Ad-Hoc/IBSS/P2P mode but not specifying a frequency. Looking at the source shows he did not convert all the functions to the newer kernel, so there are some special cases when itâs trying to print debug messages and falling-over because it contains the old code. I plan to get the latest code from Realtek somehow and re-implement this later, but hope Edimax do the right thing and update their Linux drivers first.