1. 程式人生 > >USB-WIFI RTL8188CU模組驅動

USB-WIFI RTL8188CU模組驅動

RTL8188CU模組概述

Realtek的8188cu模組WiFi是通過usb介面掛載裝置。以下是我對模組使用的所有開發工作。

Linux核心驅動適配和編譯

由於晶片驅動官方已經最高支援kernel Linux3.9版本、在對Linux3.14進行移植時出現較多問題。期間出現了很多的坑。

核心配置:

進入核心目錄,make menuconfig [*] Networking support —> [*] Wireless —> 


Device Drivers —> 
[*] Network device support —> 
Wireless LAN —> 
[*] Wireless LAN (IEEE 802.11) 

<*> IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)

原始碼移植後、出現此選項

原始碼編譯:

解壓原始碼到kernel目錄

tar -xvf rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911.tar.gz

    移動到核心檔案中
mv rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911 sbc/am3352-sbc/src/am335x-linux-3.14.26/drivers/net/wireless/rtl8192cu

編譯出現的問題

直接make命令編譯問題一:os_dep/linux/os_intfs.c:320:3: error: implicit declaration of function ‘create_proc_entry’
原因:Linux 3.10版本中已經去除了create_proc_entry函式。解決方法:下載另一個檔案:wget https://raw.github.com/raspberrypi/linux/rpi-3.10.y/drivers/net/wireless/rtl8192cu/os_dep/linux/os_intfs.c,將下載到的檔案覆蓋原來的os_dep/linux/os_intfs.c。問題二: 在編譯驅動的時候,出現錯誤macro "__TIME__" might prevent reproducible builds [-Werror=date-time],解決辦法只需在相應的Makefile中新增EXTRA_CFLAGS +=-Wno-error=date-time (不把該行為當成錯誤)
或者EXTRA_CFLAGS +=-Wno-date-time(不把該行為當成警告)便可解決該警告或者錯誤。問題三:ERROR: "wireless_send_event" [drivers/net/wireless/rtl8192cu/8192cu.ko] undefined!解決辦法:[*] Wireless LAN (IEEE 802.11) <*> IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP) 排除萬難、中與編譯成功生成驅動模組:8192cu.ko

無線工具tool編譯移植:

wpa_supplicant是wifi客戶端(client)加密認證工具,和iwconfig不同,wpa_supplicant支援wep、wpa、wpa2等完整的加密認證,而iwconfig只能支援wep。和wpa_supplocant相對應的,ap端的加密認證工具為hostapd。

iwconfig配置wep模式連線WiFi

解壓工具原始碼安裝包tar -xvf wireless_tools.30.rtl.tar.gz更改交叉編譯工具
編譯生成可執行檔案

在開發板上進行配置

[email protected]:/mnt/wifi# ifconfig
eth0 Link encap:Ethernet HWaddr 26:C7:3D:A0:40:61
inet addr:192.168.1.147 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2294 errors:0 dropped:2 overruns:0 frame:0
TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:169639 (165.6 KiB) TX bytes:5634 (5.5 KiB)
Interrupt:56
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:700 (700.0 B) TX bytes:700 (700.0 B)
[email protected]:/mnt/wifi# ls
8192cu.ko iwconfig iwevent iwgetid iwlist iwpriv iwspy

新增驅動

