fix(dfu): retry dfu-util flash on macOS detach failure

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jiang Guang Ming
2026-06-09 15:40:34 +08:00
co-authored by Cursor
parent 4b94982cf4
commit 0c835d2141
3 changed files with 9 additions and 2 deletions
+7
View File
@@ -23,6 +23,13 @@ endif()
message("Command list: ${CMD}")
execute_process(COMMAND ${CMD} RESULT_VARIABLE result)
# dfu-util may fail on the first attempt while switching from runtime to DFU mode,
# e.g. with "Lost device after RESET?" on Windows/macOS. Retry once.
if(${result} AND NOT ${ESP_DFU_LIST})
message(WARNING "${TOOL} failed, retrying once...")
execute_process(COMMAND ${CMD} RESULT_VARIABLE result)
endif()
if(${result})
message(FATAL_ERROR "${TOOL} failed")
endif()