Kakute H7 刷写 px4 固件

参考文献

Holybro Kakute H7 | PX4 User Guide

PX4 Bootloader Flashing onto Betaflight Systems | PX4 User Guide

Loading Firmware | PX4 User Guide

下载 PX4-Autopilot 源码(如果是 Kakute F7 或更早的飞控,下载 PX4-Bootloader 源码)并编译

git clone --recursive https://github.com/PX4/PX4-Autopilot.git
cd PX4-Autopilot
make  # For example: holybro_kakuteh7_bootloader

 如果出现报错

arm-none-eabi-gcc: Command not found

则先安装交叉编译包

sudo apt-get install gcc-arm-none-eabi

如果出现报错

ModuleNotFoundError: No module named 'menuconfig'
CMake Error at cmake/kconfig.cmake:6 (message):
  kconfiglib is not installed or not in PATH

  please install using "pip3 install kconfiglib"

则先安装依赖

sudo pip3 install kconfiglib
sudo pip install --ignore-installed kconfiglib

同理如果遇到别的模块未安装,按照上面的操作进行即可,常见的缺少的包的安装命令如下

sudo -H python3 -m pip install kconfiglib
sudo -H python3 -m pip install jinja2
sudo -H python3 -m pip install jsonschema
sudo -H python3 -m pip install empy
sudo -H python3 -m pip install pyros-genmsg
sudo -H python3 -m pip install packaging
sudo -H python3 -m pip install toml
sudo -H python3 -m pip install numpy
sudo -H python3 -m pip install future

如果上面的命令安装后还是报错,可以用下面的命令安装:

sudo pip3 install kconfiglib
sudo pip3 install --user empy
sudo pip3 install --user jsonschema
sudo pip3 install --user jinja2
sudo pip3 install --user pyros-genmsg
sudo pip3 install --user packaging
sudo pip3 install --user toml
sudo pip3 install --user numpy

如果还是出错,多试几次,参考

PX4从放弃到精通(二):ubuntu18.04配置px4编译环境及mavros环境_超维空间科技的博客-CSDN博客

刷写 Bootloader

方法一: Betaflight-configure 刷写(不保证成功,我没成功)

下载 Betaflight-configure,下载链接

https://github.com/betaflight/betaflight-configurator/releases

拉到下面选择 betaflight-configurator_10.9.0_amd64.deb 随便什么版本都行。

安装

sudo dpkg -i betaflight-configurator_10.9.0_amd64.deb

然后点 Ubuntu 系统左下角,打开应用程序界面,打开 Betaflight Configurator 程序,这时候长按 飞控 boot 键然后插入 USB 线。

这时 Betaflight Configurator 会识别到飞控,接下来点右下角的 Local Firmware,选择文件

./build/holybro_kakuteh7_default/holybro_kakuteh7_default.hex

如果没有 hex 文件,可以将 elf 文件转化为 hex文件,终端输入

arm-none-eabi-objcopy -O ihex ./holybro_kakuteh7_default.elf holybro_kakuteh7_default.hex

然后重新选择,点击 local firmware,选择刚刚生成的 holybro_kakuteh7_default.hex 文件,然后 flash firmware,即可刷写 holybro_kakuteh7_default 固件。(不保证成功,因为我没成功)

方法二:源码刷写(亲测可行)

编译 Bootloader

cd ~/PX4/PX4-Autopilot/
make holybro_kakuteh7_bootloader

如果没有安装 dfu-util,先安装

sudo apt-get install dfu-util

使用批量擦除擦除所有闪存参数,如果没有进度条,就多试几次(好像没擦成功也问题不大),

dfu-util -a 0 --dfuse-address 0x08000000:force:mass-erase:leave -D ./build/holybro_kakuteh7_bootloader/holybro_kakuteh7_bootloader.bin

输出结果

lilabws01@lilabws01:~/PX4/PX4-Autopilot$ dfu-util -a 0 --dfuse-address 0x08000000:force:mass-erase:leave -D ./build/holybro_kakuteh7_bootloader/holybro_kakuteh7_bootloader.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuDNLOAD-IDLE, status = 0
aborting previous incomplete transfer
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
DfuSe interface name: "Internal Flash   "
Performing mass erase, this can take a moment
Downloading to address = 0x08000000, size = 41868
Download	[=========================] 100%        41868 bytes
Download done.
File downloaded successfully
dfu-util: Error during download get_status

再次进入DFU模式,刷写 Bootloader

dfu-util -a 0 --dfuse-address 0x08000000 -D ./build/holybro_kakuteh7_bootloader/holybro_kakuteh7_bootloader.bin

刷写 PX4 固件

make holybro_kakuteh7_default upload

最后会停在下面这个地方 Waiting for bootloader...

Memory region         Used Size  Region Size  %age Used
        ITCM_RAM:          0 GB        64 KB      0.00%
           FLASH:     1779644 B      1792 KB     96.98%
       DTCM1_RAM:          0 GB        64 KB      0.00%
       DTCM2_RAM:          0 GB        64 KB      0.00%
        AXI_SRAM:       39784 B       512 KB      7.59%
           SRAM1:          0 GB       128 KB      0.00%
           SRAM2:          0 GB       128 KB      0.00%
           SRAM3:          0 GB        32 KB      0.00%
           SRAM4:          0 GB        64 KB      0.00%
          BKPRAM:          0 GB         4 KB      0.00%
[100%] Built target px4
[100%] Generating ../../holybro_kakuteh7_default.bin
[100%] Creating /home/lilabws01/PX4/PX4-Autopilot/build/holybro_kakuteh7_default/holybro_kakuteh7_default.px4
[100%] uploading px4
Waiting for bootloader...

然后一直读取不到 bootloader,这里我没有管他,挂在后台,(注意一定要挂着,如果终止的话 QGroundControl 会无法识别飞控)然后打开 QGroundControl,点左上角的 Q 进入 Vehicle Setup,然后进入 Firmware 界面,接下来拔插 USB 连接线,右边会弹出一个窗口,然后选择自定义文件

~/PX4-Autopilot/build/holybro_kakuteh7_default/holybro_kakuteh7_default.bin

然后刷写固件,这样就将 PX4 固件刷写进 Kakute H7 中了。

接下来将刚刚挂在后台的 Waiting for bootloader... 终端终止了,然后拔下 USB 接口,然后再插入,等一会 QGroundControl 就会读取到 Kakute H7 的 PX4 固件了。

后面也可以自己去 PX4 的 Github 官网上下载合适的版本刷写到飞控中啦

Tags · PX4/PX4-Autopilot · GitHub

如果是 Kakute H7 就下载所需的 PX4 版本的 Kakute H7 的固件

Kakute H7 刷写 px4 固件_第1张图片

Kakute H7 刷写 px4 固件_第2张图片

折磨了我一天(哭泣)

你可能感兴趣的:(PX4,Kakute,H7,飞控固件刷写)