Edimax 7822 wifi USB dongle on Raspberry Pi 4

Basim Ali Yoshiguchi
3 min readJan 18, 2021

So you want to use an external wifi adapter on your Raspberry pi. Maybe you bought a new case for your Raspberry that contains metal and is disturbing the built-in antenna. Maybe you want more throughput for your homemade NAS or your sweet setup to play your PC games on your TV with the Raspberry. All of these things in many cases require a fast and stable wifi connection (unless you go for ethernet). I personally needed one because my Raspberry was on the edge of my network and wasn’t performing as well as I wanted for using Parsec to control my desktop or to play games on my PC from my living room.

So I bought the cheap but powerful “Edimax 7822” USB wifi dongle. I didn’t think twice, I just bought it, plugged it in, and expected the drivers to exist in Linux just like my old trusty TP-link TL-WN722N (that has the tried and tested Atheros chip). Turns out, that’s not the case. I had to do some digging and working things out to get it to run.

My Ol’Reliable TL-WN722N

Dude! Enough rambling, get to it already!

Ok sorry, I guess social isolation has affected me more than I thought. I’ll stop oversharing now… Let’s get to it!

Ok, so what we need to do in order to get it working is grab a modified version of a driver with the same chipset but another brand and model of a dongle. Cilinx on GitHub has been so kind as to modify this for us. So assuming you are using RaspiOS with a 32bit kernel, here is what to do.

So firstly, remove the USB dongle from the RPI4, this is important, or else it could make the installation fail!

Go ahead and open a terminal and update, upgrade and install prerequisites

# Update and Upgrade your system
sudo apt update
sudo apt upgrade

# Install prerequisites
sudo apt install git dnsmasq hostapd bc build-essential dkms raspberrypi-kernel-headers

# Reboot to refresh the system (not necessary but recommended)
sudo reboot

clone the driver repo with these commands. I cloned it inside a folder called “git_repos” in my home folder to keep things neat and tidy.

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

Now we need to compile and install the kernel module (driver) which enables support for our Wifi dongle. Since this driver is outside the default kernel source tree we will use the Dynamic Kernel Module Support (DKMS) CLI tool to configure, build and install the module. This is a framework that will recompile the driver automatically for you in case you upgrade the kernel which is super sweet. No need to go back and do it manually in the future.

We start preparing for the compilation. First we grab the package version from the dkms.conf to a variable called “VER”

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

We then copy all the necessary files to a folder in /usr/src (where your kernel source files reside).

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

We then tell dkms that “Listen, dude, this module is of importance to me, please use this and recompile it when necessary” In other words… We add it to the system as a kernel module.

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

Let’s build the binaries

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

--

--

Basim Ali Yoshiguchi
0 Followers

I am a playful Developer, Maker, UNIX geek, Mechatronics engineer. I love rapid prototyping and IoT and prefer to work with Electronics and product development.