From 57beb3d36cd35fab202d8079be19c78dd8ab2a27 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 8 Dec 2014 16:36:17 +0100 Subject: [PATCH] OP-1629 Added option to erase when autoupdating formware. Option added to Wizard and Uploader plugin. --- .../setupwizard/pages/autoupdatepage.cpp | 26 ++++++------- .../setupwizard/pages/autoupdatepage.h | 1 + .../setupwizard/pages/autoupdatepage.ui | 18 ++++++--- .../src/plugins/uploader/uploader.ui | 38 ++++++++++++------- .../uploader/uploadergadgetfactory.cpp | 2 +- .../plugins/uploader/uploadergadgetfactory.h | 2 +- .../plugins/uploader/uploadergadgetwidget.cpp | 18 +++++++-- .../plugins/uploader/uploadergadgetwidget.h | 4 +- 8 files changed, 70 insertions(+), 39 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.cpp index 22af09bd1..42344519c 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.cpp @@ -16,7 +16,7 @@ AutoUpdatePage::AutoUpdatePage(SetupWizard *wizard, QWidget *parent) : UploaderGadgetFactory *uploader = pm->getObject(); Q_ASSERT(uploader); connect(ui->startUpdate, SIGNAL(clicked()), this, SLOT(disableButtons())); - connect(ui->startUpdate, SIGNAL(clicked()), uploader, SIGNAL(autoUpdate())); + connect(ui->startUpdate, SIGNAL(clicked()), this, SLOT(autoUpdate())); connect(uploader, SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep, QVariant)), this, SLOT(updateStatus(uploader::AutoUpdateStep, QVariant))); } @@ -35,6 +35,15 @@ void AutoUpdatePage::enableButtons(bool enable = false) QApplication::processEvents(); } +void AutoUpdatePage::autoUpdate() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Q_ASSERT(pm); + UploaderGadgetFactory *uploader = pm->getObject(); + Q_ASSERT(uploader); + uploader->autoUpdate(ui->eraseSettings->isChecked()); +} + void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant value) { QString msg; @@ -48,16 +57,6 @@ void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant valu ui->levellinProgressBar->setValue(value.toInt()); break; case uploader::WAITING_CONNECT: - // Note: - // the following commented out lines were probably added to fix an issue when uploader opened a popup requesting - // user to disconnect all boards - // Side effect is that the wizard dialog flickers - // the uploader was changed to avoid popups alltogether and that fix is not need anymore - // same commented fix can be found in FAILURE case and they are kept for future ref. - // getWizard()->setWindowFlags(getWizard()->windowFlags() | Qt::WindowStaysOnTopHint); - // getWizard()->setWindowIcon(qApp->windowIcon()); - // getWizard()->show(); - // End of Note disableButtons(); ui->statusLabel->setText(tr("Please connect the board to the USB port (don't use external supply).")); // TODO get rid of magic number 20s (should use UploaderGadgetWidget::BOARD_EVENT_TIMEOUT) @@ -65,7 +64,8 @@ void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant valu ui->levellinProgressBar->setValue(value.toInt()); break; case uploader::JUMP_TO_BL: - ui->levellinProgressBar->setValue(0); + ui->levellinProgressBar->setValue(value.toInt()); + ui->levellinProgressBar->setMaximum(5); ui->statusLabel->setText(tr("Board going into bootloader mode.")); break; case uploader::LOADING_FW: @@ -87,8 +87,6 @@ void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant valu ui->statusLabel->setText(tr("Board updated, please press 'Next' to continue.")); break; case uploader::FAILURE: - // getWizard()->setWindowFlags(getWizard()->windowFlags() | Qt::WindowStaysOnTopHint); - // getWizard()->setWindowIcon(qApp->windowIcon()); enableButtons(true); QString msg = value.toString(); if (msg.isEmpty()) { diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.h index 09351c810..711e3ccf1 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.h @@ -52,6 +52,7 @@ private slots: enableButtons(false); } void enableButtons(bool enable); + void autoUpdate(); private: Ui::AutoUpdatePage *ui; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.ui index 3d8b75da4..35446f27b 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/autoupdatepage.ui @@ -20,13 +20,11 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;">Firmware Update</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">It is necessary that your firmware and ground control software are the same version.</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">To update your firmware to the correct version now:</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">- Unplug all batteries and USB from OpenPilot</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">- Ensure your board is powered down &amp; no LED's are active.</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">When you are ready you can start the upgrade below by pushing the button and follow the onscreen prompts, it is critical that nothing disturbs the board while the firmware is being written.</span></p></body></html> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">When you are ready you can start the upgrade below by pushing the button. It is critical that nothing disturbs the board while the firmware is being written.</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;">It is recommended that you erase all settings on the board when upgrading firmware. Using saved settings for a previous version of the firmware </span><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">may result in undefined behaviour</span><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt;"> and in worst case danger. It is possible to suppress the erase by deselecting the check box below.</span></p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -49,6 +47,16 @@ p, li { white-space: pre-wrap; } + + + + Erase all settings + + + true + + + diff --git a/ground/openpilotgcs/src/plugins/uploader/uploader.ui b/ground/openpilotgcs/src/plugins/uploader/uploader.ui index cc143f976..af29a86c8 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploader.ui +++ b/ground/openpilotgcs/src/plugins/uploader/uploader.ui @@ -70,7 +70,7 @@ 0 - + 6 @@ -268,6 +268,16 @@ Rescue is possible in USB mode only. + + + + false + + + Auto Update && Erase + + + @@ -326,17 +336,17 @@ Rescue is possible in USB mode only. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">To upgrade the firmware in your boards,</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">press Auto Update and follow instructions</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">or</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">proceed as follows:</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">- Connect telemetry</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">- Once telemetry is running, press &quot;Halt&quot; above</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">- You will get a list of devices.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">- You can then upload/download to/from each board as you wish</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">- You can resume operations by pressing &quot;Boot&quot;</span></p></body></html> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To upgrade the firmware in your boards,</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">press Auto Update and follow instructions</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">or</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">proceed as follows:</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- Connect telemetry</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- Once telemetry is running, press &quot;Halt&quot; above</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- You will get a list of devices.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- You can then upload/download to/from each board as you wish</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">- You can resume operations by pressing &quot;Boot&quot;</p></body></html> @@ -351,8 +361,8 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"><br /></p></body></html> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.cpp b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.cpp index 35733ce6c..04dbbfc75 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.cpp @@ -44,7 +44,7 @@ Core::IUAVGadget *UploaderGadgetFactory::createGadget(QWidget *parent) UploaderGadgetWidget *gadgetWidget = new UploaderGadgetWidget(parent); isautocapable = gadgetWidget->autoUpdateCapable(); - connect(this, SIGNAL(autoUpdate()), gadgetWidget, SLOT(autoUpdate())); + connect(this, SIGNAL(autoUpdate(bool)), gadgetWidget, SLOT(autoUpdate(bool))); connect(gadgetWidget, SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep, QVariant)), this, SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep, QVariant))); return new UploaderGadget(QString("Uploader"), gadgetWidget, parent); } diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.h b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.h index 3303148f4..1e1b1e2b6 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.h +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetfactory.h @@ -51,7 +51,7 @@ private: bool isautocapable; signals: void autoUpdateSignal(uploader::AutoUpdateStep, QVariant); - void autoUpdate(); + void autoUpdate(bool erase); }; #endif // UPLOADERGADGETFACTORY_H diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp index ffaa0b9c2..42c1bdfef 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp @@ -157,8 +157,10 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent) getSerialPorts(); connect(m_config->autoUpdateButton, SIGNAL(clicked()), this, SLOT(startAutoUpdate())); + connect(m_config->autoUpdateEraseButton, SIGNAL(clicked()), this, SLOT(startAutoUpdateErase())); connect(m_config->autoUpdateOkButton, SIGNAL(clicked()), this, SLOT(closeAutoUpdate())); m_config->autoUpdateButton->setEnabled(autoUpdateCapable()); + m_config->autoUpdateEraseButton->setEnabled(autoUpdateCapable()); m_config->autoUpdateGroupBox->setVisible(false); m_config->refreshPorts->setIcon(QIcon(":uploader/images/view-refresh.svg")); @@ -606,7 +608,7 @@ bool UploaderGadgetWidget::autoUpdateCapable() return QDir(":/firmware").exists(); } -bool UploaderGadgetWidget::autoUpdate() +bool UploaderGadgetWidget::autoUpdate(bool erase) { goToBootloader(); @@ -705,7 +707,7 @@ bool UploaderGadgetWidget::autoUpdate() emit autoUpdateSignal(FAILURE, QVariant()); return false; } - systemBoot(); + commonSystemBoot(false, erase); emit autoUpdateSignal(SUCCESS, QVariant()); return true; } @@ -876,6 +878,16 @@ void UploaderGadgetWidget::downloadEnded(bool succeed) } void UploaderGadgetWidget::startAutoUpdate() +{ + startAutoUpdate(false); +} + +void UploaderGadgetWidget::startAutoUpdateErase() +{ + startAutoUpdate(true); +} + +void UploaderGadgetWidget::startAutoUpdate(bool erase) { m_config->autoUpdateProgressBar->setValue(0); autoUpdateStatus(uploader::JUMP_TO_BL, QVariant()); @@ -885,7 +897,7 @@ void UploaderGadgetWidget::startAutoUpdate() m_config->autoUpdateOkButton->setEnabled(false); connect(this, SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep, QVariant)), this, SLOT(autoUpdateStatus(uploader::AutoUpdateStep, QVariant))); - autoUpdate(); + autoUpdate(erase); } void UploaderGadgetWidget::finishAutoUpdate() diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h index 060a3c3f0..7697fc393 100644 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.h @@ -109,7 +109,6 @@ public slots: void onAutopilotDisconnect(); void populate(); void openHelp(); - bool autoUpdate(); void autoUpdateDisconnectProgress(int); void autoUpdateConnectProgress(int); void autoUpdateFlashProgress(int); @@ -133,6 +132,7 @@ private: int confirmEraseSettingsMessageBox(); int cannotHaltMessageBox(); int cannotResetMessageBox(); + void startAutoUpdate(bool erase); private slots: void onPhysicalHWConnect(); @@ -150,6 +150,8 @@ private slots: void downloadStarted(); void downloadEnded(bool succeed); void startAutoUpdate(); + void startAutoUpdateErase(); + bool autoUpdate(bool erase); void finishAutoUpdate(); void closeAutoUpdate(); void autoUpdateStatus(uploader::AutoUpdateStep status, QVariant value);