From 803528cfaa8b768c121f0397ea499221b60e9130 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Mon, 23 Nov 2026 13:00:17 -0700 Subject: [PATCH] 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 --- src/modules/commander/Commander.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index 2b4a97257dc..b78ceee91fb 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -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); }