文章目录

  • 硬件平台
  • 移植步骤
    • 1. 修改内核配置
    • 2. 编译驱动文件
    • 3. 驱动模块安装
    • 4. AP模式
    • 5. Station模式
    • 6. AP + Station并发模式
  • 错误

硬件平台

芯片:AM335X
内核版本:Linux/arm 3.14.26

移植步骤

1. 修改内核配置

添加IEEE 802.11协议

[*] Networking support  --->-*-   Wireless  --->--- Wireless                                                                    <*>   cfg80211 - wireless configuration API[*]     enable powersave by default[*]     cfg80211 wireless extensions compatibility<*>   Generic IEEE 802.11 Networking Stack (mac80211)[*]   Minstrel[*]     Minstrel 802.11n support

添加Host AP

Device Drivers  --->[*] Network device support  --->[*]   Wireless LAN  ---><*>   IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
2. 编译驱动文件

编译驱动文件,以内核模块方式加载。
驱动源码下载:[RTL8188EUS_linux_v4.3.0.7_12758.20141114.zip]
链接:https://pan.baidu.com/s/1uJDGOOCxiQ8sBTM6oHXp7Q
提取码:3wkd

解压缩RTL8188EUS_linux_v4.3.0.7_12758.20141114.zip,进入RTL8188EUS_linux_v4.3.0.7_12758.20141114/driver/文件夹,解压缩rtl8188EUS_linux_v4.3.0.7_12758.20141114.tar.gz到当前文件夹,修改Makefile文件。

CONFIG_PLATFORM_I386_PC = n     //屏蔽默认选项
...
CONFIG_PLATFORM_ARM_AM335X = y     //新增此定义ifeq ($(CONFIG_PLATFORM_ARM_AM335X), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH := arm
CROSS_COMPILE := /home/mq/project/Dasheng_AM335X/am335x/tools/x86-linux-gnu/bin/arm-linux-gnueabihf-   //交叉编译器路径
KVER  := 3.14.26       //内核版本
KSRC := /home/mq/project/Dasheng_AM335X/am335x/src/am335x-linux-3.14.26/   //内核文件路径
endif

修改完以上内容,直接编译

make

拷贝生成的8188eu.ko驱动模块到板子上
参考:《Quick_Start_Guide_for_Driver_Compilation_and_Installation.pdf》

3. 驱动模块安装

拷贝到板子之后

root@am335x-evm:~/modules# ls
8188eu.ko

安装内核模块