[email protected]:/mnt/wifi# insmod 8192cu.ko
[ 960.694600] rtl8192cu driver version=v4.0.2_9000.20130911
[ 960.700314] build time: Jan 24 2018 20:22:31
[ 960.706246]
[ 960.706246] usb_endpoint_descriptor(0):
[ 960.711844] bLength=7
[ 960.714309] bDescriptorType=5
[ 960.717430] bEndpointAddress=81
[ 960.720725] wMaxPacketSize=200
[ 960.723962] bInterval=0
[ 960.726529] RT_usb_endpoint_is_bulk_in = 1
[ 960.730835]
[ 960.730835] usb_endpoint_descriptor(1):
[ 960.736432] bLength=7
[ 960.738815] bDescriptorType=5
[ 960.741931] bEndpointAddress=2
[ 960.745151] wMaxPacketSize=200
[ 960.748356] bInterval=0
[ 960.750929] RT_usb_endpoint_is_bulk_out = 2
[ 960.755333]
[ 960.755333] usb_endpoint_descriptor(2):
[ 960.760915] bLength=7
[ 960.763312] bDescriptorType=5
[ 960.766426] bEndpointAddress=3
[ 960.769632] wMaxPacketSize=200
[ 960.772846] bInterval=0
[ 960.775418] RT_usb_endpoint_is_bulk_out = 3
[ 960.779807]
[ 960.779807] usb_endpoint_descriptor(3):
[ 960.785401] bLength=7
[ 960.787788] bDescriptorType=5
[ 960.790899] bEndpointAddress=84
[ 960.794331] wMaxPacketSize=40
[ 960.797453] bInterval=1
[ 960.800022] RT_usb_endpoint_is_int_in = 4, Interval = 1
[ 960.805534] nr_endpoint=4, in_num=2, out_num=2
[ 960.805534]
[ 960.811752] USB_SPEED_HIGH
[ 960.815172] CHIP TYPE: RTL8188C_8192C
[ 960.819076] register rtw_netdev_ops to netdev_ops
[ 960.824222] Chip Version ID: VERSION_NORMAL_TSMC_CHIP_88C.
[ 960.829991] RF_Type is 3!!
[ 960.836642] EEPROM type is E-FUSE
[ 960.840135] ====> ReadAdapterInfo8192C
[ 960.844372] Boot from EFUSE, Autoload OK !
[ 960.922000] EEPROMVID = 0x0bda
[ 960.925234] EEPROMPID = 0x8176
[ 960.928442] EEPROMCustomerID : 0x00
[ 960.932102] EEPROMSubCustomerID: 0x00
[ 960.935961] RT_CustomerID: 0x00
[ 960.939266] _ReadMACAddress MAC Address from EFUSE = 00:1d:43:30:1b:fc
[ 960.946139] EEPROMRegulatory = 0x0
[ 960.949710] _ReadBoardType(0)
[ 960.952847] BT Coexistance = disable
[ 960.956603] mlmepriv.ChannelPlan = 0x02
[ 960.960635] _ReadPSSetting...bHWPwrPindetect(0)-bHWPowerdown(0) ,bSupportRemoteWakeup(0)
[ 960.969147] ### PS params=> power_mgnt(1),usbss_enable(0) ###
[ 960.975289] ### AntDivCfg(0)
[ 960.978310] readAdapterInfo_8192CU(): REPLACEMENT = 1
[ 960.983627] <==== ReadAdapterInfo8192C in 150 ms
[ 960.989728] rtw_macaddr_cfg MAC Address = 00:1d:43:30:1b:fc
[ 960.995732] bDriverStopped:1, bSurpriseRemoved:0, bup:0, hw_init_completed:0
[ 961.008437] _rtw_drv_register_netdev, MAC Address (if1) = 00:1d:43:30:1b:fc
[ 961.020251] usbcore: registered new interface driver rtl8192cu
[email protected]:/mnt/wifi# ifconfig
eth0 Link encap:Ethernet HWaddr 26:C7:3D:A0:40:61
inet addr:192.168.1.147 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9567 errors:0 dropped:2 overruns:0 frame:0
TX packets:3781 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11071491 (10.5 MiB) TX bytes:268210 (261.9 KiB)
Interrupt:56 lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:700 (700.0 B) TX bytes:700 (700.0 B)

啟動網絡卡

[email protected]:/mnt/wifi# ifconfig wlan0 up
[ 1002.603095] +871x_drv - drv_open, bup=0
[ 1002.610055] ===> FirmwareDownload91C() fw:Rtl819XFwImageArray_TSMC
[ 1002.616726] FirmwareDownload92C accquire FW from embedded image
[ 1002.622978] fw_ver=v88, fw_subver=2, sig=0x88c0
[ 1002.649241] fw download ok!
[ 1002.652205] Set RF Chip ID to RF_6052 and RF type to 1T1R.
[ 1002.966153] IQK:Start!!!
[ 1002.975077] Path A Rx IQK fail!!
[ 1002.980110] Path A IQK Success!!
[ 1002.988366] Path A Rx IQK fail!!
[ 1002.993931] Path A IQK Success!!
[ 1002.999644] IQK: final_candidate is 0
[ 1003.003565] IQK: RegE94=104 RegE9C=15 RegEA4=ff RegEAC=1 RegEB4=0 RegEBC=0 RegEC4=0 RegECC=0
Path A IQ Calibration Success !
[ 1003.124495] pdmpriv->TxPowerTrackControl = 1
[ 1003.131213] rtl8192cu_hal_init in 520ms
[ 1003.155214] MAC Address = 00:1d:43:30:1b:fc
[ 1003.160049] -871x_drv - drv_open, bup=1
[email protected]:/mnt/wifi# [ 1005.155132] ==>rtw_ps_processor .fw_state(0)
[ 1005.159654] ==>ips_enter cnts:1
[ 1005.163013] ===> rtw_ips_pwr_down...................
[ 1005.169992] ====> rtw_ips_dev_unload...
[ 1005.191302] usb_read_port_cancel
[ 1005.195138] usb_read_port_complete()-1284: RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0) bReadPortCancel(1)
[ 1005.206415] usb_read_port_complete()-1284: RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0) bReadPortCancel(1)
[ 1005.217664] usb_read_port_complete()-1284: RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0) bReadPortCancel(1)
[ 1005.228893] usb_read_port_complete()-1284: RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0) bReadPortCancel(1)
[ 1005.239957] usb_write_port_cancel
[ 1005.244091] ==> rtl8192cu_hal_deinit
[ 1005.247950] bkeepfwalive(0)
[ 1005.250883] card disble without HWSM...........
[ 1005.259031] <=== rtw_ips_pwr_down..................... in 90ms[email protected]:/mnt/wifi# ifconfig
eth0 Link encap:Ethernet HWaddr 26:C7:3D:A0:40:61
inet addr:192.168.1.147 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9634 errors:0 dropped:2 overruns:0 frame:0
TX packets:3783 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11077353 (10.5 MiB) TX bytes:268336 (262.0 KiB)
Interrupt:56 lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:700 (700.0 B) TX bytes:700 (700.0 B)wlan0 Link encap:Ethernet HWaddr 00:1D:43:30:1B:FC
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


