海思Hi3518E移植WIFI驱动(STA模式)
1. 移植驱动
源码下载:
链接:https://pan.baidu.com/s/1EXGMkPs8-GxsdyK0735Sqw
提取码:bx5c
(1)include/rtmp_def.h中1627行左右,修改网络名始终为:wlan
(2)修改Makefile
原来默认的平台是PC,然后添加平台
添加Linux内核源码路径,编译工具链,CPU
ifeq ($(PLATFORM),HISI_3518E)
LINUX_SRC = /home/aston/sambashare/Hi3518E_SDK_V1.0.3.0/osdrv/opensource/kernel/linux-3.4.y
CROSS_COMPILE = arm-hisiv300-linux-
export ARCH = arm
endif
在402行:修改为HISI_3518E
ifeq ($(PLATFORM),DM6446)
$(MAKE) ARCH=arm CROSS_COMPILE=arm_v5t_le- -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
else
ifeq ($(PLATFORM),HISI_3518E)//《——————
$(MAKE) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
else
$(MAKE) -C $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
endif
endif
错误1:
CC [M] /home/aston/sambashare/5季/ap/mt7601u/os/linux/../../os/linux/rt_profile.o
/home/aston/sambashare/5季/ap/mt7601u/os/linux/../../os/linux/rt_profile.c:26:23: fatal
error: rt_config.h: No such file or directory
#include "rt_config.h"
主要原因是:在编译 ./os/linux/rt_profile.c 的时候找不到文件 rt_config.h 这是因为plags没有设置好
修改:在 ./os/linux/config.mk 中添加
最后编译成功:在 ./os/linux/ 下会生成KO文件 mt7601Uap.ko ,并且向 /tftp/ 下复制一份
为把KO文件复制到我们需要的目录下,因此修改Makefile
2. 部署驱动
(1)先lsusb,然后插入USB WIFI模块,再lsusb,确认模块被识别了
/mnt # lsusb
Bus 001 Device 003: ID 148f:7601 //我的开发板
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0001
(2)在开发板中创建 /etc/Wireless/RT2870STA 文件夹,把驱动源文件下的 RT2870STA.dat 复制到开发板的这个文件夹中
mkdir /etc/Wireless/RT2870STA/ -p
修改:/etc/Wireless/RT2870STA/RT2870STA.dat
SSID=MT7601AP_WPA //这里的名字是在pc机上看到的连接ssid名
AuthMode=WPA2PSK //认证方式
EncrypType=TKIP;AES //加密方式
WPAPSK=1234567890 //这个是密码
装载驱动:insmod mt7601Usta.ko
启动网卡: ifconfig wlan0 up
ifconfig -a
wlan0 Link encap:Ethernet HWaddr 0E:4B:88:00:87:9D
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:165 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:40386 (39.4 KiB) TX bytes:0 (0.0 B)
3. 移植 wpa_supplicant 和 openssl
1 源码下载
(1)wpa_supplicant http://hostap.epitest.fi/wpa_supplicant/ 和 https://w1.fi/releases/
(2)openssl ftp://ftp.openssl.org/source/old/0.9.x/
打补丁:
cp wpa_supplicant-2.5/patches/openssl-0.9.8za-tls-extensions.patch ./openssl-0.9.8za
2 编译openssl
进入openssl路径:打补丁
/openssl-0.9.8za$ patch -p1 < openssl-0.9.8za-tls-extensions.patch
patching file ssl/s3_clnt.c
patching file ssl/s3_srvr.c
patching file ssl/ssl_err.c
patching file ssl/ssl.h
patching file ssl/ssl_sess.c
patching file ssl/t1_lib.c
patching file ssl/tls1.h
patching file util/ssleay.num
开始配置
#cd openssl-0.9.8e
#mkdir /home/liu/ARM/test/openssl-0.9.8za/tmp_ssl
#vim Makefile
CC= arm-linux-gcc
AR= arm-linux-ar $(ARFLAGS) r
RANLIB= arm-linux-ranlib
INSTALLTOP=/home/liu/ARM/test/openssl-0.9.8za/tmp_ssl
OPENSSLDIR=/home/liu/ARM/test/openssl-0.9.8za/tmp_ssl
#make
#make install //执行这一步可能会出错,说什么/usr/bin/pod2man错误,只要删除这个文件就好了
出错1:
smime.pod around line 272: Expected text after =item, not a number
smime.pod around line 276: Expected text after =item, not a number
smime.pod around line 280: Expected text after =item, not a number
smime.pod around line 285: Expected text after =item, not a number
smime.pod around line 289: Expected text after =item, not a number
POD document had syntax errors at /usr/bin/pod2man line 68.
Makefile:686: recipe for target 'install_docs' failed
make: *** [install_docs] Error 1
原因:OpenSSL 与 perl版本不兼容
解决方法:rm -f /usr/bin/pod2man
再次:make install
在/home/liu/ARM/test/openssl-0.9.8za/tmp_ssl目录下安装了ssl库
root@liu-virtual-machine:/home/liu/ARM/test/openssl-0.9.8za/tmp_ssl# ls
bin certs include lib man misc openssl.cnf private
后面编译 wpa_supplicant 要依赖openssl中的lib和include
3 编译wpa_supplicant
进入wpa_supplicant-0.7.3.tar.gz解压生成的wpa_supplicant-0.7.3/wpa_supplicant目录中:直接在文件中加入这几段命令。
#cp defconfig .config
#vim .config
CC=arm-linux-gcc -L/home/liu/ARM/test/openssl-0.9.8za/tmp_ssl/lib/
CFLAGS += -I/home/liu/ARM/test/openssl-0.9.8za/tmp_ssl/include/
LIBS += -L/home/liu/ARM/test/openssl-0.9.8za/tmp_ssl/lib/
#make
出错1:
driver_nl80211.c:17:31: fatal error: netlink/genl/genl.h
进入wpa_supplicant目录下.config
将CONFIG_DRIVER_NL80211=y 注释掉即可
继续make,生成wpa_supplicant和wpa_cli后整个移植成功完成
wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。
4 配置wpa_supplicant
(1)首先拷贝wpa_supplicant和wpa-psk-tkip.conf到开发板根文件系统中
cp wpa_cli /home/liu/ARM/rootfs/rootfs2/bin/
cp wpa_supplicant /home/liu/ARM/rootfs/rootfs2/bin/
cp wpa_cli wpa_passphrase /home/liu/ARM/rootfs/rootfs2/bin/
cp examples/wpa-psk-tkip.conf /home/liu/ARM/rootfs/rootfs2/etc/wpa_supplicant.conf (更改文件名)
(2)设置配置文件
# WPA-PSK/TKIP
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="vivo Y51A" #热点的ssid
scan_ssid=1
key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
pairwise=TKIP CCMP
group=CCMP TKIP WEP104 WEP40
psk="zaq852xsw" #密码
}
由于WiFi运行要一个运行文件,因此要创建一个文件:
mkdir -p /var/run/wpa_supplicant
然后:分配IP地址
- PC:192.168.43.110
- 开发板:192.168.43.2
- 路由器:192.168.43.1
insmod mt7601Usta.ko //安装驱动程序
ifconfig ra0 up //开启无线网卡
ifconfig wlan0 192.168.43.2 //这要根据你的路由器,来设置
ifconfig
wlan0 Link encap:Ethernet HWaddr 0E:4B:88:00:87:9D
inet addr:192.168.0.233 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:492 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:121403 (118.5 KiB) TX bytes:0 (0.0 B)
连接网络:同时手机上可以显示已经连接了一个设备
# wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd &
# wpa_cli -i wlan0 status
EAPOL: EAP Session-Id not available
CTRL-DEBUG: ctrl_sock-sendto: sock=7 sndbuf=163840 outq=0 send_len=191
bssid=9c:a5:c0:15:74:1a
freq=0
ssid=vivo Y51A
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=192.168.43.2
address=0e:4b:88:00:87:9d
ping通外网:
route add default gw 192.168.43.1 dev ra0 //配置网关
ping -I ra0 192.168.43.1 //指定网卡 ra0 ping 网关
ping -I ra0 8.8.8.8 //ping 外网
ping -I ra0 202.108.22.5 //ping 百度的ip地址
vi /etc/resolv.conf //配置dns
nameserver 192.168.43.1
ping -I ra0 www.baidu.com
ping通PC:要先关闭防火墙
# ping -Iwlan0 192.168.43.110
PING 192.168.43.110 (192.168.43.110): 56 data bytes
64 bytes from 192.168.43.110: seq=0 ttl=128 time=8.872 ms
64 bytes from 192.168.43.110: seq=1 ttl=128 time=6.934 ms
64 bytes from 192.168.43.110: seq=2 ttl=128 time=4.084 ms
--- 192.168.43.110 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 4.084/6.630/8.872 ms
让开发板开机自动连上路由器上网
改/etc/profile及其相关文件
cd /tmp
insmod mt7601Usta.ko
ifconfig wlan0 up
mkdir -p /var/run/wpa_supplicant
ifconfig wlan0 192.168.43.2
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd &
route add default gw 192.168.43.1 dev wlan0
测试用例
(1)ORTP版本的sample,common/sample_common_venc.c中,修改LOCAL_HOST_IP为192.168.43.110
(2)make clean,make
(3)复制得到的sample_venc到/home/aston/rootfs中
运行结果:
4 设置动态DHCP分配IP地址
动态主机设置协议(Dynamic Host Configuration Protocol, DHCP)是一个局域网的网络协议,使用UDP协议工作,主要有两个用途:
1.给内部网络或网络服务供应商自动分配IP地址
2.给用户给内部网络管理员作为对所有计算机作中央管理的手段。
方法一:dhclient
可以参考:https://www.jb51.net/article/37379.htm
方法二:udhcpc
udhcpc是一个面向嵌入式系统的非常小的DHCP客户端,字母的缩写微- DHCP -客户端(μDHCPc)。
1.udhcpc -i wlan0
udhcpc只是获取一个IP,我们需要把\busybox-1.1.2\examples\udhcp下的脚本simple.script改名为default.script,放在开发板上的/usr/share/dhcpc/目录下,才能将获取的IP写到指定的网卡中。
default.script 依赖于 sample.bound sample.deconfig
所以:复制\busybox-1.1.2\examples\udhcp下的sample.bound sample.deconfig到/usr/share/dhcpc/
由于这两个文件又依赖于/etc/udhcpc/resolv.conf
所以:复制/busybox-1.1.2examples/var_service/fw/etc/resolv.conf 到 /etc/udhcpc/
最后:
# udhcpc -i wlan0
udhcpc (v1.20.2) started
Sending discover...
Sending select for 192.168.43.145...
Lease of 192.168.43.145 obtained, lease time 3600
deleting routers
route: SIOCDELRT: No such process
adding dns 192.168.43.1
# ifconfig
wlan0 Link encap:Ethernet HWaddr 0E:4B:88:00:87:9D
inet addr:192.168.43.145 Bcast:192.168.43.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:134087 errors:0 dropped:35 overruns:0 frame:0
TX packets:221 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31405991 (29.9 MiB) TX bytes:16830 (16.4 KiB)
# ping -Iwlan0 192.168.43.110
PING 192.168.43.110 (192.168.43.110): 56 data bytes
64 bytes from 192.168.43.110: seq=0 ttl=128 time=10.780 ms
64 bytes from 192.168.43.110: seq=1 ttl=128 time=21.844 ms
64 bytes from 192.168.43.110: seq=2 ttl=128 time=2.764 ms
最后修改 /etc/profile 开机自启动生成 IP 地址
cd /tmp
insmod mt7601Usta.ko
ifconfig wlan0 up
mkdir -p /var/run/wpa_supplicant
ifconfig wlan0 192.168.43.2
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd &
route add default gw 192.168.43.1 dev wlan0
udhcpc -i wlan0 #动态获得IP
- 分享
- 举报
-
浏览量:801次2024-01-24 15:46:44
-
浏览量:768次2023-06-12 14:35:37
-
浏览量:2885次2020-08-06 15:44:06
-
浏览量:1239次2023-06-12 14:35:43
-
浏览量:3455次2022-01-31 09:00:24
-
浏览量:991次2024-01-24 17:37:01
-
浏览量:1059次2023-06-12 14:36:04
-
浏览量:1409次2024-01-25 16:21:59
-
浏览量:1456次2023-12-29 16:51:41
-
浏览量:1034次2023-06-12 14:35:25
-
浏览量:749次2024-02-23 16:58:46
-
浏览量:2889次2018-04-03 09:48:45
-
2018-04-04 14:06:53
-
浏览量:4302次2018-03-31 20:59:15
-
浏览量:5744次2018-04-03 09:53:34
-
浏览量:2769次2020-07-31 15:13:59
-
浏览量:593次2024-01-25 16:37:07
-
浏览量:6395次2018-06-14 22:53:53
-
2024-01-11 15:44:19
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
outman
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明