Index: sources/update/Package.cpp =================================================================== diff -u -rf0118ee7e526bb64e9f78059f030929792a5a98a -r61c46e9379ca82d826fbe7fae018b8362a107d9d --- sources/update/Package.cpp (.../Package.cpp) (revision f0118ee7e526bb64e9f78059f030929792a5a98a) +++ sources/update/Package.cpp (.../Package.cpp) (revision 61c46e9379ca82d826fbe7fae018b8362a107d9d) @@ -18,6 +18,7 @@ #include #include "IDataProvider.h" #include "UiSwUpdate.h" +#include "UiProtocol.h" #include #include @@ -668,6 +669,23 @@ } /*! + * \brief Reboot to run the firmware (both HD and DG) apps if they are valid. + */ +void Package::rebootFW() { + const int retryRebootEffort = 4; + SwUpdate::MsgLink link(KBPS_WIRE); + + for (std::size_t ii = 0; ii < 2; ii++) { + SwUpdateCommand msg; + msg.id = SwUpdate::UiProtocol::getNextMsgSlotId(); + msg.cmd = SwUpdate_FormCommand(ii == 0 ? HD : DG, RunApp); + msg.rand = SwUpdate::UiProtocol::getNextMsgSeed(); + SwUpdate_createSecurity((uint8 *)&msg, sizeof(SwUpdateCommand)); + link.sendOk(SwUpdateCanMsgIds::CommandId, (uint8 *)&msg, retryRebootEffort); + } +} + +/*! * \brief Scan a directory recursively for regular files and avoid links. * * \param directory The directory to scan. Index: sources/update/Package.h =================================================================== diff -u -r20b370a54d2737831b307a0de82aec9e06e2b772 -r61c46e9379ca82d826fbe7fae018b8362a107d9d --- sources/update/Package.h (.../Package.h) (revision 20b370a54d2737831b307a0de82aec9e06e2b772) +++ sources/update/Package.h (.../Package.h) (revision 61c46e9379ca82d826fbe7fae018b8362a107d9d) @@ -248,6 +248,9 @@ bool copyUpdate(const std::string& fullNamePath, const std::string& cacheDirectory, uint32 maxCacheSize); std::string getScriptIfAny(); + + // Reboot to run the firmware (both HD and DG) apps if they are valid. + void rebootFW(); protected: bool parseInternal(FILE *fp); Index: sources/update/UiProtocol.cpp =================================================================== diff -u -r20b370a54d2737831b307a0de82aec9e06e2b772 -r61c46e9379ca82d826fbe7fae018b8362a107d9d --- sources/update/UiProtocol.cpp (.../UiProtocol.cpp) (revision 20b370a54d2737831b307a0de82aec9e06e2b772) +++ sources/update/UiProtocol.cpp (.../UiProtocol.cpp) (revision 61c46e9379ca82d826fbe7fae018b8362a107d9d) @@ -30,6 +30,23 @@ /*! + * \brief Return a new ID number. + * + * \return New ID number. + */ +uint8 UiProtocol::getNextMsgSlotId() { + return _gIdNum++; +} + +/*! + * \brief Get a new random seed. + * \return New random seed. + */ +uint16 UiProtocol::getNextMsgSeed() { + return _gRandSeed++; +} + +/*! * \brief Constructor. * * \param target Target to go after for update. Index: sources/update/UiProtocol.h =================================================================== diff -u -r20b370a54d2737831b307a0de82aec9e06e2b772 -r61c46e9379ca82d826fbe7fae018b8362a107d9d --- sources/update/UiProtocol.h (.../UiProtocol.h) (revision 20b370a54d2737831b307a0de82aec9e06e2b772) +++ sources/update/UiProtocol.h (.../UiProtocol.h) (revision 61c46e9379ca82d826fbe7fae018b8362a107d9d) @@ -124,6 +124,9 @@ _maxTransfer = pProvider->totalSize; } + static uint8 getNextMsgSlotId(); + static uint16 getNextMsgSeed(); + protected: /*! Index: sources/update/VSwUpdate.cpp =================================================================== diff -u -r7e905e51f1651ef329a9b121e31f9c22d3d898d2 -r61c46e9379ca82d826fbe7fae018b8362a107d9d --- sources/update/VSwUpdate.cpp (.../VSwUpdate.cpp) (revision 7e905e51f1651ef329a9b121e31f9c22d3d898d2) +++ sources/update/VSwUpdate.cpp (.../VSwUpdate.cpp) (revision 61c46e9379ca82d826fbe7fae018b8362a107d9d) @@ -37,11 +37,10 @@ #define REBOOT_ENABLED (0) #endif -#define MSG_ID_ENTER_BOOTLOADER_NOW (0x808F) ///< HD Jump to the bootloader application -#define MSG_ID_REBOOT_NOW (0x8090) ///< HD Reboot RM46 immediately -#define MSG_ID_SET_ENTER_BOOTLOADER (0x8091) ///< HD Set the flag to stay +#define MSG_ID_ENTER_BOOTLOADER_NOW (0x8093) ///< HD Jump to the bootloader application +#define MSG_ID_REBOOT_NOW (0x8094) ///< HD Reboot RM46 immediately +#define MSG_ID_SET_ENTER_BOOTLOADER (0x8095) ///< HD Set the flag to stay - /*! * \brief Constructor. * @@ -300,8 +299,9 @@ // This is the only point in an update that can fail and just go to the existing image. // Because we didn't write MSG_ID_HD_SET_ENTER_BOOTLOADER this should reboot to the app. // - // TODO: Don't have a good recovery for this ... - sendAppCommand(MSG_ID_REBOOT_NOW); + // This should put both into the FW bootloader, which timesout into launching the app if + // nothing else is commanded. + _package.rebootFW(); set_progress("Failed to start " + QString::fromStdString(_available[row_index].fileName)); writeLog("Failed to start " + QString::fromStdString(package_location), false);