网卡驱动设置

# 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](https://www.amazon.com/gp/product/B07LFC7VDC/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1), although it should work with any device that contains a Realtek 8821CU. 

## Instructions 

### From [brektrou](https://github.com/brektrou/rtl8821CU)'s instructions:

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

### Performing tweaks for driver to compile:

```bash
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. 

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

Then, locate this section of text inside the Makefile:

```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:

```makefile
... (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:

```bash
sudo apt-get update
sudo apt-get install dkms
```

### Running the installation script as superuser:

```bash
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:

```bash
lsusb
```

In this case my adapter showed up as:

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

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

```bash
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):

```bash
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):

```bash
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:

  ```bash
  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.

```bash
sudo systemctl stop NetworkManager
```

## Sources

- https://github.com/brektrou/rtl8821CU

- https://www.linuxbabe.com/command-line/ubuntu-server-16-04-wifi-wpa-supplicant

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值