root@am335x-evm:~/modules# insmod 8188eu.ko
[ 2432.905038] RTL871X: module init start
[ 2432.909282] RTL871X: rtl8188eu v4.3.0.7_12758.20141114
[ 2432.914775] RTL871X: build time: Mar 11 2019 15:00:26
[ 2432.922312] RTL871X:
[ 2432.922312] usb_endpoint_descriptor(0):
[ 2432.928953] RTL871X: bLength=7
[ 2432.932166] RTL871X: bDescriptorType=5
[ 2432.936158] RTL871X: bEndpointAddress=81
[ 2432.940278] RTL871X: wMaxPacketSize=512
[ 2432.944330] RTL871X: bInterval=0
[ 2432.947721] RTL871X: RT_usb_endpoint_is_bulk_in = 1
[ 2432.952841] RTL871X:
[ 2432.952841] usb_endpoint_descriptor(1):
[ 2432.959271] RTL871X: bLength=7
[ 2432.962479] RTL871X: bDescriptorType=5
[ 2432.966436] RTL871X: bEndpointAddress=2
[ 2432.970462] RTL871X: wMaxPacketSize=512
[ 2432.974508] RTL871X: bInterval=0
[ 2432.977898] RTL871X: RT_usb_endpoint_is_bulk_out = 2
[ 2432.983106] RTL871X:
[ 2432.983106] usb_endpoint_descriptor(2):
[ 2432.989528] RTL871X: bLength=7
[ 2432.992735] RTL871X: bDescriptorType=5
[ 2432.996692] RTL871X: bEndpointAddress=3
[ 2433.000718] RTL871X: wMaxPacketSize=512
[ 2433.004800] RTL871X: bInterval=0
[ 2433.008189] RTL871X: RT_usb_endpoint_is_bulk_out = 3
[ 2433.013428] RTL871X: nr_endpoint=3, in_num=1, out_num=2
[ 2433.013428]
[ 2433.020468] RTL871X: USB_SPEED_HIGH
[ 2433.026482] RTL871X: CHIP TYPE: RTL8188E
[ 2433.030694] RTL871X: register rtw_netdev_ops to netdev_ops
[ 2433.037296] RTL871X: Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_A_CUT_1T1R_RomVer(0)
[ 2433.046027] RTL871X: RF_Type is 3!!
[ 2433.049709] RTL871X: _ConfigNormalChipOutEP_8188E OutEpQueueSel(0x05), OutEpNumber(2)
[ 2433.058390] RTL871X: EEPROM type is E-FUSE
[ 2433.062829] RTL871X: ====> _ReadAdapterInfo8188EU
[ 2433.068148] RTL871X: Boot from EFUSE, Autoload OK !
[ 2433.079178] RTL871X: SetHwReg8188EU: bMacPwrCtrlOn=1
[ 2433.089888] bFWReady == _FALSE call reset 8051...
[ 2433.095716] RTL871X: =====> _8051Reset88E(): 8051 reset success .
[ 2433.115742] RTL871X: efuse_read_phymap_from_txpktbuf bcnhead:0
[ 2433.122391] RTL871X: efuse_read_phymap_from_txpktbuf len:118, lenbak:118, aaa:118, aaabak:118
[ 2433.136235] RTL871X: efuse_read_phymap_from_txpktbuf read count:116
[ 2433.143102] RTL871X: EEPROM ID=0x8129
[ 2433.147000] RTL871X: VID = 0x0BDA, PID = 0x8179
[ 2433.151761] RTL871X: Customer ID: 0x00, SubCustomer ID: 0xCD
[ 2433.157738] RTL871X: Hal_ReadPowerSavingMode88E...bHWPwrPindetect(0)-bHWPowerdown(0) ,bSupportRemoteWakeup(1)
[ 2433.168169] RTL871X: ### PS params=>  power_mgnt(1),usbss_enable(0) ###
[ 2433.175141] RTL871X: ======= Path 0, Channel 1 =======
[ 2433.180538] RTL871X: Index24G_CCK_Base[0][1] = 0x25
[ 2433.185684] RTL871X: Index24G_BW40_Base[0][1] = 0x2b
[ 2433.190895] RTL871X: ======= Path 0, Channel 2 =======
[ 2433.196313] RTL871X: Index24G_CCK_Base[0][2] = 0x25
[ 2433.201435] RTL871X: Index24G_BW40_Base[0][2] = 0x2b
[ 2433.206669] RTL871X: ======= Path 0, Channel 3 =======
[ 2433.212064] RTL871X: Index24G_CCK_Base[0][3] = 0x25
[ 2433.217207] RTL871X: Index24G_BW40_Base[0][3] = 0x2b
[ 2433.222419] RTL871X: ======= Path 0, Channel 4 =======
[ 2433.227836] RTL871X: Index24G_CCK_Base[0][4] = 0x25
[ 2433.232957] RTL871X: Index24G_BW40_Base[0][4] = 0x2b
[ 2433.238195] RTL871X: ======= Path 0, Channel 5 =======
[ 2433.243613] RTL871X: Index24G_CCK_Base[0][5] = 0x25
[ 2433.248735] RTL871X: Index24G_BW40_Base[0][5] = 0x2b
[ 2433.253969] RTL871X: ======= Path 0, Channel 6 =======
[ 2433.259365] RTL871X: Index24G_CCK_Base[0][6] = 0x25
[ 2433.264509] RTL871X: Index24G_BW40_Base[0][6] = 0x2b
[ 2433.269721] RTL871X: ======= Path 0, Channel 7 =======
[ 2433.275138] RTL871X: Index24G_CCK_Base[0][7] = 0x25
[ 2433.280260] RTL871X: Index24G_BW40_Base[0][7] = 0x2b
[ 2433.285493] RTL871X: ======= Path 0, Channel 8 =======
[ 2433.290888] RTL871X: Index24G_CCK_Base[0][8] = 0x25
[ 2433.296048] RTL871X: Index24G_BW40_Base[0][8] = 0x2b
[ 2433.301261] RTL871X: ======= Path 0, Channel 9 =======
[ 2433.306681] RTL871X: Index24G_CCK_Base[0][9] = 0x24
[ 2433.311804] RTL871X: Index24G_BW40_Base[0][9] = 0x2a
[ 2433.317039] RTL871X: ======= Path 0, Channel 10 =======
[ 2433.322526] RTL871X: Index24G_CCK_Base[0][10] = 0x24
[ 2433.327765] RTL871X: Index24G_BW40_Base[0][10] = 0x2a
[ 2433.333069] RTL871X: ======= Path 0, Channel 11 =======
[ 2433.338578] RTL871X: Index24G_CCK_Base[0][11] = 0x24
[ 2433.343811] RTL871X: Index24G_BW40_Base[0][11] = 0x2a
[ 2433.349115] RTL871X: ======= Path 0, Channel 12 =======
[ 2433.354623] RTL871X: Index24G_CCK_Base[0][12] = 0x22
[ 2433.359836] RTL871X: Index24G_BW40_Base[0][12] = 0x28
[ 2433.365163] RTL871X: ======= Path 0, Channel 13 =======
[ 2433.370649] RTL871X: Index24G_CCK_Base[0][13] = 0x22
[ 2433.375884] RTL871X: Index24G_BW40_Base[0][13] = 0x28
[ 2433.381188] RTL871X: ======= Path 0, Channel 14 =======
[ 2433.386696] RTL871X: Index24G_CCK_Base[0][14] = 0x22
[ 2433.391909] RTL871X: Index24G_BW40_Base[0][14] = 0x28
[ 2433.397237] RTL871X: ======= TxCount 0 =======
[ 2433.401904] RTL871X: CCK_24G_Diff[0][0]= 0
[ 2433.406227] RTL871X: OFDM_24G_Diff[0][0]= 2
[ 2433.410622] RTL871X: BW20_24G_Diff[0][0]= 0
[ 2433.415035] RTL871X: BW40_24G_Diff[0][0]= 0
[ 2433.419425] RTL871X: EEPROMRegulatory = 0x0
[ 2433.423844] RTL871X: mlmepriv.ChannelPlan = 0x20
[ 2433.428692] RTL871X: CrystalCap: 0x20
[ 2433.432536] RTL871X: EEPROM Customer ID: 0x 0
[ 2433.437137] RTL871X: EEPROM : AntDivCfg = 0, TRxAntDivType = 3
[ 2433.443279] RTL871X: Board Type: 0x 0
[ 2433.447124] RTL871X: ThermalMeter = 0x18
[ 2433.451244] RTL871X: <==== _ReadAdapterInfo8188EU in 390 ms
[ 2433.499563] RTL871X: init_channel_set ChannelPlan ID 20 Chan num:13
[ 2433.507932] RTL871X: pwrctrlpriv.bSupportRemoteWakeup~~~~~~
[ 2433.513843] RTL871X: pwrctrlpriv.bSupportRemoteWakeup~~~[1]~~~
[ 2433.519976] RTL871X: can't get autopm:
[ 2433.524047] RTL871X: rtw_macaddr_cfg MAC Address  = 00:11:7f:45:10:61
[ 2433.530815] RTL871X: bDriverStopped:1, bSurpriseRemoved:0, bup:0, hw_init_completed:0
[ 2433.595038] RTL871X: rtw_ndev_init(wlan0)
[ 2433.608842] RTL871X: _rtw_drv_register_netdev, MAC Address (if1) = 00:11:7f:45:10:61
[ 2433.625581] usbcore: registered new interface driver rtl8188eu
[ 2433.631752] RTL871X: module init ret=0

检查模块是否安装成功

root@am335x-evm:~/modules# ifconfig wlan0 up
[ 2505.334091] RTL871X: +871x_drv - drv_open, bup=0
[ 2505.338993] RTL871X: Set RF Chip ID to RF_6052 and RF type to 1T1R.
[ 2505.347242] RTL871X: rtl8188e_FirmwareDownload fw:NIC, size: 13904
[ 2505.354022] RTL871X: rtl8188e_FirmwareDownload: fw_ver=b fw_subver=0001 sig=0x88e1, Month=11, Date=27, Hour=30, Minute=36
[ 2505.381116] RTL871X: polling_fwdl_chksum: Checksum report OK! (1, 0ms), REG_MCUFWDL:0x00030005
[ 2505.391338] RTL871X: =====> _8051Reset88E(): 8051 reset success .
[ 2505.398168] RTL871X: _FWFreeToGo: Polling FW ready OK! (1, 10ms), REG_MCUFWDL:0x000300c6
[ 2505.406715] RTL871X: FWDL success. write_fw:1, 40ms
[ 2505.683516] ==> rtl8188e_iol_efuse_patch
[ 2505.733796] RTL871X: pDM_Odm TxPowerTrackControl = 1
[ 2505.918341] RTL871X: rtl8188eu_hal_init in 580ms
[ 2505.923964] RTL871X: hw_var_set_opmode()-2938 mode = 2
[ 2505.931653] RTL871X: MAC Address = 00:11:7f:45:10:61
[ 2505.937513] RTL871X: -871x_drv - drv_open, bup=1
root@am335x-evm:~/modules# [ 2507.936714] RTL871X: ==>rtw_ps_processor .fw_state(8)
[ 2507.942051] RTL871X: ==>ips_enter cnts:1
[ 2507.946230] RTL871X: nolinked power save enter
[ 2507.950898] RTL871X: ===> rtw_ips_pwr_down...................
[ 2507.956963] RTL871X: ====> rtw_ips_dev_unload...
[ 2507.979046] RTL871X: usb_read_port_cancel
[ 2507.983993] RTL871X: usb_read_port_complete() RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0)
[ 2507.993860] RTL871X: usb_read_port_complete() RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0)
[ 2508.003732] RTL871X: usb_read_port_complete() RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0)
[ 2508.013573] RTL871X: usb_read_port_complete() RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0)
[ 2508.023176] RTL871X: usb_read_port_complete() RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0)
[ 2508.032974] RTL871X: usb_read_port_complete() RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0)
[ 2508.043078] RTL871X: usb_read_port_complete() RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0)
[ 2508.052943] RTL871X: usb_read_port_complete() RX Warning! bDriverStopped(0) OR bSurpriseRemoved(0)
[ 2508.062645] RTL871X: usb_write_port_cancel
[ 2508.067534] RTL871X: ==> rtl8188eu_hal_deinit
[ 2508.072411] RTL871X: bkeepfwalive(0)
[ 2508.079923] RTL871X: SetHwReg8188EU: bMacPwrCtrlOn=0
[ 2508.085191] RTL871X: <=== rtw_ips_pwr_down..................... in 140ms

查看网口信息,多出wlan0网卡

root@am335x-evm:~/modules# ifconfig
eth0      Link encap:Ethernet  HWaddr E4:39:80:16:F5:C4  inet addr:192.168.2.125  Bcast:192.168.2.255  Mask:255.255.255.0UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1RX packets:16901 errors:0 dropped:6 overruns:0 frame:0TX packets:8824 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:11790505 (11.2 MiB)  TX bytes:1371622 (1.3 MiB)Interrupt:56 lo        Link encap:Local Loopback  inet addr:127.0.0.1  Mask:255.0.0.0UP LOOPBACK RUNNING  MTU:65536  Metric:1RX packets:10 errors:0 dropped:0 overruns:0 frame:0TX packets:10 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0 RX bytes:700 (700.0 B)  TX bytes:700 (700.0 B)wlan0     Link encap:Ethernet  HWaddr 00:11:7F:45:10:61  UP BROADCAST MULTICAST  MTU:1500  Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
4. AP模式

为了让板子上的RTL8188模块,发出WIFI信号,其他设备可以连接进来,即把RTL8188当作WIFI热点来使用,需要借助hostapd来实现。
解压缩wpa_supplicant_hostapd.zip,进入wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/hostapd/文件夹下,修改Makefile并编译源码

//在ifndef CC之前定义CC编译器
CC=/home/mq/project/Dasheng_AM335X/am335x/tools/x86-linux-gnu/bin/arm-linux-gnueabihf-gccifndef CC
CC=gcc
endif

执行make编译hostapd

拷贝wpa_supplicant_hostapd/文件夹下的rtl_hostapd_2G.conf到板子的/etc/目录下。
root@am335x-evm:~# hostapd -d /etc/rtl_hostapd_2G.conf -B
启动hostapd,并置于后台运行。以下为hostapd启动日志。

random: Trying to read entropy from /dev/random
Configuration file: /etc/rtl_hostapd_2G.conf
[ 9411.227675] RTL871X: +871x_drv - drv_open, bup=1
[ 9411.232722] RTL871X: -871x_drv - drv_open, bup=1
drv->ifindex=3
l2_sock_recv==l2_sock_xmit=0x0x52638[ 9411.240963] RTL871X: _rtw_pwr_wakeup call ips_leave....[ 9411.249605] RTL871X: ==>ips_leave cnts:7
[ 9411.253794] RTL871X: ===>  rtw_ips_pwr_up..............
[ 9411.259301] RTL871X: ===> ips_netdrv_open.........
[ 9411.267714] RTL871X: SetHwReg8188EU: bMacPwrCtrlOn=1
[ 9411.273013] RTL871X: Set RF Chip ID to RF_6052 and RF type to 1T1R.
[ 9411.280412] RTL871X: rtl8188e_FirmwareDownload fw:NIC, size: 13904
[ 9411.286925] RTL871X: rtl8188e_FirmwareDownload: fw_ver=b fw_subver=0001 sig=0x88e1, Month=11, Date=27, Hour=30, Minute=36
[ 9411.314026] RTL871X: polling_fwdl_chksum: Checksum report OK! (1, 0ms), REG_MCUFWDL:0x00030005
[ 9411.324259] RTL871X: =====> _8051Reset88E(): 8051 reset success .
[ 9411.331203] RTL871X: _FWFreeToGo: Polling FW ready OK! (1, 10ms), REG_MCUFWDL:0x000300c6
[ 9411.339706] RTL871X: FWDL success. write_fw:1, 40ms
[ 9411.610304] ==> rtl8188e_iol_efuse_patch
[ 9411.653651] RTL871X: pDM_Odm TxPowerTrackControl = 1
[ 9411.834743] RTL871X: rtl8188eu_hal_init in 570ms
[ 9411.839775] RTL871X: hw_var_set_opmode()-2938 mode = 2
[ 9411.847909] RTL871X: <===  rtw_ips_pwr_up.............. in 590ms
[ 9411.854276] RTL871X: nolinked power save leave
[ 9411.859176] RTL871X: ==> ips_leave.....LED(0x00028282)...
[ 9411.864890] RTL871X: set_mode = IW_MODE_MASTER
[ 9411.870200] RTL871X: hw_var_set_opmode()-2938 mode = 3
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bit[ 9411.876348] RTL871X: rtw_hostapd_sta_flush
s)
Scan for neighboring BSSes prior to enabling 40 MHz channel
Failed to request a scan of neighboring BSSes
HT40: control channel: 6  secondary channel: 10
Completing interface initialization
Mode: IEEE 802.11g  Channel: 6  Frequency: 2437 MHz
RATE[0] rate=10 flags=0x1
RATE[1] rate=20 flags=0x1
RATE[2] rate=55 flags=0x1
RATE[3] rate=110 flags=0x1
RATE[4] rate=60 flags=0x0
RATE[5] rate=90 flags=0x0
RATE[6] rate=120 flags=0x0
RATE[7] rate=180 flags=0x0
RATE[8] rate=240 flags=0x0
RATE[9] rate=360 flags=0x0
RATE[10] rate=480 flags=0x0
RATE[11] rate=540 flags=0x0
Flushing old station entries
[ 9412.061635] RTL871X: rtw_sta_flush(wlan0)
[ 9412.065871] RTL871X: issue_deauth to ff:ff:ff:ff:ff:ff
Deauthenticate all stations
+rtl871x_sta_dea[ 9412.072003] RTL871X: rtw_set_encryption
uth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2
[ 9412.079794] RTL871X: clear default encryption keys, keyid=0
rtl871x_set_key_ops
rtl871x_set_key_ops
[ 9412.126527] RTL871X: rtw_set_encryption
[ 9412.132059] RTL871X: clear default encryption keys, keyid=1
rtl871x_set_key_ops
[ 9412.138220] RTL871X: rtw_set_encryption
[ 9412.144060] RTL871X: clear default encryption keys, keyid=2
rtl871x_set_key_ops
[ 9412.253401] RTL871X: rtw_set_encryption
[ 9412.259220] RTL871X: clear default encryption keys, keyid=3
Using interface wlan0 with hwaddr 00:11:7f:45:10:61 and ssid 'rtwap'
Deriving WPA PSK based on passphrase
SSID - hexdump_ascii(len=5):72 74 77 61 70                                    rtwap
PSK (ASCII passphrase) - hexdump_ascii(len=8): [REMOVED]
PSK (from passphrase) - hexdump(len=32): [REMOVE[ 9412.397508] RTL871X: rtw_set_beacon, len=149
D]
WPS: Use configured UUID - hexdump(len=16): [ 9412.405550] RTL871X: rtw_check_beacon_data, len=135
[ 9412.414878] RTL871X: [HT] Support STBC = 0x01WPS: Build Beacon IEs
WPS:  * Version (hardcod[ 9412.424120] RTL871X: update_hw_ht_param
ed 0x10)
WPS:  * Wi-Fi Protected Setup State (2)
WPS: Build Probe Response IEs
WPS:  * Versio[ 9412.436121] RTL871X: CH=6, BW=1, offset=1
n (hardcoded 0x10)
WPS:  * Wi-Fi Protected Setu[ 9412.445057] RTL871X: HW_VAR_BASIC_RATE: 0x15f -> 0x15f -> 0x15f
p State (2)
WPS:  * Response Type (3)
WPS:  * [ 9412.455387] RTL871X: ### Set STA_(1) info
UUID-E
WPS:  * Manufacturer
WPS:  * Model Name[ 9412.463353] RTL871X: update_bmc_sta=> mac_id:1 , raid:6 , bitmap=0xfWPS:  * Model Number
WPS:  * Serial Number
W[ 9412.474354] RTL871X: rtl8188e_Add_RateATid=> mac_id:1 , raid:6 , ra_bitmap=0xf, shortGIrate=0x00
PS:  * Primary Device Type
[ 9412.487664] RTL871X: ### MacID(1),Set Max Tx RPT MID(2)WPS:  * Config Methods (18c)
WPS:  * RF Bands [ 9412.497761] RTL871X: ### rtl8188e_set_FwMediaStatus_cmd: MStatus=1 MACID=1
(1)
rtl871x_set_beacon_ops
[ 9412.510085] RTL871X: assoc success
rtl871x_set_hidden_ssid ignore_broadcast_ssid:0,[ 9412.515547] RTL871X: rtw_set_hidden_ssid(wlan0) ignore_broadcast_ssid:0, rtwap,5rtwap,5
rtl871x_set_acl
rtl871x_set_wps_[ 9412.527983] RTL871X: rtw_set_wps_assoc_resp, len=14
assoc_resp_ie
rtl871x_set_wps_beacon_ie[ 9412.536624] RTL871X: rtw_set_wps_beacon, len=30rtl871x_set_wps_probe_resp_ie
[ 9412.544879] RTL871X: rtw_set_wps_probe_resp, len=136
urandom: Got 20/20 bytes from /dev/urandom
GMK - hexdump(len=32): [REMOVED]
Key Counter - hexdump(len=32): [REMOVED]
WPA: group state machi[ 9412.561890] RTL871X: rtw_set_encryption
ne entering state GTK_INIT (VLAN-ID 0)
GTK - he[ 9412.569634] RTL871X: rtw_set_encryption, set group_key, CCMP
xdump(len=16): [REMOVED]
WPA: group state machi[ 9412.579817] RTL871X: rtw_ap_set_group_key
ne entering state SETKEYSDONE (VLAN-ID 0)
rtl871x_set_key_ops
[ 9412.589581] RTL871X: set group key camid:1, addr:00:00:00:00:00:00, kid:1, type:AES
[ 9412.602743] RTL871X: SetHwReg8188EU, 3663, RCR= 7000208e
rtl871x_set_beacon_ops
[ 9412.609151] RTL871X: rtw_set_beacon, len=171
[ 9412.615687] RTL871X: rtw_check_beacon_data, len=157
[ 9412.620862] RTL871X: [HT] Support STBC = 0x01
[ 9412.625840] RTL871X: update_hw_ht_param
[ 9412.633582] RTL871X: CH=6, BW=1, offset=1
[ 9412.640338] RTL871X: HW_VAR_BASIC_RATE: 0x15f -> 0x15f -> 0x15f
[ 9412.647292] RTL871X: ### Set STA_(1) info
[ 9412.651567] RTL871X: update_bmc_sta=> mac_id:1 , raid:6 , bitmap=0xf
[ 9412.658248] RTL871X: rtl8188e_Add_RateATid=> mac_id:1 , raid:6 , ra_bitmap=0xf, shortGIrate=0x00
[ 9412.667518] RTL871X: ### MacID(1),Set Max Tx RPT MID(2)
[ 9412.673386] RTL871X: ### rtl8188e_set_FwMediaStatus_cmd: MStatus=1 MACID=1
rtl871x_set_hidden_ssid ignore_broadcast_ssid:0,[ 9412.681310] RTL871X: rtw_set_hidden_ssid(wlan0) ignore_broadcast_ssid:0, rtwap,5rtwap,5
rtl871x_set_acl
wlan0: Setup of interface done.

通过手机或者其它WIFI设备,可以搜索到rtl8188模块发出的无线信号。WIFI名称以及密码,在rtl_hostapd_2G.conf文件中进行配置,默认配置为:

##### hostapd configuration file ##############################################interface=wlan0
ctrl_interface=/var/run/hostapd
ssid=rtwap
channel=6
wpa=2
wpa_passphrase=87654321
#bridge=br0

参考:《Quick_Start_Guide_for_SoftAP.pdf》

5. Station模式

Station模式下,RTL8188模块可以作为WIFI客户端,去连接其它设备的AP信号,比如连接到路由器级,实现上网功能。
解压缩wpa_supplicant_hostapd.zip,进入wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/wpa_supplicant/文件夹下,修改Makefile并编译源码

CC=/home/mq/project/Dasheng_AM335X/am335x/tools/x86-linux-gnu/bin/arm-linux-gnueabihf-gccifndef CC
CC=gcc
endif

执行make编译,得到wpa_supplicantwpa_cli应用程序,拷贝到板子的/usr/bin目录下,在/etc/目录下,创建wpa_supplicant.conf文件,内容为

ctrl_interface=/var/run/wpa_supplicant
update_config=1

通过wpa_cli配置目标AP的信号,即WIFI用户名和密码。

//首先启动wpa_supplicant,后台运行
root@am335x-evm:~# wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant.conf -B
//扫描周边的wifi信号
root@am335x-evm:~# wpa_cli -p/var/run/wpa_supplicant scan
//查看扫描的结果
root@am335x-evm:~# wpa_cli -p/var/run/wpa_supplicant scan_results
Selected interface 'wlan0'
bssid / frequency / signal level / flags / ssid
68:db:54:30:08:ff   2412    93  [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][ESS]  317
40:f4:20:bf:fa:0a   2452    80  [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] ChinaNet-kisW
8c:14:b4:5a:6f:10   2447    68  [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] ChinaNet-7ECn
d0:76:e7:2f:6b:20   2437    61  [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]  myy888
74:7d:24:d2:b5:dc   2422    58  [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][ESS]  @PHICOMM_401
50:3a:a0:48:24:1e   2412    56  [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]  gja2095
d0:c7:c0:e8:84:f4   2452    56  [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] TP-LINK_84F4
50:bd:5f:10:e0:a4   2437    56  [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]
dc:fe:18:00:1e:d7   2462    42  [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][ESS]  ________________________
50:bd:5f:6b:16:a6   2437    48  [WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS] TPlink-RunOne
a4:56:02:d6:1f:45   2412    46  [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]  happle12345
28:f3:66:b3:a2:52   2422    46  [WPA2-PSK-CCMP][WPS][ESS]   B-LINK_B3A252
fc:d7:33:c2:dd:3c   2462    44  [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]  401
d4:61:2e:b8:84:80   2462    43  [WPA2-PSK-CCMP][WPS][ESS]   HUAWEI-8
0c:ef:af:d0:c5:1c   2462    43  [WPA-PSK-CCMP][ESS] Widora-C51C
8c:14:b4:53:98:08   2427    46  [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] ChinaNet-sUXm
18:bc:5a:0b:78:90   2462    45  [WPA2-PSK-CCMP][ESS]
1e:bc:5a:0b:78:90   2462    44  [WPA2-PSK-CCMP][ESS]    runone
22:bc:5a:0b:78:90   2462    43  [WPA2-PSK-CCMP][ESS]    runone_guest
28:6c:07:45:78:2e   2457    42  [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] QianDou Technoligy
88:44:77:a8:ec:95   2412    47  [WPA2-PSK-CCMP][ESS]
74:7d:24:ca:76:68   2437    26  [WPA2-PSK-CCMP][ESS]    PD
bc:46:99:4a:8b:60   2462    26  [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]  TP-LINK_201
8c:be:be:10:0e:23   2432    26  [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][WPS][ESS] Xiaomi_0E22
2a:f3:66:b2:a2:52   2422    44  [ESS]    __________________WiFi
2a:6c:07:44:78:2e   2457    26  [ESS]
//连接到目标AP
//查看当前连接的AP(没有连接)
root@am335x-evm:~# wpa_cli -p/var/run/wpa_supplicant list_network
Selected interface 'wlan0'
network id / ssid / bssid / flags
//新增网络信息
root@am335x-evm:~# wpa_cli -p/var/run/wpa_supplicant add_network 0
Selected interface 'wlan0'
0
//再次查看网络列表,多了id为0的网络
root@am335x-evm:~# wpa_cli -p/var/run/wpa_supplicant list_network
Selected interface 'wlan0'
network id / ssid / bssid / flags
0       any [DISABLED]
//设置wifi用户名,注意字符串格式
root@am335x-evm:~# wpa_cli -p/var/run/wpa_supplicant set_network 0 ssid '"317"'
Selected interface 'wlan0'
OK
//设置wifi密码
root@am335x-evm:~# wpa_cli -p/var/run/wpa_supplicant set_network 0 psk '"woyaohaohaoxuexi"'
//启动网络连接
root@am335x-evm:~# wpa_cli -p/var/run/wpa_supplicant select_network 0
//保存以上配置
root@am335x-evm:~/modules# wpa_cli -p/var/run/wpa_supplicant save_config

