OrangePi-PCを使ってみる

Free Driver WiFi Module


2020年ごろからFree Driverと呼ばれるUSB WiFiモジュールが入手できるようになりました。
これはWindowsで使うことを前提とした製品で、Windowsマシンに刺すとUSBメモリー、あるいはCD-ROMドライブとして認識され ます。
ドライブをクリックすると内蔵されているWindows用のドライバーが自動的にシステムに組み込まれ、
WiFiモードに切り替わるという、なんともユニークな製品です。

今回、RTL8188GUのFreeDrive製品を入手しましたので紹介します。

Ubuntuを起動後に、これを刺すと以下の様にRTL8188GUとして認識されます。
$ lsusb
Bus 002 Device 003: ID 0bda:1a2b Realtek Semiconductor Corp.

この時点では、このデバイスはCD-ROMとして動作しています。
起動前に刺してしまうと、BIOSの設定によっては、CD-ROM(このデバイス)からブートしようとして起動できません。

次に以下のコマンドを実行します。
$ sudo apt install usb-modeswitch

$ sudo usb_modeswitch -KW -v 0bda -p 1a2b
Take all parameters from the command line


 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.5.2 (C) Josua Dietze 2017
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x0bda
DefaultProduct= 0x1a2b

StandardEject=1

Look for default devices ...
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
  found USB ID 8087:0024
  found USB ID 1d6b:0002
  found USB ID 8087:0024
  found USB ID 1d6b:0002
 Found devices in default mode (1)
Access device 003 on bus 002
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 8
Use endpoints 0x0b (out) and 0x8a (in)

USB description data (for identification)
-------------------------
Manufacturer: Realtek
     Product: DISK
  Serial No.: not provided
-------------------------
Sending standard EJECT sequence
Looking for active drivers ...
 OK, driver detached
Set up interface 0
Use endpoint 0x0b for message sending ...
Trying to send message 1 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response successfully read (13 bytes), status 1
Trying to send message 2 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 2 (CSW) ...
 Response successfully read (13 bytes), status 0
Trying to send message 3 to endpoint 0x0b ...
 Sending the message returned error -1. Try to continue
Read the response to message 3 (CSW) ...
 Response reading failed (error -1)
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

これで動作モードがCD-ROMモードからWiFiモードに切り替わります。
lsusbでIDを確認するとIDが変わり、RTL8811CUと認識されます。
$ lsusb
Bus 002 Device 004: ID 0bda:c811 Realtek Semiconductor Corp.

Armbianでは動作モードを切り替えるための設定が最初から登録されています。
これにより、Armbianではこのデバイスを最初からWiFiモジュールとして認識します。
$ sudo vi /lib/udev/rules.d/40-usb_modeswitch.rules

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

RTL8811CUは802.11 a/b/g/n/acに対応している貴重なモジュールです。
Ubuntuなどでも、同じファイルに設定を追加することで、WiFiモードに切り替えることができます。
あとはRTL8811CUのWiFiドライバーを入れれば動きます。



もう1つ別のFreeDriver製品を入手しました。
Ubuntuマシンを起動後に、これを刺すと以下の様に認識されます。
上の製品と同じRTL8188GU(0bda:1a2b)です。
$ lsusb
Bus 002 Device 005: ID 0bda:1a2b Realtek Semiconductor Corp.

Debianでは、ずばりCDROMモードと表示されます。
$ lsusb
Bus 003 Device 002: ID 0bda:1a2b Realtek Semiconductor Corp. RTL8188GU 802.11n WLAN Adapter (Driver CDROM Mode)

次に以下のコマンドを実行します。
$ sudo usb_modeswitch -KW -v 0bda -p 1a2b
Take all parameters from the command line


 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.5.2 (C) Josua Dietze 2017
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x0bda
DefaultProduct= 0x1a2b

StandardEject=1

Look for default devices ...
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
  found USB ID 8087:0024
  found USB ID 1d6b:0002
  found USB ID 8087:0024
  found USB ID 1d6b:0002
 Found devices in default mode (1)
Access device 005 on bus 002
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 8
Use endpoints 0x0b (out) and 0x8a (in)

USB description data (for identification)
-------------------------
Manufacturer: Realtek
     Product: DISK
  Serial No.: not provided
-------------------------
Sending standard EJECT sequence
Looking for active drivers ...
 OK, driver detached
Set up interface 0
Use endpoint 0x0b for message sending ...
Trying to send message 1 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response successfully read (13 bytes), status 1
Trying to send message 2 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 2 (CSW) ...
 Response successfully read (13 bytes), status 1
