将USB-WiFi网卡移植到X210开发板

编程知识 更新时间:2023-04-29 06:15:36

以下内容源于朱有鹏嵌入式课程的学习与整理,如有侵权请告知删除。

一、移植前的准备工作

1、搭建开发环境

(1)虚拟机运行着ubuntu14.04系统。

(2)X210开发板运行着linux内核镜像、QT4.8文件系统镜像。相关的镜像文件在开发板光盘资料的X210V3S_B\linux\QT4.8目录中,账号与密码是root、123456。

(3)虚拟机中有内核源码树,这个内核源码树主要用来编译无线网卡驱动源码,它的版本必须与板载系统的内核版本一致,否则编译后的驱动程序在开发版上运行时,会遇到不匹配的问题。这里的内核源码树位于位于/home/xjh/iot/embedded_basic/kernel/x210_kernel。

(4)搭建好NFS服务器,制作好文件夹形式的rootfs。


2、下载与解压无线网卡驱动

(1)下载地址:DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2。

(2)将驱动源码压缩包解压至/home/xjh/iot/embedded_basic/x210_usb-wifi目录。

通过对比博文第五季2:STA模式USB-WIFI网卡移植与测试的无线网卡驱动的内容,可以看出两者是完全一样的。

#本课程的无线网卡驱动内容
root@ubuntu:/home/xjh/iot/embedded_basic/x210_usb-wifi# ls
DPO_MT7601U_LinuxSTA_3.0.0.4_20130913  DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2
root@ubuntu:/home/xjh/iot/embedded_basic/x210_usb-wifi# cd DPO_MT7601U_LinuxSTA_3.0.0.4_20130913
root@ubuntu:/home/xjh/iot/embedded_basic/x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913# ls
ate    common   iwpriv_usage.txt  Makefile  mgmt  phy        README_STA_usb     RT2870STA.dat  sta_ate_iwpriv_usage.txt
chips  include  mac               mcu       os    rate_ctrl  RT2870STACard.dat  sta            tools
root@ubuntu:/home/xjh/iot/embedded_basic/x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913# 

#第五季2:STA模式USB-WIFI网卡移植与测试
root@ubuntu:/home/xjh/iot/hisi_development/usb-wifi/MT7601_driver# ls
ap  sta
root@ubuntu:/home/xjh/iot/hisi_development/usb-wifi/MT7601_driver# cd sta/
root@ubuntu:/home/xjh/iot/hisi_development/usb-wifi/MT7601_driver/sta# ls
DPO_MT7601U_LinuxSTA_3.0.0.4_20130913          openssl-0.9.8za         wpa_supplicant-2.5
DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2  openssl-0.9.8za.tar.gz  wpa_supplicant-2.5.tar.gz
root@ubuntu:/home/xjh/iot/hisi_development/usb-wifi/MT7601_driver/sta# cd DPO_MT7601U_LinuxSTA_3.0.0.4_20130913
root@ubuntu:/home/xjh/iot/hisi_development/usb-wifi/MT7601_driver/sta/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913# ls
ate    common   iwpriv_usage.txt  Makefile  mgmt  phy        README_STA_usb     RT2870STA.dat  sta_ate_iwpriv_usage.txt
chips  include  mac               mcu       os    rate_ctrl  RT2870STACard.dat  sta            tools
root@ubuntu:/home/xjh/iot/hisi_development/usb-wifi/MT7601_driver/sta/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913# 

3、确认无线网卡的硬件信息

在板载系统上使用lsusb命令查看无线网卡的“VID:PID”,分别是厂商ID和产品ID。

[root@x210v3 ~]# lsusb 
Bus 001 Device 009: ID 148f:7601

二、编译驱动源码得到mt7601Usta.ko文件

以下的操作,主要为了得到无线网卡的驱动,即mt7601Usta.ko文件。

1、确认USB的VID和PID

在x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/common/rtusb_dev_id.c文件中的rtusb_dev_id[ ]数组里,列出了该驱动所支持的USB的VID和PID,如果USB-WIFI网卡的USB的VID和PID不在该数组中,移植时要添加。

