This post is a guide on how to prepare the firmware for a USB AC Wifi adapter with the RTL8811CU chipset.
I had read that the firmware of a USB Wifi adapter with the RTL8811au chipset would be supported by upcoming OSMC updates. Armed with this knowledge I order a Wifi USB adapter from Aliexpress for my rpi2 that was advertised as including the RTL8811au chipset. Once it arrived, the USB Wifi instead included the RTL8811cu, a different chipset. Most of the AC USB Wifi dongles seems pretty much similar so I suspect this is not a unique case of a RTL8811au advertised chipset arriving as a RTL8811cu. Anyway, I managed to build the firmware and my rpi2 is now able to connect to 5Ghz Wifi networks.
I followed the guide from the following github page: [url]https://github.com/brektrou/rtl8821CU[/url]
However, when running DKMS-install.sh it will break as some of the linux-headers files from OSMC are missing. To resolve this issue, go to kernel.org and download the kernel source.
I downloaded the kernel linux-4.19.146, extracted the tar and then copied the /include/linux to the folder where the firmware was being build (~/rtl8821CU in my case). I then replaced the OSMC kernel headers with the downloaded ones.
sudo apt install rbp2-headers-$(uname -r)
sudo rm -r /usr/src/rbp2-headers-$(uname -r)/include/linux/*
sudo cp -ar ~/rtl8821CU/include/linux/* /usr/src/rbp2-headers-$(uname -r)/include/linux/
sudo ln -s /usr/src/rbp2-headers-$(uname -r) /lib/modules/$(uname -r)/build
After this, the command ./dkms-install.sh or make if not using dkms runs fine. Takes more than 20 mins to compile. The Pi 2 is not a powerful machine, be patient!
After it complied, I then was able to use the firmware.
sudo modprobe 8821cu
My final issue was specific to my USB dongle. Whenever the Pi was rebooted, it mounted as media storage as it included a partition for Windows drivers. I sourced the code from [url]https://github.com/uzh-rpg/rpg_dwa171_wifidongle[/url] to stop mounting as USB media on boot. If your dongle doesn’t include a partition with Windows drivers you don’t need this.
Created a file stopmounting.sh and included the following:
#!/bin/bash
# Sudo check
if [ "$EUID" -ne 0 ]
then echo "Please run this script with sudo"
exit
fi
# Install usb-modeswitch package is not available
echo 'Check if usb-modeswtich package is installed'
if dpkg --get-selections | grep -q "^usb-modeswitch\s*install$"; then
echo 'Package usb-modeswtich already installed! Continuing...'
else
echo 'Getting usb-modeswitch package'
if apt install -y usb-modeswitch; then
echo 'Package installed'
else
echo 'Could not get usb-modeswitch package. Exiting...'
exit
fi
fi
# Add script to switch usb mode
echo 'Adding script to switch USB mode to /usr/bin'
SCRIPT=/usr/bin/dwa171script
cat > $SCRIPT << EOL
#!/bin/bash
usb_modeswitch -KW -v 0bda -p 1a2b
EOL
# Make it executable
echo 'Making it executable'
if [ -e $SCRIPT ]; then
chmod +x $SCRIPT
else
echo "File $SCRIPT does not exist."
fi
# Create rule to run script as dongle gets mounted
echo 'Adding udev rule'
cat > /etc/udev/rules.d/dwa171.rules << EOL
ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="1a2b", RUN+="/usr/bin/dwa171script"
EOL
# Reload rules
echo 'Reloading udev rules'
udevadm control --reload-rules
# Done
echo 'Done, try plugging in the dongle'
Then made the file executable and ran the script.
sudo chmod +x stopmounting.sh
sudo ./stopmounting.sh
After this, it’s been plain sailing and no issues with connectivity so far.
I hope this helps people who are interested in having a USB Wifi 5Ghz dongle and were stuck with a RTL8811cu chipset.