搜尋周圍WiFi AP點

[email protected]:/mnt/wifi# ifconfig wlan0 192.168.1.166
[email protected]:/mnt/wifi# ./iwlist wlan0 scanning
[ 1251.243269] _rtw_pwr_wakeup call ips_leave....
[ 1251.247992] ==>ips_leave cnts:1
[ 1251.251292] ===> rtw_ips_pwr_up..............
[ 1251.256064] ===> ips_netdrv_open.........
[ 1251.264501] ===> FirmwareDownload91C() fw:Rtl819XFwImageArray_TSMC
[ 1251.271108] FirmwareDownload92C accquire FW from embedded image
[ 1251.277517] fw_ver=v88, fw_subver=2, sig=0x88c0
[ 1251.303432] fw download ok!
[ 1251.306388] Set RF Chip ID to RF_6052 and RF type to 1T1R.
[ 1251.626253] IQK:Start!!!
[ 1251.635242] Path A Rx IQK fail!!
[ 1251.640332] Path A Rx IQK fail!!
[ 1251.643774] Path A IQK Only Tx Success!!
[ 1251.652991] Path A Rx IQK fail!!
[ 1251.658083] Path A Rx IQK fail!!
[ 1251.661478] Path A IQK Only Tx Success!!
[ 1251.668513] IQK: final_candidate is 0
[ 1251.672379] IQK: RegE94=104 RegE9C=14 RegEA4=0 RegEAC=0 RegEB4=0 RegEBC=0 RegEC4=0 RegECC=0
Path A IQ Calibration Success !
[ 1251.685692] _PHY_PathAFillIQKMatrix only Tx OK
[ 1251.794453] pdmpriv->TxPowerTrackControl = 1
[ 1251.801205] rtl8192cu_hal_init in 540ms
[ 1251.825412] <=== rtw_ips_pwr_up.............. in 580ms
[ 1251.830990] ==> ips_leave.....LED(0x00028080)...
[ 1253.135544] survey done event(12) band:0 for wlan0
wlan0 Scan completed :
Cell 01 - Address: 00:6B:8E:F1:6F:70
ESSID:"@PHICOMM_68"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.427 GHz (Channel 4)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd1a0050f20101000050f20202000050f2020050f20401000050f202
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : TKIP CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30180100000fac020200000fac02000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : TKIP CCMP
Authentication Suites (1) : PSK
Quality=58/100 Signal level=57/100
Cell 02 - Address: B0:95:8E:5A:1C:18
ESSID:"huchengwei"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.437 GHz (Channel 6)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Quality=0/100 Signal level=10/100
Cell 03 - Address: EC:26:CA:41:63:FD
ESSID:"deutschwerkstatt"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.437 GHz (Channel 6)
Encryption key:on
Bit Rates:144 Mb/s
Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30140100000fac040100000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Quality=0/100 Signal level=23/100
Cell 04 - Address: DC:FE:18:14:74:BE
ESSID:"YATIGERS-2.4G"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.462 GHz (Channel 11)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd1a0050f20101000050f20202000050f2020050f20401000050f202
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : TKIP CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30180100000fac020200000fac02000fac040100000fac020000
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : TKIP CCMP
Authentication Suites (1) : PSK
Quality=66/100 Signal level=82/100

連線WiFi