USB_DEVICE_ID rtusb_dev_id[] = {
#ifdef RT6570
	{USB_DEVICE(0x148f,0x6570)}, /* Ralink 6570 */
#endif /* RT6570 */
	{USB_DEVICE(0x148f, 0x7650)}, /* MT7650 */
#ifdef MT7601U
	{USB_DEVICE(0x148f,0x6370)}, /* Ralink 6370 */
	{USB_DEVICE(0x148f,0x7601)}, /* MT 6370 */  // 我们的模块就是这个
#endif /* MT7601U */
	{ }/* Terminating entry */
};

2、修改Makefile文件

该文件位于x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/目录下。

(1)注释掉之前的PLATFORM,然后在67行添加“PLATFORM = SMDK”。

//省略部分代码,注释掉这些
#PLATFORM = BLPMP
#PLATFORM = MT85XX
#PLATFORM = MT53XX
#PLATFORM = NXP_TV550
#PLATFORM = MVL5
#PLATFORM = RALINK_3352
#PLATFORM = UBICOM_IPX8
#PLATFORM = INTELP6
#PLATFORM = MSTARTV
 
//添加下面代码
PLATFORM = SMDK

(2)根据实际情况设置内核源码树的路径、交叉编译工具链路径。如果交叉编译工具链没有export出来的话就要添加绝对路径。

ifeq ($(PLATFORM),SMDK)
#LINUX_SRC = /home/bhushan/itcenter/may28/linux-2.6-samsung
#CROSS_COMPILE = /usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-
LINUX_SRC = /home/xjh/iot/embedded_basic/kernel/x210_kernel
CROSS_COMPILE = arm-linux-
endif

3、修改网卡名字(可选操作)

(1)有线网卡的名字一般叫做eth0、eth1…ethn,无线网卡的名字一般叫做ra0、ra1…ran(或者wlan0、wlan1…wlann)。

(2)在x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/include/rtmp_def.h文件中修改内容如下。

1600 //#ifdef ANDROID_SUPPORT
1601 #define INF_MAIN_DEV_NAME               "wlan"
1602 #define INF_MBSSID_DEV_NAME             "wlan"
1603 //#else
1604 //#define INF_MAIN_DEV_NAME             "ra"
1605 //#define INF_MBSSID_DEV_NAME           "ra"
1606 //#endif /* ANDROID_SUPPORT */

4、添加wpa_supplicant支持

(1)在x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/config.mk文件中,搜索“HAS_WPA_SUPPLICANT”,确保“HAS_WPA_SUPPLICANT=y”。

  24 # Support Wpa_Supplicant
  25 # i.e. wpa_supplicant -Dralink
  26 HAS_WPA_SUPPLICANT=y
  27 
  28 
  29 # Support Native WpaSupplicant for Network Maganger
  30 # i.e. wpa_supplicant -Dwext
  31 HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y

(2)继续搜索“SMDK”,大概在1089行处进行如下修改。

ifeq ($(PLATFORM),SMDK)
         EXTRA_CFLAGS := $(WFLAGS)
         export EXTRA_CFLAGS
endif

5、编译驱动源码得到mt7601Usta.ko文件

(1)在x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/下执行“make clen”,然后执行“make”,此时在该目录下的os/linux/目录中生成mt7601Usta.ko文件。为了挂载,将该文件拷贝到/home/xjh/iot/embedded_basic/rootfs/rootfs_xjh目录中。

(2)可以使用“modinfo mt7601Usta.ko”命令查看驱动信息。

root@ubuntu:/home/xjh/iot/embedded_basic/x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux# ls mt*
mt7601Usta.ko  mt7601Usta.mod.c  mt7601Usta.mod.o  mt7601Usta.o
root@ubuntu:/home/xjh/iot/embedded_basic/x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux# modinfo mt7601Usta.ko 
filename:       /home/xjh/iot/embedded_basic/x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux/mt7601Usta.ko
version:        3.0.0.3
description:    RT2870 Wireless Lan Linux Driver
author:         Paul Lin <paul_lin@ralinktech>
license:        GPL
srcversion:     B2632BD2D7AD40A63B72D9E
alias:          usb:v148Fp760Bd*dc*dsc*dp*ic*isc*ip*
alias:          usb:v148Fp7601d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v148Fp6370d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v148Fp7650d*dc*dsc*dp*ic*isc*ip*
depends:        
vermagic:       2.6.35.7 preempt mod_unload ARMv7 
parm:           mac:rt28xx: wireless mac addr (charp)
root@ubuntu:/home/xjh/iot/embedded_basic/x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/os/linux# 

三、配置无线网卡以实现上网功能

1、安装无线网卡驱动mt7601Usta.ko文件

(1)首先将上面生成的mt7601Usta.ko文件复制到板载系统的/usr/xjh_usb-wifi目录中。即启动开发板进入系统(账号密码是root、123456),然后“ifconfig eth0 up”开启有线网卡,接着“ifconfig eth0 192.168.1.11”配置有线网卡的IP地址,然后利用下面命令将mt7601Usta.ko文件所在的虚拟机目录挂载到板载系统的/mnt目录,接着将mt7601Usta.ko文件复制到板载系统/usr/xjh_usb-wifi目录中。

mount -t nfs -o nolock 192.168.1.141:/home/xjh/iot/embedded_basic/rootfs/rootfs_xjh /mnt

(2)然后将无线网卡插入X210开发板的任意USB插槽。

# 插进第一个USB插槽时的输出
[root@x210v3 ~]# 
[root@x210v3 ~]# [  425.611753] usb 1-1.1: new high speed USB device using s5p-ehci and address 4
[  425.716551] usb 1-1.1: New USB device found, idVendor=148f, idProduct=7601
[  425.722827] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  425.730077] usb 1-1.1: Product: 802.11 n WLAN
[  425.734381] usb 1-1.1: Manufacturer: MediaTek
[  425.738685] usb 1-1.1: SerialNumber: 1.0

# 拔掉usb-wifi网卡时的输出
[root@x210v3 ~]# [  564.425135] usb 1-1.1: USB disconnect, address 4

(3)然后安装无线网卡驱动,即在/usr/xjh_usb-wifi目录下执行“insmod mt7601Usta.ko”。

[root@x210v3 xjh_usb-wifi]# ls
mt7601Usta.ko
[root@x210v3 xjh_usb-wifi]# insmod mt7601Usta.ko
[  589.033836] rtusb init rt2870 --->
[  589.036208] ===>rt2870_probe()!
[  589.040985] --> RTMPAllocAdapterBlock
[  589.044569] 
[  589.044572] 
#省略部分内容
[  589.215602] Allocate net device ops success!
[  589.219828] The name of the new wlan interface is wlan0...
[  589.225298] RtmpOSNetDevAttach()--->
[  589.232064] <---RtmpOSNetDevAttach(), ret=0
[  589.235286] <===rt2870_probe()!
[  589.238079] usbcore: registered new interface driver rt2870
[root@x210v3 xjh_usb-wifi]#

(4)此时使用“ifconfig -a”查看,可以得知无线网卡wlan0的一些信息。

[root@x210v3 xjh_usb-wifi]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:09:C0:FF:EC:48  
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::209:c0ff:feff:ec48/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9603 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5241 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:14523906 (13.8 MiB)  TX bytes:367990 (359.3 KiB)
          Interrupt:42 Base address:0x4300 

# 省略部分代码

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)
#省略部分代码
#无线网卡对应的“设备文件”wlan0
wlan0     Link encap:Ethernet  HWaddr 00:00:00:00:00:00  
          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)

2、开启无线网卡并设置IP地址

(1)首先使用命令“ifconfig wlan0 up”开启无线网卡。

