Building a Module - Navio2

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

1 Like

Oh wait.
It didn’t work.
:rage:

sudo insmod 8812au.ko

gives me ‘Invalid module format’

I’m about to go on a rampage, this is vexing.

Working now!

I found an updated driver:

The instructions on the readme are a good start, but I still had to edit the Makefile to point at the rpi-source downloaded kernel source that I’d achieved in my above guide.

1 Like

:joy:

Congrats on finding the solution and many thanks for posting it!

oh, and for anyone who needs a 8812au.ko module and doesn’t want to build it the painful way…

https://drive.google.com/file/d/0BwD-7v5rSfICSlVfeWN1OXVsRmM/view?usp=sharing

Hey Mike,

great that you solved the problem! But unfortunately I can`t get it working because I am not so familiar with Linux. The thread is starting with a mix of what is needed and parts that were not working and ends with a link to a ready 8812au.ko file. But how to install this ready? driver via cli comands? Noob - I know :-), but hope you can help.

Hi Tom,

Yeah, it’s a bit confusing, I know!

In the end I’ve actually had to cross-compile the whole kernel and the module on a Ubuntu machine (and even this has issues, as I had to use a different compiler for the kernel and the module as well)

To install a module you need " sudo insmod 8812au.ko" - this will work until you restart the device.

To install a module permantently, you need “sudo modprobe 8812au.ko”

Hope that helps!

Mike

@Mikebert4 @tOm we now have kernel headers pre-installed in the new image, so it should be possible to compile the modules on the RPi2\3 itself.

1 Like

@Mikebert4 @igor.vereninov

Hi Mike, Hi mikhailavkhimenia,

today I tred with the new image, but I run in the same problems. I did so far:

git clone https://github.com/meoow/dkms-rtl8812au.git

sudo cp -r dkms-rtl8812au/8812au-4.3.8 /usr/src

sudo dkms install 8812au/4.3.8

After that is ready, I have the module 8812au.ko but:
$ sudo modprobe /lib/modules/4.4.6-4d0ae01-emlid-v7+/kernel/drivers/net/wireless/8812au.ko

=> modprobe: FATAL: Module /lib/modules/4.4.6-4d0ae01-emlid-v7+/kernel/drivers/net/wireless/8812au.ko not found.

pi@navio:/ $ dir /lib/modules/4.4.6-4d0ae01-emlid-v7+/kernel/drivers/net/wireless
8812au.ko b43legacy libertas_tf p54 zd1201.ko
at76c50x-usb.ko brcm80211 mac80211_hwsim.ko realtek zd1211rw
ath hostap mediatek rndis_wlan.ko
b43 libertas mwifiex rt2x00

Where is the mistake? The file exists but cannot be found …

@tOm, what does simple “sudo modprobe 8812au” output?

Hi Mikhail,
that brings no error but also nothing else. No wlan if, but the Driver seems to be loaded but not with the real used hardware (DLink DW 171, 802.11ac and other Serial). Idea? Hope you have …

[ 26.207117] usb 1-1.2: Product: 802.11n WLAN Adapter
[ 26.207129] usb 1-1.2: Manufacturer: Realtek
[ 26.207140] usb 1-1.2: SerialNumber: 00e04c000001
[ 124.272416] RTL871X: module init start
[ 124.272445] RTL871X: rtl8812au v4.3.8_12175.20140902
[ 124.272454] RTL871X: build time: Apr 14 2016 13:33:02
[ 124.272681] usbcore: registered new interface driver rtl8812au
[ 124.272698] RTL871X: module init ret=0
pi@navio:~ $ lsusb
Bus 001 Device 005: ID 2001:3314 D-Link Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@navio:~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:74:e8:5e
inet addr:192.168.88.110 Bcast:192.168.88.255 Mask:255.255.255.0
inet6 addr: fe80::d197:6e59:1d9a:718a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1252 errors:0 dropped:0 overruns:0 frame:0
TX packets:804 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:124234 (121.3 KiB) TX bytes:156386 (152.7 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:200 errors:0 dropped:0 overruns:0 frame:0
TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:16656 (16.2 KiB) TX bytes:16656 (16.2 KiB)

pi@navio:~ $

we now have kernel headers pre-installed in the new image, so it should be possible to compile the modules on the RPi2\3 itself.

Heros.

1 Like

Seems like the module is loaded and the device is working. Probably something is wrong with the network configuration or maybe you need to add a rule for udev, I’m not sure.

I would recommend to use a WiFi adapter that is already supported by the kernel\raspbian.

Hi Mike,

Thank you for the module! Unfortunately, I cannot install it. Both “sudo insmod 8812au.ko” and “sudo modprobe 8812au.ko” failed (it says module not found). Any idea? Thank you!

Fixed here.