Skip to content

Commit 9b392c9

Browse files
committed
Handle bug in boot loader 1.1 by waiting 100ms
Reset currentPage when starting new update
1 parent 2b54dcf commit 9b392c9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/oi_can.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ static void handleUpdate(twai_message_t *rxframe) {
228228
updstate = SEND_SIZE;
229229
DBG_OUTPUT_PORT.printf("Sending ID %" PRIu32 "\r\n", *(uint32_t*)tx_frame.data);
230230
twai_transmit(&tx_frame, pdMS_TO_TICKS(10));
231+
232+
if (rxframe->data[1] < 1) //boot loader with timing quirk, wait 100 ms
233+
delay(100);
231234
}
232235
break;
233236
case SEND_SIZE:
@@ -317,14 +320,15 @@ static void handleUpdate(twai_message_t *rxframe) {
317320
// Do not exit this state
318321
break;
319322
}
320-
321323
}
322324

323325
int StartUpdate(String fileName) {
324326
updateFile = SPIFFS.open(fileName, "r");
325327
//Reset host processor
326328
setValueSdo(SDO_INDEX_COMMANDS, SDO_CMD_RESET, 1U);
327329
updstate = SEND_MAGIC;
330+
currentPage = 0;
331+
DBG_OUTPUT_PORT.println("Starting Update");
328332

329333
return (updateFile.size() + PAGE_SIZE_BYTES - 1) / PAGE_SIZE_BYTES;
330334
}

0 commit comments

Comments
 (0)