應(yīng)用技巧-OKMX6UL-C開發(fā)板無線網(wǎng)絡(luò)測試
為了方便用戶對核心板的性能及功能進(jìn)行測試,飛凌提供了配套的功能評估板,將產(chǎn)品開發(fā)過程中常用的功能接口引出,比如說2路的Ethernet、2路的USB、2路的CAN以及4路的UART、2路的SPI和2路的IIC,同時(shí)這里還預(yù)留了顯示的LCD接口以及4G模組、WIFI模組的插槽等。
本文以用戶快速熟悉產(chǎn)品,了解接口功能和測試方法為目的,主要講述了飛凌iMX6ULL開發(fā)板WIFI接口功能的測試方法,以及使用過程中出現(xiàn)的一些問題如何排查。在測試過程中,對一些命令進(jìn)行了注釋,方便用戶理解,以實(shí)用夠用為主。
一、iMX6ULL開發(fā)板 WIFI 功能測試
WiFi支持:
模塊 | 支持 |
RTL8188EUS | WiFi |
RTL8723BU | WiFi |
RTL8723DU | WiFi |
1、 USB WIFI RTL8188eus使用
說明: USB WIFI無線局域網(wǎng)卡是選配模塊 ,如若有需求,請聯(lián)系飛凌嵌入式官網(wǎng)在線客服。
以下對wifi模塊在STA模式下,連接到無線網(wǎng)絡(luò)的測試:
步驟1:iMX6ULL開發(fā)板上電,啟動(dòng)Linux系統(tǒng)。
步驟2:連接USB WIFI到飛凌iMX6ULL開發(fā)板的USB Host接口
步驟 3 :按照如下格式輸入相應(yīng)的參數(shù):
-i表示wifi型號(hào);
-s表示wifi熱點(diǎn)名稱;
-p表示密碼,若無密碼輸入-p NONE;
路由器采用wpa加密方式。具體操作指令可查看wifi.sh腳本。
連接打印內(nèi)容如下:
root@fl-imx6ull:~# fltest_cmd_wifi.sh -i 8188 -s forlinx -p xxxx |
打印信息如下:
wifi 8188 ssid forlinx pasw xxxx usbcore: deregistering interface driver rtl8723bu RTL871X: module exit start usbcore: deregistering interface driver rtl8188eu RTL871X: rtw_ndev_uninit(wlan1) usb 1-1.3: reset high-speed USB device number 7 using ci_hdrc RTL871X: module exit success RTL871X: module init start RTL871X: rtl8188eu v4.3.0.9_15178.20150907 RTL871X: build time: Mar 25 2020 02:23:46 bFWReady == _FALSE call reset 8051... RTL871X: rtw_ndev_init(wlan0) usbcore: registered new interface driver rtl8188eu RTL871X: module init ret=0 ==> rtl8188e_iol_efuse_patch IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready ps: invalid option -- 'f' BusyBox v1.24.1 (2019-04-27 02:24:01 CST) multi-call binary.
Usage: ps Successfully initialized wpa_supplicant rfkill: Cannot open RFKILL controRTL871X: set bssid:00:00:00:00:00:00 l device RTL871X: set ssid [g?isQ?J?)?????F|?T??vZ.c3?????<????] fw_state=0x00000008 ioctl[SIOCSIWAP]: Operation not permitted ioctl[SIOCGIWSCAN]: Resource temporarily unavailable ioctl[SIOCGIWSCAN]: Resource temporarily unavailable RTL871X: indicate disassoc wlan0: Trying to associate with 04:d7:a5:84:fa:40 (SSID='forlinx' freq=2437 MHz) RTL871X: set ssid [forlinx] fw_state=0x00000008 RTL871X: set bssid:04:d7:a5:84:fa:40 RTL871X: start auth RTL871X: auth success, start assoc RTL871X: assoc success IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready RTL871X: recv eapol packet wlan0: Associated with 04:d7:a5:84:fa:40 RTL871X: send eapol packet RsvdPageNum: 8 udhcpc (v1.24.1) started RTL871X: recv eapol packet RTL871X: send eapol packet RTL871X: recv eapol packet RTL871X: send eapol packet RTL871X: set pairwise key camid:4, addr:04:d7:a5:84:fa:40, kid:0, type:AES wlan0: WPA: Key negotiation completed with 04:d7:a5:84:fa:40 [PTKRTL871X: set group key camid:5, addr:04:d7:a5:84:fa:40, kid:2, type:AES =CCMP GTK=CCMP] wlan0: CTRL-EVENT-CONNECTED - Connection to 04:d7:a5:84:fa:40 completed [id=0 id_str=] Sending discover... Sending select for 192.168.4.129... Lease of 192.168.4.129 obtained, lease time 36000 /etc/udhcpc.d/50default: Adding DNS 222.222.202.202 /etc/udhcpc.d/50default: Adding DNS 222.222.222.222 Finshed! |
腳本運(yùn)行完,能自動(dòng)分配ip并添加DNS,則wifi連接成功。
步驟5:ping ip或者域名,命令如下。
root@fl-imx6ull:~# ping -c 4 www.baidu.com PING www.baidu.com (220.181.38.149): 56 data bytes 64 bytes from 220.181.38.149: seq=0 ttl=51 time=26.648 ms 64 bytes from 220.181.38.149: seq=1 ttl=51 time=13.529 ms 64 bytes from 220.181.38.149: seq=2 ttl=51 time=15.656 ms 64 bytes from 220.181.38.149: seq=3 ttl=51 time=26.249 ms
--- www.baidu.com ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 13.529/20.520/26.648 ms |
步驟6:卸載已經(jīng)加入內(nèi)核的模塊。
root@fl-imx6ull:~# rmmod 8188eu |
打印信息如下:
RTL871X: module exit start usbcore: deregistering interface driver rtl8188eu RTL871X: indicate disassoc RTL871X: rtw_cmd_thread: DriverStopped(1) SurpriseRemoved(0) break at line 478 wlan0: CTRL-EVENT-DISCONNECTED bssid=04:d7:a5:84:fa:40 reason=3 locally_generated=1 RTL871X: rtw_ndev_uninit(wlan0) RTL871X: rtw_dev_unload: driver not in IPS usb 1-1.3: reset high-speed USB device number 7 using ci_hdrc RTL871X: module exit success |
2、 板載WIFI的使用
說明:
l wifi頻率為2.4G
l 兼容8723bu和8723du兩種wifi驅(qū)動(dòng)
l 默認(rèn)路由器采用wpa加密方式。
如果開發(fā)板有板載的WIFI無線局域網(wǎng)卡,則焊接在評估板如圖所示位置(下圖為8723du):
步驟1:檢查iMX6ULL開發(fā)板是否已經(jīng)焊接該模塊,正確焊接如上圖。連接上天線。
步驟2:iMX6ULL開發(fā)板上電,啟動(dòng)Linux系統(tǒng),先使用lsmod查看模塊加載狀態(tài):
root@fl-imx6ull:~# lsmod Module Size Used by mx6s_capture 14876 0 8723 du 1313893 0 //默認(rèn)wifi自動(dòng)加載,8723du已加載成功 ov9650_camera 12446 0 |
注意:若 飛凌iMX6ULL 開發(fā)板上焊接的是8723 b u,使用lsmod會(huì)顯示8723 b u
以下以8723du為例進(jìn)行測試描述:
步驟3:測試
? STA模式
該模式即作為一個(gè)站點(diǎn),連接到無線網(wǎng)絡(luò)中,操作方法如下:
-i表示wifi型號(hào);-s表示wifi熱點(diǎn)名稱;-p表示密碼,若無密碼輸入-p NONE;路由器采用wpa加密方式,具體操作指令可查看wifi.sh腳本
root@fl-imx6ull:~# fltest_cmd_wifi.sh -i 8723du -s forlinx -p xxx //執(zhí)行測試腳本 |
打印信息如下:
wifi 8723du ssid forlinx pasw xxx usbcore: deregistering interface driver rtl8723du usbcore: registered new interface driver rtl8723du IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready Successfully initialized wpa_supplicant rfkill: Cannot open RFKILL control device udhcpc (v1.24.1) started Sending discover... wlan0: CTRL-EVENT-REGDOM-CHANGE init=BEACON_HINT type=UNKNOWN wlan0: Trying to associate with 04:d7:a5:f9:26:1d (SSID='forlinx' freq=2427 MHz) wlan0: Associated with 04:d7:a5:f9:26:1d IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready wlan0: WPA: Key negotiation completed with 04:d7:a5:f9:26:1d [PTK=CCMP GTK=TKIP] wlan0: CTRL-EVENT-CONNECTED - Connection to 04:d7:a5:f9:26:1d completed [id=0 id_str=] nf_conntrack: automatic helper assignment is deprecated and it will be removed soon. Use the iptables CT target to attach helpers instead. Sending discover... Sending select for 192.168.5.186... Lease of 192.168.5.186 obtained, lease time 1800 /etc/udhcpc.d/50default: Adding DNS 222.222.202.202 /etc/udhcpc.d/50default: Adding DNS 222.222.222.222 WLAN Finshed! |
腳本運(yùn)行完,能自動(dòng)分配ip并生成DNS,則wifi連接成功。
ping ip或者域名,命令如下:
root@fl-imx6ull:~# ping -c 5 www.baidu.com |
打印信息如下:
PING 192.168.4.1 (192.168.4.1): 56 data bytes 64 bytes from 192.168.4.1: seq=0 ttl=128 time=39.783 ms 64 bytes from 192.168.4.1: seq=1 ttl=128 time=81.529 ms 64 bytes from 192.168.4.1: seq=2 ttl=128 time=15.236 ms 64 bytes from 192.168.4.1: seq=3 ttl=128 time=12.076 ms 64 bytes from 192.168.4.1: seq=4 ttl=128 time=16.300 ms
--- 192.168.4.1 ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 12.076/32.984/81.529 ms |
wifi信號(hào)
查看WiFi信號(hào)方法如下:
root@fl-imx6ull:~# cat /proc/net/wireless | grep wlan0 | awk '{print $3}' //獲取信號(hào)強(qiáng)度 78. root@fl-imx6ull:~# cat /proc/net/wireless | grep wlan0 | awk '{print $4}' //獲取信號(hào)質(zhì)量,單位dBm -68. root@fl-imx6ull:~# cat /proc/net/wireless | grep wlan0 | awk '{print $5}' //網(wǎng)口背景噪聲,單位dBm -256. |
AP模式
說明:
l 本模塊支持AP模式,理論最大連接用戶為8個(gè)。
l 本例為以太網(wǎng)eth0連接路由器說明,配置完以太網(wǎng)后,需要測試eth0是否可以連接外網(wǎng),如果可以連接外網(wǎng)(方法參考 “有線網(wǎng)卡”章節(jié)),請繼續(xù)按照操作步驟執(zhí)行,如果不可以請檢查以太網(wǎng)或者路由器連接是否正常。
工作在AP模式下,手機(jī)等設(shè)備可以直接連接模塊。
設(shè)置以太網(wǎng)IP,配置網(wǎng)絡(luò)防火墻:
root@fl-imx6ull:~# udhcpc -i eth0 //自動(dòng)分配IP,若以測試eth0網(wǎng)絡(luò)正常,可不操作此步 root@fl-imx6ull:~# echo 1 > /proc/sys/net/ipv4/ip_forward //打開 IP 轉(zhuǎn)發(fā) root@fl-imx6ull:~# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE//設(shè)置轉(zhuǎn)發(fā)規(guī)則 |
設(shè)置WiFi的模式與IP
確保模塊8723bu已經(jīng)加載。
root@fl-imx6ull:~# ifconfig wlan0 up //打開WiFi root@fl-imx6ull:~# ifconfig wlan0 192.168.0.10 netmask 255.255.255.0 //設(shè)置IP與子網(wǎng)掩碼 root@fl-imx6ull:~# ifconfig wlan0 promisc //設(shè)置 wlan0 為混雜模式 |
開啟AP
root@fl-imx6ull:~# udhcpd /etc/udhcpd/udhcpd.conf & //WiFi 地址、網(wǎng)關(guān)等配置信息 root@fl-imx6ull:~# hostapd -d /etc/hostapd/hostapd.conf & //加密方式、用戶名、密碼等設(shè)置 |
hostapd.conf文件中:ssid為用戶名,/為密碼
手機(jī)等移動(dòng)終端可以通過WiFi連接到開發(fā)板的AP熱點(diǎn),iMX6ULL開發(fā)板默認(rèn)使用以下用戶名和密碼:
熱點(diǎn)名:forlinxtest密碼:1234567890
步驟4:卸載已經(jīng)加入內(nèi)核的模塊:
root@fl-imx6ull:~# rmmod 8723du usbcore: deregistering interface driver rtl8723du wlan0: CTRL-EVENT-DISCONNECTED bssid=04:d7:a5:f9:26:1d reason=0 |
FETMX6ULL-C核心板是飛凌基于NXP i.MX6U系列處理器推出的第三款核心板,成熟的技術(shù)方案,帶來穩(wěn)定可靠的全新體驗(yàn)。核心板尺寸僅40*29mm,并采用2mm合高的板對板連接器,將小體積、便于拆卸的優(yōu)勢集一身。您可搜索飛凌嵌入式,聯(lián)系在線客服,獲取更多詳細(xì)資料。
*博客內(nèi)容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀點(diǎn),如有侵權(quán)請聯(lián)系工作人員刪除。