📡 Install driver for RTL8812BU wifi dongle on a Raspberry Pi

November 8, 2020

Recently I bought a wifi dongle (with the generic name AC1200) for my Raspberry Pi 3 (Model B) to extend its wifi range and quality (and adding support 5GHz connections).

First of all I connected the device to a free usb port and checked with lsusb if the device itself is recognized:

pi@raspberrypi:~ $ lsusb
Bus 001 Device 004: ID 0bda:b812 Realtek Semiconductor Corp.

The next step was to check if the wifi driver was able to load. A quick check with sudo iwconfig showed that no wifi device was detected 😕.

pi@raspberrypi:~ $ sudo iwconfig
eth0      no wireless extensions.

lo        no wireless extensions.

wlan0     IEEE 802.11  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on

After a short Google search with the usb device identifier which lsusb returned (0bda:b812), I was able to determine the used chipset (Realtek RTL8812BU). Sadly the default installation of Raspberry Pi OS (formerly Rasbian) don’t contain any driver for the chipset used in that dongle.

After various google searches here is my solution to compile and install the RTL88x2BU driver.

Install dependencies

First step is to install all required dependencies for the build. Keep also in mind, that the driver is build for the current installed kernel version. So performing an sudo apt update && sudo apt upgrade beforehand maybe useful. 🙂

sudo apt update
sudo apt install build-essential bc git wget libssl-dev bison flex dkms libncurses5-dev

Download kernel source files

To compile the driver we need the source code of the currently running kernel. Luckily the rpi-source tool takes care of that.

# Create build folder
mkdir ~/rtl8812bu-build/
cd ~/rtl8812bu-build/

# Download rpi-source tool
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

# Download kernel source (around ~150MB to download)
rpi-source

Install driver

cd ~/rtl8812bu-build/

git clone https://github.com/cilynx/rtl88x2bu.git

cd rtl88x2bu

Modify driver Makefile

To make the driver compile on a Raspberry Pi, some small adjustments to the Makefile are required. This to sed commands will do the job.

sed -i '/CONFIG_PLATFORM_I386_PC = y/c\CONFIG_PLATFORM_I386_PC = n' Makefile
sed -i '/CONFIG_PLATFORM_ARM_RPI = n/c\CONFIG_PLATFORM_ARM_RPI = y' Makefile

Compile driver

Now the fun begins 🙂 The following commands will compile and install the driver as Dynamic Kernel Module (DKMS). When everything works out the modprobe command will then load the compiled driver itself.

VER=$(sed -n 's/\PACKAGE_VERSION="\(.*\)"/\1/p' dkms.conf)

sudo rsync -rvhP ./ /usr/src/rtl88x2bu-${VER}

sudo dkms add -m rtl88x2bu -v ${VER}

sudo dkms build -m rtl88x2bu -v ${VER}

sudo dkms install -m rtl88x2bu -v ${VER}

sudo modprobe 88x2bu

Check if driver works

After the driver is loaded it can be check with sudo iwconfig if the wifi device is correctly loaded and ready to use. On my Raspberry Pi 3 (which have an onboard wifi card) the new device is added as wlan1. Now this can be used as any other wifi device.

pi@raspberrypi:~ $ sudo iwconfig
wlan1       IEEE 802.11AC ESSID:off/any Nickname:"<WIFI@REALTEK>"
            Mode:Managed  Access Point: Not-Associated
            Retry short limit:7   RTS thr:off   Fragment thr:off
            Encryption key:off
            Power Management:on

eth0      no wireless extensions.

lo        no wireless extensions.

wlan0     IEEE 802.11  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on

Please keep in mind, that the driver is compiled for the currently running kernel version. As soon as a kernel update is performed the driver will stop working and need the be compiled again.

Imprint & Privacy policy