Thursday, July 21, 2022

Alfa AWUS036ACH Driver on Devuan

    Well Prime day came and went recently. To my excitement, I was able to get a nice deal on a new Alfa AWUS036ACH USB Wi-Fi adapter! Upon receiving the adapter I quickly went to test it on the laptop only to find that Devuan didn't have the proper firmware to use the adapter. Dang!

root@Devuan:~# dmesg --follow
[ 1154.560128] usb 1-1.1.1: new high-speed USB device number 10 using ehci-pci
[ 1154.669536] usb 1-1.1.1: New USB device found, idVendor=0bda, idProduct=8812, bcdDevice= 0.00
[ 1154.669546] usb 1-1.1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1154.669550] usb 1-1.1.1: Product: 802.11n NIC
[ 1154.669553] usb 1-1.1.1: Manufacturer: Realtek
[ 1154.669556] usb 1-1.1.1: SerialNumber: 123456
...

root@Devuan:~# lsusb -d 0bda:8812 -v

Bus 001 Device 010: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Device Descriptor:
...
  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x8812 RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
  iManufacturer           1 Realtek
  iProduct                2 802.11n NIC
    Normally at this point, I'll check repositories for non-free firmware and hope that the distribution maintainers have already pre-packaged the needed firmware.

root@Devuan:~# apt-cache search 8812
firmware-realtek - Binary firmware for Realtek wired/wifi/BT adapters

root@Devuan:~# apt-cache show firmware-realtek | grep 8812
  * Realtek RTL8812AE Bluetooth firmware (rtl_bt/rtl8812ae_fw.bin)
  * Realtek RTL8821AEFW firmware (rtlwifi/rtl8812aefw.bin)
  * Realtek RTL8821AEFW wowlan firmware (rtlwifi/rtl8812aefw_wowlan.bin)

    Well that's a bummer. It doesn't appear that the realtek firmware package in Devuan's repository doesn't include the needed code for this new adapter! Well off to Alfa's site to see where the source is available. Luckily from the looks of it, Alfa has already shared a number of instructions for getting the driver working on different distributions here. A quick review of the page shows that Kali, Ubuntu, and Debian already have guides available which is really good news! So to get things started, the firmware needs to be downloaded. 

git clone https://github.com/morrownr/8812au-20210629.git

    Now at this point one could run the install script but it does request root privileges and I'm not a particularly trusting individual when it comes from code downloaded off the internet. So taking a look at the install script shows that there's only a handful of things that actually need root privileges (installing the module and the module's configuration file being the main items). Easy enough to get around.

aut0exec@devuan:~$ cd 8812au-20210629/
aut0exec@devuan:~/8812au-20210629$ make clean
aut0exec@devuan:~/8812au-20210629$ make

    Once the make process finishes, hopefully error free, there will be a file named 8812au.ko as well as 8812au.conf in the current directory. These files then need to be copied to the proper locations ('su -c' will prompt for root's password).

aut0exec@devuan:~/8812au-20210629$ su -c "cp 8812au.conf /etc/modprobe.d/"
aut0exec@devuan:~/8812au-20210629$ su -c "cp 8812au.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless/"
aut0exec@devuan:~/8812au-20210629$ su -c "/sbin/depmod $(uname -r)"

    After all of these steps, the module should be ready to go! One could simply reboot but this shouldn't be necessary; just unplug the adapter and plug it back in. 

root@Devuan:~# dmesg --follow
[ 6192.608297] usb 1-1.1.1: new high-speed USB device number 11 using ehci-pci
[ 6192.721143] usb 1-1.1.1: New USB device found, idVendor=0bda, idProduct=8812, bcdDevice= 0.00
[ 6192.721149] usb 1-1.1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 6192.721151] usb 1-1.1.1: Product: 802.11n NIC
[ 6192.721152] usb 1-1.1.1: Manufacturer: Realtek
[ 6192.721153] usb 1-1.1.1: SerialNumber: 123456
[ 6193.100284] usbcore: registered new interface driver rtl8812au  <--------SUCCESS!
[ 6193.117356] rtl8812au 1-1.1.1:1.0 wlx00c0caaff351: renamed from wlan1 <--SUCCESS!
...

root@Devuan:~# lsmod | grep 8812
8812au               2191360  0
cfg80211              970752  4 b43,8812au,mac80211,brcmsmac
usbcore               323584  5 ehci_pci,usbhid,ehci_hcd,8812au

root@Devuan:~# ip a sh dev wlan0
3: wlx00c0caaff351: <NO-CARRIER,BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state DORMANT group default qlen 1000
    link/ether de:ad:be:ef:c0:de brd ff:ff:ff:ff:ff:ff permaddr de:ad:be:ef:c0:de

Success! There is now an extra wireless adapter showing up in the output of the 'ip a' command as well as the new module shows as loaded in the output of 'lsmod'. Enjoy connecting to the all the networks!

No comments:

Post a Comment

Have a thought or question? Please share!