Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

嵌入式 Linux 編譯 RTL8188CU USB 無線網卡驅動全流程

編輯:Linux 系統常見問題解答

硬件與環境

  • 芯片:Realtek RTL8188CUS (水星 MW150UM 等)
  • 內核源碼:/root/linux-kernel (假設路徑)
  • 交叉編譯工具鏈:已配置 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

驅動源碼獲取與集成

  1. 下載官方驅動:
    
    wget ftp://WebUser:AxPL9s3k@58.211.24.153/cn/wlan/RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip
    unzip *.zip
    tar xf RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911/rtl8192_8188CU_linux_v4.0.2_9000.20130911.tar.gz
    
  2. 放入內核源碼樹:
    
    mv rtl8192_8188CU_linux_v4.0.2_9000.20130911 /root/linux-kernel/drivers/net/wireless/rtl8192cu
    
  3. 修改內核 Kconfig/Makefile:
    
    # drivers/net/wireless/Kconfig
    source "drivers/net/wireless/rtl8192cu/Kconfig"
    
    # drivers/net/wireless/Makefile
    obj-$(CONFIG_RTL8192CU) += rtl8192cu/
    
  4. 內核配置:
    
    make menuconfig
    # Device Drivers → Network device support → Wireless LAN
    # 選中  Realtek 8192C/8188C USB Wireless
    
  5. 編譯內核/模塊:
    
    make -j$(nproc)   # 編譯內核
    # 或僅編譯模塊
    make M=drivers/net/wireless/rtl8192cu modules
    

常見編譯錯誤修復

錯誤:error: 'struct net_device' has no member named 'wireless_handlers'

原因:內核配置未啟用 CONFIG_WIRELESS_EXT (Wireless Extensions API)。

修復:


make menuconfig
# Networking support → Wireless →
# [*] Wireless extensions (WE) API
# [*]   Wireless extensions sysfs support
重新編譯模塊或內核。

運行時配置無線連接


# 1. 加載模塊
insmod /lib/modules/$(uname -r)/kernel/drivers/net/wireless/rtl8192cu/8192cu.ko
# 或 modprobe 8192cu

# 2. 查看接口名
iwconfig
# 假設為 wlan1

# 3. 連接 AP (WEP 示例,WPA 需 wpa_supplicant)
iwconfig wlan1 essid "MyAP" key "1234-5678-90"   # 密鑰每 4 字符一組,- 分隔

# 4. 啟動接口
ifconfig wlan1 up

# 5. 獲取 IP
# 靜態 IP
ifconfig wlan1 192.168.1.100 netmask 255.255.255.0
# 動態 DHCP
udhcpc -i wlan1
# 或 dhclient wlan1

WPA/WPA2 企業級連接 (wpa_supplicant)


# /etc/wpa_supplicant.conf
network={
    ssid="MyAP"
    psk="mypassword"
    key_mgmt=WPA-PSK
}
# 後台運行
wpa_supplicant -B -i wlan1 -c /etc/wpa_supplicant.conf
udhcpc -i wlan1

驅動加載自動化

  • 將 8192cu 加入 /etc/modules (或 /etc/modules-load.d/wireless.conf) 開機自動加載。
  • 配置 /etc/network/interfaces (Debian) 或 /etc/sysconfig/network-scripts/ifcfg-wlan1 (RHEL) 實現開機自動聯網。
Copyright © Windows教程網 All Rights Reserved