msposd 开源代码之树莓派3B+ Bookworm部署

msposd 开源代码之树莓派3B+ Bookworm部署

1. 源由

在前面文档中,我们已经基本上搭建了 树莓派FPV的 Ardupilot Rover测试平台:

在实际使用过程中,由于msposd采用了native build方式,与OpenIPC的安装方式不太一样,所以有些细节需要进行调整。

  1. 天空端安装路径
  2. 自定义数据支持

2. 安装

msposd由于navtive build方式编译,安装应用了gs目录结构。

  • 目录结构:
$ tree /usr/local/bin/fpvdrone/
/usr/local/bin/fpvdrone/
├── font_ardu_hd.png
├── font_ardu.png
├── font_btfl_hd.png
├── font_btfl.png
├── font_inav_hd.png
├── font_inav.png
├── fpv-drone.sh
├── fpv-update.sh
├── vtxmenu.ini
└── msposd

1 directory, 8 files

3. 脚本

  • 自定义更新脚本 (每秒更新)
$ sudo nano /usr/local/bin/fpvdrone/fpv-update.sh
$ sudo chmod +x /usr/local/bin/fpvdrone/fpv-update.sh
$ cat /usr/local/bin/fpvdrone/fpv-update.sh
#!/bin/bash

while true; do
  echo "Monitor... &L24 &F28 CPU:&C &B temp:&T" > /usr/local/bin/fpvdrone/MSPOSD.msg
  sleep 1
done
  • 启动脚本支持libcamera-vid日志管道
$ cat /usr/local/bin/fpvdrone/fpv-drone.sh
#!/bin/bash

# Set up environment variables
export PATH=$PATH:/usr/local/bin:/usr/bin
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib

# Start the wfb_tx process
/usr/bin/wfb_tx \
  -p 17 \
  -u 14560 \
  -K /etc/drone.key \
  -B 20 \
  -M 1 \
  -S 1 \
  -L 1 \
  -G long \
  -k 1 \
  -n 2 \
  -T 0 \
  -i 7669206 \
  -f data \
  wfb-rf0 &

# Check if /tmp/libcamera-logs FIFO file exists, create it if not
if [ ! -p /tmp/libcamera-logs ]; then
  mkfifo /tmp/libcamera-logs
fi

# Start libcamera-vid and pipe its output to GStreamer while logging to /tmp/libcamera-logs
/usr/bin/libcamera-vid \
  --verbose \
  --inline \
  --width 1920 \
  --height 1080 \
  --bitrate 4000000 \
  --framerate 30 \
  --hflip \
  --vflip \
  --timeout 0 \
  -o - 2> /tmp/libcamera-logs | \
  /usr/bin/gst-launch-1.0 \
    -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=35 ! udpsink sync=false host=127.0.0.1 port=5602 &

# Change to the FPVDrone directory and start the msposd process
cd /usr/local/bin/fpvdrone/
/usr/local/bin/fpvdrone/msposd \
  --master /dev/ttyUSB0 \
  --baudrate 115200 \
  --out 127.0.0.1:14560 \
  --matrix 11 \
  --ahi 1 \
  -r 30 \
  -c 7 \
  -c 9 &

# (Optional) Run the FPVDrone update script
# /usr/local/bin/fpvdrone/fpv-update.sh &

# Wait for all background processes to finish
wait

4. 服务

  • 服务配置路径更新
$ cat /etc/systemd/system/fpvdrone.service
[Unit]
Description=FPV Drone Service
Requires=wifibroadcast.service
ReloadPropagatedFrom=wifibroadcast.service
After=wifibroadcast.service

[Service]
Type=simple
ExecStartPre=/bin/sleep 10
ExecStart=/usr/local/bin/fpvdrone/fpv-drone.sh

Restart=always
User=root
Group=root
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
WorkingDirectory=/
StandardOutput=journal
StandardError=journal
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

5. TODO

树莓派目前尚不在msposd支持范围,树莓派官网在制作工具链二进制方面的情况尚没有研究透,所以暂时还没有计划。

依据前面步骤,调整安装路径,脚本,以及相关配置,native build是可以在树莓派Pi3B+上部署和使用的。

以下libcamera-vid日志数据可以提供FPS/bitrate分析:

#31 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d97a000 size 21529
Viewfinder frame 32
#32 (30.01 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d8ba000 size 21331
Viewfinder frame 33
#33 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d7fa000 size 20932
Viewfinder frame 34
#34 (29.99 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d73a000 size 21008
Viewfinder frame 35
#35 (30.02 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d67a000 size 14030
Viewfinder frame 36
FileOutput: output buffer 0x7f9d5ba000 size 20665
#36 (30.01 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 37
#37 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7fa40c0000 size 13858
FileOutput: output buffer 0x7fa4000000 size 13573
Viewfinder frame 38
#38 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 39
#39 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9dc7a000 size 20551
FileOutput: output buffer 0x7f9dbba000 size 13894
Viewfinder frame 40
#40 (30.01 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 41
#41 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9dafa000 size 13314
Viewfinder frame 42
FileOutput: output buffer 0x7f9da3a000 size 26276
#42 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 43
#43 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d97a000 size 15762
Viewfinder frame 44
FileOutput: output buffer 0x7f9d8ba000 size 8856
#44 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 45
FileOutput: output buffer 0x7f9d7fa000 size 10674
#45 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 46
#46 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d73a000 size 16184
Viewfinder frame 47
FileOutput: output buffer 0x7f9d67a000 size 16389
#47 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
Viewfinder frame 48
#48 (30.00 fps) exp 33216.00 ag 8.00 dg 1.00
FileOutput: output buffer 0x7f9d5ba000 size 16489
Viewfinder frame 49
<think>我们正在为树莓派4B更换适用于Bookworm版本的系统软件源。 根据用户需求,我们需要将软件源更换为适用于Debian Bookworm的源。 树莓派系统基于Debian,因此我们需要使用Debian Bookworm的软件源。 步骤: 1. 备份当前的软件源列表文件。 2. 编辑软件源列表文件,替换为Bookworm的源。 3. 更新软件包列表。 注意:树莓派系统有两个主要的软件源配置文件: - /etc/apt/sources.list - /etc/apt/sources.list.d/raspi.list 其中,sources.list提供基本的Debian软件包,而raspi.list提供树莓派专用的软件包。 对于Debian Bookworm,我们通常使用以下镜像源(以清华大学开源软件镜像站为例): Debian 软件源:deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware Debian 安全更新:deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware 树莓派专用源:deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main 但是,请注意,树莓派官方的raspi.list中,通常使用archive.raspberrypi.org,我们也可以替换为国内镜像。 操作步骤: 1. 备份原有文件: sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak 2. 编辑sources.list文件: sudo nano /etc/apt/sources.list 将原有内容全部注释或删除,替换为以下内容: deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware 3. 编辑raspi.list文件: sudo nano /etc/apt/sources.list.d/raspi.list 替换为: deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main # deb-src https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main 4. 更新软件包列表: sudo apt update 注意:如果使用其他镜像站,请替换URL。例如,阿里云、中科大等也有相应的镜像。 另外,如果用户在国外,也可以使用官方源,但国内用户建议使用国内镜像以加速下载。 引用说明:在操作过程中,我们参考了清华大学开源软件镜像站的树莓派镜像使用帮助[^1]。 相关问题: 1. 如何选择适合自己的软件源镜像? 2. 更换软件源后出现无法更新的问题怎么办? 3. 树莓派系统如何升级到新版本(如从Bullseye升级到Bookworm)?</think>### 为树莓派4B更换Bookworm版本软件源指南 以下是详细操作步骤(以清华大学镜像站为例): 1. **备份原配置文件** ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak ``` 2. **修改Debian软件源** 编辑主配置文件: ```bash sudo nano /etc/apt/sources.list ``` 替换为以下内容: ```conf deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware ``` 3. **修改树莓派专用源** 编辑专用源文件: ```bash sudo nano /etc/apt/sources.list.d/raspi.list ``` 替换为: ```conf deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main # deb-src https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main ``` 4. **更新软件列表** ```bash sudo apt update && sudo apt upgrade -y ``` **关键注意事项**: - 镜像站选择建议: - 国内用户:清华/阿里云/中科大镜像 - 海外用户:官方源 `deb http://archive.raspberrypi.org/debian/ bookworm main` - 验证Bookworm支持:确保系统已升级到Raspberry Pi OS Bookworm版本[^1] - 若使用其他镜像站,需同步修改两个文件中的URL路径 - 操作前建议连接稳定的网络 > 小技巧:使用 `lsb_release -a` 可查看当前系统版本,确认是否为Bookworm 完成上述步骤后,您的树莓派4B将使用针对Bookworm优化的国内镜像源,显著提升软件下载速度。 --- ### 相关问题 1. 如何验证树莓派软件源是否已成功更换? 2. 更换软件源后出现依赖错误该如何解决? 3. 除了清华镜像站,还有哪些推荐的国内开源镜像站? 4. 树莓派系统从Bullseye升级到Bookworm的注意事项有哪些? [^1]: 树莓派系统镜像需与软件源版本匹配,烧录前请确认OS版本 https://www.raspberrypi.com/software/
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值