一:mt7663源码配置及编译
1:下载mt7663源码,这里面已经有我配置好的海思3531平台的Makfile.aarch
下载地址:mt7663USB转wifi源码(已配置好用于交叉编译的makefile)资源-优快云文库
2:修改Makefile.aarch,将CROSS_COMPILE , LINUX_SRC , DRIVER_DIR 换成自己对应的路径即可,如国目标平台不是arm64 则make 参数 ARCH=arch64 也需要更换成自己需要编译的目标平台
3:修改完makefile后 make -f Makefile.aarch 编译即可生成3M左右大小的wlan_mt7663_usb.ko
4:将生成的wlan_mt7663_usb.ko拷贝到开发板即可
二:内核配置80211
1:进到目标平台的linux源码目录 make ARCH=arm64 menuconfig ,配置如下:
*Networking support->*Wirless
M cfg80211-wireless configuration
* cfg80211 wireless extensions compatibility
M Generic IEEE 802.11 Networking stack (mac80211)
* Enable mac80211 mesh networking (pre-802.11s) support
2:重新编译目标平台内核,将 net/mac80211/mac80211.ko net/wireless/cfg80211.ko 拷贝到开发板
三:目标板配置补丁
将第一步中下载的源码中的mt7663_patch_e2_hdr.bin WIFI_RAM_CODE_MT7663.bin 文件复制到开发板/lib/firmware,没有这个目录则新建
四:加载驱动
在开发板加载驱动
insmod cfg80211.ko
insmod mac80211.ko
insmod wlan_mt7663_usb.ko
五:交叉编译hostapd和wpa_supplicant
1:下载hostapd2.5源码,libnl-3.2.5源码,openssl-1.0.1g源码,wpa_supplicant-2.5源码
下载地址:hostpad2.5libnl-3.2.5openssl-1.0.1gwpa-supplicant-2.5源码资源-优快云文库
2:交叉编译openssl-1.0.1g(最好用这个版本,其他版本api接口和hostpad2.5不一样)
cd openssl-1.0.1g
./config no-asm shared \
--prefix=/home/hfzuo/work/openssl/openssl-1.0.1g/install \
--cross-compile-prefix=aarch64-linux-gnu-
sed -i 's/-m64/ /g' Makefile
sed -i 's/-m64/ /g' Makefile
make && make install
error:cms.pod around line 457: Expected text after =item, not a number
解决方案:rm -f /usr/bin/pod2man
3:交叉编译libnl-3.2.5
cd libnl-3.2.5
./configure --host=arm CC=aarch64-linux-gnu-gcc \
--prefix=/home/hfzuo/work/libnl/libnl-3.2.5/install
sudo apt-get install -y byacc
sudo apt-get install -y flex
sudo apt-get install -y bison
sudo apt-get install -y libtool
make && make install
4:交叉编译hostpad 2.5
cd hostapd-2.5/hostapd/
cp defconfig .config
修改.config
CONFIG_LIBNL32=y
CONFIG_IEEE80211N=y
修改makefile,在合适的位置加上如下代码
CFLAGS += -I/home/hfzuo/work/openssl/openssl-1.0.1g/install/include
LIBS += -L/home/hfzuo/work/openssl/openssl-1.0.1g/install/lib
CFLAGS += -I/home/hfzuo/work/libnl/libnl-3.2.5/install/include/libnl3
CFLAGS += -I/home/hfzuo/work/libnl/libnl-3.2.5/install/include
LIBS += -L/home/hfzuo/work/libnl/libnl-3.2.5/install/lib
export PKG_CONFIG_PATH=/home/hfzuo/work/libnl/libnl-3.2.5/install/lib/pkgconfig:$PKG_CONFIG_PATH
make clean
make CC=aarch64-linux-gnu-gcc
5:将librt.so.1 libssl.so.1.0.0 libcrypto.so.1.0.0 hostapd 复制到开发板
6:交叉编译wpa_supplicant
cd wpa_supplicant-2.5/wpa_supplicant
cp defconfig .config
修改.config
CONFIG_LIBNL32=y
CONFIG_IEEE80211N=y
修改makefile,在合适的位置加上如下代码
CFLAGS += -I/home/hfzuo/work/openssl/openssl-1.0.1g/install/include
LIBS += -L/home/hfzuo/work/openssl/openssl-1.0.1g/install/lib
CFLAGS += -I/home/hfzuo/work/libnl/libnl-3.2.5/install/include/libnl3
CFLAGS += -I/home/hfzuo/work/libnl/libnl-3.2.5/install/include
LIBS += -L/home/hfzuo/work/libnl/libnl-3.2.5/install/lib
在 wpa_passphrase: $(OBJS_p) 下面加上-L/home/hfzuo/work/openssl/openssl-1.0.1g/install/lib
make clean
make CC=aarch64-linux-gnu-gcc
将wpa_supplicant 复制到开发板
六:配置ap模式
udhcpd wlan0
echo ap_start 1 >/proc/net/wlan/driver
hostapd hostapd_5G.conf -B
hostapd_5G.conf内容如下:
interface=wlan0
ctrl_interface=/var/run/hostapd
ssid=mt_wifi
channel=36
wpa=2
wpa_passphrase=12345678
#bridge=br0
driver=nl80211
beacon_int=100
hw_mode=a
ieee80211n=1
wme_enabled=1
ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+]
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
max_num_sta=8
wpa_group_rekey=86400
在PC端即可看到名字为mt_wifi的热点,密码是12345678
七:配置sta模式
udhcpc -i wlan0 &
wpa_supplicant -D nl80211 -i wlan0 -c wpa_supplicant_hfzuo.conf
其中udhcpc为请求dhcp服务分配IP的工具,一般开发板都自带,如果没有则需要自己交叉编译udhcpc
wpa_supplicant_hfzuo.conf内容如下:
ctrl_interface=/var/run/wpa_supplicants
network={
ssid="hfzuo"
psk="88888888"
proto=WPA2
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP
}
即可自动连接密码为88888888名字为hfzuo的热点了