[email protected]:/mnt/wifi# ./iwconfig wlan0 key YTGS25257758
Error for wireless request "Set Encode" (8B2A) :
invalid argument "YTGS25257758".
[email protected]:/mnt/wifi# ./iwconfig wlan0 essid "YATIGERS-2.4G"
[ 1421.483915] _rtw_pwr_wakeup call ips_leave....
[ 1421.488626] ==>ips_leave cnts:2
[ 1421.491926] ===> rtw_ips_pwr_up..............
[ 1421.496744] ===> ips_netdrv_open.........
[ 1421.505563] ===> FirmwareDownload91C() fw:Rtl819XFwImageArray_TSMC
[ 1421.512173] FirmwareDownload92C accquire FW from embedded image
[ 1421.518589] fw_ver=v88, fw_subver=2, sig=0x88c0
[ 1421.544544] fw download ok!
[ 1421.547499] Set RF Chip ID to RF_6052 and RF type to 1T1R.
[ 1421.866093] IQK:Start!!!
[ 1421.875145] Path A IQK Success!!
[ 1421.883112] Path A Rx IQK fail!!
[ 1421.888205] Path A Rx IQK fail!!
[ 1421.891601] Path A IQK Only Tx Success!!
[ 1421.902763] Path A IQK Success!!
[ 1421.908461] IQK: final_candidate is 0
[ 1421.912331] IQK: RegE94=104 RegE9C=14 RegEA4=ff RegEAC=0 RegEB4=0 RegEBC=0 RegEC4=0 RegECC=0
Path A IQ Calibration Success !
[ 1422.034466] pdmpriv->TxPowerTrackControl = 1
[ 1422.041203] rtl8192cu_hal_init in 540ms
[ 1422.065457] <=== rtw_ips_pwr_up.............. in 580ms
[ 1422.071035] ==> ips_leave.....LED(0x00028080)...
[ 1422.075945] =>rtw_wx_set_essid
[ 1422.079158] ssid=YATIGERS-2.4G, len=13
[ 1422.083503] Set SSID under fw_state=0x00000008
[ 1422.088213] [by_bssid:0][assoc_ssid:YATIGERS-2.4G][to_roaming:0] new candidate: YATIGERS-2.4G(dc:fe:18:14:74:be, ch11) rssi:-58
[ 1422.100317] rtw_select_and_join_from_scanned_queue: candidate: YATIGERS-2.4G(dc:fe:18:14:74:be, ch:11)
[ 1422.110203] link to Ralink AP
[ 1422.113385] <=rtw_wx_set_essid, ret 0
[email protected]:/mnt/wifi# [ 1422.121616] set ch/bw before connected
[ 1422.125868] start_join_set_ch_bw: ch=11, bwmode=1, ch_offset=2
[ 1422.217255] link to Ralink AP
[ 1422.267760] OnAuthClient
[ 1422.270479] network.SupportedRates[0]=82
[ 1422.274601] network.SupportedRates[1]=84
[ 1422.278719] network.SupportedRates[2]=8B
[ 1422.282836] network.SupportedRates[3]=96
[ 1422.286954] network.SupportedRates[4]=12
[ 1422.291070] network.SupportedRates[5]=24
[ 1422.295188] network.SupportedRates[6]=48
[ 1422.299305] network.SupportedRates[7]=6C
[ 1422.303422] network.SupportedRates[8]=0C
[ 1422.307540] network.SupportedRates[9]=18
[ 1422.311658] network.SupportedRates[10]=30
[ 1422.315866] network.SupportedRates[11]=60
[ 1422.320079] bssrate_len = 12
[ 1422.342232] OnAssocRsp
[ 1422.344765] report_join_res(4)
[ 1422.348014] rtw_joinbss_update_network
[ 1422.351961] +rtw_update_ht_cap()
[ 1422.355382] rtw_joinbss_update_stainfo
[ 1422.359619] OnAction_back
[ 1422.362388] OnAction_back, action=0
[ 1422.366117] issue_action_BA, category=3, action=1, status=0
[ 1422.372152] HW_VAR_BASIC_RATE: BrateCfg(0x15d)
[ 1422.379523] WMM(0): 0, a42b
[ 1422.382886] WMM(1): 0, a44f
[ 1422.385902] WMM(2): 0, 5e4322
[ 1422.389088] WMM(3): 0, 2f3222
[ 1422.392211] HTOnAssocRsp
[ 1422.398868] update raid entry, mask=0xfffff, arg=0x80
[ 1422.405371] rtl8192c_set_FwJoinBssReport_cmd mstatus(1)
[ 1422.411380] SetFwRsvdPagePkt
[ 1422.415505] Set RSVD page location to Fw.
[ 1422.420276] =>mlmeext_joinbss_event_callback
[ 1427.075863] rtl8192c_dm_RF_Saving(): RF_Save
[ 1431.072987] rtw_set_ps_mode(): Enter 802.11 power save mode...
[ 1431.079829] rtl8192c_dm_RF_Saving(): RF_Normal
[ 1431.084564] rtl8192c_set_FwPwrMode_cmd(): Mode = 1, SmartPS = 2
[email protected]:/mnt/wifi# ./iwconfig wlan0
[ 1499.280772] rtw_wx_get_rts, rts_thresh=2347
[ 1499.286239] rtw_wx_get_frag, frag_len=2346
wlan0 IEEE 802.11bgn ESSID:"YATIGERS-2.4G" Nickname:"<[email protected]>"
Mode:Managed Frequency:2.462 GHz Access Point: DC:FE:18:14:74:BE
Bit Rate:150 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=99/100 Signal level=67/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

