feat(commander): reboot into the ROM bootloader on ArduPilot's DFU command

ArduPilot asks for its DFU reboot with MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN and params 42, 24, 71 and 99. Accepting the same command lets one flashing tool put either stack into the ROM bootloader. PX4 otherwise needs reboot -i from a shell.

Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
Jacob Dahl committed 2026-11-23 13:00:23 -07:00
1 parent e8f9fed0c8
commit 803528cfaa
1 file changed
+11
+11
View File
@@ -1437,6 +1437,17 @@ Commander::handle_command(const vehicle_command_s &cmd)
#endif // CONFIG_BOARDCTL_RESET
#if defined(CONFIG_BOARDCTL_RESET) && defined(BOARD_HAS_ISP_BOOTLOADER)
} else if ((lroundf(cmd.param1) == 42) && (lroundf(cmd.param2) == 24) && (lroundf(cmd.param3) == 71)
&& (lroundf(cmd.param4) == 99) && !isArmed() && (px4_reboot_request(REBOOT_TO_ISP, 400_ms) == 0)) {
// ArduPilot's magic numbers for its DFU reboot, so one tool can send either stack to the ROM bootloader
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_ACCEPTED);
while (1) { px4_usleep(1); }
#endif // CONFIG_BOARDCTL_RESET && BOARD_HAS_ISP_BOOTLOADER
} else {
answer_command(cmd, vehicle_command_ack_s::VEHICLE_CMD_RESULT_DENIED);
}