chore(cpn): refactor firmware flashing to use edgetx rs_dfu (#6521)

Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
This commit is contained in:
Neil Horne
2025-09-14 09:59:34 +10:00
committed by GitHub
co-authored by raphaelcoeffic
parent 23830197b3
commit dbce54dec6
105 changed files with 2926 additions and 3676 deletions
+36 -34
View File
@@ -21,7 +21,6 @@
#include "mainwindow.h"
#include "mdichild.h"
#include "burnconfigdialog.h"
#include "comparedialog.h"
#include "logsdialog.h"
#include "apppreferencesdialog.h"
@@ -34,7 +33,6 @@
#include "warnings.h"
#include "helpers.h"
#include "appdata.h"
#include "radionotfound.h"
#include "process_sync.h"
#include "radiointerface.h"
#include "progressdialog.h"
@@ -483,7 +481,7 @@ void MainWindow::sdsync(bool postUpdate)
if (syncOpts.folderA.isEmpty())
syncOpts.folderA = g.profile[g.id()].sdPath();
if (syncOpts.folderB.isEmpty())
syncOpts.folderB = findMassstoragePath("SOUNDS", true);
syncOpts.folderB = findMassStoragePath("SOUNDS", true);
if (syncOpts.folderA.isEmpty())
errorMsgs << tr("No local SD structure path configured!");
@@ -556,11 +554,14 @@ void MainWindow::readSettings()
bool MainWindow::readFirmwareFromRadio(const QString & filename)
{
ProgressDialog progressDialog(this, tr("Read Firmware from Radio"), CompanionIcon("read_flash.png"));
bool result = readFirmware(filename, progressDialog.progress());
if (!result && !progressDialog.isEmpty()) {
progressDialog.open();
if (readFirmware(filename, progressDialog.progress())) {
progressDialog.exec();
return true;
}
return result;
return false;
}
bool MainWindow::readSettingsFromRadio(const QString & filename)
@@ -587,40 +588,38 @@ void MainWindow::writeFlash(QString fileToFlash)
{
FlashFirmwareDialog * cd = new FlashFirmwareDialog(this);
cd->exec();
cd->deleteLater();
}
void MainWindow::readBackup()
{
if (IS_FAMILY_HORUS_OR_T16(getCurrentBoard())) {
QMessageBox::information(this, CPN_STR_APP_NAME, tr("This function is not yet implemented"));
return;
// TODO implementation
}
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Radio Backup to File"), g.eepromDir(), EXTERNAL_EEPROM_FILES_FILTER);
if (!fileName.isEmpty()) {
if (!readSettingsFromRadio(fileName))
return;
}
}
void MainWindow::readFlash()
{
QString fileName = QFileDialog::getSaveFileName(this,tr("Read Radio Firmware to File"), g.flashDir(), FLASH_FILES_FILTER);
if (!fileName.isEmpty()) {
readFirmwareFromRadio(fileName);
if (!isRadioConnected()) {
QMessageBox::critical(this, tr("Detect Radio"),
tr("Radio could not be detected by DFU or UF2 modes") % ".\n" %
tr("Check cable is securely connected and radio lights are illuminated") % ".\n" %
tr("Note: USB mode is not suitable for flashing firmware."));
return;
}
}
void MainWindow::burnConfig()
{
burnConfigDialog *bcd = new burnConfigDialog(this);
bcd->exec();
delete bcd;
}
ProgressDialog progressDialog(this, tr("Read Firmware From Radio"),
CompanionIcon("read_flash.png"));
void MainWindow::burnList()
{
burnConfigDialog bcd(this);
auto progress = progressDialog.progress();
readFirmware(
[this, progress](const QByteArray &_data) {
writeFirmwareToFile(this, _data, progress, true);
},
[this](const QString &err) {
qDebug() << tr("Could not read radio firmware: %1").arg(err);
},
progress);
progressDialog.exec();
}
void MainWindow::compare()
@@ -824,7 +823,6 @@ void MainWindow::retranslateUi(bool showMsg)
trAct(exportAppSettingsAct, tr("Export Settings..."), tr("Save all the current %1 and Simulator settings (including radio profiles) to a file.").arg(CPN_STR_APP_NAME));
trAct(importAppSettingsAct, tr("Import Settings..."), tr("Load %1 and Simulator settings from a prevously exported settings file.").arg(CPN_STR_APP_NAME));
trAct(burnConfigAct, tr("Configure Radio Communications..."), tr("Configure Companion for communicating with the Radio"));
trAct(editSplashAct, tr("Edit Radio Splash Image..."), tr("Edit the splash image of your Radio"));
trAct(readFlashAct, tr("Read Firmware from Radio"), tr("Read firmware from Radio"));
trAct(writeFlashAct, tr("Write Firmware to Radio"), tr("Write firmware to Radio"));
@@ -832,6 +830,7 @@ void MainWindow::retranslateUi(bool showMsg)
trAct(readSettingsAct, tr("Read Models and Settings from Radio"), tr("Read Models and Settings from Radio"));
trAct(writeBUToRadioAct, tr("Write Backup to Radio"), tr("Write Backup from file to Radio"));
trAct(readBUToFileAct, tr("Backup Radio to File"), tr("Save a complete backup file of all settings and model data in the Radio"));
trAct(radioGetDevicesAct, tr("Connected Radios"), tr("Get a list of connected radios"));
trAct(compareAct, tr("Compare Models"), tr("Compare models"));
trAct(updatesAct, tr("Update components..."), tr("Download and update EdgeTX components and supporting resources"));
@@ -897,7 +896,7 @@ void MainWindow::createActions()
editAppSettingsAct = addAct("apppreferences.png", SLOT(editAppSettings()), QKeySequence::Preferences);
exportAppSettingsAct = addAct("saveas.png", SLOT(exportAppSettings()));
importAppSettingsAct = addAct("open.png", SLOT(importAppSettings()));
burnConfigAct = addAct("configure.png", SLOT(burnConfig()));
radioGetDevicesAct = addAct("configure.png", SLOT(radioGetDevices()));
compareAct = addAct("compare.png", SLOT(compare()), tr("Ctrl+Alt+R"));
updatesAct = addAct("download.png", SLOT(updates()), tr("Ctrl+Alt+D"));
@@ -910,7 +909,6 @@ void MainWindow::createActions()
sdsyncAct = addAct("sdsync.png", SLOT(sdsync()));
logsAct = addAct("logs.png", SLOT(logFile()), tr("Ctrl+Alt+L"));
burnListAct = addAct("list.png", SLOT(burnList()));
readFlashAct = addAct("read_flash.png", SLOT(readFlash()));
writeFlashAct = addAct("write_flash.png", SLOT(writeFlash()));
writeSettingsAct = addAct("write_eeprom.png", SLOT(writeSettings()));
@@ -1003,8 +1001,8 @@ void MainWindow::createMenus()
radioMenu->addAction(writeFlashAct);
radioMenu->addAction(readFlashAct);
radioMenu->addSeparator();
radioMenu->addAction(burnConfigAct);
radioMenu->addAction(editSplashAct);
radioMenu->addAction(radioGetDevicesAct);
settingsMenu = menuBar()->addMenu("");
settingsMenu->addAction(editAppSettingsAct);
@@ -1090,7 +1088,6 @@ void MainWindow::createToolBars()
radioToolBar->addAction(writeFlashAct);
radioToolBar->addAction(readFlashAct);
radioToolBar->addSeparator();
radioToolBar->addAction(burnConfigAct);
settingsToolBar = addToolBar("");
settingsToolBar->setObjectName("Settings");
@@ -1577,3 +1574,8 @@ void MainWindow::viewToolsToolbar()
const QSignalBlocker blocker(toolsToolBar);
toolsToolBar->setVisible(viewToolsToolbarAct->isChecked());
}
void MainWindow::radioGetDevices()
{
QMessageBox::information(this, tr("Connected Radios"), getDevicesInfo());
}