遮蔽eth0來試著ping閘道器

[email protected]:/mnt/wifi# ./iwconfig wlan0
[ 1499.280772] rtw_wx_get_rts, rts_thresh=2347
[ 1499.286239] rtw_wx_get_frag, frag_len=2346
wlan0 IEEE 802.11bgn ESSID:"YATIGERS-2.4G" Nickname:"<[email protected]>"
Mode:Managed Frequency:2.462 GHz Access Point: DC:FE:18:14:74:BE
Bit Rate:150 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=99/100 Signal level=67/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0[email protected]:/mnt/wifi# ifconfig
eth0 Link encap:Ethernet HWaddr 26:C7:3D:A0:40:61
inet addr:192.168.1.147 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10239 errors:0 dropped:7 overruns:0 frame:0
TX packets:3881 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11213377 (10.6 MiB) TX bytes:278688 (272.1 KiB)
Interrupt:56 lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:700 (700.0 B) TX bytes:700 (700.0 B)wlan0 Link encap:Ethernet HWaddr 00:1D:43:30:1B:FC
inet addr:192.168.1.166 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:335 errors:0 dropped:339 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40400 (39.4 KiB) TX bytes:0 (0.0 B)[email protected]:/mnt/wifi# ifconfig eth0 down
[email protected]:/mnt/wifi# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:700 (700.0 B) TX bytes:700 (700.0 B)wlan0 Link encap:Ethernet HWaddr 00:1D:43:30:1B:FC
inet addr:192.168.1.166 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:375 errors:0 dropped:379 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:45253 (44.1 KiB) TX bytes:0 (0.0 B)[email protected]:/mnt/wifi# ping 192.168.1.1
[ 1606.213877] rtw_set_ps_mode(): Busy Traffic , Leave 802.11 power save..
[ 1606.221047] rtl8192c_set_FwPwrMode_cmd(): Mode = 0, SmartPS = 0
[ 1606.227764] OnAction_back
[ 1606.230533] OnAction_back, action=0
[ 1606.234249] issue_action_BA, category=3, action=1, status=0
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: seq=0 ttl=64 time=26.190 ms
64 bytes from 192.168.1.1: seq=1 ttl=64 time=13.609 ms
64 bytes from 192.168.1.1: seq=2 ttl=64 time=9.448 ms
64 bytes from 192.168.1.1: seq=3 ttl=64 time=13.246 ms
64 bytes from 192.168.1.1: seq=4 ttl=64 time=19.149 ms
64 bytes from 192.168.1.1: seq=5 ttl=64 time=25.671 ms
64 bytes from 192.168.1.1: seq=6 ttl=64 time=15.957 ms
--- 192.168.1.1 ping statistics ---
22 packets transmitted, 22 packets received, 0% packet loss
round-trip min/avg/max = 6.152/22.831/183.121 ms

用hostapd配置WiFi作為AP接入點

hostapd是一款執行在使用者態軟體,能夠為認證伺服器提供管理接入點。下面是無線網絡卡常見的工作模式及其作用。


顯然,平時我們的計算機的無線網絡卡一般工作在Managed模式,而我們平常使用的路由器的無線網絡卡則是一般工作在Master模式。我們藉助hostapd讓我們計算機的無線網絡卡更換模式,使其工作在Master模式,這樣我們的計算機就能夠成為一個無線接入點從而為其他裝置提供服務。

移植hostapd

libnl庫的安裝

    下載1.1版本的、libnl-1.1.4.tar.gz
    解壓
    tar -xvf libnl-1.1.4.tar.gz
    mkdir install
    配置安裝目錄
    ./configure -prefix=/home/fluency/workspace/wifi/libnl-1.1.4/install
    編譯
    make CC=arm-linux-gnuabihf-gcc
    make install

