Enabling TP-Link Archer TX20U Nano on NixOS and Linux 6.12

Published by Philipp Schuster on

Archer TX20U Nano

Recently, I’ve bought a TP-Link Archer TX20U Nano WiFi USB dongle (vendor website) for my desktop PC. The driver for Windows is provided by the stick itself, as it exposes a storage volume with the Windows driver on it. On Linux, the Windows driver doesn’t work, of course. However, with only minor modifications to the system’s NixOS configuration, we can leverage the already packaged out-of-tree driver for this device and use it for fast and stable WiFi connections when the device is plugged into our machine.

Low-Level Hardware Information

The WiFi chipset on the USB dongle is a Realtek rtl8852bu chipset. At first, the USB device exposes itself as USB storage/CDROM device with the hardware ID 0bda:1a2b. We have to switch its USB mode to WiFi mode. This can be done using usb_switchmode -K -v 0bda -p 1a2b. After that, the device exposes the hardware ID a35bc:0108 (the ID of the WiFi chipset) and the driver can attach.

NixOS Configuration

The following NixOS configuration snipped is all you additionally need.

{ config, lib, pkgs, ... }:

  boot.kernelModules = [
    "8852au"
  ];

  boot.extraModulePackages = [
    config.boot.kernelPackages.rtl8852bu # TP-Link Archer TX20U Nano
  ];

  services.udev.extraRules =
    # Switch Archer TX20U Nano from CDROM mode (default) to WiFi mode.
    ''
      ATTR{idVendor}=="0bda", ATTR{idProduct}=="1a2b", RUN+="${lib.getExe pkgs.usb-modeswitch} -K -v 0bda -p 1a2b"
    ''
  ;
}
Archer TX20U Nano
Archer TX20U Nano

Philipp Schuster

Hi, I'm Philipp and interested in Computer Science. I especially like low level development, making ugly things nice, and de-mystify "low level magic".

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *