Manuel Bauer

Install driver for RTL8812BU wifi dongle on a Raspberry Pi

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 for 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 raspberrypi-kernel-headers

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 two 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, DKMS should compile the driver again.