PX4 DroneCAN Firmware
Last updated
Last updated
PX4 can run as the firmware on many DroneCAN peripherals. There are multiple benefits to this:
PX4 has built-in drivers for a of sensors and peripherals components.
PX4 has a robust DroneCAN driver implementation that has undergone multiple years of field testing.
PX4 is continuously being developed. You routinely get access to the latest improvements.
PX4's estimation and control code makes it easy to create "smart" cannodes like integrated AHRS modules.
The firmware is completely open source (PX4 is BSD licensed).
Follow the just as you would to build firmware for a flight controller. Device build configurations are stored . After installing the , clone the sources and build. For example, to build for the target:
This will create an output in build/ark_can-flow_default named XX-X.X.XXXXXXXX.uavcan.bin. Follow the instructions at to flash the firmware.
This section has information that is relevant to developers who want to add support for new DroneCAN hardware to the PX4 Autopilot.
:::warning DroneCAN devices typically ship with a bootloader pre-installed. Do not follow the instructions in this section unless you are developing DroneCAN devices, or have (accidentally) corrupted/wiped your bootloader. :::
The PX4 project includes a standard DroneCAN bootloader for STM32 devices.
This process ensures that a DroneCAN device can recover from invalid or corrupted application firmware without user intervention, and also permits automatic firmware updates.
Build the bootloader firmware by specifying the same peripheral target with the canbootloader
build configuration instead of the default
configuration.
For the most part, peripheral firmware works the same way as flight controller firmware builds. However, most modules are disabled - only the sensor drivers, DroneCAN driver, and internal infrastructure (uORB, etc.) are enabled.
The build system also produces firmware binaries designed to be flashed through a DroneCAN bootloader via [PX4's DroneCAN flashing support] or the DroneCAN GUI, in addition to the standard raw binary, ELF, and .px4
firmware files.
The bootloader occupies the first 8-16 KB of flash, and is the first code executed on power-up. Typically the bootloader performs low-level device initialization, automatically determines the CAN bus baud rate, acts as a to obtain a unique node ID, and waits for confirmation from the flight controller before proceeding with application boot.
For example, to build for the target:
The binary can then be flashed to the microcontroller using your favorite SWD/JTAG debugger, such as the , , or .
DroneCAN communication is handled by the module. This driver handles producer-side communication - it takes sensor/actuator data from uORB, serializes it using the DroneCAN libraries, and publishes it over CAN. In the future, this will likely be merged with the module which handles flight controller side (consumer side) drivers, which receive/deserialize data from the CAN bus and publish them over uORB.