Skip to content

Instantly share code, notes, and snippets.

@TOTON95
Created March 4, 2021 01:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TOTON95/b445509399a0d0314d2bc4079527f5a8 to your computer and use it in GitHub Desktop.
Save TOTON95/b445509399a0d0314d2bc4079527f5a8 to your computer and use it in GitHub Desktop.
Installing 8821CU driver in Jetson Nano

Installing 8821CU driver in Jetson Nano

The following guide is to install the driver for Realtek 8821CU into a fresh Jetson Nano official OS installation. This set of instructions is tested using a Techkey USB WiFi adapter, although it should work with any device that contains a Realtek 8821CU.

Instructions

From brektrou's instructions:

mkdir -p ~/8821CU/
cd ~/8821CU
git clone https://github.com/brektrou/rtl8821CU.git
cd rtl8821CU

Performing tweaks for driver to compile:

sudo cp /lib/modules/$(uname -r)/build/arch/arm64/Makefile /lib/modules/$(uname -r)/build/arch/arm64/Makefile.$(date +%Y%m%d%H%M)

sudo sed -i 's/-mgeneral-regs-only//' /lib/modules/$(uname -r)/build/arch/arm64/Makefile

Also we need to open and modify the target platform on the driver Makefile with a text editor, in this case is nano, but you can use whichever you prefer.

sudo apt-get install nano
nano ~/8821CU/rtl8821CU/Makefile

Then, locate this section of text inside the Makefile:

... (line 102 aprox)
##################### Platform Related #######################
CONFIG_PLATFORM_I386_PC = y
CONFIG_PLATFORM_ARM_RPI = n
CONFIG_PLATFORM_ARM64_RPI = n
CONFIG_PLATFORM_ANDROID_X86 = n
CONFIG_PLATFORM_ANDROID_INTEL_X86 = n
CONFIG_PLATFORM_JB_X86 = n
CONFIG_PLATFORM_ARM_S3C2K4 = n
...

Later, modify it to:

... (line 102 aprox)
##################### Platform Related #######################
CONFIG_PLATFORM_I386_PC = n
CONFIG_PLATFORM_ARM_RPI = n
CONFIG_PLATFORM_ARM64_RPI = y
CONFIG_PLATFORM_ANDROID_X86 = n
CONFIG_PLATFORM_ANDROID_INTEL_X86 = n
CONFIG_PLATFORM_JB_X86 = n
CONFIG_PLATFORM_ARM_S3C2K4 = n
...

With this modification, the common target to PC is turned off, and the ARM64 for Raspberry Pi is turned on. Although, this is meant for Rasberry Pi devices, it is an option that works in this case for a Jetson Nano.

Installing the driver

In these instructions the DKMS option is used, this is due to its ability to recompile the module and install it if the Linux headers are updated.

Install dkms:

sudo apt-get update
sudo apt-get install dkms

Running the installation script as superuser:

sudo ./dkms-install.sh

Plug the USB dongle into your Jetson Nano

  • If it works, good! You can proceed to connect to your WiFi AP using the GUI or CLI.
  • If it does not work, then continue with the following steps.

Additional steps after plug it in, and was not recognized as a WiFi adapter:

The USB ID is required to be known in order to change it later:

lsusb

In this case my adapter showed up as:

Bus 001 Device 005: ID 0bda:1a2b Realtek Semiconductor Corp. 

Later, an utility has to be installed to change the USB behavior:

sudo apt-get install usb_modeswitch

Then, to change the USB behavior the following command has to be executed, note that the vendor and product ID (-v and -p flags parameters have to match with your device):

sudo usb_modeswitch -KW -v 0bda -p 1a2b

Additionally, the bluetooth service has to be activated if inactive (not really sure why brektrou mentions it, but I suspect that is due to some adapters that are a combination of both and may have some relation at deeper level):

systemctl start bluetooth.service

By now, it should work, but this configuration is not permanent.

Make permanent available the configuration for the WiFi adapter

  • The usb_modeswitch rules need to be open for modification:

    sudo nano /lib/udev/rules.d/40-usb_modeswitch.rules
  • Append the following prior to LABEL="modeswitch_rules_end" line, which is located at the end-of-file. Again, make sure to match the vendor and product ID with your device as previous commands

    # Realtek 8211CU Wifi AC USB
    ATTR{idVendor}=="0bda", ATTR{idProduct}=="1a2b", RUN+="/usr/sbin/usb_modeswitch -K -v 0bda -p 1a2b"
    

Now, configuration is permanent on your system.

At this point it should be possible to connect to an WiFi AP by using GUI or CLI.

If you would like to do a headless setup, then follow the instructions at https://www.linuxbabe.com/command-line/ubuntu-server-16-04-wifi-wpa-supplicant. While paying attention to stop NetworkManager process, otherwise it won't let you scan and add your WiFi AP.

sudo systemctl stop NetworkManager

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment