首先我们要对imx6平台的内核的驱动程序进行编译,添加WiFi驱动,并重新烧写金imx6内核中,这一步不多赘述。
连接主机和imx6平台后,打开我们的串口调试工具
进入root界面
1.使用ifconfig查看无线网卡设备
root@IMX6DLsabresd:~# ifconfig –a
eth0 Link encap:Ethernet HWaddr 00:09:C0:FF:EC:48
inet addr:192.168.12.199 Bcast:192.168.12.255 Mask:255.255.255.0
inet6 addr: fe80::209:c0ff:feff:ec48/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:1 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:78 (78.0 B)
Interrupt:41
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 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:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 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:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 00:0F:11:24:0A:68
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)
root@IMX6DLsabresd:~#
2.查看到USB无线网卡设备为wlan0时,此时驱动程序工作正常。
3.启动无线网卡设备wlan0
root@IMX6DLsabresd:~# ifconfig wlan0 up
+871x_drv - drv_open, bup=0
===> FirmwareDownload91C() fw:Rtl819XFwImageArray_TSMC
fw_ver=v75, fw_subver=0, sig=0x88c0
fw download ok!
Set RF Chip ID to RF_6052 and RF type to 1T1R.
GPIO_IN=08
eRfPowerStateToSet=0
IQK:Start!!!
Path A IQK Success!!
Path A IQK Success!!
IQK: final_candidate is 0
IQK: RegE94=100 RegE9C=b RegEA4=fc RegEAC=0 RegEB4=0 RegEBC=0 Reg
EC4=0 RegECC=0
Path A IQ Calibration Success !
pdmpriv->TxPowerTrackControl = 1
MAC Address from REG_MACID = 00:0f:11:24:0a:68
MAC Address = 00:0f:11:24:0a:68
-871x_drv - drv_open, bup=1
ADDRCONF(NETDEV_UP): wlan0: link is not ready
root@IMX6DLsabresd:~#
4.扫描可用无线网络
root@IMX6DLsabresd:~# iwlist scanning
lo Interface doesn't support scanning.
eth0 Interface doesn't support scanning.
usb0 Interface doesn't support scanning.
sit0 Interface doesn't support scanning.
ip6tnl0 Interface doesn't support scanning.
wlan0 Scan completed :
lo Interface doesn't support scanning.
eth0 Interface doesn't support scanning.
usb0 Interface doesn't support scanning.
sit0 Interface doesn't support scanning.
ip6tnl0 Interface doesn't support scanning.
wlan0 Scan completed :
Cell 01 - Address: B0:95:8E:A8:63:A7
ESSID:"dlink_Yanfa"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.462 GHz (Channel 11)
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=36/100 Signal level=65/100
root@IMX6DLsabresd:~#
5.发现可用网络dlink_Yanfa
6.加入dlink_Yanfa_无线网络
root@IMX6DLsabresd:~# vi /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
network={
ssid="dlink_Yanfa"
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP CCMP
group=TKIP CCMP
psk="1234554321"
}
ctrl_interface = 存放数据的目录
ctrl_interface_group = 0 //确保只有 root 用户能读取 WPA 的配置
ssid =WIFI 名称
psk = WIFI 密码
key_mgmt = 加密类型,wifi 主要用到的加密类型有:NONE 没有密 码,WEP(pre-RSNA), WPA-PSK(TKIP),
WPA2-PSK(CCMP-AES),WPA-PSK(TKIP)+WPA2-PSK(AES),本实验路由器用的是 WPA/WPA2 PSK,用户可根据自
己的加密类型进行选择。Proto = 支持的协议列表
Pairwise = 加密算法 CCMP TKIP 等
group = 密钥协议 CCMP TKIP 等
TKIP:Temporal Key Integrity Protocol(暂时密钥集成协议)属于 WPA 加密方式,路由是否支持该加密方式。
其中essid和psk为必选项
7.连接wifi,查看状态
root@imx6DLsabresd:~# wpa_supplicant -d –Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf &
wpa_supplicant :wpa_supplicant 可执行程序 path
-d :增加调试信息
-Dwext :wext,驱动名称,对于不支持 nl80211 协议的硬 件,加上此参数
-iwlan0 :wlan0,网络接口名称
-c :配置文件
& :后台运行\
root@imx6DLsabresd:~# iwconfig
wlan0 IEEE 802.11bgn ESSID:"dlink_Yanfa" Nickname:"<WIFI@REALTEK>"
Mode:Managed Frequency:2.437 GHz Access Point: 14:D6:4D:7C:44:04
Bit Rate:54 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:****-****-****-****-****-****-****-**** Security mode
:open
Power Management:off
Link Quality=100/100 Signal level=49/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:
会看到路由器名称会 wlan0
IEEE 802.11bgn
ESSID:“dlink_Yanfa”
证明已连接成功。
8.关闭有线网络,手动设置 USB 无线网卡 IP 地址,与 dlink_Yanfa 无线网络保持同一个网段(本实验路由
是 192.168.12.1)
root@IMX6DLsabresd:~# ifconfig eth0 down
root@IMX6DLsabresd:~# ifconfig wlan0 192.168.12.198
root@IMX6DLsabresd:~# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:92:C7:08:56:FD
inet addr:192.168.12.198 Bcast:192.168.12.255
Mask:255.255.255.0
inet6 addr: fe80::292:c7ff:fe08:56fd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:262 errors:0 dropped:5 overruns:0 frame:0
TX packets:23 errors:0 dropped:3 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:36639 (35.7 KiB) TX bytes:6577 (6.4 KiB)
root@IMX6DLsabresd:~#
- 设置无线网络的网关,与 dlink_Yanfa 网络的网关保持一致
root@IMX6DLsabresd:~# route add default gw 192.168.12.1 dev wlan0
root@IMX6DLsabresd:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.12.1 0.0.0.0 UG 0 0 0 wlan0
192.168.12.0 * 255.255.255.0 U 0 0 0 wlan0
root@IMX6DLsabresd:~#
10.关闭有线网络,测试。使用无线网络一定要先关闭有线网络。
root@IMX6DLsabresd:~# ifconfig eth0 down
root@IMX6DLsabresd:~# ping 192.168.12.109
PING 192.168.12.109 (192.168.12.1 (wlan0)): 56 data bytes
64 bytes from 192.168.12.109: seq=0 ttl=64 time=260.898 ms
64 bytes from 192.168.12.109: seq=1 ttl=64 time=185.255 ms
64 bytes from 192.168.12.109: seq=2 ttl=64 time=336.494 ms
^C
--- 192.168.12.109 ping statistics ---
root@IMX6DLsabresd:~#