openssl庫的安裝

OpenSSL官網https://www.openssl.org/source/old/0.9.x/
    下載openssl-0.9.8e.tar.gz
    解壓配置
    tar -xvf openssl-0.9.8e.tar.gz
    mkdir install
    安裝目錄
    ./config -prefix=/home/fluency/workspace/wifi/openssl-0.9.8e/install/
    交叉編譯工具
    ./config os/compiler:arm-linux-gnueabihf-gcc
    make
    make install

hostapd的編譯

解壓配置

    tar -xvf hostapd-0.8-snapshot.tar.gz

    cp deconfig .config

    vim .config


修改Makefile
指定libnl、ssl的標頭檔案和庫檔案路徑

關於Relocations in generic ELF (EM: 40)的解決辦法

然後命令編譯(指定編譯器和連線工具)
make CC=arm-linux-gnueabihf-gcc LD=arm-linux-gnueabihf-ld
移植
hostapd hostapd_cli 可執行檔案
執行中出現庫檔案缺失(進行cp)
[email protected]:~/workspace/wifi/libnl-1.1.4/install/lib$ cp libnl.so* /home/fluency/nfsboot/wifi/
sudo ln -s 原始檔 目標檔案 (為庫檔案建立連線)

命令執行AP設定

/*---------配置檔案AM335Wifi.conf----------------------*/
interface=wlan0
ssid=Fluency
channel=9
hw_mode=g
ignore_broadcast_ssid=0
auth_algs=1
wpa=3
wpa_passphrase=12345679
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
/*------------------------------------------*/
[email protected]:/mnt/wifi# ./hostapd ./AM335Wifi.conf -B
Configuration file: ./hostapAP.conf
drv->ifindex=4
l2_sock_recv==l2_sock_xmit=0x0x5[28441.760693] _rtw_pwr_wakeup call ips_leave....
2630
[28441.768844] ==>ips_leave cnts:3
[28441.772652] ===>  rtw_ips_pwr_up..............
[28441.777335] ===> ips_netdrv_open.........
[28441.786126]  ===> FirmwareDownload91C() fw:Rtl819XFwImageArray_TSMC
[28441.792915] FirmwareDownload92C accquire FW from embedded image
[28441.799145] fw_ver=v88, fw_subver=2, sig=0x88c0
[28441.824193] fw download ok!
[28441.827141] Set RF Chip ID to RF_6052 and RF type to 1T1R.
[28442.136384] IQK:Start!!!
[28442.145387] Path A IQK Success!!
[28442.153503] Path A IQK Success!!
[28442.159184] IQK: final_candidate is 0
[28442.163094] IQK: RegE94=104 RegE9C=14 RegEA4=ff RegEAC=1 RegEB4=0 RegEBC=0 RegEC4=0 RegECC=0
 Path A IQ Calibration Success !
[28442.284387] pdmpriv->TxPowerTrackControl = 1
[28442.291139] rtl8192cu_hal_init in 510ms
[28442.315333] <===  rtw_ips_pwr_up.............. in 540ms
[28442.320912] ==> ips_leave.....LED(0x00028080)...
[28442.325816] set_mode = IW_MODE_MASTER
[28442.330516] hw_var_set_opmode()-4234 mode = 3
[28442.335576] rtw_hostapd_sta_flush
[28442.340158] rtw_sta_flush(wlan0)
[28442.343639] issue_deauth to ff:ff:ff:ff:ff:ff
+rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is de[28442.349304] rtw_set_encryption
auth, reason=2
rtl871x_set_key_ops
[28442.356518] clear default encryption keys, keyid=0
rtl871x_set_key_ops
[28442.366165] rtw_set_encryption
[28442.371042] clear default encryption keys, keyid=1
rtl871x_set_key_ops
[28442.376983] rtw_set_encryption
[28442.381887] clear default encryption keys, keyid=2
rtl871x_set_key_ops
[28442.387511] rtw_set_encryption
[28442.392466] clear default encryption keys, keyid=3
Using interface wlan0 with hwaddr 00:1d:43:30:1b:fc and ssid 'YOUR_SSID'
rtl871x_set_wps_assoc_resp_ie
[28442.551185] rtw_set_wps_assoc_resp, len=14
rtl871x_set_wps_beacon_ie
[28442.558408] rtw_set_wps_beacon, len=14
rtl871x_set_wps_probe_resp_ie
[28442.564877] rtw_set_wps_probe_resp, len=14
rtl871x_set_key_ops
[28442.580558] rtw_set_encryption
[28442.585520] rtw_set_encryption, set group_key, TKIP
[28442.590653] set_group_key
[28442.594451] SetHwReg8192CU, 5126, RCR= 7000228e 
rtl871x_set_beacon_ops
[28442.599478] rtw_set_beacon, len=105
[28442.605184] rtw_check_beacon_data, len=91
[28442.613419] CH=9, BW=0, offset=0
[28442.617047] HW_VAR_BASIC_RATE: BrateCfg(0x15d)
[28442.623180] update_bmc_sta, mask=0x6000000f, arg=0x81
rtl871x_set_hidden_ssid ignore_broadcast_ssid:0,[28442.628976] rtw_set_hidden_ssid(wlan0) ignore_broadcast_ssid:0, YOUR_SSID,9 YOUR_SSID,9rtl871x_set_acl
[28447.325844] rtl8192c_dm_RF_Saving(): RF_Normal
[28519.433519] IQK:Start!!!
[28519.442255] Path A IQK Success!!
[28519.451203] Path A IQK Success!!
[28519.457527] IQK: final_candidate is 0
[28519.461397] IQK: RegE94=103 RegE9C=11 RegEA4=fe RegEAC=2 RegEB4=0 RegEBC=0 RegEC4=0 RegECC=0

 Path A IQ Calibration Success !

