mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Fixes #1997: firmware upload failed when "Check Firmware Compatibility" was selected (ported from master)
This commit is contained in:
parent
27314d04cf
commit
fcbe4572b8
4 changed files with 25 additions and 1 deletions
|
@ -203,6 +203,8 @@ void FlashFirmwareDialog::on_burnButton_clicked()
|
|||
g.checkHardwareCompatibility(ui->checkHardwareCompatibility->isChecked());
|
||||
g.backupOnFlash(ui->backupEEprom->isChecked());
|
||||
|
||||
qDebug() << "FlashFirmwareDialog: flashing" << fwName;
|
||||
|
||||
if (imageSource != FIRMWARE) {
|
||||
// load the splash image
|
||||
const QPixmap * pixmap = ui->splash->pixmap();
|
||||
|
@ -220,6 +222,7 @@ void FlashFirmwareDialog::on_burnButton_clicked()
|
|||
tempFile = generateProcessUniqueTempFileName("flash.hex");
|
||||
else
|
||||
tempFile = generateProcessUniqueTempFileName("flash.bin");
|
||||
qDebug() << "FlashFirmwareDialog: patching" << fwName << "with custom splash screen and saving to" << tempFile;
|
||||
FirmwareInterface firmware(fwName);
|
||||
firmware.setSplash(image);
|
||||
if (firmware.save(tempFile) <= 0) {
|
||||
|
@ -253,15 +256,21 @@ void FlashFirmwareDialog::startFlash(const QString &filename)
|
|||
|
||||
// check hardware compatibility if requested
|
||||
if (g.checkHardwareCompatibility()) {
|
||||
QString tempFirmware = generateProcessUniqueTempFileName("flash.bin");
|
||||
QString tempFirmware = generateProcessUniqueTempFileName("flash-check.bin");
|
||||
if (!readFirmware(tempFirmware, progressDialog.progress())) {
|
||||
QMessageBox::warning(this, tr("Firmware check failed"), tr("Could not check firmware from radio"));
|
||||
return;
|
||||
}
|
||||
FirmwareInterface previousFirmware(tempFirmware);
|
||||
qunlink(tempFirmware);
|
||||
FirmwareInterface newFirmware(filename);
|
||||
qDebug() << "startFlash: checking firmware compatibility between " << tempFirmware << "and" << filename;
|
||||
if (!newFirmware.isHardwareCompatible(previousFirmware)) {
|
||||
QMessageBox::warning(this, tr("Firmware check failed"), tr("New firmware is not compatible with the one currently installed!"));
|
||||
if (isTempFileName(filename)) {
|
||||
qDebug() << "startFlash: removing temporary file" << filename;
|
||||
qunlink(filename);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -293,4 +302,9 @@ void FlashFirmwareDialog::startFlash(const QString &filename)
|
|||
|
||||
progressDialog.progress()->setInfo(tr("Flashing done"));
|
||||
progressDialog.exec();
|
||||
|
||||
if (isTempFileName(filename)) {
|
||||
qDebug() << "startFlash: removing temporary file" << filename;
|
||||
qunlink(filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -990,6 +990,11 @@ QString generateProcessUniqueTempFileName(const QString &fileName)
|
|||
return QDir::tempPath() + QString("/%1-").arg(QCoreApplication::applicationPid()) + sanitizedFileName;
|
||||
}
|
||||
|
||||
bool isTempFileName(const QString & fileName)
|
||||
{
|
||||
return fileName.startsWith(QDir::tempPath());
|
||||
}
|
||||
|
||||
QString getSoundsPath(const GeneralSettings &generalSettings)
|
||||
{
|
||||
QString path = g.profile[g.id()].sdPath() + "/SOUNDS/";
|
||||
|
|
|
@ -152,6 +152,7 @@ class QTimeS : public QTime
|
|||
int qunlink(const QString & fileName);
|
||||
|
||||
QString generateProcessUniqueTempFileName(const QString & fileName);
|
||||
bool isTempFileName(const QString & fileName);
|
||||
|
||||
QString getSoundsPath(const GeneralSettings &generalSettings);
|
||||
QSet<QString> getFilesSet(const QString &path, const QStringList &filter, int maxLen);
|
||||
|
|
|
@ -251,12 +251,14 @@ bool readFirmware(const QString &filename, ProgressWidget *progress)
|
|||
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||
QString path = findMassstoragePath("FIRMWARE.BIN");
|
||||
if (!path.isEmpty()) {
|
||||
qDebug() << "readFirmware: reading" << path << "into" << filename;
|
||||
CopyProcess copyProcess(path, filename, progress);
|
||||
result = copyProcess.run();
|
||||
}
|
||||
}
|
||||
|
||||
if (result == false) {
|
||||
qDebug() << "readFirmware: reading" << filename << "with" << getRadioInterfaceCmd() << getReadFirmwareArgs(filename);
|
||||
FlashProcess flashProcess(getRadioInterfaceCmd(), getReadFirmwareArgs(filename), progress);
|
||||
result = flashProcess.run();
|
||||
}
|
||||
|
@ -273,11 +275,13 @@ bool writeFirmware(const QString &filename, ProgressWidget *progress)
|
|||
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||
QString path = findMassstoragePath("FIRMWARE.BIN");
|
||||
if (!path.isEmpty()) {
|
||||
qDebug() << "writeFirmware: writing" << path << "from" << filename;
|
||||
CopyProcess copyProcess(filename, path, progress);
|
||||
return copyProcess.run();
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "writeFirmware: writing" << filename << "with" << getRadioInterfaceCmd() << getWriteFirmwareArgs(filename);
|
||||
FlashProcess flashProcess(getRadioInterfaceCmd(), getWriteFirmwareArgs(filename), progress);
|
||||
return flashProcess.run();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue