1. 引言
关于EasyMesh概念我们这里就不再过多的赘述,此篇文档的目的是,让广大初学者,有一个很方便的平台进行EasyMesh的学习和测试。
2. X86 Ubuntu平台
2.1 硬件环境准备
备注:QCA206x WiFi module推荐使用移远的FC64E/FC66E。
2.2 软件环境准备
假设已经在X86 PC上完成了Ubuntu18.04系统的安装(如有问题,自行百度)。
2.2.1 必要组件安装
$ sudo apt update
$ sudo apt install -y openssh-server x11vnc dos2unix iperf linux-crashdump wireless-tools exfat-utils exfat-fuse
$ sudo apt install build-essential libncurses5-dev flex bison libnl-3-dev
$ sudo apt install kernel-package openssl kexex-tools kdump-tools
$ sudo apt install libssl-dev
$ sudo apt install libelf-dev
$ sudo apt install -y libnl-genl-3-dev
$ sudo apt install libdbus-1-dev
$ sudo apt install lua5.1 liblua5.1-0-dev libjson-c-dev libbsd-dev libjansson-dev
$ sudo apt install net-tools dhcpcd5 bridge-utils
$ sudo apt install cmake git
$ git config --global user.email "user email address"
$ git config --global user.name "user name"
备注:
安装kexex-tools和kdump-tools时的提示选项全部选择“Yes”。
2.3 内核编译和安装
本博主只基于X86 Ubuntu 4.9.11、5.4.0和5.10.0的Linux内核版本进行验证和测试,并且当前只有4.9、5.4和5.10的内核patch,如有其他版本请自行解决相关问题。
2.3.1 编译内核版本(4.9)
Step1: 获取Linux内核版本
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
$ cd linux-stable-rc
$ git checkout v4.9.11
Step 2: 下载Linux内核补丁
相关patch请联系博主。
Step 3: 应用Linux内核补丁
$ git am 0001-Changes-for-wireless-and-cfg80211-for-v4.9.11-support.patch
$ git am 0002-Sysctl-support-for-TCP-IP-parameters-for-performance.patch
$ git am 0003-cfg80211-Add-support-for-FILS-shared-key-authentication.patch
$ git am 0004-cfg80211-Add-macros-to-indicate-backport-support-for.patch
$ git am 0005-cfg80211-size-various-nl80211-messages-correctly.patch
$ git am 0006-cfg80211-Modifiying-__cfg80211_connect_result-API.patch
$ git am 0007-cfg80211-Match-4.9.11-kernel-cfg80211-nl80211_attrs-.patch
$ git am 0008-cfg80211-Use-a-structure-to-pass-connect-response-pa.patch
$ git am 0009-cfg80211-Define-macro-to-indicate-support-for-new-cf.patch
$ git am 0010-sae-owe-station.patch
$ git am 0011-sae-owe-sap.patch
$ git am 0012-x86-kernel-reserve-CMA-memory-space-under-4G.patch
$ git am 0013-nl80211-add-6GHz-band-definition-to-enum-nl80211_ban.patch
$ git am 0014-cfg80211-add-6GHz-UNII-band-definitions.patch
$ git am 0015-cfg80211-util-add-6GHz-channel-to-freq-conversion-an.patch
$ git am 0016-cfg80211-extend-ieee80211_operating_class_to_band-fo.patch
$ git am 0017-cfg80211-add-6GHz-in-code-handling-array-with-NUM_NL.patch
$ git am 0018-cfg80211-use-same-IR-permissive-rules-for-6GHz-band.patch
$ git am 0019-cfg80211-ibss-use-11a-mandatory-rates-for-6GHz-band-.patch
$ git am 0020-cfg80211-apply-same-mandatory-rate-flags-for-5GHz-an.patch
$ git am 0021-cfg80211-Indicate-support-6GHz-band-in-kernel.patch
$ git am 0022-cfg80211-Add-support-for-HE.patch
$ git am 0023-mac80211-add-ieee80211_get_he_iftype_cap-helper.patch
$ git am 0024-6GHz-Add-support-to-validate-6GHz-channels.patch
$ git am 0025-cfg80211-Adjust-6ghz-frequencies-per-channelization.patch
$ git am 0026-nl80211-fix-nlmsg-allocation-in-cfg80211_ft_event.patch
$ git am 0027-dsa-mv88e6xxx-Optimise-atu_get.patch
$ git am 0028-cfg80211-add-and-use-strongly-typed-element-iteratio.patch
$ git am 0029-cfg80211-Parsing-of-Multiple-BSSID-information-in-sc.patch
$ git am 0030-cfg80211-use-for_each_element-for-multi-bssid-parsin.patch
$ git am 0031-cfg80211-Properly-track-transmitting-and-non-transmi.patch
$ git am 0032-cfg80211-Move-Multiple-BSS-info-to-struct-cfg80211_b.patch
$ git am 0033-cfg80211-parse-multi-bssid-only-if-HW-supports-it.patch
$ git am 0034-cfg80211-make-BSSID-generation-function-inline.patch
$ git am 0035-cfg80211-add-various-struct-element-finding-helpers.patch
$ git am 0036-cfg80211-save-multi-bssid-properties.patch
$ git am 0037-cfg80211-fix-the-IE-inheritance-of-extension-IEs.patch
$ git am 0038-cfg80211-fix-memory-leak-of-new_ie.patch
$ git am 0039-ieee80211-fix-for_each_element_extid.patch
$ git am 0040-cfg80211-fix-and-clean-up-cfg80211_gen_new_bssid.patch
$ git am 0041-cfg80211-Define-macro-to-indicate-prev_bssid-connect.patch
$ git am 0042-nl80211-add-NL80211_CMD_UPDATE_FT_IES-to-supported-c.patch
$ git am 0043-cfg80211-Add-backport-flag-for-user-cellular-base-hi.patch
Step 4: 编译Linux内核
配置内核
$ cp /boot/config-$(uname -r) .config
$ make menuconfig
然后在弹出的内核配置界面依次进行如下选择。
save > ok > exit
使能如下内核配置
CONFIG_CFG80211_INTERNAL_REGDB=yCONFIG_CFG80211=m
CONFIG_NL80211_TESTMODE=y
CONFIG_FRAME_WARN=2048
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=512
编译Linux内核
$ sudo make-kpkg -j4 --initrd kernel_image kernel_headers
编译生成的镜像文件自动保存于内核源码上层目录。
Step 5: 安装Linux内核到ubuntu
$ sudo dpkg -i linux-image-4.9.11+_4.9.11+-10.00.Custom_amd64.deb
$ sudo dpkg -i linux-headers-4.9.11+_4.9.11+-10.00.Custom_amd64.deb
Step 6: 应用相应的Linux内核
安装完成后更新GRUB配置(具体如何配置GRUB,请自行百度),再重启X86 PC。
2.3.2 编译内核版本(5.4)
Step1: 获取Linux内核版本
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
$ cd linux-stable-rc
$ git checkout v5.4
Step 2: 下载Linux内核补丁
相关patch请联系博主。
Step 3: 应用Linux内核补丁
$ git am 0001-cfg80211-Use-new-wiphy-flag-WIPHY_FLAG_DFS_OFFLOAD.patch
$ git am 0002-cfg80211-Copying-db.tx-from-wireless-regdb-for-v5.4.patch
$ git am 0003-cfg80211-Miscellenous-changes-for-bringing-up-cld-2..patch
$ git am 0006-cfg80211-Add-macros-to-indicate-backport-support-for.patch
$ git am 0007-cfg80211-fixing-dfs-master-issue.patch
$ git am 0010-saeowe-station.patch
$ git am 0011-x86-kernel-reserve-CMA-memory-space-under-4G.patch
$ git am 0012-cfg80211-Adjust-6ghz-frequencies-per-channelization.patch
$ git am 0013-6GHz-Add-support-to-validate-6GHz-channels.patch
Step 4/5/6: Follow上一章节
2.3.3 编译内核版本(5.10)
Step1: 获取Linux内核版本
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
$ cd linux-stable-rc
$ git checkout v5.10
Step 2: 下载Linux内核补丁
相关patch请联系博主。
Step 3: 应用Linux内核补丁
$ git am 0001-cfg80211-Use-new-wiphy-flag-WIPHY_FLAG_DFS_OFFLOAD.patch
$ git am 0002-cfg80211-Copying-db.tx-from-wireless-regdb-for-v5.10.patch
$ git am 0003-cfg80211-Miscellenous-changes-for-bringing-up-cld-2..patch
$ git am 0004-cfg80211-Add-macros-to-indicate-backport-support-for.patch
$ git am 0005-cfg80211-fixing-dfs-master-issue.patch
$ git am 0006-sae.patch
$ git am 0007-x86-kernel-reserve-CMA-memory-space-under-4G.patch
$ git am 0008-cfg80211-Add-support-to-configure-SAE-PWE-value-to-d.patch
Step 4/5/6: Follow上一章节
2.4 编译WiFi驱动
2.4.1 获取WiFi源代码
相关EasyMesh源代码,请联系博主。
2.4.2 Linux内核合入驱动头文件
执行如下命令拷贝AIO/drivers/core_tech_modules/目录下对应文件夹中的cnss2.h、qcn_sdio_al.h及cnss_utils.h文件至内核<kernel_path>/include/net/目录下。
$ sudo cp -r AIO/drivers/core_tech_modules/cnss2/cnss2.h <kernel_path>/include/net/
$ sudo cp -r AIO/drivers/core_tech_modules/inc/qcn_sdio_al.h <kernel_path>/include/net/
$ sudo cp -r AIO/drivers/core_tech_modules/cnss_utils/cnss_utils.h <kernel_path>/include/net/
2.4.3 编译WiFi驱动和相关应用代码
执行如下命令进行编译:
$ cd WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/build
$ make CONFIG_ONE_MSI_BUILD=y CONFIG_PERF_BUILD=y
$ make mesh_daemon MAKECMDGOALS=all
$ make mesh_pack
2.5 加载EasyMesh
2.5.1 准备环境
Step 1: 检查PCIe是否枚举成功
$ lspci
若包含如下显示信息,则表示PCIe枚举成功。
02:00.0 Network controller: Qualcomm Device 1103 (rev 01)
Step 2: 编辑/etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
[ifupdown]
managed=false
[keyfile]
unmanaged-devices=interface-name:br-lan,interface-name:wlan*
Step 3: 拷贝Wi-Fi固件、配置文件和应用程序
$ sudo mkdir /lib/firmware/wlan
$ sudo cp WiFi_EasyMesh/meta_build/load_meta/wlan_ firmware/* /lib/firmware/
$ sudo cp WiFi_EasyMesh/meta_build/load_meta/BDF&INI/FC64EABMD/bdwlan* /lib/firmware/
$ sudo cp WiFi_EasyMesh/meta_build/load_meta/BDF&INI/FC64EABMD/wlan/qcom_cfg.ini_ map /lib/firmware/wlan/qcom_cfg.ini
$ sudo cp WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/roofs-ve-f10c1.build/sbin/* /sbin
Step 4: 安装EasyMesh应用,修改WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh _pack/emesh_install.sh脚本中的EMESH_PATH变量为绝对路径后,执行脚本。
备注:配置文件qcom_cfg.ini_map适用于MAP Agent模式,而配置文件qcom_cfg.ini适用于默认的STA模式。
2.5.2 配置Agent角色
Step 1: 执行如下命令修改Agent角色配置
$ uci delete network.wan
$ uci delete network.wan6
$ uci commit network
$ uci set repacd.repacd.Role='NonCAP'
$ sudo uci commit repacd
Step 2: 执行如下命令使能Agent角色
## insert modules
$ sudo su
$ modprobe llc
$ modprobe stp
$ modprobe bridge
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/module/emesh-sp.ko
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/module/hyfi-bridging.ko
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/roofs-ve-f10c1.build/lib/ modules/ wlan_cnss_core_pcie.ko
$ modprobe cfg80211
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/roofs-ve-f10c1.build/lib/ modules/wlan.ko country_code=US
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/module/wlan_son _cld.ko
## process
$ ubusd &
$ procd -s /var/run/ubus/ubus.sock &
$ netifd -s /var/run/ubus/ubus.sock -c /etc/config -p /lib/netifd &
## config bridge
$ brctl addbr br-lan
$ ifconfig br-lan hw ether $(iw dev wlan1 info |grep addr|awk '{print $2}')
$ ip addr flush dev eth0
$ ip addr flush dev br-lan
## scripts
$ ./WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/cfg_hyctl.sh
$ . /WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/cfg_wireless_mac.sh
$ /etc/init.d/repacd start
Step 3: 执行如下命令检查EasyMesh功能是否加载成功
$ ps -x
若显示信息包含如下进程信息,则表示EasyMesh功能加载成功。
3228 ? Ss 0:00 /sbin/hostapd /var/run/hostapd-wlan1.conf -ddd -f /tmp/hostapd-wlan1.log -t -B
3241 ? Ss 0:00 /sbin/hostapd_cli -i wlan1 -p /var/run/hostapd-wlan1
3346 ? Ss 0:00 /sbin/hostapd /var/run/hostapd-wlan2.conf -ddd -f /tmp/hostapd-wlan2.log -t -B
3354 ? Ss 0:00 /sbin/hostapd_cli -i wlan2 -p /var/run/hostapd-wlan2
3437 ? Ss 0:00 wpa_supplicant -i wlan0 -u -c /var/run/wpa_supplicant-wlan0.conf -ddd
3631 ? S 0:00 /usr/sbin/wsplcd -c /tmp/wsplcd-lan.conf -a -M /etc/wsplcd/map/bss-policy.conf
3906 ? Sl 0:01 /usr/sbin/ezmesh -d -C /tmp/ezmesh-lan.conf -P 7777 -cfg80211
2.5.3 配置Controller角色
Step 1: 执行如下命令修改Controller角色配置
$ uci set network.wan=interface
$ uci set network.wan.ifname=eth1
$ uci set network.wan.proto=dhcp
$ sudo uci commit network
$ uci set repacd.MAPConfig.FronthaulSSID='EasyMeshssid-MAP'
$ uci set repacd.MAPConfig.FronthaulKey='EasyMeshssid-MAP'
$ uci set repacd.repacd.Role='CAP'
$ sudo uci commit repacd
$ uci set wireless.wlan0.disabled='1'
$ uci set wireless.@wifi-iface[1].ssid=EasyMeshssid-MAP
$ uci set wireless.@wifi-iface[1].encryption='psk2+ccmp'
$ uci set wireless.@wifi-iface[1].key=EasyMeshssid-MAP
$ uci set wireless.@wifi-iface[2].ssid=EasyMeshssid-MAP
$ uci set wireless.@wifi-iface[2].encryption='psk2+ccmp'
$ uci set wireless.@wifi-iface[2].key=EasyMeshssid-MAP
$ sudo uci commit wireless
Step 2: 执行如下命令使能Controller角色
## insert modules
$ sudo su
$ modprobe llc
$ modprobe stp
$ modprobe bridge
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/module/emesh-sp.ko
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/module/hyfi-bridging.ko
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/roofs-ve-f10c1.build/lib/
modules/ wlan_cnss_core_pcie.ko
$ modprobe cfg80211
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/roofs-ve-f10c1.build/lib/ modules/wlan.ko country_code=US
$ insmod WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/module/wlan_son _cld.ko
## process
$ ubusd &
$ procd -s /var/run/ubus/ubus.sock &
$ netifd -s /var/run/ubus/ubus.sock -c /etc/config -p /lib/netifd &
## config bridge
$ brctl addbr br-lan
$ ifconfig br-lan hw ether $(iw dev wlan1 info |grep addr|awk '{print $2}')
$ ip addr flush dev eth0
$ ip addr flush dev br-lan
## scripts
$ ./WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/cap_cfg_hyctl.sh
$ . /WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/cfg_wireless_mac.sh
$ /etc/init.d/repacd start
$ ./WiFi_EasyMesh/chss_host_LEA/chss_proc/host/AIO/emesh_pack/dnsmasq.sh
Step 3: 执行如下命令检查EasyMesh功能是否加载成功
$ ps -x
若显示信息包含如下进程信息,则表示EasyMesh功能加载成功。
3228 ? Ss 0:00 /sbin/hostapd /var/run/hostapd-wlan1.conf -ddd -f /tmp/hostapd-wlan1.log -t -B
3241 ? Ss 0:00 /sbin/hostapd_cli -i wlan1 -p /var/run/hostapd-wlan1
3346 ? Ss 0:00 /sbin/hostapd /var/run/hostapd-wlan2.conf -ddd -f /tmp/hostapd-wlan2.log -t -B
3354 ? Ss 0:00 /sbin/hostapd_cli -i wlan2 -p /var/run/hostapd-wlan2
3437 ? Ss 0:00 wpa_supplicant -i wlan0 -u -c /var/run/wpa_supplicant-wlan0.conf -ddd
3631 ? S 0:00 /usr/sbin/wsplcd -c /tmp/wsplcd-lan.conf -a -M /etc/wsplcd/map/bss-policy.conf
3906 ? Sl 0:01 /usr/sbin/ezmesh -d -C /tmp/ezmesh-lan.conf -P 7777 -cfg80211
4013 ? S 0.00 dnsmasq --dhcp-range=192.168.39.10,192.168.39.100,12h -p 54