Commit 60099c12 authored by Don Gagne's avatar Don Gagne

Merge pull request #1875 from pritamghanghas/apm_support

Added support for flashing beta and developer versions of APM stack
parents f6121689 aba85785
This diff is collapsed.
...@@ -43,33 +43,68 @@ ...@@ -43,33 +43,68 @@
#include <stdint.h> #include <stdint.h>
/// Supported firmware types. If you modify these you will need to update the qml file as well.
// Firmware Upgrade MVC Controller for FirmwareUpgrade.qml. // Firmware Upgrade MVC Controller for FirmwareUpgrade.qml.
class FirmwareUpgradeController : public QObject class FirmwareUpgradeController : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
typedef enum {
AutoPilotStackPX4,
AutoPilotStackAPM,
PX4Flow,
ThreeDRRadio
} AutoPilotStackType_t;
typedef enum {
StableFirmware,
BetaFirmware,
DeveloperFirmware,
CustomFirmware
} FirmwareType_t;
typedef enum {
QuadFirmware,
X8Firmware,
HexaFirmware,
OctoFirmware,
YFirmware,
Y6Firmware,
HeliFirmware,
PlaneFirmware,
RoverFirmware,
DefaultVehicleFirmware
} FirmwareVehicleType_t;
Q_ENUMS(AutoPilotStackType_t)
Q_ENUMS(FirmwareType_t)
Q_ENUMS(FirmwareVehicleType_t)
class FirmwareIdentifier
{
public:
FirmwareIdentifier(AutoPilotStackType_t stack = AutoPilotStackPX4,
FirmwareType_t firmware = StableFirmware,
FirmwareVehicleType_t vehicle = DefaultVehicleFirmware)
: autopilotStackType(stack), firmwareType(firmware), firmwareVehicleType(vehicle) {}
bool operator==(const FirmwareIdentifier& firmwareId) const
{
return (firmwareId.autopilotStackType == autopilotStackType &&
firmwareId.firmwareType == firmwareType &&
firmwareId.firmwareVehicleType == firmwareVehicleType);
}
// members
AutoPilotStackType_t autopilotStackType;
FirmwareType_t firmwareType;
FirmwareVehicleType_t firmwareVehicleType;
};
FirmwareUpgradeController(void); FirmwareUpgradeController(void);
/// Supported firmware types. If you modify these you will need to update the qml file as well.
typedef enum {
PX4StableFirmware,
PX4BetaFirmware,
PX4DeveloperFirmware,
PX4CustomFirmware,
ApmArduCopterQuadFirmware,
ApmArduCopterX8Firmware,
ApmArduCopterHexaFirmware,
ApmArduCopterOctoFirmware,
ApmArduCopterYFirmware,
ApmArduCopterY6Firmware,
ApmArduCopterHeliFirmware,
ApmArduPlaneFirmware,
ApmRoverFirmware,
} FirmwareType_t;
Q_ENUMS(FirmwareType_t)
Q_PROPERTY(QString boardPort READ boardPort NOTIFY boardFound) Q_PROPERTY(QString boardPort READ boardPort NOTIFY boardFound)
Q_PROPERTY(QString boardDescription READ boardDescription NOTIFY boardFound) Q_PROPERTY(QString boardDescription READ boardDescription NOTIFY boardFound)
Q_PROPERTY(QString boardType MEMBER _foundBoardType NOTIFY boardFound) Q_PROPERTY(QString boardType MEMBER _foundBoardType NOTIFY boardFound)
...@@ -90,8 +125,13 @@ public: ...@@ -90,8 +125,13 @@ public:
Q_INVOKABLE void cancel(void); Q_INVOKABLE void cancel(void);
/// Called when the firmware type has been selected by the user to continue the flash process. /// Called when the firmware type has been selected by the user to continue the flash process.
Q_INVOKABLE void flash(FirmwareType_t firmwareType); Q_INVOKABLE void flash(AutoPilotStackType_t stackType,
FirmwareType_t firmwareType = StableFirmware,
FirmwareVehicleType_t vehicleType = DefaultVehicleFirmware );
// overload, not exposed to qml side
void flash(const FirmwareIdentifier& firmwareId);
// Property accessors // Property accessors
QQuickItem* progressBar(void) { return _progressBar; } QQuickItem* progressBar(void) { return _progressBar; }
...@@ -133,27 +173,30 @@ private slots: ...@@ -133,27 +173,30 @@ private slots:
void _linkDisconnected(LinkInterface* link); void _linkDisconnected(LinkInterface* link);
private: private:
void _getFirmwareFile(FirmwareType_t firmwareType); void _getFirmwareFile(FirmwareIdentifier firmwareId);
void _initFirmwareHash();
void _downloadFirmware(void); void _downloadFirmware(void);
void _appendStatusLog(const QString& text, bool critical = false); void _appendStatusLog(const QString& text, bool critical = false);
void _errorCancel(const QString& msg); void _errorCancel(const QString& msg);
typedef struct {
FirmwareType_t firmwareType;
const char* downloadLocation;
} DownloadLocationByFirmwareType_t;
QString _portName; QString _portName;
QString _portDescription; QString _portDescription;
// firmware hashes
QHash<FirmwareIdentifier, QString> _rgPX4FMUV2Firmware;
QHash<FirmwareIdentifier, QString> _rgAeroCoreFirmware;
QHash<FirmwareIdentifier, QString> _rgPX4FMUV1Firmware;
QHash<FirmwareIdentifier, QString> _rgPX4FLowFirmware;
QHash<FirmwareIdentifier, QString> _rg3DRRadioFirmware;
/// Information which comes back from the bootloader /// Information which comes back from the bootloader
bool _bootloaderFound; ///< true: we have received the foundBootloader signals bool _bootloaderFound; ///< true: we have received the foundBootloader signals
uint32_t _bootloaderVersion; ///< Bootloader version uint32_t _bootloaderVersion; ///< Bootloader version
uint32_t _bootloaderBoardID; ///< Board ID uint32_t _bootloaderBoardID; ///< Board ID
uint32_t _bootloaderBoardFlashSize; ///< Flash size in bytes of board uint32_t _bootloaderBoardFlashSize; ///< Flash size in bytes of board
bool _startFlashWhenBootloaderFound; bool _startFlashWhenBootloaderFound;
FirmwareType_t _startFlashWhenBootloaderFoundFirmwareType; FirmwareIdentifier _startFlashWhenBootloaderFoundFirmwareIdentity;
QPixmap _boardIcon; ///< Icon used to display image of board QPixmap _boardIcon; ///< Icon used to display image of board
...@@ -184,4 +227,7 @@ private: ...@@ -184,4 +227,7 @@ private:
FirmwareImage* _image; FirmwareImage* _image;
}; };
// global hashing function
uint qHash(const FirmwareUpgradeController::FirmwareIdentifier& firmwareId);
#endif #endif
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