From 865cffa5f2a850f892ab43def2d4ad21b8a9adca Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 24 Dec 2023 06:28:34 +1100 Subject: [PATCH] AP_IOMCU: retry forcing IOMCU into bootloader multiple times this fixes an issue where the update of IO firmware can fail --- libraries/AP_IOMCU/AP_IOMCU.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_IOMCU/AP_IOMCU.cpp b/libraries/AP_IOMCU/AP_IOMCU.cpp index 7e2ab850a9..8881a3fb59 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.cpp +++ b/libraries/AP_IOMCU/AP_IOMCU.cpp @@ -869,8 +869,13 @@ bool AP_IOMCU::check_crc(void) DEV_PRINTF("IOMCU: CRC mismatch expected: 0x%X got: 0x%X\n", (unsigned)crc, (unsigned)io_crc); } + // get IOMCU into the bootloader. We retry to maximise the chances + // of success const uint16_t magic = REBOOT_BL_MAGIC; - write_registers(PAGE_SETUP, PAGE_REG_SETUP_REBOOT_BL, 1, &magic); + for (uint8_t i=0; i<16; i++) { + write_registers(PAGE_SETUP, PAGE_REG_SETUP_REBOOT_BL, 1, &magic); + hal.scheduler->delay(1); + } // avoid internal error on fw upload delay last_reg_read_ms = 0;