本文以飞凌嵌入式 OKMX6ULL-S 开发板为基础讲解,其它板卡请参考使用,本文主要讲解了 iMX6ULL 网络功能的测试,分为无线网络测试以及有线网络测试,通过本文您可以快速了解飞凌 iMX6ULL 开发板网络测试的全过程。
1、有线网络测试 1 基本命令测试
每个开发板的网络使用环境未必相同,本节测试示例中,网络环境如下。实际使用中,请按照实际网络环境自行进行配置。
底板丝印 | 软件设备 |
---|---|
NET1 | eth1 |
NET2 | eth0 |
OKMX6ULL-C 有 eth0、eth1 两路网卡。开机已设置默认 eth0、eth1 自动分配 IP。如果修改 IP 请修改 /etc/network/interfaces。
注意:eth1 与 eth0 不能用于同一个局域网。
下面以 eth0 为例进行命令说明。
① 在 Linux 系统下,使用 ifconfig 命令可以显示或配置网络设备,使用 ethtool 查询及设置网卡参数。
② 设置 IP 地址 ,查看当前网卡详情:
root@fl-imx6ull:~# ifconfig eth0 192.168.1.120
root@fl-imx6ull:~#ifconfig eth0
eth0 Link encap:Ethernet HWaddr3A:D9:93:8E:A8:A4
inet addr:192.168.1.120 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::38d9:93ff:fe8e:a8a4%2124311408/64Scope:Link
inet6 addr: fec0::38d9:93ff:fe8e:a8a4%2124311408/64Scope:Site
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:28 errors:0 dropped:0 overruns:0 frame:0
TX packets:63 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11550(11.2KiB) TX bytes:11579(11.3KiB)
③ 动态分配 IP 地址
如果您的开发板与路由器连接,且路由器支持 DHCP 自动 IP 地址分配可以在超级终端里面输入命令:
root@fl-imx6ull:~#udhcpc -i eth0
udhcpc (v1.24.1) started
Sending discover...
Sending select for192.168.20.101...
Lease of 192.168.20.101 obtained, lease time 86400
/etc/udhcpc.d/50default: Adding DNS 222.222.222.222
用来动态获取 IP 地址,“-i” 参数用来指定网卡名称,飞凌 iMX6ULL 开发板有线网络的网卡名称为 eth0。
/etc/resolv.conf 文件中有 dns 服务器信息会被自动添加。
④ 修改 mac 地址:
root@fl-imx6ull:~#ifconfig eth0 hw ether 00:00:00:00:00:01
root@fl-imx6ull:~#ifconfig eth0
eth0 Link encap:Ethernet HWaddr00:00:00:00:00:01
inet addr:192.168.20.101 Bcast:192.168.20.255 Mask:255.255.255.0
inet6 addr: fec0::38d9:93ff:fe8e:a8a4%2128292720/64Scope:Site
inet6 addr: fec0::200:ff:fe00:1%2128292720/64Scope:Site
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:85 errors:0 dropped:0 overruns:0 frame:0
TX packets:118 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:22942(22.4KiB) TX bytes:22259(21.7KiB)
另外在 /forlinx/shell/mac.sh 中根据 uid 设置 MAC 地址,如果需要请添加到开机自启动脚本中。
⑤ 设置子网掩码:
root@fl-imx6ull:~#ifconfig eth0 netmask 255.255.255.0
root@fl-imx6ull:~#ifconfig eth0
eth0 Link encap:Ethernet HWaddr00:00:00:00:00:01
inet addr:192.168.20.101 Bcast:192.168.20.255 Mask:255.255.255.0
inet6 addr: fec0::38d9:93ff:fe8e:a8a4%2128915312/64Scope:Site
inet6 addr: fec0::200:ff:fe00:1%2128915312/64Scope:Site
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:107 errors:0 dropped:0 overruns:0 frame:0
TX packets:118 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25700(25.0KiB) TX bytes:22259(21.7KiB)
⑥ 设置广播地址
root@fl-imx6ull:~#ifconfig eth0 broadcast 192.168.20.120
root@fl-imx6ull:~#ifconfig eth0
eth0 Link encap:Ethernet HWaddr00:00:00:00:00:01
inet addr:192.168.20.101 Bcast:192.168.20.120 Mask:255.255.255.0
inet6 addr: fec0::38d9:93ff:fe8e:a8a4%2123332464/64Scope:Site
inet6 addr: fec0::200:ff:fe00:1%2123332464/64Scope:Site
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:111 errors:0 dropped:0 overruns:0 frame:0
TX packets:132 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26130(25.5KiB) TX bytes:25947(25.3KiB)
⑦ 添加 / 删除默认网关
添加默认网关:
root@fl-imx6ull:~#route add default gw 192.168.20.1
删除默认网关:
root@fl-imx6ull:~#route del default gw 192.168.20.1
⑧ 关闭开启网卡
关闭 eth0 网卡:
root@fl-imx6ull:~#ifconfig eth0 down
开启 eth0 网卡:
root@fl-imx6ull:~#ifconfig eth0 up
fec 20b4000.ethernet eth0: Freescale FEC PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=20b4000.ethernet:01, irq=-1)
root@fl-imx6ull:~# fec 20b4000.ethernet eth0: Link is Up- 100Mbps/Full- flow control rx/tx
2FTP 服务
① 设置 root 用户密码,这里设置为 forlinx,输入密码没有回显,串口终端无法看到输入内容。
root@imx6ullevk:~# passwd root
New password:
Re-enter new password:
② 然后配置开发板 ip 地址,保证和电脑通信正常。
root@imx6ullevk:~#ifconfig eth0 192.168.2.207
root@imx6ullevk:~#ping 192.168.2.135-c 3
③ 电脑使用 FileZilla 连接 iMX6ULL 开发板。 点击文件,站点管理器:
创建“新站点”,主机输入开发板 IP,加密方式选择只是用明文 FTP,登陆类型选择正常,用户和密码为开发板的用户和密码,点击“连接”。
3SSH 登录测试
以太网相关服务测试之前,确保已经设置好 IP。设置 IP 请参考以太网驱动测试部分。
配置信息:
开发板 ip:192.168.2.85
Linux 主机地址:192.168.2.149
Windows 主机地址:192.168.2.12
① 测试由 linux 主机通过 ssh 访问开发板
zs@developer-RH2485-V2:~$ssh root@192.168.2.85
The authenticity of host '192.168.2.85 (192.168.2.85)' can't be established.
RSA key fingerprint is 25:57:00:82:72:8f:09:8e:2d:b9:9b:41:e5:d6:06:bb.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.2.85'(RSA) to the list of known hosts.
② 测试由 Windows 主机通过 cmd.exe 或者 Cmder 访问开发板:
$ ssh root@192.168.2.85
root@fl-imx6ull:~#
③ 由 iMX6ULL 开发板访问 linux 主机
root@fl-imx6ull:~#dbclient zs@192.168.2.149
Host'192.168.2.149' is not in the trusted hosts file.
(ecdsa-sha2-nistp256 fingerprint md5 93:ff:74:8a:ed:ba:fd:21:39:d9:87:93:ad:9e:19:6f)
Do you want to continue connecting? (y/n) y
zs@192.168.2.149's password:
Welcome to Ubuntu14.04.5 LTS (GNU/Linux4.4.0-31-generic x86_64)
* Documentation: /zixunimg/eefocusimg/help.ubuntu.com/
504 packages can be updated.
421 updates are security updates.
New release '16.04.6 LTS' available.
Run'do-release-upgrade' to upgrade to it.
Last login: MonMar2312:50:222020 from 192.168.2.87
4USB 转网络测试
① 将 USB 转以太网插入 USB host 接口,识别信息如下:
usb 1-1.3: new high-speed USB device number 8 using ci_hdrc
asix 1-1.3:1.0 eth2: register 'asix' at usb-ci_hdrc.1-1.3, ASIX AX88772B USB 2.0 Ethernet, 00:0e:c6:8f:9c:b7
IPv6: ADDRCONF(NETDEV_UP): eth2: link is not ready
② 测试方法参考以太网驱动测试章节。
2、无线网络测试 1WIFI 测试
RTL8188eus—USB WIFI、RTL8723bu—USB WIFI 使用方法如下。
① USB WIFI RTL8188eus 使用
USB WIFI 无线局域网卡是选配模块。
步骤 1:开发板上电,启动 Linux 系统。
步骤 2:连接 USB WIFI 到飞凌开发板的 USB host 接口,正确安装如下图。
步骤 3:打开脚本所在的位置:
root@fl-imx6ull:~#cd /forlinx/shell/
步骤 4:按照如下格式输入相应的参数:
说明:
-s 表示 wifi 热点的名称
-p 表示密码,如果没有密码请输入 -p NONE
路由器采用 wpa 加密方式。
连接打印内容如下:
root@fl-imx6ull:/forlinx/shell#./wifi.sh -i 8188 -s forlinx -p xxxx
wifi 8188
ssid forlinx
pasw xxxx
usbcore: deregistering interface driver rtl8723bu
RTL871X: moduleexit start
usbcore: deregistering interface driver rtl8188eu
RTL871X: rtw_ndev_uninit(wlan1)
usb 1-1.3: reset high-speed USB device number 7using ci_hdrc
RTL871X: moduleexit success
RTL871X: module init start
RTL871X: rtl8188eu v4.3.0.9_15178.20150907
RTL871X: build time: Mar25202002:23:46
bFWReady == _FALSE call reset 8051...
RTL871X: rtw_ndev_init(wlan0)
usbcore: registered newinterface driver rtl8188eu
RTL871X: module init ret=0
==> rtl8188e_iol_efuse_patch
IPv6: ADDRCONF(NETDEV_UP): wlan0: link isnot read
ps: invalid option -- 'f'
BusyBox v1.24.1(2019-04-2702: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]: Operationnot permitted
ioctl[SIOCGIWSCAN]: Resource temporarily unavailable
ioctl[SIOCGIWSCAN]: Resource temporarily unavailable
RTL871X: indicate disassoc
wlan0: Trying to associate with04:d7:a5:84:fa:40(SSID='forlinx' freq=2437MHz)
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: Associatedwith04: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 with04:d7:a5:84:fa:40[PTKRTL871X: setgroup 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...
Sendingselectfor192.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!
步骤 5:ping ip 或者域名,命令如下。
root@fl-imx6ull:/forlinx/shell#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:卸载已经加入内核的模块。
root@fl-imx6ull:/forlinx/shell#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 的使用
如果开发板有板载的 WIFI 无线局域网卡,则焊接在评估板如图所示位置:
步骤 1:检查开发板是否已经焊接该模块,正确焊接如上图。连接上天线。
步骤 2:开发板上电,启动 Linux 系统。
步骤 3:进入测试脚本所在目录:
root@fl-imx6ull:~# cd /forlinx/shell
步骤 4:执行测试脚本:
说明:-s 表示 wifi 热点的名称;
-p 表示密码,如果没有密码请输入 -p NONE;
路由器采用 wpa 加密方式。
连接打印内容如下:
root@fl-imx6ull:/forlinx/shell#./wifi.sh -i 8723-sforlinx -pxxxx
wifi 8723
ssid forlinx
paswxxxx
usbcore: deregistering interface driver rtl8723bu
usbcore: registered new interface driver rtl8723bu
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
ps: invalid option -- 'f'
BusyBox v1.24.1(2019-04-2702:24:01 CST) multi-call binary.
Usage: ps
Successfully initialized wpa_supplicant
rfkill: Cannot open RFKILL control device
wlan0: Trying to associate with04:d7:a5:84:fa:40(SSID='forlinx' freq=2437MHz)
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
wlan0: Associatedwith04:d7:a5:84:fa:40
wlan0: WPA: Key negotiation completed with04:d7:a5:84:fa:40[PTK=CCMP GTK=CCMP]
wlan0: CTRL-EVENT-CONNECTED - Connection to 04:d7:a5:84:fa:40 completed [id=0 id_str=]
udhcpc (v1.24.1) started
Sending discover...
Sending discover...
Sending select for192.168.4.225...
Lease of 192.168.4.225 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!
步骤 5:ping ip 或者域名,命令如下。
root@fl-imx6ull:/forlinx/shell#ping -c 5192.168.4.1
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
步骤 6:卸载已经加入内核的模块:
root@fl-imx6ull:/forlinx/shell#rmmod 8723bu
usbcore: deregistering interface driver rtl8723bu
wlan0: CTRL-EVENT-DISCONNECTED bssid=04:d7:a5:84:fa:40 reason=0
34G 模块实现 IE 上网
① 将外扩 USB 4G 扩展板插入 USB 口,固定 ME909s-821 PCIE 封装 4G 模块,安装 ipex 天线座,插入 SIM 卡,开机上电。
② 拨号上网
root@fl-imx6ull:~#cd /forlinx/shell/
root@fl-imx6ull:/forlinx/shell#./me909s.sh
eth0 Link encap:Ethernet HWaddr7E:09:81:93:F3:0A
eth1 Link encap:Ethernet HWaddr DE:EA:3F:6C:A7:33
wlan0 Link encap:Ethernet HWaddr7C:A7:B0:0F:FC:14
udhcpc (v1.24.1) started
Sending discover...
Sending select for10.63.223.158...
Lease of 10.63.223.158 obtained, lease time 518400
/etc/udhcpc.d/50default: Adding DNS 222.222.222.222
/etc/udhcpc.d/50default: Adding DNS 222.222.202.202
fec 20b4000.ethernet eth0: Freescale FEC PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=20b4000.ethernet:01, irq=-1)
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
fec 2188000.ethernet eth1: Freescale FEC PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=20b4000.ethernet:02, irq=-1)
IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
Finished!
③ 连接成功之后,ping 百度测试:
root@fl-imx6ull:/forlinx/shell#ping www.baidu.com
PING www.baidu.com (220.181.38.150): 56 data bytes
64 bytes from 220.181.38.150: seq=0 ttl=53 time=59.450 ms
64 bytes from 220.181.38.150: seq=1 ttl=53 time=71.086 ms
64 bytes from 220.181.38.150: seq=2 ttl=53 time=57.385 ms
64 bytes from 220.181.38.150: seq=3 ttl=53 time=71.033 ms
--- www.baidu.com ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 57.385/64.738/71.086 ms
④ 断网与复位指令测试:
断开网络连接:
root@fl-imx6ull:/forlinx/shell#echo "AT^NDISDUP=1,0"> /dev/ttyUSB2
复位重启模块:
root@fl-imx6ull:/forlinx/shell#echo "AT^RESET "> /dev/ttyUSB2
⑤ 更换 SIM 卡需要更换 me909.sh 中相应的 APN:
中国移动:
echo "AT^NDISDUP=1,1,\"cmnet\""> /dev/ttyUSB2
中国联通:
echo "AT^NDISDUP=1,1,\"3gnet\""> /dev/ttyUSB2
中国电信(本文使用):
echo "AT^NDISDUP=1,1,\"ctnet\""> /dev/ttyUSB2
4GPRS 模块测试
GPRS 模块与开发板之间采用串口连接,客户可以使用飞凌公司自产的 GPRS 模块,也可以使用自己购买的串口 GPRS 模块。
① 在确保模块和开发板串口 UART3 连接、上电 OK 情况下, 启动开发板子,进入命令行终端输入如下命令。
root@fl-imx6ull:~#cd /forlinx/shell/
root@fl-imx6ull:~#pppd call gprs /dev/ttymxc2 &
[1] 638
root@fl-imx6ull:/etc/ppp/peers# timeout set to 15 seconds
abort on (\nDELAYED\r)
abort on (\nBUSY\r)
abort on (\nERROR\r)
abort on (\nNO DIALTONE\r)
abort on (\nNO CARRIER\r)
send (^MAT^M)
expect (OK)
AT^M^M
OK
-- got it
send (ATS0=0^M)
expect (OK)
^M
ATS0=0^M^M
OK
-- got it
send (ATE0V1^M)
expect (OK)
^M
ATE0V1^M^M
OK
-- got it
send (AT+CGDCONT=1,"IP","CMNET"^M)
expect (OK)
^M
^M
OK
-- got it
send (ATDT*99***1#^M)
expect (CONNECT)
^M
^M
CONNECT
-- got it
send (^M)
Script/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-gprs-connect finished (pid 639), status = 0x0
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttymxc2
sent [LCP ConfReq id=0x1
rcvd [LCP ConfReq id=0x1 ]
No auth is possible
sent [LCP ConfRej id=0x1]
rcvd [LCP ConfRej id=0x1
sent [LCP ConfReq id=0x2]
rcvd [LCP ConfReq id=0x2 ]
No auth is possible
sent [LCP ConfRej id=0x2]
rcvd [LCP ConfAck id=0x2]
rcvd [LCP ConfReq id=0x3]
sent [LCP ConfAck id=0x3]
sent [IPCP ConfReq id=0x1
sent [IPCP ConfReq id=0x1
sent [IPCP ConfReq id=0x1
sent [IPCP ConfReq id=0x1
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfRej id=0x1
sent [IPCP ConfReq id=0x2
rcvd [IPCP ConfNak id=0x2
sent [IPCP ConfReq id=0x3
rcvd [IPCP ConfAck id=0x3
not replacing existing default route via 192.168.1.1with metric -1
local IP address 10.131.70.33
remote IP address 192.200.1.21
primary DNS address 111.11.1.3
secondary DNS address 111.11.11.3
② 连接成功可以尝试 ping 一下 www.forlinx.com
root@fl-imx6ull:~#ping www.forlinx.com
PING www.forlinx.com (39.156.66.18): 56 data bytes
64 bytes from 39.156.66.18: seq=0 ttl=51 time=315.605 ms
64 bytes from 39.156.66.18: seq=1 ttl=51 time=732.351 ms
64 bytes from 39.156.66.18: seq=2 ttl=51 time=234.874 ms
64 bytes from 39.156.66.18: seq=3 ttl=51 time=2990.813 ms
64 bytes from 39.156.66.18: seq=4 ttl=51 time=2110.219 ms
64 bytes from 39.156.66.18: seq=5 ttl=51 time=1151.022 ms
64 bytes from 39.156.66.18: seq=6 ttl=51 time=450.403 ms
64 bytes from 39.156.66.18: seq=7 ttl=51 time=4650.867 ms
64 bytes from 39.156.66.18: seq=8 ttl=51 time=3747.240 ms
64 bytes from 39.156.66.18: seq=9 ttl=51 time=2866.635 ms
64 bytes from 39.156.66.18: seq=10 ttl=51 time=1986.155 ms
64 bytes from 39.156.66.18: seq=11 ttl=51 time=1087.178 ms
64 bytes from 39.156.66.18: seq=12 ttl=51 time=368.113 ms
--- www.forlinx.com ping statistics ---
13 packets transmitted, 13 packets received, 0% packet loss
round-trip min/avg/max = 234.874/1745.498/4650.867 ms
注意: 假如 ping 命令不通,可能是之前测试以太网或无线网络接口时的一些配置的影响,此时需要先执行以下命令再测试模块:
root@imx6ulevk:~# ifconfig eth0 down
root@imx6ulevk:~#ifconfig wlan0 down