From 9b392c94d095ca54cd7cb441c6910bb0d8a27a88 Mon Sep 17 00:00:00 2001 From: johannes Date: Thu, 25 Jul 2024 18:44:51 +0200 Subject: [PATCH] Handle bug in boot loader 1.1 by waiting 100ms Reset currentPage when starting new update --- src/oi_can.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/oi_can.cpp b/src/oi_can.cpp index 9033e78..f2c7c0a 100644 --- a/src/oi_can.cpp +++ b/src/oi_can.cpp @@ -228,6 +228,9 @@ static void handleUpdate(twai_message_t *rxframe) { updstate = SEND_SIZE; DBG_OUTPUT_PORT.printf("Sending ID %" PRIu32 "\r\n", *(uint32_t*)tx_frame.data); twai_transmit(&tx_frame, pdMS_TO_TICKS(10)); + + if (rxframe->data[1] < 1) //boot loader with timing quirk, wait 100 ms + delay(100); } break; case SEND_SIZE: @@ -317,7 +320,6 @@ static void handleUpdate(twai_message_t *rxframe) { // Do not exit this state break; } - } int StartUpdate(String fileName) { @@ -325,6 +327,8 @@ int StartUpdate(String fileName) { //Reset host processor setValueSdo(SDO_INDEX_COMMANDS, SDO_CMD_RESET, 1U); updstate = SEND_MAGIC; + currentPage = 0; + DBG_OUTPUT_PORT.println("Starting Update"); return (updateFile.size() + PAGE_SIZE_BYTES - 1) / PAGE_SIZE_BYTES; }