-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add optional DFU mode parameter to MSP_REBOOT command #11238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sensei-hacker
merged 5 commits into
iNavFlight:maintenance-9.x
from
sensei-hacker:msp-reboot-dfu-mode
Jan 11, 2026
Merged
Add optional DFU mode parameter to MSP_REBOOT command #11238
sensei-hacker
merged 5 commits into
iNavFlight:maintenance-9.x
from
sensei-hacker:msp-reboot-dfu-mode
Jan 11, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Add optional parameter to MSP_REBOOT (message 68) to trigger DFU mode directly via MSP protocol. This provides a reliable programmatic method for tools and scripts to enter DFU mode without CLI timing issues. Changes: - Add static variable mspRebootBootloader to store DFU mode flag - Modify mspRebootFn to use the bootloader flag when calling fcReboot() - Add mspFcRebootCommand() helper to read optional parameter - Update mspFcProcessCommand() to handle MSP_REBOOT with new logic - Update USB Flashing.md documentation with proper CLI sequence - Add MSP method as recommended approach for programmatic DFU entry Backwards compatibility: - Empty payload (existing behavior) = normal reboot - Parameter 0x00 = explicit normal reboot - Parameter 0x01 = reboot to DFU/bootloader mode Tested on AOCODARCF722AIO: - ✓ Empty payload reboots normally (backwards compatible) - ✓ Parameter 0x00 reboots normally - ✓ Parameter 0x01 enters DFU mode (verified with dfu-util)
6edcae8 to
797d64c
Compare
After moving MSP_REBOOT to mspFcProcessCommand, the mspPostProcessFn parameter in mspFcProcessOutCommand became unused. Remove it from both the function signature and call site to fix CI build warnings.
Validate that MSP_REBOOT payload is exactly 0 or 1 byte. Reject malformed packets with larger payloads to improve protocol robustness. Suggested-by: qodo-merge bot
…Command" This reverts commit 94420f5.
Contributor
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Based on qodo-merge bot review suggestion (importance: 7). Changes: - Remove static global variable mspRebootBootloader - Add two distinct post-process functions: - mspRebootNormalFn() for normal reboot - mspRebootDfuFn() for DFU mode reboot - Update mspFcRebootCommand() to directly assign function pointer Benefits: - Eliminates global state - Makes control flow more explicit - Easier to maintain and understand - Improves code quality per qodo review Tested on AOCODARCF722AIO hardware: ✅ Backwards compatible reboot (empty payload) ✅ Explicit normal reboot (payload 0x00) ✅ DFU mode reboot (payload 0x01)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
Summary
Add optional parameter to MSP_REBOOT (message 68) to trigger DFU mode directly via MSP protocol. This provides a reliable programmatic method for tools and scripts to enter DFU mode without CLI timing issues or manual hardware button presses.
Changes
Firmware (
src/main/fc/fc_msp.c):mspRebootBootloaderto store DFU mode flagmspRebootFn()to use bootloader flag when callingfcReboot()mspFcRebootCommand()helper function to read optional parametermspFcProcessCommand()to handle MSP_REBOOT with new logicDocumentation (
docs/USB Flashing.md):Protocol Details
Backwards Compatibility:
0x00= explicit normal reboot0x01= reboot to DFU/bootloader modeMSP Message:
Testing
Tested on AOCODARCF722AIO hardware:
0x00reboots normally0x01enters DFU mode (verified withdfu-util -lshowing device 0483:df11)All three test cases passed successfully.
Motivation
Current DFU entry methods have limitations:
The MSP_REBOOT method:
PR Type
Enhancement, Bug fix
Description
Add optional DFU mode parameter to MSP_REBOOT command for programmatic bootloader entry
Support backwards-compatible reboot behavior with optional bootloader flag parameter
Improve DFU mode entry documentation with reliable serial CLI sequence
Diagram Walkthrough
File Walkthrough
fc_msp.c
Implement MSP_REBOOT DFU mode parameter supportsrc/main/fc/fc_msp.c
mspRebootBootloaderto store DFU mode flagmspFcRebootCommand()function to parse optional bootloaderparameter from MSP payload
mspRebootFn()to use bootloader flag when callingfcReboot()mspFcProcessOutCommand()to main commandprocessor with proper armed state check
USB Flashing.md
Improve DFU mode entry documentation with reliable methodsdocs/USB Flashing.md
sequence documentation
####CLI entry followed bydfucommand
CLI prompt
9.x+