配置DHCP服務

[email protected]:/mnt/wifi#udhcpd ./udhcpd.conf
/*---------配置檔案udhcpd.conf----------------------*/
start   192.168.63.100
end             192.168.63.254
interface       wlan0
opt     dns     192.168.10.2 192.168.10.10
option  subnet  255.255.255.0
opt     router  192.168.63.70
opt     wins    192.168.63.10
option  dns     129.219.13.81   # appened to above DNS servers for a total of 3
option  domain  local

option  lease   864000          # 10 days of seconds

/*------------------------------------------*/連線加入AP熱點 name為Fluencypasswd為12345679可以看到分配的ID為192.168.2.100

[email protected]:/mnt/wifi# ping 192.168.2.100PING 192.168.2.100 (192.168.2.100): 56 data bytes64 bytes from 192.168.2.100: seq=0 ttl=64 time=129.361 ms64 bytes from 192.168.2.100: seq=1 ttl=64 time=143.283 ms64 bytes from 192.168.2.100: seq=2 ttl=64 time=34.387 ms64 bytes from 192.168.2.100: seq=3 ttl=64 time=70.293 ms64 bytes from 192.168.2.100: seq=4 ttl=64 time=79.402 ms64 bytes from 192.168.2.100: seq=5 ttl=64 time=103.304 ms--- 192.168.2.100 ping statistics ---35 packets transmitted, 35 packets received, 0% packet lossround-trip min/avg/max = 24.044/76.401/150.222 ms到此RTL8188CU模組驅動的驅動所有功能都已完成新增到rc.local指令碼啟動

WiFi效能測試

用iperf命令啟動tcp伺服器

手機軟體netwroktool


然後server端就能看到測試頻寬資訊


以上完成對WiFi驅動的所有工作、裝置就有了一個無線網絡卡啦

相關推薦

USB-WIFI RTL8188CU模組驅動

RTL8188CU模組概述Realtek的8188cu模組WiFi是通過usb介面掛載裝置。以下是我對模組使用的所有開發工作。Linux核心驅動適配和編譯由於晶片驅動官方已經最高支援kernel Linux3.9版本、在對Linux3.14進行移植時出現較多問題。期間出現了很

hi3518e移植USB-WiFi RT3070 STA驅動

/**************************************************************************************************/                                    

如何檢視LINUX下的一個USB裝置使用的驅動模組

http://unix.stackexchange.com/questions/60078/find-out-which-modules-are-associated-with-a-usb-device Finding the Kernel Driver(s) Th

imx6 linux wifi ap模式配置(usb-wifi模組rt3070)

轉載自:https://blog.csdn.net/weixin_42381443/article/details/80566047 不是所有的usb-wif模組在linux下面都可以支援ap模式。 在linux下的ap模式是通過工具hostapd工具進行配置執行的,該工具一般使用nl8

ath9k usb wifi 網絡卡驅動淺析

ieee80211   802.11協議簇是國際電工電子工程學會(IEEE)為無線區域網絡制定的標準。 概述 nl80211: 用於對無線裝置進行配置管理,它是一個基本Netlink的使用者態協議(User態) cfg80211: 用於對無線裝置進行

USB wifi模組mt7601U移植至imx 6q android 6.0平臺

        最近公司使用imx6q開發新產品,我們沒有經驗,選了最新的android 6.0平臺來做開發。而硬體給我們提供的wifi模組竟然是使用USB外接的wifi模組,沒錯,就是淘寶上買的那種小型無線網絡卡,不是嵌入式wifi模組(不想說硬體兄弟坑我們了,沒辦法,小

第十七章:STA模式USB WIFI驅動移植

1、下載原始碼 首先將原始碼複製到ubuntu中實驗目錄,並解壓開,這裡我們用到的是sta模式,所以解壓MT7601U_LinuxAP_3.0.0.1_20130802.tar.bz2這個檔案。 我們這裡解壓之後放在了以下目錄中.             2、修改

Marvell 88W8686/88W8782/88W8801 WiFi模組驅動程式的編寫

本文以STM32F1系列的微控制器為例,詳細講解Marvell公司的88W8686/88W8782/88W8801 WiFi模組驅動程式的編寫。編寫程式時為了程式碼簡短起見,直接用暫存器操作,不使用STM32庫函式。IDE採用Keil uVision5。為了儲存下

基於RK3399的USB轉串列埠驅動模組的編譯

首先參考了Firefly論壇上帖子:http://developer.t-firefly.com/thread-1546-1-1.html 開發板裡燒寫的韌體的版本是官方的:Firefly-rk339

petalinux+usb wifi+驅動安裝+工具使用(一/二)

8812au驅動編譯 rtl8812au-master$ vim Makefile iw編譯(在本應用中沒有用到iw,僅僅備忘) wireless_tools編譯 新增8812au到petalinux BSP工程 經過以上步驟,網絡卡驅動已經編譯得到可執行檔案,

嵌入式linux usb wifi驅動移植

wpa_driver_wext_set_operstate: operstate 0->0 (DORMANT) netlink: Operstate: linkmode=-1, operstate=5 wpa_driver_wext_associate wpa_driver_wext_set_

petalinux+usb wifi+驅動安裝+工具使用(二/二)

插入USB網絡卡 使用image.ub和BOOT.bin,從SD卡上啟動zedboard。進入系統後,插入網絡卡,系統會自動載入驅動(8812au.ko)。這時候需要確認系統是否已經接受了我們的新網絡卡,輸入ifconfig是無法檢視無線介面的,必須加-a作為選項,輸出結果

android 平臺USB wifi驅動移植及使用

來自: http://blog.csdn.net/haomcu/article/details/7267090 一.   Android平臺Wifi的基本程式碼路徑 1.       Wpa_supplicant原始碼部分 external/wpa_sup

在Windows10中安卓adb通過USB,WIFI連線電腦一些error的解決思路

could not read ok from ADB Server * failed to start daemon error: cannot connect to daemon adb server version (36) doesn’t match this client (40

linux使用USB轉串列埠驅動設定

【一】、驅動相關說明: 如果直接使用串列埠線,而沒有用到USB轉串列埠裝置,就不需要安裝驅動。 如果使用了USB轉串列埠,一般情況下也不需要安裝驅動了,目前linux系統已經包含了該驅動,可以自動識別,亦可通過以下命令檢視以便確認是否支援。 檢視模組裝載的情況: 引用 lsmod |

ubuntu安裝USB轉串列埠驅動(PL2303)

在Ubuntu下利用minicom進行嵌入式開發時可能會用到USB轉串列埠,這時就會用到USB轉串列埠驅動,以前的Ubuntu是直接將此驅動編譯進核心,但不知道從哪個版本開始Ubuntu將其從核心去掉了,所以要用到Ubuntu的minicom時只能由我們自己安裝USB轉串列埠驅動,方法如下:

USB轉串列埠驅動應用於macbook

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

Hi3518EV200移植MT7601 USB-WIFI(STA)

1.修改makefile 1)增加platform PLATFORM = HI3518EV200 2)新增 #swann add ifeq ($(PLATFORM),HI3518EV200) LINUX_SRC = /home/swann/hi3518e/Hi3518E_SDK_V1.0.3.0

高通camera模組驅動指南資料介紹

本資料提供了攝像機感測器和相關模組的驅動程式開發指南,並描述瞭如何在MSM 8909、MSM 8916、MSM 8992、MSM 8994和MSM8x36 Android平臺。 攝像機感測器框架包括以下元件的配置: Sensor CSIPHY CSID Camera Co

hisi mmz模組驅動講解

一、概述          如圖所示,在海思平臺上將記憶體分為兩個部分:os記憶體和mmz記憶體。os記憶體指:由linux作業系統管理的記憶體;mmz記憶體:由mmz驅動模組進行管理供媒體業務單獨使用的記憶體,在驅動載入時可以指定該模組管理記憶體的大小: insmod m