[root@x210v3 xjh_usb-wifi]# ifconfig wlan0 up
# 省略部分输出
[ 1492.081350] ==>  DMAIdle, GloCfg=0x40000050
[ 1492.085317] Driver auto reconnect to last OID_802_11_SSID setting - 11n-AP, len - 6
[ 1492.093366] CntlOidSsidProc():CNTL - 0 BSS of 0 BSS match the desire RTMPDrvOpen(2):Check if PDMA is idle!
[ 1492.101944] (6)SSID - 11n-AP
[ 1492.105507] CNTL - All roaming failed, restore to channel 1, Total BSS[00]
[ 1492.111625] ==>  DMAIdle, GloCfg=0x40000050

(2)接着设置无线网卡的IP地址。

通过查看windows主机的无线网络信息,可知其连接的无线路由器的地址为192.168.1.1。

SSID:	XJH-ChinaNet-2.4G
协议:	802.11n
安全类型:	WPA2-个人
网络频带:	2.4 GHz
网络通道:	2
IPv6 地址:	240e:3b6:30f4:ad80:912d:a070:e7d1:14ac
IPv6 DNS 服务器:	fe80::1%17
IPv4 地址:	192.168.1.2 #笔记本的IP地址
IPv4 DNS 服务器:	192.168.1.1 #路由器的IP地址
制造商:	Intel Corporation
描述:	Intel(R) Dual Band Wireless-AC 8265
驱动程序版本:	20.70.4.2
物理地址(MAC):	88-B1-11-9A-37-5B

于是我们执行命令“ifconfig wlan0 192.168.1.211”,将无线网卡的IP地址设置成和无线路由器IP地址同一网段的,然后使用“ifconfig”命令查看wlan0是否启动。

[root@x210v3 xjh_usb-wifi]# ifconfig wlan0 192.168.1.211
[root@x210v3 xjh_usb-wifi]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:09:C0:FF:EC:48  
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::209:c0ff:feff:ec48/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9600 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5247 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:14523684 (13.8 MiB)  TX bytes:368318 (359.6 KiB)
          Interrupt:42 Base address:0x4300 

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)

wlan0     Link encap:Ethernet  HWaddr 1C:BF:CE:2C:B2:5E  
          inet addr:192.168.1.211  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::1ebf:ceff:fe2c:b25e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1078 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:312870 (305.5 KiB)  TX bytes:0 (0.0 B)

[root@x210v3 xjh_usb-wifi]#

3、使用wpa_supplicant工具将无线网卡接入网络

经过上面的操作,无线网卡wlan0已经启动并且配置有IP地址,就等待着接入无线路由器。此时我们可以使用 wpa_supplicant 工具将无线网卡wlan0接入网络。wpa_supplicant 工具主要用于管理无线网络,它已经集成到busybox中,因此可以直接使用。

[root@x210v3 xjh_usb-wifi]# find / -name "wpa_supplicant"
/usr/sbin/wpa_supplicant
[root@x210v3 xjh_usb-wifi]#

(1)在板载系统中创建/etc/Wireless/RT2870STA目录,然后将虚拟机的x210_usb-wifi/DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/RT2870STA.dat文件拷贝到该目录。

(2)在板载系统中创建并编辑/etc/wpa_supplicant.conf文件(注意删掉注释)。

ctrl_interface=/var/run/wpa_supplicant
 
network={
ssid="XJH-ChinaNet-2.4G"                # 当前我房间的无线路由器的网络名字
scan_ssid=1
key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE # 加密方式
pairwise=TKIP CCMP
group=CCMP TKIP WEP104 WEP40
psk="xie732787"                         # 路由器的密码
}

(3)使用命令“wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd &”,将无线网卡接入连接无线网络。

[root@x210v3 xjh_usb-wifi]# wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd &
#省略部分输出
EAPOL: SUPP_BE entering state IDLE
EAPOL authentication completed - result=SUCCESS
RTM_NEWLINK: operstate=1 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK, IFLA_IFNAME: Interface 'wlan0' added
WEXT: if_removed already cleared - ignore event
SYNC - AP changed N OperaionMode to 0
EAPOL: startWhen --> 0
EAPOL: disable timer tick
MT7601AsicTemperatureCompensation::Change to TEMPERATURE_MODE_HIGH
SYNC - AP changed N OperaionMode to 3
SYNC - AP changed B/G protection to 0
SYNC - AP changed N OperaionMode to 0
SYNC - AP changed N OperaionMode to 1
SYNC - AP changed B/G protection to 1
#这是动态的输出,需要按下回车继续下一步