Trying to send message 3 to endpoint 0x0b ...
 Sending the message returned error -1. Try to continue
Read the response to message 3 (CSW) ...
 Response reading failed (error -1)
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

これで動作モードがCD-ROMモードからWiFiモードに切り替わりますが、上の製品とは別のRTL8188GU(0bda:b711)となり ます。
$ lsusb
Bus 002 Device 006: ID 0bda:b711 Realtek Semiconductor Corp.

Debianではもっと親切に表示されます。
$ lsusb
Bus 003 Device 003: ID 0bda:b711 Realtek Semiconductor Corp. RTL8188GU 802.11n WLAN Adapter (After Modeswitch)

つまり、モード切替前にRTL8188GU(0bda:1a2b)として認識される製品でも、
モード切替後のIDはRTL8811CU(0bda:c811)だったり、RTL8188GU(0bda:b711)だったりします。

モード切替後にRTL8811CU(0bda:c811)になるものはArmbianで動きますが、RTL8188GU(0bda:b711)に なるものは動きません。
RTL8188GU(0bda:1a2b)として売られている製品でも、Armbianで動く製品とArmbianで動かない製品が有るのはこの ためで、
これが混乱の原因にもなっています。

RTL8188GU(0bda:1a2b)→RTL8811CU(0bda:c811)の製品は5Ghz帯をサポートしていますが、
RTL8188GU(0bda:1a2b)→RTL8188GU(0bda:b711)の製品は5Ghz帯をサポートしていません。



モード切替後にRTL8188GU(0bda:b711)と認識される製品は、Armbian標準のドライバーでは動きません。
こちらのドライバーを追加すると動く ようになります。
$ sudo apt install build-essential dkms

$ git clone https://github.com/McMCCRU/rtl8188gu

リポジトリにはdkms.confが含まれていないので、dkms.confを自分で作る必要が有ります。
以下の内容でdkms.confを作ります。
$ cat rtl8188gu/dkms.conf
PACKAGE_NAME="rtl8188gu"
PACKAGE_VERSION="1.0.1"
BUILT_MODULE_NAME[0]="8188gu"
MAKE="'make' KVER=${kernelver}"
CLEAN="'make' clean"
DEST_MODULE_LOCATION[0]="/kernel/drivers/net/wireless/realtek/rtl8188gu"
AUTOINSTALL="YES"

さらにMakefileのPlatformを変更します。
$ vi rtl8188gu/Makefile

###################### Platform Related #######################
CONFIG_PLATFORM_I386_PC = n
CONFIG_PLATFORM_ARM_RPI = y

これでビルドが通るようになります。
$ sudo dkms add ./rtl8188gu

Creating symlink /var/lib/dkms/rtl8188gu/1.0.1/source ->
                 /usr/src/rtl8188gu-1.0.1


$ sudo dkms install rtl8188gu/1.0.1

$ sudo dkms status
rtl8188gu, 1.0.1, 5.10.21-sunxi, armv7l: installed

$ sudo reboot

再起動後にWifiを認識しました。
$ nmcli d wifi
IN-USE  SSID             MODE   CHAN  RATE        SIGNAL  BARS  SECURITY
        aterm-22fa1c-g   Infra  7     270 Mbit/s  100     ????  WPA1 WPA2
        aterm-22fa1c-gw  Infra  7     54 Mbit/s   100     ????  WEP
        ESP_CAE141       Infra  1     135 Mbit/s  85      ????  --
        aterm-d5a4ee-g   Infra  1     540 Mbit/s  67      ???_  WPA1 WPA2
        TP-Link_E828     Infra  10    270 Mbit/s  65      ???_  WPA1 WPA2
        HG8045-CA9C-bg   Infra  8     195 Mbit/s  64      ???_  WPA1 WPA2
        MaoMinton        Infra  10    135 Mbit/s  40      ??__  WPA2
        inumber          Infra  1     195 Mbit/s  39      ??__  WPA2
        HG8045-809F-bg   Infra  3     195 Mbit/s  25      ?___  WPA1 WPA2
        ctc-g-748153     Infra  3     270 Mbit/s  19      ?___  WPA1 WPA2

dkmsでインストールしたドライバーは、カーネルが更新されるとドライバーも自動的にリビルドされます。

dkmsでインストールしたドライバーの削除は以下の手順で行います。
$ sudo dkms status
rtl8188gu, 1.0.1, 5.10.21-sunxi, armv7l: installed

$ sudo dkms remove rtl8188gu/1.0.1 --all