mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-27 02:05:10 +03:00
#1876 fixed. Still needs tests on Taranis (I only tested on Taranis+)
This commit is contained in:
parent
fac4ff10c3
commit
62ea9c2648
8 changed files with 69 additions and 9 deletions
|
@ -673,6 +673,8 @@ AppData::AppData()
|
||||||
getset( _outputDisplayDetails, "outputDisplayDetails" ,false );
|
getset( _outputDisplayDetails, "outputDisplayDetails" ,false );
|
||||||
getset( _enableBackup, "backupEnable" ,false );
|
getset( _enableBackup, "backupEnable" ,false );
|
||||||
getset( _backupOnFlash, "backupOnFlash" ,true );
|
getset( _backupOnFlash, "backupOnFlash" ,true );
|
||||||
|
getset( _checkHardwareCompatibility, "checkHardwareCompatibility" ,true );
|
||||||
|
|
||||||
getset( _jsSupport, "js_support" ,false );
|
getset( _jsSupport, "js_support" ,false );
|
||||||
getset( _maximized, "maximized" ,false );
|
getset( _maximized, "maximized" ,false );
|
||||||
getset( _showSplash, "show_splash" ,true );
|
getset( _showSplash, "show_splash" ,true );
|
||||||
|
|
|
@ -200,6 +200,7 @@ class AppData: protected CompStoreObj
|
||||||
BOOL_PROPERTY(enableBackup, false)
|
BOOL_PROPERTY(enableBackup, false)
|
||||||
BOOL_PROPERTY(outputDisplayDetails, false)
|
BOOL_PROPERTY(outputDisplayDetails, false)
|
||||||
BOOL_PROPERTY(backupOnFlash, true)
|
BOOL_PROPERTY(backupOnFlash, true)
|
||||||
|
BOOL_PROPERTY(checkHardwareCompatibility, true)
|
||||||
|
|
||||||
// All the global variables
|
// All the global variables
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -123,6 +123,29 @@ QString FirmwareInterface::seekLabel(const QString & label)
|
||||||
return seekString(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)
|
bool FirmwareInterface::SeekSplash(QByteArray splash)
|
||||||
{
|
{
|
||||||
int start = flash.indexOf(splash);
|
int start = flash.indexOf(splash);
|
||||||
|
|
|
@ -46,7 +46,8 @@ class FirmwareInterface
|
||||||
inline QString getDate() { return date; }
|
inline QString getDate() { return date; }
|
||||||
inline QString getTime() { return time; }
|
inline QString getTime() { return time; }
|
||||||
int getSize() { return flash_size; }
|
int getSize() { return flash_size; }
|
||||||
inline QString getFlavour() { return flavour; }
|
QString getFlavour() const;
|
||||||
|
bool isHardwareCompatible(const FirmwareInterface &previousFirmware) const;
|
||||||
inline QString getVersion() { return version; }
|
inline QString getVersion() { return version; }
|
||||||
unsigned int getVersionId() { return versionId; }
|
unsigned int getVersionId() { return versionId; }
|
||||||
inline int getEEpromVersion() { return eepromVersion; }
|
inline int getEEpromVersion() { return eepromVersion; }
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "progressdialog.h"
|
#include "progressdialog.h"
|
||||||
#include "radiointerface.h"
|
#include "radiointerface.h"
|
||||||
#include "splashlibrary.h"
|
#include "splashlibrary.h"
|
||||||
|
#include "progresswidget.h"
|
||||||
|
|
||||||
#if defined WIN32 || !defined __GNUC__
|
#if defined WIN32 || !defined __GNUC__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -50,6 +51,8 @@ fwName(g.profile[g.id()].fwName())
|
||||||
ui->backupEEprom->setEnabled(false);
|
ui->backupEEprom->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->checkHardwareCompatibility->setChecked(g.checkHardwareCompatibility());
|
||||||
|
|
||||||
updateUI();
|
updateUI();
|
||||||
|
|
||||||
resize(0, 0); // TODO needed?
|
resize(0, 0); // TODO needed?
|
||||||
|
@ -197,6 +200,8 @@ void FlashFirmwareDialog::on_useLibrarySplash_clicked()
|
||||||
void FlashFirmwareDialog::on_burnButton_clicked()
|
void FlashFirmwareDialog::on_burnButton_clicked()
|
||||||
{
|
{
|
||||||
g.flashDir(QFileInfo(fwName).dir().absolutePath());
|
g.flashDir(QFileInfo(fwName).dir().absolutePath());
|
||||||
|
g.checkHardwareCompatibility(ui->checkHardwareCompatibility->isChecked());
|
||||||
|
g.backupOnFlash(ui->backupEEprom->isChecked());
|
||||||
|
|
||||||
if (imageSource != FIRMWARE) {
|
if (imageSource != FIRMWARE) {
|
||||||
// load the splash image
|
// load the splash image
|
||||||
|
@ -240,13 +245,27 @@ void FlashFirmwareDialog::shrink()
|
||||||
|
|
||||||
void FlashFirmwareDialog::startFlash(const QString &filename)
|
void FlashFirmwareDialog::startFlash(const QString &filename)
|
||||||
{
|
{
|
||||||
bool backup = ui->backupEEprom->checkState() == Qt::Checked;
|
bool backup = g.backupOnFlash();
|
||||||
g.backupOnFlash(backup);
|
|
||||||
|
|
||||||
close();
|
close();
|
||||||
|
|
||||||
ProgressDialog progressDialog(this, tr("Write Firmware to Radio"), CompanionIcon("write_flash.png"));
|
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
|
// backup if requested
|
||||||
bool result = true;
|
bool result = true;
|
||||||
QString backupFilename;
|
QString backupFilename;
|
||||||
|
@ -272,5 +291,6 @@ void FlashFirmwareDialog::startFlash(const QString &filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressDialog.progress()->setInfo(tr("Flashing done"));
|
||||||
progressDialog.exec();
|
progressDialog.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,22 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QCheckBox" name="backupEEprom">
|
<widget class="QCheckBox" name="backupEEprom">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
|
|
|
@ -274,11 +274,10 @@ void FlashProcess::onFinished(int code=0)
|
||||||
errorWizard();
|
errorWizard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (hasErrors)
|
else if (hasErrors) {
|
||||||
progress->setInfo(tr("Flashing done with errors"));
|
progress->setInfo(tr("Flashing done with errors"));
|
||||||
else
|
}
|
||||||
progress->setInfo(tr("Flashing done"));
|
if (lfuse || hfuse || efuse) {
|
||||||
if(lfuse || hfuse || efuse) {
|
|
||||||
addReadFuses();
|
addReadFuses();
|
||||||
}
|
}
|
||||||
progress->setValue(progress->maximum());
|
progress->setValue(progress->maximum());
|
||||||
|
|
|
@ -248,8 +248,6 @@ bool readFirmware(const QString &filename, ProgressWidget *progress)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
g.flashDir(QFileInfo(filename).dir().absolutePath());
|
|
||||||
|
|
||||||
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
|
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||||
QString path = findMassstoragePath("FIRMWARE.BIN");
|
QString path = findMassstoragePath("FIRMWARE.BIN");
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue