I'm having trouble to compile and use drivers for dwa-171 wifi usb. I have tried a lot of things but currently i'm unable to load module.

Recap of what i have done so far:

Getting kernel sources:
  mkdir src && cd src
  git clone --depth 500 https://github.com/raspberrypi/linux.git
  git clone --depth 15 https://github.com/raspberrypi/firmware.git
Link sources:
  sudo ln -s /home/pi/src/linux /lib/modules/$(uname -r)/build
  sudo ln -s /home/pi/src/linux/arch/arm /home/pi/src/linux/arch/armv6l
Preparing to compile modules
  make mrproper && make menuconfig && make modules_prepare
  cp ../firmware/extra/Module.symvers .
Get drivers and compile
  git clone https://github.com/gnab/rtl8812au
  cd rtl8812au/
  *edit Makefile for raspberry*
  make clean && make && make install
Insert fresh module
  insmod 8812au.ko

Which return me: Error: could not insert module 8812au.ko: Invalid module format

I haven't made much more progress, trying different stuff without success. Any help will be greatly appreciated. Thank you :)


Solved, somes errors where mades when creating kernel config file. Copying current config and recompile does the job.

zcat /proc/config.gz > ./.config
  • Does this USB dongle explicitly require a driver? Most of them will work right out of the box. All you have to do is edit a network entry in wpa_supplicant.conf. Jan 2, 2015 at 0:10
  • @JamesTaylor It does require 8812au driver which is not in the rpi out of the box modules.
    – Cyrbil
    Jan 3, 2015 at 14:40
  • Followed "Recap of what i have done so far" on a Pi 2 model B. Cannot make for some reason. Anyone else run into this? sudo make make ARCH=arm CROSS_COMPILE= -C /lib/modules/3.18.7-v7+/build M=/opt/rtl8812au modules make[1]: Entering directory '/lib/modules/3.18.7-v7+/build' make[1]: *** No rule to make target 'modules'. Stop. make[1]: Leaving directory '/lib/modules/3.18.7-v7+/build' Makefile:1051: recipe for target 'modules' failed make: *** [modules] Error 2
    – Richard
    Apr 1, 2015 at 16:53
  • Near duplicate: raspberrypi.stackexchange.com/q/28307/5538
    – goldilocks
    Oct 1, 2016 at 16:59

2 Answers 2


Retrying from scratch did the job. Main error was the kernel config file. So copying current raspbian running config file correct this.

Here is the full list of command to compile the drivers.

  1. Get a fresh raspbian, use raspi-config to expand disk and allow maximum ram (16 or 32 only to gpu), then reboot.
  2. Update and install dependancies:

    sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
    sudo apt-get install  build-essential bc libncurses5-dev
  3. Clone raspberry linux kernel. (make some tea)

    git clone http://github.com/raspberrypi/linux rpi-kernel
    cd rpi-kernel

    You may want to dl only your desired version

    # replace 3.12 to the one you want, see uname -r to current
    wget -c https://codeload.github.com/raspberrypi/linux/tar.gz/rpi-3.12.y
    tar xavf rpi-3.2.y
    rm rpi-3.2.y
    cd linux-rpi-3.12.y
  4. Copy or Create config file

    • Copy from current config

      zcat /proc/config.gz > ./.config
    • Create new one

      make bcmrpi_defconfig
  5. (Optionnal) If you want to tune in some features: make menuconfig.

  6. Build kernel: make (Very long (about 7h), maybe use cross compile or go to bed)

  7. Build and install modules: make modules_install

  8. Set up for building external modules: make modules_prepare

  9. Install headers: sudo make headers_install

  10. Install kernel: sudo make zinstall then reboot (you can look uname -a before and after to ensure kernel is installed)

  11. Get driver sources (from gnab's modified version because it include config for rpi)

    git clone https://github.com/gnab/rtl8812au
    cd rtl8812au
    nano Makefile # <-- pick RPI platform and disable others
  12. Build module: make (Time to make tea again)

  13. Install module: sudo make install

  14. Load module: modprobe 8812au

  15. Your usb dongle should work and an interface should be shown in iwconfig

You should now have drank two cup of tea, a nice night of sleep and a working driver for your wifi dongle

  • 1
    first thank you for the instruction, but I'm facing a challenge as well on step 12. When I tried make, I get this error; make make ARCH=arm CROSS_COMPILE= -C /lib/modules/3.18.7-v7+/build M=/home/pi/rtl8812au modules make[1]: *** /lib/modules/3.18.7-v7+/build: No such file or directory. Stop. Makefile:1051: recipe for target 'modules' failed make: *** [modules] Error 2 Please advise and thank you in advance.
    – user28671
    Apr 4, 2015 at 12:07
  • It was a long, i remember having your error but cant recall what i did to solved it. My thought would be, check your kernel sources and makefile options.
    – Cyrbil
    Apr 5, 2015 at 13:02

This answer is actually the same answer I gave to the problem described in DWA-171 using 8812au.ko does not seem to work on Linux kernel version 3.18.8+.

I recently stumbled upon similar problems when I was trying to find a driver for my Edimax EW-7811UTC which uses the same chipset as the D-Link DWA-171. I had to realize that while OpenELEC for instance does come with a driver for the Edimax EW-7811UTC out of the box, Raspbian doesn’t.

I found a small tool called rpi-source that is able to install the kernel sources used to build the kernel on your Raspbian image. It's supposed to work for Raspberry Pis 1 and 2 and kernels starting from version 3.10.37.

I've tested following procedure to compile and install the rtl8812au driver on a Raspberry Pi 2 Model B running Raspbian in different versions:

  • Raspbian Jessie release 2016-05-27 using kernel version 4.4.11-v7+
  • Raspbian Jessie release 2016-09-23 using kernel version 4.4.21-v7+
# install necessary software
sudo apt-get update
sudo apt-get install bc git

# download raspbian kernel sources, takes some minutes
sudo wget "https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source" -O /usr/bin/rpi-source
sudo chmod 755 /usr/bin/rpi-source

# download the rtl8812au kernel driver and compile it, takes some minutes
git clone "https://github.com/gnab/rtl8812au"
cd rtl8812au
sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile
# copy the driver and use it
sudo cp 8812au.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless
sudo depmod -a
sudo modprobe 8812au

# check wlan0 interface appeared

I also created an Ansible role called raspbian-rtl8812au you can use to automate the driver setup in an Ansible playbook.


Not the answer you're looking for? Browse other questions tagged or ask your own question.