Index: sources/update/VSwUpdate.cpp =================================================================== diff -u -r61c46e9379ca82d826fbe7fae018b8362a107d9d -r7cf31f6cfef97bb564a103c263821a3b722c8a2b --- sources/update/VSwUpdate.cpp (.../VSwUpdate.cpp) (revision 61c46e9379ca82d826fbe7fae018b8362a107d9d) +++ sources/update/VSwUpdate.cpp (.../VSwUpdate.cpp) (revision 7cf31f6cfef97bb564a103c263821a3b722c8a2b) @@ -103,6 +103,12 @@ this , &VSWUpdate::onSettingsDone); connect(&_ApplicationController, &ApplicationController::didPOSTDone, this , &VSWUpdate::onPostDone); + + // Tell the package code this class will send the enter bootloader command, + // if not set, this is skipped. + _package.setEnterBootloader(this); + + // Must be > 1 Hz. _timer.start(500); } @@ -247,20 +253,32 @@ return QVariant(); } + /*! + * \brief IEnterBootLoader interface. + * + * \param asHd If true HD processor if false DG processor. + */ +void VSWUpdate::sendEnterBootloader(bool asHd) { + sendAppCommand(MSG_ID_ENTER_BOOTLOADER_NOW, asHd); +} + +/*! * \brief The start/stop button was clicked. */ void VSWUpdate::startStopBtnClicked() { // Either we are updating or not. if (_updating) { + // Abort. _CanInterface.setSWUpdateMode(false); _package.abort(); set_progress("Aborted."); startStopUpdate("Aborted update", false); _ApplicationController.enableKeepAlive(true); } else { + // Start. int row_index = (int)_selected; if (row_index >= 0) { std::vector update; @@ -284,8 +302,6 @@ // // If these did fail which is extremely unlikely it feels to the user like they didn't quite // press the start button. - sendAppCommand(MSG_ID_ENTER_BOOTLOADER_NOW); - sendAppCommand(MSG_ID_ENTER_BOOTLOADER_NOW); ok = _package.start_hasKey(package_location, update); if (ok) @@ -419,9 +435,11 @@ * 0x8091 Set boot bit to stay in bootloader after reboot (MSG_ID_HD_SET_ENTER_BOOTLOADER) * * \param cmd 16 bit command. + * \param asHd As the HD (true) or else the DG (false) */ -void VSWUpdate::sendAppCommand(uint16 cmd) { +void VSWUpdate::sendAppCommand(uint16 cmd, bool asHd) { + // Do twice. for (std::size_t ii = 0; ii < 2; ii++) { QByteArray msg; msg.append(ePayload_Sync); // 0xA5 @@ -448,7 +466,7 @@ // Send it. // eChlid_UI_HD = 0x100, ///< UI => HD [Out] // eChlid_UI_DG = 0x110, ///< UI => DG [Out] - _CanInterface.sendSWUpdateMsg(ii == 0 ? eChlid_UI_HD : eChlid_UI_DG, (uint8_t *)msg.data(), 8); + _CanInterface.sendSWUpdateMsg(asHd ? eChlid_UI_HD : eChlid_UI_DG, (uint8_t *)msg.data(), 8); // Sleep long enough to ensure FW acted on it. //