(4)使用命令“wpa_cli -i wlan0 status”查看连接状态。

[root@x210v3 xjh_usb-wifi]# wpa_cli -i wlan0 status
RX ctrl_iface - hexdump_ascii(len=6):
     53 54 41 54 55 53                                 STATUS          
wlan0: Control interface command 'STATUS'
bssid=28:93:7d:25:a5:bd
ssid=XJH-ChinaNet-2.4G
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=TKIP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=192.168.1.211
address=1c:bf:ce:2c:b2:5e
[root@x210v3 xjh_usb-wifi]# 

4、ping通路由器与外网的测试

(1)注意先使用“ifconfig eth0 down”关掉eth0,否则开发板默认使用eth0而非wlan0。

(2)经过上面操作之后,开发板可以ping通路由器(ping 192.168.1.1),但是因为还没有设置网关,所以不能ping通外部网络(比如ping 8.8.8.8)。我们可以通过在命令行输入下面命令来设置网关信息。

route add default gw 192.168.1.1 dev wlan0

(3)设置网关之后,因为还没有设置DNS,因此不能ping www.baidu等域名。我们可以在/etc/resolv.conf文件中配置DNS,即创建此文件并添加“nameserver 192.168.1.1”。注意这里的IP是无线路由器的IP。

[root@x210v3 xjh_usb-wifi]# ping www.baidu
PING www.baidu (14.215.177.38): 56 data bytes
64 bytes from 14.215.177.38: seq=0 ttl=56 time=19.485 ms
64 bytes from 14.215.177.38: seq=1 ttl=56 time=7.584 ms
64 bytes from 14.215.177.38: seq=2 ttl=56 time=7.942 ms
64 bytes from 14.215.177.38: seq=3 ttl=56 time=8.450 ms

--- www.baidu ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 7.584/10.865/19.485 ms
[root@x210v3 xjh_usb-wifi]# 

5、在interface文件中配置静态IP或动态IP(可选操作)

之前都是通过手动设置IP地址,其实也可以修改板载系统的/etc/network/interfaces文件来配置静态或者动态IP地址。设置静态IP的修改如下,其实就是替代手工配置时的ifconfig分配IP地址、route添加网关这两步。简单起见,这里删除有线网卡的配置,保留无线网卡的配置。

auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet static
#address 192.168.1.11  
#netmask 255.255.255.0 
#gateway 192.168.1.1

auto wlan0
iface wlan0 inet static
address 192.168.1.211
netmask 255.255.255.0
gateway 192.168.1.1

6、设置开发板开机自动连接路由器

这里是前面内容的总结,可以忽略前面1~4的操作,完成第5点后直接进行下面操作。开发板开机自动连接路由器,这个功能可以通过修改板载系统的/etc/init.d/rcS文件来实现。

(1)rcS文件所在目录及内容如下,可知它会遍历执行/etc/init.d目录下S??*的文件。

[root@x210v3 init.d]# pwd
/etc/init.d
[root@x210v3 init.d]# ls
S01logging* S20urandom* S50sshd*    rcK*
S10mdev*    S40network* S99qttest*  rcS*
[root@x210v3 init.d]#
#!/bin/sh

# Start all init scripts in /etc/init.d
# executing them in numerical order.   
#                                      

for i in /etc/init.d/S??* ;do          
                                       
     # Ignore dangling symlinks (if any).
     [ ! -f "$i" ] && continue           
                                         
     case "$i" in                        
        *.sh)                            
            # Source shell script for speed.
            (                               
                trap - INT QUIT TSTP        
                set start                   
                . $i                        
            )                       
            ;;                      
        *)               
            # No sh extension, so fork subprocess.
            $i start                              
            ;;                                    
    esac                                          
done

(2)于是在板载系统/etc/init.d/目录下创建S41WIFI文件并添加以下内容,然后使用“chmod 777 S41WIFI”命令修改该文件权限。

insmod /usr/xjh_usb-wifi/mt7601Usta.ko
ifconfig wlan0 up
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd &
wpa_cli -i wlan0 status

ifconfig wlan0 up

(3)在板载系统下执行“reboot”重启系统,完全启动后使用“ifconfig”查看,可见wlan0分配的IP地址和interfaces文件配置的一致,而且可以ping通“ 8.8.8.8 ”,但不能ping域名,这是因为之前的DNS配置文件/etc/resolv.conf文件重启后会消失。

Welcome to Buildroot
x210v3 login: root
Password: 
[root@x210v3 ~]# ifconfig
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)

wlan0     Link encap:Ethernet  HWaddr 1C:BF:CE:2C:B2:5E  
          inet addr:192.168.1.211  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::1ebf:ceff:fe2c:b25e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:892 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:304603 (297.4 KiB)  TX bytes:2980 (2.9 KiB)

[root@x210v3 ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=116 time=15.673 ms
64 bytes from 8.8.8.8: seq=1 ttl=116 time=25.335 ms
64 bytes from 8.8.8.8: seq=2 ttl=116 time=22.043 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 3 packets received, 25% packet loss
round-trip min/avg/max = 15.673/21.017/25.335 ms
[root@x210v3 ~]# ping www.baidu
ping: bad address 'www.baidu'
[root@x210v3 ~]#

四、在自己定制的rootfs中移植网卡

1、确认自制的rootfs正常工作

(1)在板载系统中删除上节的/etc/init.d/S41WIFI文件,修改/etc/network/interfaces文件如下,然后重启开发板。

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.141
netmask 255.255.255.0
gateway 192.168.1.1

(2)在uboot控制台依次输入下面指令,修改环境变量bootargs和bootcmd并保存。

setenv bootargs "root=/dev/nfs nfsroot=192.168.1.141:/home/xjh/iot/embedded_basic/rootfs/rootfs_xjh ip=192.168.1.88:192.168.1.141:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC2,115200"
set bootcmd "tftp 30008000 zImage;bootm 30008000"
save

原来的环境变量bootargs和bootcmd的内容如下:

setenv bootargs "console=ttySAC2,115200 root=/dev/mmcblk0p2 rw init=/linuxrc rootfstype=ext3"
setenv bootcmd "movi read kernel 30008000; movi read rootfs 30B00000 300000; bootm 30008000 30B00000"

busybox交叉编译

(2)启动后直接nfs方式挂载文件夹形式的rootfs,测试ok后再做成镜像烧录

(3)挂载参数

2、确认需要的移植的工具集

(1)iwconfig工具集:需要另外移植,不是busybox中的

(2)dhcp工具集:是busybox中集成的,确认busybox的menuconfig中配置支持了这个

(3)wpa_supplicant工具集:需要另外移植,不是busybox中的

3、交叉编译iwconfig

(1)源码下载

(2)配置

(3)交叉编译

(4)部署安装

(5)测试

4、交叉编译wpa_supplicant

(1)下载wpa_supplicant源码并配置编译。参考http://blog.csdn/hktkfly6/article/details/48949863

(2)下载配套版本的openssl并配置编译。

(3)去掉配置NL相关的选项省去移植libnl。参考:http://wwwblogs/helloworldtoyou/p/6145995.htm

5、在nfs中测试wpa_supplicant使用

6、制作ext2镜像并刷机测试

制作ext2格式的根文件系统镜像_天糊土的博客-CSDN博客_ext2 文件系统制作

更多推荐

将USB-WiFi网卡移植到X210开发板

本文发布于:2023-04-21 19:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/da97b296a0adce7c1371576b20cb75fa.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网卡   开发板   USB   WiFi

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 93947文章数
  • 23794阅读数
  • 0评论数