执行DHCP动态获取IP地址

udhcpc -i wlan0 -q

设置路由

route add default gw 192.168.2.1 dev wlan0

参考:《Quick_Start_Guide_for_Station_Mode.pdf》

6. AP + Station并发模式

为了能够让WIFI工作在AP+Station模式,RTL8188 需要配置成并发模式(concurrent mode)。具体可以参考RTL8188EUS_linux_v4.3.0.7_12758.20141114/document/Realtek_WiFi_concurrent_mode_Introduction.pdf文档。
driver/rtl8188EUS_linux_v4.3.0.7_12758.20141114/include/autoconf.h文件中,定位到110行,取消//#define CONFIG_CONCURRENT_MODE

#define CONFIG_CONCURRENT_MODE
#ifdef CONFIG_CONCURRENT_MODE//#define CONFIG_HWPORT_SWAP               //Port0->Sec , Port1 -> Pri#define CONFIG_RUNTIME_PORT_SWITCH//#define DBG_RUNTIME_PORT_SWITCH#define CONFIG_STA_MODE_SCAN_UNDER_AP_MODE#define CONFIG_TSF_RESET_OFFLOAD          // For 2 PORT TSF SYNC.
#endif

重新编译内核模块,拷贝到板子,安装内核模块insmod 8188eu.ko
查看网口信息,可以看到多了wlan0wlan1,说明已经安装成功。

