飞行控制器移植指南
本主题主要针对希望将 PX4 移植到 新 飞控硬件平台上的开发人员。
PX4 架构
PX4 由两个主要层组成: 基于主机操作系统(NuttX、Linux 或任何其他 POSIX 平台如 Mac OS)的板级支持与中间件层,以及应用程序(位于src/modules目录下的飞行栈)。 更多信息请参阅PX4架构概述。
本指南仅关注主机操作系统和中间件,因为 应用层/飞行控制栈 可以在任何目标平台上运行。
飞行控制器配置文件分布位置
板卡启动和配置文件位于每个板卡厂商专属目录下的 /boards 路径中(即 boards/VENDOR/MODEL/)。
例如,对于 FMUv5 飞控硬件平台:
- (所有) 板卡专用文件:/boards/px4/fmu-v5。
- 构建配置:/boards/px4/fmu-v5/default.px4board。
- 板卡专用初始化文件:/boards/px4/fmu-v5/init/rc.board_defaults
- 如果在主板目录下找到位于init/rc.board的文件,则该主板专用的初始化文件会自动包含在启动脚本中。
- 该文件用于启动仅存在于特定主板上的传感器 (和其他东西)。 它也可用于设置电路板的默认参数、UART映射以及任何其他特殊情况。
- 对于FMUv5,您可以看到所有Pixhawk 4传感器均已启动,同时它还设置了更大的LOGGER_BUF缓冲区。
主机操作系统配置
本节介绍了移植每个受支持的主机操作系统到新的飞控板硬件平台上需要用到的配置文件的用途和所处位置。
NuttX
参见NuttX 板移植指南。
Linux
基于 Linux 的飞控板不包含任何 操作系统和内核的配置。 这些功能已由该开发板可用的Linux镜像提供(该镜像需开箱即支持惯性传感器)。
- boards/px4/raspberrypi/default.px4board - RPi 交叉编译。
中间件组件和配置
本节介绍各类中间件组件,以及将它们移植到新的飞行控制器硬件所需更新的配置文件。
QuRT / Hexagon
- 启动脚本位于 posix-configs/。
- 操作系统配置是默认 Linux 镜像的一部分(TODO: 需要提供 LINUX 镜像文件位置和程序烧写指南)。
- PX4 中间件配置位于src/boards。 TODO: 添加BUS CONFIG
RC UART 接线建议
通常建议通过独立的RX和TX引脚将RC连接至微控制器。但若RX和TX引脚连接在一起,则必须将UART置于单线模式以避免竞争冲突。此操作需通过板级配置文件和清单文件实现。示例可参考px4fmu-v5。 如果 RX 和 TX 连在了一起,那么 UART 需要设置为单线模式以防止出现争用。 这可以用过对飞控板的配置文件和 manifest 文件进行更改来实现。 一个例子是 px4fmu-v5。
Getting Your Board Supported
This page covers the technical work of porting PX4 to new hardware. The process for getting that port reviewed, merged, and listed on the PX4 website, including board IDs, USB VID/PID, flight-test evidence, and maintenance expectations, is documented separately:
In short: build your own firmware target based on PX4, demonstrate stable flight on the current release, and open a pull request with your board support code, documentation, and flight logs. The board support guide explains each step.
The PX4 project supports and maintains the FMU standard reference hardware and any boards compatible with the standard, including the Pixhawk series (see the full list of supported hardware). Boards merged into PX4 benefit from a port in the repository, firmware builds accessible from QGroundControl, compatibility with the rest of the ecosystem, and automated CI checks.
TIP
The cost of maintaining a port is proportional to how far it diverges from the standard. Consider that cost before deviating: staying close to the reference design lets you benefit from day-to-day PX4 development with minimal maintenance burden.
Manufacturers are responsible for keeping their port up to date and working across PX4 releases. The PX4 project reserves the right to refuse or remove ports that do not meet the project's requirements, and all contributors are expected to follow the Code of Conduct.