Commit 91423217 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5275 from DonLakeFlyer/FlashV3

Support for V3 flashing
parents 999f09ad 8bfce347
......@@ -582,6 +582,13 @@ bool Bootloader::getPX4BoardInfo(QextSerialPort* port, uint32_t& bootloaderVersi
qWarning() << _errorString;
goto Error;
}
// Older V2 boards have large flash space but silicon error which prevents it from being used. Bootloader v5 and above
// will correctly account/report for this. Older bootloaders will not. Newer V2 board which support larger flash space are
// reported as V3 board id.
if (_boardID == boardIDPX4FMUV2 && _bootloaderVersion >= _bootloaderVersionV2CorrectFlash && _boardFlashSize > _flashSizeSmall) {
_boardID = boardIDPX4FMUV3;
}
bootloaderVersion = _bootloaderVersion;
boardID = _boardID;
......
......@@ -74,6 +74,11 @@ public:
static const int boardIDTAPV1 = 64; ///< TAP V1 board, as from USB PID
static const int boardIDASCV1 = 65; ///< ASC V1 board, as from USB PID
static const int boardIDCrazyflie2 = 12; ///< Crazyflie 2.0 board, as from USB PID
/// Simulated board id for V3 which is a V2 board which supports larger flash space
/// IMPORTANT: Make sure this id does not conflict with any newly added real board ids
static const int boardIDPX4FMUV3 = 255;
signals:
/// @brief Signals progress indicator for long running bootloader utility routines
void updateProgress(int curr, int total);
......@@ -141,11 +146,13 @@ private:
QString _errorString; ///< Last error
static const int _eraseTimeout = 20000; ///< Msecs to wait for response from erase command
static const int _rebootTimeout = 10000; ///< Msecs to wait for reboot command to cause serial port to disconnect
static const int _verifyTimeout = 5000; ///< Msecs to wait for response to PROTO_GET_CRC command
static const int _readTimout = 2000; ///< Msecs to wait for read bytes to become available
static const int _responseTimeout = 2000; ///< Msecs to wait for command response bytes
static const int _eraseTimeout = 20000; ///< Msecs to wait for response from erase command
static const int _rebootTimeout = 10000; ///< Msecs to wait for reboot command to cause serial port to disconnect
static const int _verifyTimeout = 5000; ///< Msecs to wait for response to PROTO_GET_CRC command
static const int _readTimout = 2000; ///< Msecs to wait for read bytes to become available
static const int _responseTimeout = 2000; ///< Msecs to wait for command response bytes
static const int _flashSizeSmall = 1032192; ///< Flash size for boards with silicon error
static const int _bootloaderVersionV2CorrectFlash = 5; ///< Anything below this bootloader version on V2 boards cannot trust flash size
};
#endif // PX4FirmwareUpgrade_H
......@@ -19,6 +19,7 @@
#include "QGCApplication.h"
#include "FirmwarePlugin.h"
#include "ParameterManager.h"
#include "Bootloader.h"
#include <QDebug>
#include <QFile>
......@@ -236,7 +237,8 @@ bool FirmwareImage::_px4Load(const QString& imageFilename)
}
uint32_t firmwareBoardId = (uint32_t)px4Json.value(_jsonBoardIdKey).toInt();
if (firmwareBoardId != _boardId) {
uint32_t actualBoardId = _boardId == Bootloader::boardIDPX4FMUV3 ? Bootloader::boardIDPX4FMUV2 : _boardId;;
if (firmwareBoardId != actualBoardId) {
emit statusMessage(QString("Downloaded firmware board id does not match hardware board id: %1 != %2").arg(firmwareBoardId).arg(_boardId));
return false;
}
......
......@@ -231,6 +231,35 @@ void FirmwareUpgradeController::_initFirmwareHash()
{ SingleFirmwareMode,StableFirmware, DefaultVehicleFirmware, _singleFirmwareURL},
};
//////////////////////////////////// PX4FMUV3 firmwares //////////////////////////////////////////////////
// Note: ArduPilot stable does not yet support V3 firmwares, so fall back to V2
FirmwareToUrlElement_t rgPX4FMV3FirmwareArray[] = {
{ AutoPilotStackPX4, StableFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/stable/px4fmu-v3_default.px4"},
{ AutoPilotStackPX4, BetaFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/beta/px4fmu-v3_default.px4"},
{ AutoPilotStackPX4, DeveloperFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/master/px4fmu-v3_default.px4"},
{ AutoPilotStackAPM, StableFirmware, QuadFirmware, "http://firmware.ardupilot.org/Copter/stable/PX4-quad/ArduCopter-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, X8Firmware, "http://firmware.ardupilot.org/Copter/stable/PX4-octa-quad/ArduCopter-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, HexaFirmware, "http://firmware.ardupilot.org/Copter/stable/PX4-hexa/ArduCopter-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, OctoFirmware, "http://firmware.ardupilot.org/Copter/stable/PX4-octa/ArduCopter-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, YFirmware, "http://firmware.ardupilot.org/Copter/stable/PX4-tri/ArduCopter-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, Y6Firmware, "http://firmware.ardupilot.org/Copter/stable/PX4-y6/ArduCopter-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, HeliFirmware, "http://firmware.ardupilot.org/Copter/stable/PX4-heli/ArduCopter-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, PlaneFirmware, "http://firmware.ardupilot.org/Plane/stable/PX4/ArduPlane-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, RoverFirmware, "http://firmware.ardupilot.org/Rover/stable/PX4/APMrover2-v2.px4"},
{ AutoPilotStackAPM, StableFirmware, SubFirmware, "http://firmware.ardupilot.org/Sub/stable/PX4/ArduSub-v2.px4"},
{ AutoPilotStackAPM, BetaFirmware, CopterFirmware, "http://firmware.ardupilot.org/Copter/beta/PX4/ArduCopter-v3.px4"},
{ AutoPilotStackAPM, BetaFirmware, HeliFirmware, "http://firmware.ardupilot.org/Copter/beta/PX4-heli/ArduCopter-v3.px4"},
{ AutoPilotStackAPM, BetaFirmware, PlaneFirmware, "http://firmware.ardupilot.org/Plane/beta/PX4/ArduPlane-v3.px4"},
{ AutoPilotStackAPM, BetaFirmware, RoverFirmware, "http://firmware.ardupilot.org/Rover/beta/PX4/APMrover2-v3.px4"},
{ AutoPilotStackAPM, BetaFirmware, SubFirmware, "http://firmware.ardupilot.org/Sub/beta/PX4/ArduSub-v3.px4"},
{ AutoPilotStackAPM, DeveloperFirmware, CopterFirmware, "http://firmware.ardupilot.org/Copter/latest/PX4/ArduCopter-v3.px4"},
{ AutoPilotStackAPM, DeveloperFirmware, HeliFirmware, "http://firmware.ardupilot.org/Copter/latest/PX4-heli/ArduCopter-v3.px4"},
{ AutoPilotStackAPM, DeveloperFirmware, PlaneFirmware, "http://firmware.ardupilot.org/Plane/latest/PX4/ArduPlane-v3.px4"},
{ AutoPilotStackAPM, DeveloperFirmware, RoverFirmware, "http://firmware.ardupilot.org/Rover/latest/PX4/APMrover2-v3.px4"},
{ AutoPilotStackAPM, DeveloperFirmware, SubFirmware, "http://firmware.ardupilot.org/Sub/latest/PX4/ArduSub-v3.px4"},
{ SingleFirmwareMode,StableFirmware, DefaultVehicleFirmware, _singleFirmwareURL},
};
//////////////////////////////////// PX4FMUV2 firmwares //////////////////////////////////////////////////
FirmwareToUrlElement_t rgPX4FMV2FirmwareArray[] = {
{ AutoPilotStackPX4, StableFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/stable/px4fmu-v2_default.px4"},
......@@ -373,6 +402,12 @@ void FirmwareUpgradeController::_initFirmwareHash()
_rgPX4FMUV4Firmware.insert(FirmwareIdentifier(element.stackType, element.firmwareType, element.vehicleType), element.url);
}
size = sizeof(rgPX4FMV3FirmwareArray)/sizeof(rgPX4FMV3FirmwareArray[0]);
for (int i = 0; i < size; i++) {
const FirmwareToUrlElement_t& element = rgPX4FMV3FirmwareArray[i];
_rgPX4FMUV3Firmware.insert(FirmwareIdentifier(element.stackType, element.firmwareType, element.vehicleType), element.url);
}
size = sizeof(rgPX4FMV2FirmwareArray)/sizeof(rgPX4FMV2FirmwareArray[0]);
for (int i = 0; i < size; i++) {
const FirmwareToUrlElement_t& element = rgPX4FMV2FirmwareArray[i];
......@@ -456,6 +491,8 @@ QHash<FirmwareUpgradeController::FirmwareIdentifier, QString>* FirmwareUpgradeCo
return &_rgPX4FLowFirmware;
case Bootloader::boardIDPX4FMUV2:
return &_rgPX4FMUV2Firmware;
case Bootloader::boardIDPX4FMUV3:
return &_rgPX4FMUV3Firmware;
case Bootloader::boardIDPX4FMUV4:
return &_rgPX4FMUV4Firmware;
case Bootloader::boardIDPX4FMUV4PRO:
......
......@@ -204,6 +204,7 @@ private:
QHash<FirmwareIdentifier, QString> _rgPX4FMUV5Firmware;
QHash<FirmwareIdentifier, QString> _rgPX4FMUV4PROFirmware;
QHash<FirmwareIdentifier, QString> _rgPX4FMUV4Firmware;
QHash<FirmwareIdentifier, QString> _rgPX4FMUV3Firmware;
QHash<FirmwareIdentifier, QString> _rgPX4FMUV2Firmware;
QHash<FirmwareIdentifier, QString> _rgAeroCoreFirmware;
QHash<FirmwareIdentifier, QString> _rgPX4FMUV1Firmware;
......
......@@ -205,7 +205,6 @@ bool PX4FirmwareUpgradeThreadWorker::_findBootloader(const QGCSerialPortInfo& po
uint32_t bootloaderVersion = 0;
uint32_t boardID;
uint32_t flashSize = 0;
_bootloaderPort = new QextSerialPort(QextSerialPort::Polling);
if (radioMode) {
......
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