1.下载rtl8189ftv驱动:
git clone https://github.com/jwrdegoede/rtl8189ES_linux.git
git checkout -b rtl8189fs origin/rtl8189fs //下载8189fs的分支
git pull //检查更新
2.处理一下包:
进入rtl8189ES_linux目录:把git删除掉
find . -name ".git" | xargs rm -rf
拷贝rtl8189ES_linux到hisi的kernel/linux-(分支)/drivers/net/wireless/rtl8189ES_linux/
3.修改rtl8189ftv驱动包里面的Makefile:
CONFIG_RTL8188F = y#已经默认了,对应rtl8189ftv的驱动
CONFIG_SDIO_HCI = y#使用SDIO接口
CONFIG_PLATFORM_HISILICON = y#对应平台打开
##################################################################
#这里是配置海思平台的内容
ifeq ($(CONFIG_PLATFORM_HISILICON), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_HISILICON
ifeq ($(SUPPORT_CONCURRENT),y)
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
endif
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
ARCH := arm
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE = arm-hisiv500-linux- #修改编译环境
endif
MODULE_NAME := rtl8192eu #指定驱动的名字: rtl8192eu.ko
ifeq ($(KSRC),)
KSRC := ../../../../ #定义kernel位置,注意要编译驱动,先编译kernel,否则驱动编译出错
endif
endif
#######################################################################
4.加载到内核
我们看一下驱动的Kconfig是啥:
cat Kconfig
########################################################################
# SPDX-License-Identifier: GPL-2.0
config RTL8189FS #配置好后; .config文件会有宏:CONFIG_RTL8189FS,用于Makefile使用
tristate "Realtek 8189F SDIO WiFi"
---help---
Help message of RTL8189FS
########################################################################
linux-*/drivers/net/wireless/Kconfig添加:
source "drivers/net/wireless/rtl8189ES_linux/Kconfig"
linux-*/drivers/net/wireless/Makefile添加:其中CONFIG_RTL8189FS由Kconfig添加
obj-$(CONFIG_RTL8189FS) += rtl8189ES_linux/
5.配置kernel:(根据海思的wifi使用指南来做)
a.wifi驱动依赖于cfg80211;所以进入 Network support->Wireless,设置 cfg80211 和 mac80211 为 M
│ │ --- Wireless │ │
│ │ <M> cfg80211 - wireless configuration API │ │
│ │ [ ] nl80211 testmode command │ │
│ │ [ ] enable developer warnings │ │
│ │ [ ] cfg80211 regulatory debugging │ │
│ │ [*] enable powersave by default │ │
│ │ [ ] cfg80211 wireless extensions compatibility │ │
│ │ <M> Generic IEEE 802.11 Networking Stack (mac80211) │ │
│ │ Default rate control algorithm (Minstrel) ---> │ │
│ │ [ ] Enable mac80211 mesh networking (pre-802.11s) support │ │
│ │ [ ] Trace all mac80211 debug messages │ │
│ │ [ ] Select mac80211 debugging features ----
b. iwconfig、iwlist、iwpriv依赖于WEXT;而WEXT在 USB ZD1201 based Wireless device support有这个功能;所以在Device Drivers->Network device support->WirelessLAN,设置 USB ZD1201 based Wireless device support 为 M.
其中<M> Realtek 8189F SDIO WiFi 是我们配置的8189ftv驱动,勾上
│ │ --- Wireless LAN │ │
│ │ < > Marvell 8xxx Libertas WLAN driver support with thin firmware │ │
│ │ < > Atmel at76c503/at76c505/at76c505a USB cards │ │
│ │ <M> USB ZD1201 based Wireless device support │ │
│ │ < > Wireless RNDIS USB support │ │
│ │ < > Realtek 8187 and 8187B USB support │ │
│ │ <M> Realtek 8189F SDIO WiFi │ │
│ │ < > Simulated radio testing tool for mac80211 │ │
│ │ [ ] Enable WiFi control function abstraction │ │
│ │ < > Atheros Wireless Cards ---- │ │
│ │ < > Broadcom 43xx wireless support (mac80211 stack) │ │
│ │ < > Broadcom 43xx-legacy wireless support (mac80211 stack) │ │
│ │ < > Broadcom IEEE802.11n PCIe SoftMAC WLAN driver │ │
│ │ < > Broadcom IEEE802.11n embedded FullMAC WLAN driver │ │
│ │ < > IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP) │ │
│ │ < > Marvell 8xxx Libertas WLAN driver support │ │
│ │ < > Softmac Prism54 support │ │
│ │ < > Ralink driver support ---- │ │
│ │ <M> Realtek rtlwifi family of devices ---> │ │
│ │ [ ] TI Wireless LAN support ---- │ │
│ │ < > ZyDAS ZD1211/ZD1211B USB-wireless support │ │
│ │ < > Marvell WiFi-Ex Driver │ │
│ │ < > CW1200 WLAN support │ │
│ │ < > Redpine Signals Inc 91x WLAN driver support
c.rtl8189ftv对应SDIO时钟为 50MHz 左右 (暂未修改); 如果wifi电压为1.8,修改SDIO为1.8v.(暂未修改)
d.Network support->Networking options,设置 The IPv6 protocol 为 y
e.rtl8189ftv需要将 cap-sdio-irq添加到dtsi对应的mmc设备树上
6.编译内核,烧写到板子上,然后运行cfg80211.ko、8189fs.ko
7.运行:
ifconfig -a可以查看是否有wlan0网卡!如果有可以使用ifconfig wlan0 up尝试启动。我遇到启动失败,原因是因为内核自带的rtl8188cus驱动需要rtl8192cufw.bin。然后去找了个驱动后,能正常启动!
# ifconfig -a
eth0 Link encap:Ethernet HWaddr B6:C0:55:51:DA:05
inet addr:192.168.6.181 Bcast:192.168.7.255 Mask:255.255.248.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:113992 errors:2 dropped:95 overruns:0 frame:0
TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7057458 (6.7 MiB) TX bytes:1151 (1.1 KiB)
Interrupt:24 Base address:0xc000
...
wlan0 Link encap:Ethernet HWaddr 00:11:7F:12:F2:5D
inet addr:192.168.9.101 Bcast:192.168.15.255 Mask:255.255.248.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8976 errors:0 dropped:3473 overruns:0 frame:0
TX packets:8189 errors:0 dropped:1 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1226599 (1.1 MiB) TX bytes:1001401 (977.9 KiB)
我加载程序驱动后,能ifconfig wlan0 up得到:
# ifconfig
eth0 Link encap:Ethernet HWaddr 36:A1:60:6B:F0:F7
inet addr:192.168.6.181 Bcast:192.168.7.255 Mask:255.255.248.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:334388 errors:1399 dropped:338 overruns:0 frame:1397
TX packets:2552 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:43357654 (41.3 MiB) TX bytes:255641 (249.6 KiB)
Interrupt:24 Base address:0xc000
...
wlan0 Link encap:Ethernet HWaddr 00:11:7F:12:F2:5D
UP BROADCAST RUNNING 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)
hostap,udhcpd,wpa_supplicant都是应用层了.
#################################################################################################################
备注我再其他平台移植rtl8188cus的WiFi模块时,usbWiFi配置就没那么多了,但cfg80211 等配置还是要的。遇到的问题:
1.我用到的系统内核自带rtl8188cu.ko。但是执行ifconfig wlan0 up时出现:需要rtl8192cufw.bin。而这东西不知道再哪里搞,只能使用别的方法了。
2.自己下载驱动(淘宝买模块却不提供),然后修改一下MAKEFILE,编译一下即可,加载cfg80211.ko,8192cu.ko即可:https://github.com/CalielOfSeptem/rtl8188cus/tree/master/driver
添加自己的内核路径和编译器!
ifeq ($(CONFIG_PLATFORM_ARM_SAM9X35), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH := arm
CROSS_COMPILE := arm-linux-
KVER := 2.6.24
KSRC := /home/lxin/workdir/kernelLize/linux-2.6.39-samkernel
endif
3.如果cfg80211.ko已经编译进内核,就不用insmod cfg80211.ko
│ │ --- Wireless │ │
│ │ <*> cfg80211 - wireless configuration API │ │
│ │ [ ] nl80211 testmode command │ │
│ │ [ ] enable developer warnings │ │
│ │ [ ] cfg80211 regulatory debugging │ │
│ │ [*] enable powersave by default │ │
│ │ [ ] cfg80211 DebugFS entries │ │
│ │ [ ] use statically compiled regulatory rules database │ │
│ │ [*] cfg80211 wireless extensions compatibility │ │
│ │ [*] Wireless extensions sysfs files │ │
│ │ {*} Common routines for IEEE802.11 drivers │ │
│ │ [ ] lib80211 debugging messages │ │
│ │ <*> Generic IEEE 802.11 Networking Stack (mac80211) │ │
│ │ [ ] PID controller based rate control algorithm │ │
│ │ [*] Minstrel │ │
│ │ [*] Minstrel 802.11n support │ │
│ │ Default rate control algorithm (Minstrel) ---> │ │
│ │ [ ] Enable mac80211 mesh networking (pre-802.11s) support │ │
│ │ -*- Enable LED triggers │ │
│ │ [ ] Export mac80211 internals in DebugFS │ │
│ │ [ ] Select mac80211 debugging features --->
4.wpa_supplicant使用:
#!/bin/sh
killall -9 wpa_supplicant
killall -9 udhcpc
#insmod cfg80211.ko
insmod 8192cu.ko
#ifconfig wlan0 up。使用了wpa_supplicant 后,wlan0会被直接启动,因此无需这一句
wpa_supplicant -Dwext -iwlan0 -c./lzWpa.conf &
sleep 4
udhcpc -iwlan0
这里备注一下:-Dwext而不是-Dnl80211(nl80211在pc端有这个驱动名)
5.wpa_supplicant的配置:
ctrl_interface=/var/run/wpa_supplicant # 一个目录,用于wpa_supplicant和wpa_cli的socket通信
network={
ssid="TP-LINK_EBEB" #WIFI名称
proto=WPA # proto: list of accepted protocols, 可取WPA,RSN
# 如果没有设置,默认为: WPA RSN
key_mgmt=WPA-PSK # 认证方式
# 如果没有设置,默认为: WPA-PSK WPA-EAP
# pairwise=TKIP # 如果没有设置,默认为: CCMP TKIP
# group=TKIP # 如果没有设置,默认为: CCMP TKIP WEP104 WEP40
psk="done123456" # WIFI密码
}
6.usb的wifi我遇到这么一个问题:
启动wpa_supplicant和udhcpc后,打印一些powersave信息,正常情况是不会有这些信息的。过一会还出现了 usb 1-1: USB disconnect, device number 2。然后wifi就被down掉了!
原因是usb供电不足。
###############################################################################################################
wifi可以ping通wifi路由器,或者wifi路由器所处的路由器环境
对wlan0添加默认网关:
route add default gw 192.168.9.1 dev wlan0
route -n来查看路由情况。这里有eth0的干扰,可能造成eth0处于局域网的情况。可以ifconfig eth0 down掉
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.5.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.9.1 0.0.0.0 UG 0 0 0 wlan0
192.168.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0
192.168.8.0 0.0.0.0 255.255.248.0 U 0 0 0 wlan0
# ifconfig eth0 down
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.9.1 0.0.0.0 UG 0 0 0 wlan0
192.168.8.0 0.0.0.0 255.255.248.0 U 0 0 0 wlan0
如果出现还不能上外网:查一下DNS配置:
# cat /etc/resolv.conf
nameserver 202.96.134.133
nameserver 202.96.134.133
###############################################################################################################