@[TOC](wfb-ng Release 23.01镜像无头烧录&配置(2))
1. 简介
在wfb-ng Release 23.01镜像无头烧录&配置(1)的基础上,整理天空端step by step配置过程。
2. 步骤
Step 1 加载bootfs & rootfs
插入已经按照Raspbian镜像无头烧录烧录好的tf卡。
请根据各自系统情况,笔者的ubuntu系统识别tf卡设备符号是/dev/sdb。
$ sudo mount /dev/sdb1 /mnt/bootfs
$ sudo mount /dev/sdb2 /mnt/rootfs
Step 2 配置ssh
$ cd /mnt/bootfs
$ sudo touch ssh
Step 3 RNDIS-ethernet登录
默认账号:pi
默认密码:raspberry
注:请参考wfb-ng Release 23.01镜像无头烧录&配置(1)调试联网internet。
Step 4 安装wpasupplicant
pi@raspberrypi:~ $ sudo apt-get install wpasupplicant
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
eject exfatprogs gdisk libatasmart4 libblockdev-crypto2 libblockdev-fs2 libblockdev-loop2 libblockdev-part-err2
libblockdev-part2 libblockdev-swap2 libblockdev-utils2 libblockdev2 libgpgme11 libparted-fs-resize0
libudisks2-0 libvolume-key1
Use 'sudo apt autoremove' to remove them.
Suggested packages:
wpagui libengine-pkcs11-openssl
The following NEW packages will be installed:
wpasupplicant
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,027 kB of archives.
After this operation, 2,828 kB of additional disk space will be used.
Get:1 http://mirrors.zju.edu.cn/raspbian/raspbian bullseye/main armhf wpasupplicant armhf 2:2.9.0-21 [1,027 kB]
Fetched 1,027 kB in 2s (507 kB/s)
Selecting previously unselected package wpasupplicant.
(Reading database ... 120971 files and directories currently installed.)
Preparing to unpack .../wpasupplicant_2%3a2.9.0-21_armhf.deb ...
Unpacking wpasupplicant (2:2.9.0-21) ...
Setting up wpasupplicant (2:2.9.0-21) ...
wpa_supplicant.service is a disabled or a static unit not running, not starting it.
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for dbus (1.12.24-0+deb11u1) ...
Step 5 配置无线维测通道
使能默认的板载wifi网卡
pi@raspberrypi:~ $ sudo nano /etc/modprobe.d/blacklist-rtl8xxxu.conf
pi@raspberrypi:~ $ sudo cat /etc/modprobe.d/blacklist-rtl8xxxu.conf
#blacklist brcmfmac
blacklist rtl8xxxu
增加wlan0网卡接口
pi@raspberrypi:~ $ sudo nano /etc/network/interfaces
pi@raspberrypi:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
iface default inet dhcp
配置无线网络登录账号密码
pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
pi@raspberrypi:~ $ sudo cat /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CN
network={
ssid="your-network-ssid"
psk="your-network-password"
}
Step 6 安装8812AU wfb_ng驱动
可以先检查下当前内核配置下是否有该驱动(插上网卡)
- 使用
iwconfig
确认下是否有新的网卡接口出现
pi@piCamera:~ $ iwconfig
lo no wireless extensions.
usb0 no wireless extensions.
wlan0 IEEE 802.11 ESSID:"AutoLab"
Mode:Managed Frequency:2.412 GHz Access Point: D0:C7:C0:5C:CE:50
Bit Rate=72.2 Mb/s Tx-Power=31 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=70/70 Signal level=-21 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
- 使用
dmesg
查询下是否usb枚举到设备的消息
pi@piCamera:~ $ lsusb
Bus 001 Device 005: ID 0bda:881a Realtek Semiconductor Corp. RTL8812AU-VS 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@piCamera:~ $ dmesg |tail
[ 145.468344] usb 1-1.4: Manufacturer: Realtek
[ 145.468377] usb 1-1.4: SerialNumber: 123456
[ 183.382996] usb 1-1.4: USB disconnect, device number 4
[ 186.324635] usb 1-1.4: new high-speed USB device number 5 using dwc2
[ 186.455273] usb 1-1.4: config 1 interface 0 altsetting 0 endpoint 0x85 has an invalid bInterval 0, changing to 7
[ 186.456087] usb 1-1.4: New USB device found, idVendor=0bda, idProduct=881a, bcdDevice= 0.00
[ 186.456144] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 186.456172] usb 1-1.4: Product: 802.11n NIC
[ 186.456194] usb 1-1.4: Manufacturer: Realtek
[ 186.456215] usb 1-1.4: SerialNumber: 123456
- 查看下当前内核下是否有驱动ko文件
pi@raspberrypi:~ $ uname -r
5.15.76+
pi@raspberrypi:~ $ ls /lib/modules/5.15.76+/kernel/drivers/net/wireless/
ath atmel broadcom intersil mac80211_hwsim.ko.xz marvell mediatek ralink realtek rndis_wlan.ko.xz zydas
pi@raspberrypi:~ $ ls /lib/modules/5.15.76+/kernel/drivers/net/wireless/realtek/
rtl818x rtl8xxxu rtlwifi
如果没有上述驱动和网络接口,大概率是驱动没有安装,请使用下面命令进行安装。
pi@raspberrypi:~ $ cd rtl8812au && make && sudo make install
安装以后出现了88XXau_wfb.ko
文件
pi@raspberrypi:~ $ uname -r
5.15.76+
pi@raspberrypi:~ $ ls /lib/modules/5.15.76+/kernel/drivers/net/wireless/
88XXau_wfb.ko ath atmel broadcom intersil mac80211_hwsim.ko.xz marvell mediatek ralink realtek rndis_wlan.ko.xz zydas
Step 7 配置无线图传
通过ifconfig
查询到网卡的MAC地址,并建立udev规则。
pi@raspberrypi:~ $ sudo nano /etc/udev/rules.d/75-wifi-interface-name-change.rules
pi@raspberrypi:~ $ sudo cat /etc/udev/rules.d/75-wifi-interface-name-change.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="b8:27:eb:53:31:30", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="w*", NAME="wlan0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="0c:91:60:03:5b:62", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="w*", NAME="wfb-rf1"
pi@raspberrypi:~ $ udevadm control --reload-rules && udevadm trigger
配置天空端图传使用的网卡接口
pi@raspberrypi:~ $ cat /etc/default/wifibroadcast
#WFB_NICS="wlx00c0caa578a9"
#WFB_NICS="wlan1 wlan2"
WFB_NICS="wfb-rf1"
Step 8 视频stream端口配置
在天空端图传配置stream的端口peer = 'listen://0.0.0.0:5602' # listen for video stream (gstreamer on drone)
pi@raspberrypi:~ $ sudo nano /etc/wifibroadcast.cfg
pi@raspberrypi:~ $ sudo cat /etc/wifibroadcast.cfg
[common]
wifi_channel = 165 # default channel for 5.8 GHz
log_file = None # Set to "wifibroadcast.log" to disable log to stdout
link_id = "default" # It will be hashed and mapped to three bytes of MAC
# You can use different link ids for multi-vehicle setup without stream remapping.
# For that case need to have several instances of wifibroadcast.cfg on GS - one for each link (GS <-> droneX)
# Redefine peer addresses, tunnel interfaces and tunnel addresses to not overlap
# Copy and rename wifibroadcast@.gs service and set path to custom wfb config.
###############################
### DRONE PART
###############################
[drone_video]
bandwidth = 20 # bandwidth 20 or 40 MHz
short_gi = False # use short GI or not
stbc = 1 # stbc streams: 1, 2, 3 or 0 if unused
ldpc = 1 # 8812au only
mcs_index = 1 # mcs index
peer = 'listen://0.0.0.0:5602' # listen for video stream (gstreamer on drone)
[drone_mavlink]
bandwidth = 20 # bandwidth 20 or 40 MHz
short_gi = False # use short GI or not
stbc = 1 # stbc streams: 1, 2, 3 or 0 if unused
ldpc = 1 # 8812au only
mcs_index = 1 # mcs index
stats_port = 8001 # used by wfb-cli
# Uncoment if you need to forward mavlink stream
#peer = 'serial:/dev/ttyS0:1500000' # Serial port for autopilot
[drone_tunnel]
bandwidth = 20 # bandwidth 20 or 40 MHz
short_gi = False # use short GI or not
stbc = 1 # stbc streams: 1, 2, 3 or 0 if unused
ldpc = 1
mcs_index = 1 # mcs index
stats_port = 8003 # used by wfb-cli
###############################
### GS PART
###############################
[gs_video]
# gs video is RX only, so you doesn't need to specify ldpc, stbc, gi and mcs_index
bandwidth = 20 # bandwidth 20 or 40 MHz
stats_port = 8002 # used by wfb-cli
peer = 'connect://127.0.0.1:5600' # outgoing connection for RTP video sink (RTSP server, local video pipeline or QGC), use 224.0.0.1 for multicast streaming
[gs_mavlink]
bandwidth = 20 # bandwidth 20 or 40 MHz
short_gi = False # use short GI or not
stbc = 1 # stbc streams: 1, 2, 3 or 0 if unused
ldpc = 1
mcs_index = 1 # mcs index
stats_port = 8001 # used by wfb-cli
# Uncomment and set QGroundControl address
#peer = 'connect://192.168.1.1:14550'
# OSD
mirror = 'connect://127.0.0.1:14551'
[gs_tunnel]
bandwidth = 20 # bandwidth 20 or 40 MHz
short_gi = False # use short GI or not
stbc = 1 # stbc streams: 1, 2, 3 or 0 if unused
ldpc = 1
mcs_index = 1 # mcs index
stats_port = 8003 # used by wfb-cli
Step 9 链路安全加密
9.1 wfb_ng链路
建议先测试链路(使用自带image的drone.key & gs.key)。
然后再使用wfb_keygen
生成秘钥,并成对替换天空端和地面端key。
pi@raspberrypi:~ $ ls
gst-mmal gst-rtsp-server rtl8812au userland wfb_ng wfb_ng_osd
pi@raspberrypi:~ $ wfb_keygen
Drone keypair (drone sec + gs pub) saved to drone.key
GS keypair (gs sec + drone pub) saved to gs.key
pi@raspberrypi:~ $ ls
drone.key gs.key gst-mmal gst-rtsp-server rtl8812au userland wfb_ng wfb_ng_osd
此时,会生成两个文件
- drone.key // 天空端/etc/drone.key
- gs.key // 地面端/etc/gs.key
9.2 维测链路-ssh账号密码修改
pi@raspberrypi:~ $ passwd pi
Changing password for pi.
Current password:
New password:
Retype new password:
passwd: password updated successfully
9.3 维测链路-wifi密码修改
pi@raspberrypi:~ $ wpa_passphrase your-network-ssid your-network-password
network={
ssid="your-network-ssid"
#psk="your-network-password"
psk=deeab159f8342bdb4ef476d4d2191ce8e2a9dbeebc5b2ae7d7330b2b86b01194
}
替换为
pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
pi@raspberrypi:~ $ sudo cat /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CN
network={
ssid="your-network-ssid"
psk=deeab159f8342bdb4ef476d4d2191ce8e2a9dbeebc5b2ae7d7330b2b86b01194
}