#1876 fixed. Still needs tests on Taranis (I only tested on Taranis+)

This commit is contained in:
bsongis
2015-01-09 12:50:03 +01:00
parent fac4ff10c3
commit 62ea9c2648
8 changed files with 69 additions and 9 deletions
+2
View File
@@ -673,6 +673,8 @@ AppData::AppData()
getset( _outputDisplayDetails, "outputDisplayDetails" ,false );
getset( _enableBackup, "backupEnable" ,false );
getset( _backupOnFlash, "backupOnFlash" ,true );
getset( _checkHardwareCompatibility, "checkHardwareCompatibility" ,true );
getset( _jsSupport, "js_support" ,false );
getset( _maximized, "maximized" ,false );
getset( _showSplash, "show_splash" ,true );
+1
View File
@@ -200,6 +200,7 @@ class AppData: protected CompStoreObj
BOOL_PROPERTY(enableBackup, false)
BOOL_PROPERTY(outputDisplayDetails, false)
BOOL_PROPERTY(backupOnFlash, true)
BOOL_PROPERTY(checkHardwareCompatibility, true)
// All the global variables
public:
+23
View File
@@ -123,6 +123,29 @@ QString FirmwareInterface::seekLabel(const QString & label)
return seekString(label + ":");
}
QString FirmwareInterface::getFlavour() const
{
if (flavour == "opentx-x9dp")
return "opentx-taranis-plus";
else if (flavour == "opentx-x9d")
return "opentx-taranis";
else
return flavour;
}
bool FirmwareInterface::isHardwareCompatible(const FirmwareInterface &previousFirmware) const
{
QString newFlavour = getFlavour();
if (newFlavour.isEmpty())
return true;
QString previousFlavour = previousFirmware.getFlavour();
if (previousFlavour.isEmpty())
return true;
return (newFlavour == previousFlavour);
}
bool FirmwareInterface::SeekSplash(QByteArray splash)
{
int start = flash.indexOf(splash);
+2 -1
View File
@@ -46,7 +46,8 @@ class FirmwareInterface
inline QString getDate() { return date; }
inline QString getTime() { return time; }
int getSize() { return flash_size; }
inline QString getFlavour() { return flavour; }
QString getFlavour() const;
bool isHardwareCompatible(const FirmwareInterface &previousFirmware) const;
inline QString getVersion() { return version; }
unsigned int getVersionId() { return versionId; }
inline int getEEpromVersion() { return eepromVersion; }
+22 -2
View File
@@ -10,6 +10,7 @@
#include "progressdialog.h"
#include "radiointerface.h"
#include "splashlibrary.h"
#include "progresswidget.h"
#if defined WIN32 || !defined __GNUC__
#include <windows.h>
@@ -50,6 +51,8 @@ fwName(g.profile[g.id()].fwName())
ui->backupEEprom->setEnabled(false);
}
ui->checkHardwareCompatibility->setChecked(g.checkHardwareCompatibility());
updateUI();
resize(0, 0); // TODO needed?
@@ -197,6 +200,8 @@ void FlashFirmwareDialog::on_useLibrarySplash_clicked()
void FlashFirmwareDialog::on_burnButton_clicked()
{
g.flashDir(QFileInfo(fwName).dir().absolutePath());
g.checkHardwareCompatibility(ui->checkHardwareCompatibility->isChecked());
g.backupOnFlash(ui->backupEEprom->isChecked());
if (imageSource != FIRMWARE) {
// load the splash image
@@ -240,13 +245,27 @@ void FlashFirmwareDialog::shrink()
void FlashFirmwareDialog::startFlash(const QString &filename)
{
bool backup = ui->backupEEprom->checkState() == Qt::Checked;
g.backupOnFlash(backup);
bool backup = g.backupOnFlash();
close();
ProgressDialog progressDialog(this, tr("Write Firmware to Radio"), CompanionIcon("write_flash.png"));
// check hardware compatibility if requested
if (g.checkHardwareCompatibility()) {
QString tempFirmware = generateProcessUniqueTempFileName("flash.bin");
if (!readFirmware(tempFirmware, progressDialog.progress())) {
QMessageBox::warning(this, tr("Firmware check failed"), tr("Could not check firmware from radio"));
return;
}
FirmwareInterface previousFirmware(tempFirmware);
FirmwareInterface newFirmware(filename);
if (!newFirmware.isHardwareCompatible(previousFirmware)) {
QMessageBox::warning(this, tr("Firmware check failed"), tr("New firmware is not compatible with the one currently installed!"));
return;
}
}
// backup if requested
bool result = true;
QString backupFilename;
@@ -272,5 +291,6 @@ void FlashFirmwareDialog::startFlash(const QString &filename)
}
}
progressDialog.progress()->setInfo(tr("Flashing done"));
progressDialog.exec();
}
+16
View File
@@ -216,6 +216,22 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkHardwareCompatibility">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Allows Companion to write to older version of the firmware</string>
</property>
<property name="text">
<string>Check Hardware compatibility</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="backupEEprom">
<property name="enabled">
+3 -4
View File
@@ -274,11 +274,10 @@ void FlashProcess::onFinished(int code=0)
errorWizard();
}
}
else if (hasErrors)
else if (hasErrors) {
progress->setInfo(tr("Flashing done with errors"));
else
progress->setInfo(tr("Flashing done"));
if(lfuse || hfuse || efuse) {
}
if (lfuse || hfuse || efuse) {
addReadFuses();
}
progress->setValue(progress->maximum());
-2
View File
@@ -248,8 +248,6 @@ bool readFirmware(const QString &filename, ProgressWidget *progress)
return false;
}
g.flashDir(QFileInfo(filename).dir().absolutePath());
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
QString path = findMassstoragePath("FIRMWARE.BIN");
if (!path.isEmpty()) {