Commit 1ca503d9 authored by Daniel Agar's avatar Daniel Agar

bootloader avoid syncing multiple times if first succeeded

parent 53681a28
...@@ -167,9 +167,10 @@ bool Bootloader::initFlashSequence(void) ...@@ -167,9 +167,10 @@ bool Bootloader::initFlashSequence(void)
return false; return false;
} }
_port.setBaudRate(QSerialPort::Baud115200); _port.setBaudRate(QSerialPort::Baud115200);
}
if (!_sync()) { if (!_sync()) {
return false; return false;
}
} }
return true; return true;
} }
...@@ -330,6 +331,8 @@ bool Bootloader::_sendCommand(const uint8_t cmd, int responseTimeout) ...@@ -330,6 +331,8 @@ bool Bootloader::_sendCommand(const uint8_t cmd, int responseTimeout)
if (!_write(buf, 2)) { if (!_write(buf, 2)) {
goto Error; goto Error;
} }
_port.flush();
if (!_getCommandResponse(responseTimeout)) { if (!_getCommandResponse(responseTimeout)) {
goto Error; goto Error;
} }
...@@ -710,6 +713,10 @@ bool Bootloader::_sync(void) ...@@ -710,6 +713,10 @@ bool Bootloader::_sync(void)
bool success = false; bool success = false;
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
success = _syncWorker(); success = _syncWorker();
if (success) {
return true;
}
} }
return success; return success;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment