QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
Bootloader.cc
Go to the documentation of this file.
1#include "Bootloader.h"
3#include "FirmwareImage.h"
4#include "QGCMath.h"
5
6#include <QtCore/QElapsedTimer>
7#include <QtCore/QFile>
8#include <QtCore/QThread>
9
10QGC_LOGGING_CATEGORY(FirmwareUpgradeLog, "VehicleSetup.FirmwareUpgrade")
11QGC_LOGGING_CATEGORY(FirmwareUpgradeVerboseLog, "VehicleSetup.FirmwareUpgrade:verbose")
12
14Bootloader::Bootloader(bool sikRadio, QObject *parent)
15 : QObject (parent)
16 , _sikRadio (sikRadio)
17{
18
19}
20
21bool Bootloader::open(const QString portName)
22{
23 qCDebug(FirmwareUpgradeLog) << "open:" << portName;
24
25 _port.setPortName (portName);
26 _port.setBaudRate (QSerialPort::Baud115200);
27 _port.setDataBits (QSerialPort::Data8);
28 _port.setParity (QSerialPort::NoParity);
29 _port.setStopBits (QSerialPort::OneStop);
30 _port.setFlowControl(QSerialPort::NoFlowControl);
31
32 if (!_port.open(QIODevice::ReadWrite)) {
33 _errorString = tr("Open failed on port %1: %2").arg(portName, _port.errorString());
34 return false;
35 }
36
37 if (_sikRadio) {
38 // Radios are slow to start up
39 QThread::msleep(1000);
40 }
41 return true;
42}
43
44QString Bootloader::_getNextLine(int timeoutMsecs)
45{
46 QString line;
47 QElapsedTimer timeout;
48 bool foundCR = false;
49
50 timeout.start();
51 while (timeout.elapsed() < timeoutMsecs) {
52 char oneChar;
53 _port.waitForReadyRead(100);
54 if (_port.read(&oneChar, 1) > 0) {
55 if (oneChar == '\r') {
56 foundCR = true;
57 continue;
58 } else if (oneChar == '\n' && foundCR) {
59 return line;
60 }
61 line += oneChar;
62 }
63 }
64
65 return QString();
66}
67
68bool Bootloader::getBoardInfo(uint32_t& bootloaderVersion, uint32_t& boardID, uint32_t& flashSize)
69{
70 if (_sikRadio) {
71 // Try sync to see if already in bootloader mode
72 _sync();
73 if (_inBootloaderMode) {
74 qCDebug(FirmwareUpgradeLog) << "Radio in bootloader mode already";
75 if (!_get3DRRadioBoardId(_boardID)) {
76 goto Error;
77 }
78 } else {
79 qCDebug(FirmwareUpgradeLog) << "Radio in normal mode";
80 _port.readAll();
81 _port.setBaudRate(QSerialPort::Baud57600);
82 // Put radio into command mode
83 _write("+++");
84 if (!_port.waitForReadyRead(2000)) {
85 _errorString = tr("Unable to put radio into command mode +++");
86 goto Error;
87 }
88 QByteArray bytes = _port.readAll();
89 if (!bytes.contains("OK")) {
90 _errorString = tr("Radio did not respond to command mode");
91 goto Error;
92 }
93
94 // Use ATI2 command to get board id
95 _write("ATI2\r\n");
96 QString echo = _getNextLine(2000);
97 if (echo.isEmpty() || echo != "ATI2") {
98 _errorString = tr("Radio did not respond to ATI2 command");
99 goto Error;
100 }
101 QString boardIdStr = _getNextLine(2000);
102 bool ok = false;
103 _boardID = boardIdStr.toInt(&ok);
104 if (boardIdStr.isEmpty() || !ok) {
105 _errorString = tr("Radio did not return board id");
106 goto Error;
107 }
108 }
109 bootloaderVersion = 0;
110 boardID = _boardID;
111 flashSize = 0;
112
113 return true;
114 } else {
115 if (!_sync()) {
116 goto Error;
117 }
118 if (!_protoGetDevice(INFO_BL_REV, _bootloaderVersion)) {
119 goto Error;
120 }
121 if (_bootloaderVersion < BL_REV_MIN || _bootloaderVersion > BL_REV_MAX) {
122 _errorString = tr("Found unsupported bootloader version: %1").arg(_bootloaderVersion);
123 goto Error;
124 }
125 if (!_protoGetDevice(INFO_BOARD_ID, _boardID)) {
126 goto Error;
127 }
128 if (!_protoGetDevice(INFO_FLASH_SIZE, _boardFlashSize)) {
129 qWarning() << _errorString;
130 goto Error;
131 }
132
133 // Older V2 boards have large flash space but silicon error which prevents it from being used. Bootloader v5 and above
134 // will correctly account/report for this. Older bootloaders will not. Newer V2 board which support larger flash space are
135 // reported as V3 board id.
136 if (_boardID == boardIDPX4FMUV2 && _bootloaderVersion >= _bootloaderVersionV2CorrectFlash && _boardFlashSize > _flashSizeSmall) {
137 _boardID = boardIDPX4FMUV3;
138 }
139
140 bootloaderVersion = _bootloaderVersion;
141 boardID = _boardID;
142 flashSize = _boardFlashSize;
143
144 return true;
145 }
146
147Error:
148 qCDebug(FirmwareUpgradeLog) << "getBoardInfo failed:" << _errorString;
149 _errorString.prepend(tr("Get Board Info: "));
150 return false;
151}
152
154{
155 if (_sikRadio && !_inBootloaderMode) {
156 _write("AT&UPDATE\r\n");
157 if (!_port.waitForReadyRead(1500)) {
158 _errorString = tr("Unable to reboot radio (ready read)");
159 return false;
160 }
161 _port.setBaudRate(QSerialPort::Baud115200);
162
163 if (!_sync()) {
164 return false;
165 }
166 }
167 return true;
168}
169
171{
172 uint32_t timeout = _eraseTimeout;
173
174 // If flash size is bigger then 2MB we need to increase timeout
175 if(_boardFlashSize > 2000 * 1024) {
176 // Increase timeout for each 1MB by 4 seconds
177 timeout += (_boardFlashSize / 1e6) * 4000;
178 }
179
180 // Erase is slow, need larger timeout
181 if (!_sendCommand(PROTO_CHIP_ERASE, timeout)) {
182 _errorString = tr("Erase failed: %1").arg(_errorString);
183 return false;
184 }
185
186 return true;
187}
188
190{
191 if (image->imageIsBinFormat()) {
192 return _binProgram(image);
193 } else {
194 return _ihxProgram(image);
195 }
196}
197
199{
200 bool success;
201 if (_sikRadio && !_inBootloaderMode) {
202 qCDebug(FirmwareUpgradeLog) << "reboot ATZ";
203 _port.readAll();
204 success = _write("ATZ\r\n");
205 } else {
206 qCDebug(FirmwareUpgradeLog) << "reboot";
207 success = _write(PROTO_BOOT) && _write(PROTO_EOC);
208 }
209 _port.flush();
210 if (success) {
211 QThread::msleep(1000);
212 }
213 return success;
214}
215
216bool Bootloader::_write(const char* data)
217{
218 return _write((uint8_t*)data, qstrlen(data));
219}
220
221bool Bootloader::_write(const uint8_t* data, qint64 maxSize)
222{
223 qint64 bytesWritten = _port.write((const char*)data, maxSize);
224 if (bytesWritten == -1) {
225 _errorString = tr("Write failed: %1").arg(_port.errorString());
226 qWarning() << _errorString;
227 return false;
228 }
229 if (bytesWritten != maxSize) {
230 _errorString = tr("Incorrect number of bytes returned for write: actual(%1) expected(%2)").arg(bytesWritten).arg(maxSize);
231 qWarning() << _errorString;
232 return false;
233 }
234
235 return true;
236}
237
238bool Bootloader::_write(const uint8_t byte)
239{
240 uint8_t buf[1] = { byte };
241 return _write(buf, 1);
242}
243
244bool Bootloader::_read(uint8_t* data, qint64 cBytesExpected, int readTimeout)
245{
246 QElapsedTimer timeout;
247
248 timeout.start();
249 while (_port.bytesAvailable() < cBytesExpected) {
250 if (timeout.elapsed() > readTimeout) {
251 _errorString = tr("Timeout waiting for bytes to be available");
252 return false;
253 }
254 _port.waitForReadyRead(100);
255 }
256
257 qint64 bytesRead;
258 bytesRead = _port.read((char *)data, cBytesExpected);
259
260 if (bytesRead != cBytesExpected) {
261 _errorString = tr("Read failed: error: %1").arg(_port.errorString());
262 return false;
263 }
264
265 return true;
266}
267
270bool Bootloader::_getCommandResponse(int responseTimeout)
271{
272 uint8_t response[2];
273
274 if (!_read(response, 2, responseTimeout)) {
275 _errorString.prepend(tr("Get Command Response: "));
276 return false;
277 }
278
279 // Make sure we get a good sync response
280 if (response[0] != PROTO_INSYNC) {
281 _errorString = tr("Invalid sync response: 0x%1 0x%2").arg(response[0], 2, 16, QLatin1Char('0')).arg(response[1], 2, 16, QLatin1Char('0'));
282 return false;
283 } else if (response[0] == PROTO_INSYNC && response[1] == PROTO_BAD_SILICON_REV) {
284 _errorString = tr("This board is using a microcontroller with faulty silicon and an incorrect configuration and should be put out of service.");
285 return false;
286 } else if (response[1] != PROTO_OK) {
287 QString responseCode = tr("Unknown response code");
288 if (response[1] == PROTO_FAILED) {
289 responseCode = "PROTO_FAILED";
290 } else if (response[1] == PROTO_INVALID) {
291 responseCode = "PROTO_INVALID";
292 }
293 _errorString = tr("Command failed: 0x%1 (%2)").arg(response[1], 2, 16, QLatin1Char('0')).arg(responseCode);
294 return false;
295 }
296
297 return true;
298}
299
303bool Bootloader::_protoGetDevice(uint8_t param, uint32_t& value)
304{
305 uint8_t buf[3] = { PROTO_GET_DEVICE, param, PROTO_EOC };
306
307 if (!_write(buf, sizeof(buf))) {
308 goto Error;
309 }
310 if (!_read((uint8_t*)&value, sizeof(value))) {
311 goto Error;
312 }
313 if (!_getCommandResponse()) {
314 goto Error;
315 }
316
317 return true;
318
319Error:
320 _errorString.prepend(tr("Get Device: "));
321 return false;
322}
323
327bool Bootloader::_sendCommand(const uint8_t cmd, int responseTimeout)
328{
329 uint8_t buf[2] = { cmd, PROTO_EOC };
330
331 if (!_write(buf, 2)) {
332 goto Error;
333 }
334 _port.flush();
335
336 if (!_getCommandResponse(responseTimeout)) {
337 goto Error;
338 }
339
340 return true;
341
342Error:
343 _errorString.prepend(tr("Send Command: "));
344 return false;
345}
346
347bool Bootloader::_binProgram(const FirmwareImage* image)
348{
349 QFile firmwareFile(image->binFilename());
350 if (!firmwareFile.open(QIODevice::ReadOnly)) {
351 _errorString = tr("Unable to open firmware file %1: %2").arg(image->binFilename(), firmwareFile.errorString());
352 return false;
353 }
354 uint32_t imageSize = (uint32_t)firmwareFile.size();
355 // The bootloader rejects PROTO_PROG_MULTI lengths which are not a multiple of 4. FirmwareImage refuses such
356 // an image when it loads it, before the erase; this guards a caller which skips that.
357 if ((imageSize % 4) != 0) {
358 _errorString = tr("Firmware image size (%1 bytes) is not a multiple of 4").arg(imageSize);
359 return false;
360 }
361
362 uint8_t imageBuf[PROG_MULTI_MAX];
363 uint32_t bytesSent = 0;
364 _imageCRC = 0;
365
366 static_assert((PROG_MULTI_MAX <= 0x8F) && ((PROG_MULTI_MAX % 4) == 0));
367
368 while (bytesSent < imageSize) {
369 int bytesToSend = imageSize - bytesSent;
370 if (bytesToSend > (int)sizeof(imageBuf)) {
371 bytesToSend = (int)sizeof(imageBuf);
372 }
373
374 int bytesRead = firmwareFile.read((char *)imageBuf, bytesToSend);
375 if (bytesRead == -1 || bytesRead != bytesToSend) {
376 _errorString = tr("Firmware file read failed: %1").arg(firmwareFile.errorString());
377 return false;
378 }
379
380 bool failed = true;
381 if (_write(PROTO_PROG_MULTI) &&
382 _write((uint8_t)bytesToSend) &&
383 _write(imageBuf, bytesToSend) &&
384 _write(PROTO_EOC)) {
385 if (_getCommandResponse()) {
386 failed = false;
387 }
388 }
389 if (failed) {
390 _errorString = tr("Flash failed: %1 at address 0x%2").arg(_errorString).arg(bytesSent, 8, 16, QLatin1Char('0'));
391 return false;
392 }
393
394 bytesSent += bytesToSend;
395
396 // Calculate the CRC now so we can test it after the board is flashed.
397 _imageCRC = QGC::crc32((uint8_t *)imageBuf, bytesToSend, _imageCRC);
398
399 emit updateProgress(bytesSent, imageSize);
400 }
401 firmwareFile.close();
402
403 // We calculate the CRC using the entire flash size, filling the remainder with 0xFF.
404 while (bytesSent < _boardFlashSize) {
405 const uint8_t fill = 0xFF;
406 _imageCRC = QGC::crc32(&fill, 1, _imageCRC);
407 bytesSent++;
408 }
409
410 return true;
411}
412
413bool Bootloader::_ihxProgram(const FirmwareImage* image)
414{
415 uint32_t imageSize = image->imageSize();
416 uint32_t bytesSent = 0;
417
418 for (uint16_t index=0; index<image->ihxBlockCount(); index++) {
419 bool failed;
420 uint16_t flashAddress;
421 QByteArray bytes;
422
423 if (!image->ihxGetBlock(index, flashAddress, bytes)) {
424 _errorString = tr("Unable to retrieve block from ihx: index %1").arg(index);
425 return false;
426 }
427
428 qCDebug(FirmwareUpgradeVerboseLog) << QString("Bootloader::_ihxProgram - address:0x%1 size:%2 block:%3").arg(flashAddress, 8, 16, QLatin1Char('0')).arg(bytes.length()).arg(index);
429
430 // Set flash address
431
432 failed = true;
433 if (_write(PROTO_LOAD_ADDRESS) &&
434 _write(flashAddress & 0xFF) &&
435 _write((flashAddress >> 8) & 0xFF) &&
436 _write(PROTO_EOC)) {
437 _port.flush();
438 if (_getCommandResponse()) {
439 failed = false;
440 }
441 }
442
443 if (failed) {
444 _errorString = tr("Unable to set flash start address: 0x%2").arg(flashAddress, 8, 16, QLatin1Char('0'));
445 return false;
446 }
447
448 // Flash
449
450 int bytesIndex = 0;
451 uint16_t bytesLeftToWrite = bytes.length();
452
453 while (bytesLeftToWrite > 0) {
454 uint8_t bytesToWrite;
455
456 if (bytesLeftToWrite > PROG_MULTI_MAX) {
457 bytesToWrite = PROG_MULTI_MAX;
458 } else {
459 bytesToWrite = bytesLeftToWrite;
460 }
461
462 failed = true;
463 if (_write(PROTO_PROG_MULTI) &&
464 _write(bytesToWrite) &&
465 _write(&((uint8_t *)bytes.data())[bytesIndex], bytesToWrite) &&
466 _write(PROTO_EOC)) {
467 _port.flush();
468 if (_getCommandResponse()) {
469 failed = false;
470 }
471 }
472 if (failed) {
473 _errorString = tr("Flash failed: %1 at address 0x%2").arg(_errorString).arg(flashAddress, 8, 16, QLatin1Char('0'));
474 return false;
475 }
476
477 bytesIndex += bytesToWrite;
478 bytesLeftToWrite -= bytesToWrite;
479 bytesSent += bytesToWrite;
480
481 emit updateProgress(bytesSent, imageSize);
482 }
483 }
484
485 return true;
486}
487
489{
490 bool ret;
491
492 if (!image->imageIsBinFormat() || _bootloaderVersion <= 2) {
493 ret = _verifyBytes(image);
494 } else {
495 ret = _verifyCRC();
496 }
497
498 reboot();
499
500 return ret;
501}
502
504bool Bootloader::_verifyBytes(const FirmwareImage* image)
505{
506 if (image->imageIsBinFormat()) {
507 return _binVerifyBytes(image);
508 } else {
509 return _ihxVerifyBytes(image);
510 }
511}
512
513bool Bootloader::_binVerifyBytes(const FirmwareImage* image)
514{
515 QFile firmwareFile(image->binFilename());
516 if (!firmwareFile.open(QIODevice::ReadOnly)) {
517 _errorString = tr("Unable to open firmware file %1: %2").arg(image->binFilename(), firmwareFile.errorString());
518 return false;
519 }
520 uint32_t imageSize = (uint32_t)firmwareFile.size();
521 // The bootloader rejects PROTO_READ_MULTI lengths which are not a multiple of 4
522 if ((imageSize % 4) != 0) {
523 _errorString = tr("Firmware image size (%1 bytes) is not a multiple of 4").arg(imageSize);
524 return false;
525 }
526
527 if (!_sendCommand(PROTO_CHIP_VERIFY)) {
528 return false;
529 }
530
531 uint8_t fileBuf[READ_MULTI_MAX];
532 uint8_t readBuf[READ_MULTI_MAX];
533 uint32_t bytesVerified = 0;
534
535 static_assert((READ_MULTI_MAX <= 0x8F) && ((READ_MULTI_MAX % 4) == 0));
536
537 while (bytesVerified < imageSize) {
538 int bytesToRead = imageSize - bytesVerified;
539 if (bytesToRead > (int)sizeof(readBuf)) {
540 bytesToRead = (int)sizeof(readBuf);
541 }
542
543 int bytesRead = firmwareFile.read((char *)fileBuf, bytesToRead);
544 if (bytesRead == -1 || bytesRead != bytesToRead) {
545 _errorString = tr("Firmware file read failed: %1").arg(firmwareFile.errorString());
546 return false;
547 }
548
549 bool failed = true;
550 if (_write(PROTO_READ_MULTI) &&
551 _write((uint8_t)bytesToRead) &&
552 _write(PROTO_EOC)) {
553 _port.flush();
554 if (_read(readBuf, bytesToRead)) {
555 if (_getCommandResponse()) {
556 failed = false;
557 }
558 }
559 }
560 if (failed) {
561 _errorString = tr("Read failed: %1 at address: 0x%2").arg(_errorString).arg(bytesVerified, 8, 16, QLatin1Char('0'));
562 return false;
563 }
564
565 for (int i=0; i<bytesToRead; i++) {
566 if (fileBuf[i] != readBuf[i]) {
567 _errorString = tr("Compare failed: expected(0x%1) actual(0x%2) at address: 0x%3").arg(fileBuf[i], 2, 16, QLatin1Char('0')).arg(readBuf[i], 2, 16, QLatin1Char('0')).arg(bytesVerified + i, 8, 16, QLatin1Char('0'));
568 return false;
569 }
570 }
571
572 bytesVerified += bytesToRead;
573
574 emit updateProgress(bytesVerified, imageSize);
575 }
576
577 firmwareFile.close();
578
579 return true;
580}
581
582bool Bootloader::_ihxVerifyBytes(const FirmwareImage* image)
583{
584 uint32_t imageSize = image->imageSize();
585 uint32_t bytesVerified = 0;
586
587 for (uint16_t index=0; index<image->ihxBlockCount(); index++) {
588 bool failed;
589 uint16_t readAddress;
590 QByteArray imageBytes;
591
592 if (!image->ihxGetBlock(index, readAddress, imageBytes)) {
593 _errorString = tr("Unable to retrieve block from ihx: index %1").arg(index);
594 return false;
595 }
596
597 qCDebug(FirmwareUpgradeLog) << QString("Bootloader::_ihxVerifyBytes - address:0x%1 size:%2 block:%3").arg(readAddress, 8, 16, QLatin1Char('0')).arg(imageBytes.length()).arg(index);
598
599 // Set read address
600
601 failed = true;
602 if (_write(PROTO_LOAD_ADDRESS) &&
603 _write(readAddress & 0xFF) &&
604 _write((readAddress >> 8) & 0xFF) &&
605 _write(PROTO_EOC)) {
606 _port.flush();
607 if (_getCommandResponse()) {
608 failed = false;
609 }
610 }
611
612 if (failed) {
613 _errorString = tr("Unable to set read start address: 0x%2").arg(readAddress, 8, 16, QLatin1Char('0'));
614 return false;
615 }
616
617 // Read back
618
619 int bytesIndex = 0;
620 uint16_t bytesLeftToRead = imageBytes.length();
621
622 while (bytesLeftToRead > 0) {
623 uint8_t bytesToRead;
624 uint8_t readBuf[READ_MULTI_MAX];
625
626 if (bytesLeftToRead > READ_MULTI_MAX) {
627 bytesToRead = READ_MULTI_MAX;
628 } else {
629 bytesToRead = bytesLeftToRead;
630 }
631
632 failed = true;
633 if (_write(PROTO_READ_MULTI) &&
634 _write(bytesToRead) &&
635 _write(PROTO_EOC)) {
636 _port.flush();
637 if (_read(readBuf, bytesToRead)) {
638 if (_getCommandResponse()) {
639 failed = false;
640 }
641 }
642 }
643 if (failed) {
644 _errorString = tr("Read failed: %1 at address: 0x%2").arg(_errorString).arg(readAddress, 8, 16, QLatin1Char('0'));
645 return false;
646 }
647
648 // Compare
649
650 for (int i=0; i<bytesToRead; i++) {
651 if ((uint8_t)imageBytes[bytesIndex + i] != readBuf[i]) {
652 _errorString = tr("Compare failed: expected(0x%1) actual(0x%2) at address: 0x%3")
653 .arg(static_cast<qulonglong>(static_cast<quint8>(imageBytes[bytesIndex + i])), 2, 16, QLatin1Char('0'))
654 .arg(static_cast<qulonglong>(static_cast<quint8>(readBuf[i])), 2, 16, QLatin1Char('0'))
655 .arg(static_cast<qulonglong>(readAddress + i), 8, 16, QLatin1Char('0'));
656 return false;
657 }
658 }
659
660 bytesVerified += bytesToRead;
661 bytesIndex += bytesToRead;
662 bytesLeftToRead -= bytesToRead;
663
664 emit updateProgress(bytesVerified, imageSize);
665 }
666 }
667
668 return true;
669}
670
672bool Bootloader::_verifyCRC(void)
673{
674 uint8_t buf[2] = { PROTO_GET_CRC, PROTO_EOC };
675
676 quint32 flashCRC = 0;
677
678 bool failed = true;
679 if (_write(buf, 2)) {
680 _port.flush();
681 if (_read((uint8_t*)&flashCRC, sizeof(flashCRC), _verifyTimeout)) {
682 if (_getCommandResponse()) {
683 failed = false;
684 }
685 }
686 }
687 if (failed) {
688 return false;
689 }
690
691 if (_imageCRC != flashCRC) {
692 _errorString = tr("CRC mismatch: board(0x%1) file(0x%2)").arg(flashCRC, 4, 16, QLatin1Char('0')).arg(_imageCRC, 4, 16, QLatin1Char('0'));
693 return false;
694 }
695
696 return true;
697}
698
699bool Bootloader::_syncWorker(void)
700{
701 // Send sync command
702 if (_sendCommand(PROTO_GET_SYNC)) {
703 _inBootloaderMode = true;
704 return true;
705 } else {
706 _errorString.prepend("Sync: ");
707 return false;
708 }
709}
710
711bool Bootloader::_sync(void)
712{
713 // Sometimes getting sync is flaky, try 3 times
714 _port.readAll();
715 bool success = false;
716 for (int i=0; i<3; i++) {
717 success = _syncWorker();
718
719 if (success) {
720 return true;
721 }
722 }
723 return success;
724}
725
726bool Bootloader::_get3DRRadioBoardId(uint32_t& boardID)
727{
728 uint8_t buf[2] = { PROTO_GET_DEVICE, PROTO_EOC };
729
730 if (!_write(buf, sizeof(buf))) {
731 goto Error;
732 }
733 _port.flush();
734
735 if (!_read((uint8_t*)buf, 2)) {
736 goto Error;
737 }
738 if (!_getCommandResponse()) {
739 goto Error;
740 }
741
742 boardID = buf[0];
743
744 _bootloaderVersion = 0;
745 _boardFlashSize = 0;
746
747 return true;
748
749Error:
750 _errorString.prepend(tr("Get Board Id: "));
751 return false;
752}
#define QGC_LOGGING_CATEGORY(name, categoryStr)
bool program(const FirmwareImage *image)
void updateProgress(int curr, int total)
Signals progress indicator for long running bootloader utility routines.
bool erase(void)
static const int boardIDPX4FMUV2
PX4 V2 board, as from USB PID.
Definition Bootloader.h:34
bool reboot(void)
bool initFlashSequence(void)
static const int boardIDPX4FMUV3
Definition Bootloader.h:35
Bootloader(bool sikRadio, QObject *parent=0)
This class manages interactions with the bootloader.
Definition Bootloader.cc:14
bool open(const QString portName)
Definition Bootloader.cc:21
bool verify(const FirmwareImage *image)
bool getBoardInfo(uint32_t &bootloaderVersion, uint32_t &boardID, uint32_t &flashSize)
Definition Bootloader.cc:68
Support for Intel Hex firmware file.
bool imageIsBinFormat(void) const
QString binFilename(void) const
bool ihxGetBlock(uint16_t index, uint16_t &address, QByteArray &bytes) const
uint32_t imageSize(void) const
Returns the number of bytes in the image.
uint16_t ihxBlockCount(void) const
bool waitForReadyRead(int msecs=30000) override
Returns true only for input that was not announced before.
QByteArray line(std::string_view command)
command as one CR/LF-terminated line.
quint32 crc32(const quint8 *src, unsigned len, unsigned state)
Definition QGCMath.cc:66