root@am335x-evm:~/modules# ifconfig -a
eth0      Link encap:Ethernet  HWaddr E4:39:80:16:F5:C4  inet addr:192.168.2.132  Bcast:192.168.2.255  Mask:255.255.255.0UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1RX packets:55920 errors:0 dropped:33 overruns:0 frame:0TX packets:12445 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:21227695 (20.2 MiB)  TX bytes:1857228 (1.7 MiB)Interrupt:56 lo        Link encap:Local Loopback  inet addr:127.0.0.1  Mask:255.0.0.0UP LOOPBACK RUNNING  MTU:65536  Metric:1RX packets:10 errors:0 dropped:0 overruns:0 frame:0TX packets:10 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0 RX bytes:700 (700.0 B)  TX bytes:700 (700.0 B)wlan0     Link encap:Ethernet  HWaddr 00:11:7F:45:10:61  BROADCAST MULTICAST  MTU:1500  Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)wlan1     Link encap:Ethernet  HWaddr 02:11:7F:45:10:61  BROADCAST MULTICAST  MTU:1500  Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

参考:《Realtek_WiFi_concurrent_mode_Introduction.pdf》

移植dns服务器
首先手动设置wlan0网口的IP地址为192.168.8.1,启动AP模式,root@am335x-evm:~/modules# hostapd /etc/rtl_hostapd_2G.conf -B

要让hostap模式能够自动为连接上来的用户分配IP地址,需要借助dns服务器来实现。dns服务器有很多种,这里选择dnsmasq,下载链接:dnsmasq下载链接

我这里选择的版本是:dnsmasq-2.80.tar.gz
解压缩,进入dnsmasq-2.80/文件夹,修改Makefile文件

CC            = /home/mq/project/Dasheng_AM335X/am335x/tools/x86-linux-gnu/bin/arm-linux-gnueabihf-gcc
# PREFIX        = /usr/local
PREFIX        = /home/mq/project/Dasheng_AM335X/wifi_rtl8188eus/dnsmasq-2.80/_install

添加CC变量,指定交叉编译器;修改make install的安装路径为当前路径下的_install文件夹,_install文件夹手动创建。修改完之后,保存,然后执行编译并安装。

make;make install

安装完成之后,在dnsmasq-2.80/_install/sbin/文件夹下,得到可执行文件dnsmasq,拷贝到板子的/usr/sbin目录下。
接下来是修改dnsmasq的配置文件。
拷贝dnsmasq-2.80/dnsmasq.conf.example到板子系统的/etc/目录下,并改名为dnsmasq.conf

# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
interface=wlan0        # 指定网口# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
#dhcp-range=192.168.0.50,192.168.0.150,12h
dhcp-range=192.168.8.2,192.168.8.255,12h   # 指定分配的IP地址范围

启动dnsmasq服务器,root@am335x-evm:~/modules# dnsmasq -C /etc/dnsmasq.conf

添加端口转发

# echo '1' > /proc/sys/net/ipv4/ip_forward
# iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
# iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

eth0 连接到路由器,然后,手机连接到rtl8188的AP上,即可实现手机和板子同时上网。

屏蔽调试信息
/RTL8188EUS_linux_v4.3.0.7_12758.20141114/driver/rtl8188EUS_linux_v4.3.0.7_12758.20141114/include/autoconf.h文件的379行,屏蔽

#define CONFIG_DEBUG /* DBG_871X, etc... */
//#define CONFIG_DEBUG_RTL871X /* RT_TRACE, RT_PRINT_DATA, _func_enter_, _func_exit_ */#define CONFIG_PROC_DEBUG#define DBG_CONFIG_ERROR_DETECT
//#define DBG_CONFIG_ERROR_DETECT_INT
#define DBG_CONFIG_ERROR_RESET===>
//#define CONFIG_DEBUG /* DBG_871X, etc... */
//#define CONFIG_DEBUG_RTL871X /* RT_TRACE, RT_PRINT_DATA, _func_enter_, _func_exit_ *///#define CONFIG_PROC_DEBUG//#define DBG_CONFIG_ERROR_DETECT
//#define DBG_CONFIG_ERROR_DETECT_INT
//#define DBG_CONFIG_ERROR_RESET

错误

  1. hostapd无法启动

    root@am335x-evm:~# hostapd -d /etc/rtl_hostapd_2G.conf -B
    random: Trying to read entropy from /dev/random
    Configuration file: /etc/rtl_hostapd_2G.conf
    drv->ifindex=5
    l2_sock_recv==l2_sock_xmit=0x0x52638
    ioctl[SIOCSIWMODE]: Operation not supported
    Could not set interface to mode(3)!
    Could not set interface to master mode!
    rtl871xdrv driver initialization failed.
    rmdir[ctrl_interface]: No such file or directory
    

    需要修改内核配置

    Device Drivers  --->[*] Network device support  --->[*]   Wireless LAN  ---><*>   IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
    
  2. MASQUERADE 错误
    root@am335x-evm:~#  iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    iptables v1.8.2 (legacy): Couldn't load target `MASQUERADE':No such file or directoryTry `iptables -h' or 'iptables --help' for more information.
    root@am335x-evm:~# iptables -h
    

    编译iptables时候,使用静态链接方式,不要使用动态链接方式。
    ./configure --host=arm-linux --enable-static --disable-shared --prefix=/home/mq/project/Dasheng_AM335X/wifi_rtl8188eus/iptables/__install/ --disable-ipv6 --disable-largefile --disable-nftables CC=/home/mq/project/Dasheng_AM335X/am335x/tools/x86-linux-gnu/bin/arm-linux-gnueabihf-gcc
    make;make isntall
    拷贝xtables-legacy-multi到板上的/usr/sbin目录下,手动创建软连接ln -s xtables-legacy-multi iptables

AM335x移植WIFI模块RTL8818EUS相关推荐

  1. AM335x添加WiFi模块WILC1000

    基于TI 的PSDK的linux和文件系统添加wilc1000.sdk版本:ti-processor-sdk-linux-am335x-evm-06.03.00.106. 1.硬件连接 wilc100 ...

  2. hi3518e移植wifi模块注意事项

    最近在海思平台上移植mt7601和5370两款wif模块,加载驱动和启用网络设备时都发现循环打印一个RTUSB_VendorRequest failed(-110),TxFlags=0x0, ReqT ...

  3. 全志T7平台上移植WiFi RTL8188EUS

    T7平台上移植WiFi RTL8188EUS 需求 在T7平台上移植wifi驱动模块RTL8818EUS,工作模式为AP模式,即RTL8818EUS模块当作WIFI热点来使用,便于其他设备连接进去,实 ...

  4. 关于AM335X移植SDIO WIFI的简易教程(转)

    最近应一个朋友邀请,帮他移植了SDIO WIFI到3.2版本内核.因为之前已经成功移植了3.14内核,所以整个过程花了一个下午就完成了. 话不多说,先交待一下平台: CPU:TI AM3352 600 ...

  5. Linux 开发板4G转WiFi热点 手机连接热点上网(三 WiFi模块的移植及AP的建立)

    这里对WiFi模块的驱动就不做详细介绍,本篇文章可能会涉及两款WiFi模块,一个是USB接口的WiFi模块,一个是SDIO接口的wifi模块,即AP6212,平台可能涉及爱特梅尔和三星的4418两个平 ...

  6. wifi模块服务器项目心得,一次关于WiFi 驱动移植的总结复盘

    1 简介 WiFi 是什么?能用来做什么? 都 2021 年了,相信您对 WiFi 一定不陌生了. 可以参考这里的百度百科释义:[百度百科 - WiFi(https://baike.baidu.com ...

  7. Linux WIFI模块驱动移植

    作者 QQ群:852283276 微信:arm80x86 微信公众号:青儿创客基地 B站:主页 https://space.bilibili.com/208826118 参考 请问有知道atheros ...

  8. 嵌入式Linux:移植USB接口的RTL8188EUS、RTL8188ETV WIFI模块

    文章目录 参考博客 github上面的源码 神仙网站 一.驱动移植 二.内核配置 1.配置USB支持设备 2.配置支持WIFI设备 3.配置支持IEEE 802.11 三.编译.拷贝和运行 1.运行测 ...

  9. 基于I.MX6UL平台的WIFI模块AP6214A 驱动移植

    基于I.MX6UL平台的WIFI模块AP6214A 驱动移植 IoT-6ULX简要介绍 IoT-6ULX,主要面向Internet Of Things应用,该产品集成了 ARM Cortex-A7 9 ...

最新文章

  1. 爬虫准备工作1-Java写入字符串到txt文档
  2. emmc linux.格式化参数,大家都是怎么格式化emmc芯片的?能在ADB SHELL 中操作吗?uboot 就实现了GPT分区和烧录功能...
  3. [BZOJ 2425] 计数
  4. APUE读书笔记-第15章-进程间通信
  5. POJ1269(判断线段相交)
  6. redis-cli 常用命令
  7. 抛弃NVelocity,来玩玩Razor
  8. java字符串反转及替换_字符串的替换(str_replace)
  9. ACM模板——差分约束
  10. 用一句位运算判断两个整数的大小并返回较大者
  11. 转:解决vs2015生成软件在XP中运行时提示“不是有效的WIN32应用程序”
  12. android eclipse下载
  13. 二代U盾/迷你充电宝/护颈仪液晶段码屏驱动芯片:VK1088B QFN32 超小体积封装LCD驱动芯片
  14. ionCube 安装
  15. yolov5训练模型
  16. tensorflow出现报错: Could not locate zlibwapi.dll或者Could not load library cudnn_cnn_infer64_8.dll.
  17. 艾永亮:回力鞋生死的92年,风靡全球后没落,如今成功逆袭
  18. 政策频出 | 明确应用商店职责,聚焦个人信息保护
  19. 网页端Skype更新 在桌面/移动平台添加对Safari的支持
  20. HTML代码学习(上)

热门文章

  1. HashMap扩容死锁
  2. ​国务院机构改革方案的学习
  3. micropython开发板有什么用_迷惘的邂逅 的想法: 玩转MicroPython开发板!你和Ta会有什么…...
  4. 关于yuv 格式-Semi Planar和Planar
  5. mysql 修改表字段长度
  6. 装修工地现场工程队监控时间水印相机软件新利器
  7. AI大数据可视化EasyCVR视频融合平台的部署操作流程详解
  8. H-Builder 品优购-购物车的实现
  9. 现在微商怎么做营销?
  10. 展讯8910DM:如果VBus和VBat接在一起,导致模组某些功能出现异常的问题分析