I’m writing this as a homage to Building a module and to update that guide with my findings for building a module for the new emlid rpi2 image.
EDIT - save yourself the headache - use the 8812au.ko I built! https://drive.google.com/file/d/0BwD-7v5rSfICSlVfeWN1OXVsRmM/view?usp=sharing
EDIT - This doesn’t work - see my post below for how to actually get it working!
I follow this guide for most of what happens next - with a few tweaks along the way:
http://wannabe-nerd.tweakblogs.net/blog/10870/wifi-access-point-using-a-realtek-8192cu-based-usb-wifi-dongle-with-a-raspberry-pi.html
I’ve been trying to build rtl8812au drivers for about 10 days, so I’m going to use them as my example, and (of course) to prove my absolute mastery of all things.
We’re going to use rpi-source to get the sources we need to build our module - I’ve tried using linux-headers but for some reason during compilation I’d continually get an error like: ‘barriers.h - No such file or directory’.
This was demoralizing.
So, on to installing and running rpi-source:
$ cd ~ $ sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
you’ll also need a couple of libraries for rpi-source to compile your kernel’s modules correctly
$ sudo apt-get install libncurses5 libncurses5-dev build-essential
then you can run
$ rpi-source
(this will take some time - it’ll download and unpack your kernel source, then make the various modules that come along with it… took me about 4 minutes on a fresh install of the emlid image. There might be a few options it asks of you along the way - as far as I’m aware you can accept the defaults given)
I immediately got a gcc mismatch error, you can look at the guide I lined about and see how to install two versions of gcc… or…
$ rpi-source --skip-gcc
I’ll let you choose as to which one is a good use of your time.
We then need to create a symlink - if we dont’ do this the compilation can’t find stuff and it fails.
tl;dr: do this bit:
$ ln -s ~/linux/arch/arm ~/linux/arch/armv6l
The guide I was using then runs off and grabs a copy of the driver this guy was trying to compile. This was also a wifi card driver. We all love wifi driver installation on linux here, don’t we? anyway…
I’ll diverge slightly and go and get my drivers from gnab’s wonderful work:
$ git clone https://github.com/gnab/rtl8812au.git
$ cd rtl8812au
Now we need to edit the makefile to suit our build:
$ nano Makefile
change the following lines:
CONFIG_PLATFORM_I386_PC = y to CONFIG_PLATFORM_I386_PC = n
CONFIG_PLATFORM_ARM_RPI = n to CONFIG_PLATFORM_ARM_RPI = y
CONFIG_POWER_SAVING = y to CONFIG_POWER_SAVING = n
(ok, you don’t have to do that last one, but if you’re using this card in a drone, why would you want less than max power?!)
Now, for the moment of truth!
$ make
I got a few warnings, but I also got a file called 8812au.ko
which is the golden egg this wild goose chase has been about.
To install:
$ sudo make install
or to test:
$ sudo insmod 8812au.ko
–EDIT
This didn’t work - see below