|
本帖最后由 conway 于 2015-7-19 22:21 编辑
WiFi模块:MY-WF003U USB WIFI Module开发板平台:Z-turn
1、在内核源码根目录下执行以下命令打开内核配置界面:
[mw_shl_code=applescript,true]$ make ARCH=arm menuconfig[/mw_shl_code]
添加rtl8192cu驱动:
Device Drivers --->
[ * ] Network device support --->
[ * ] Wireless LAN --->
<*> Realtek rtlwifi family of devices --->
<*> Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter
2、复制固件到开发板
如果开发板上/lib/firmware/rtlwifi/目录下没有rtl8192cufw_TMSC.bin文件,需要复制附件中的MY-WF003U USB WIFI Module/Linux/Tools/firmware/rtl8192cufw_TMSC.bin到该目录。
3、交叉编译WPA工具
解压附件中的wpa工具
[mw_shl_code=applescript,true]$ tar xzf wpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz
$ cd wpa_supplicant_hostapd-0.8_rtw_r7475.20130812/wpa_supplicant
$ make CC=arm-xilinx-linux-gnueabi-gcc[/mw_shl_code]
4、使用WAP工具配置WLAN
正确配置好内核和驱动后,更新到开发板,插上USB WIFI模块,就可以使用wpa来配置使用wlan了,以下是使用wpa工具的一些命令和配置wlan的步骤。
(1)使用配置文件
使用wpa_passphase生成配置文件,wpa_passphase使用方法:
[mw_shl_code=applescript,true]# wpa_passphase ssid ssid_code > /etc/wpa_supplicant.conf[/mw_shl_code]
如我的WIFI SSID为my_wifi,wifi 密码为:12345678,
[mw_shl_code=applescript,true]# wpa_passphase my_wifi 12345678 > /etc/wpa_supplicant.conf[/mw_shl_code]
这样在/etc/目录下就生成了wifi的配置文件wpa_supplicant.conf,使用该配置去连接wifi:
[mw_shl_code=applescript,true]# wpa_supplicant -i wlan0 -c/etc/wpa_supplicant.conf -Dwext -B[/mw_shl_code]
连接上wifi之后,就可以使用以下命令来获取IP地址:
[mw_shl_code=applescript,true]# udhcpc -i wlan0[/mw_shl_code]
完成以后的步骤,就可以通过wifi来上网了:
[mw_shl_code=applescript,true]# ping www.baidu.com[/mw_shl_code]
PING www.baidu.com (115.239.210.26): 56 data bytes
64 bytes from 115.239.210.26: seq=0 ttl=54 time=107.556 ms
64 bytes from 115.239.210.26: seq=1 ttl=54 time=217.601 ms
64 bytes from 115.239.210.26: seq=2 ttl=54 time=131.467 ms
64 bytes from 115.239.210.26: seq=3 ttl=54 time=150.235 ms
64 bytes from 115.239.210.26: seq=4 ttl=54 time=154.285 ms
(2) 使用命令行配置
启动 wpa_supplicant:
[mw_shl_code=applescript,true]# wpa_supplicant -i wlan0 -c/etc/wpa_supplicant.conf -Dwext -B[/mw_shl_code]
如果提示不支持wext,就去掉“-Dwext”选项。
扫描无线网络:
[mw_shl_code=applescript,true]# wpa_cli -p/var/run/wpa_supplicant scan[/mw_shl_code]
显示扫描到的无线网络:
[mw_shl_code=applescript,true]# wpa_cli -p/var/run/wpa_supplicant scan_results[/mw_shl_code]
添加到一个网络,注意返回的网络ID,在后面的设置ssid和psk的时候将会用到,这里的返回值为”20”:
[mw_shl_code=applescript,true]# wpa_cli -p/var/run/wpa_supplicant add_network[/mw_shl_code]
Selected interface 'wlan0'
20
设置网络的ssid,这里假设网络名为“MYIR”:
[mw_shl_code=applescript,true]# wpa_cli -p/var/run/wpa_supplicant set_network 20 ssid ‘“MYIR”’[/mw_shl_code]
设置网络的psk,这里假设为“123456”:
[mw_shl_code=applescript,true]# wpa_cli -p/var/run/wpa_supplicant set_network 20 psk ‘“123456”’[/mw_shl_code]
选择网络:
[mw_shl_code=applescript,true]# wpa_cli -p/var/run/wpa_supplicant select_network 20[/mw_shl_code]
如果这时候 wlan0 还没有获得 IP 地址,可以使用以下命令来获取IP地址:
[mw_shl_code=applescript,true]# udhcpc -i wlan0[/mw_shl_code]
完成以后的步骤,就可以通过wifi来上网了:
[mw_shl_code=applescript,true]# ping www.baidu.com[/mw_shl_code]
PING www.baidu.com (115.239.210.26): 56 data bytes
64 bytes from 115.239.210.26: seq=0 ttl=54 time=107.556 ms
64 bytes from 115.239.210.26: seq=1 ttl=54 time=217.601 ms
64 bytes from 115.239.210.26: seq=2 ttl=54 time=131.467 ms
64 bytes from 115.239.210.26: seq=3 ttl=54 time=150.235 ms
64 bytes from 115.239.210.26: seq=4 ttl=54 time=154.285 ms
|
|