From 1870facf5636ee237b217c5950bb64597ee21a51 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 29 May 2020 22:14:22 +0300 Subject: Quectel Delta Radio Firmware Upgrade support - radio-cmd implementation Implemented a command for delta radio firmware upgrade file uploads. --- main.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 5169d4e..8ac634d 100644 --- a/main.cpp +++ b/main.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "Version.h" const std::string DEFAULT_PORT("/dev/modem_at1"); @@ -68,6 +70,7 @@ std::string g_sConfigFile; Json::Value g_jData; std::string g_sSimPin; std::string g_sCellularMode; +std::string g_sDeltaFwPath; MTS::AutoPtr g_apRadio; @@ -108,6 +111,8 @@ const uint32_t OPT_SET_CELLULAR_MODE = 0x08000000; const uint32_t OPT_UNLOCK_SIM_CARD = 0x20000000; const uint32_t OPT_RESET_RADIO = 0x40000000; +int32_t g_iAuxOptions = 0; +const uint32_t AOPT_DFU_UPLOAD = 0x00000001; void handle_sigterm(int signum); void printHelp(const std::string& sApp); @@ -152,11 +157,13 @@ static struct option long_options[] = { { "init-activation", no_argument, &iOption, OPT_INIT_ACTIVATION }, { "factory-default", no_argument, &iOption, OPT_INIT_RTN }, { "set-cellular-mode", required_argument, 0, 'w' }, + { "delta-fwu-upload", required_argument, 0, 'x' }, { 0, 0, 0, 0 } }; Json::Value getStaticData(); Json::Value getNetworkData(); +MTS::IO::ICellularRadio::CODE handleDeltaFwUpload(const std::string& sPath); MTS::IO::ICellularRadio::UpdateCb cb = [](const Json::Value& s)->void { if(s.isString()) { @@ -386,6 +393,8 @@ int main(int argc, char** argv) { } else { printf("Invalid argument: %s\n", g_sCellularMode.c_str()); } + } else if (g_iAuxOptions & AOPT_DFU_UPLOAD) { + result = handleDeltaFwUpload(g_sDeltaFwPath); } shutdown(); @@ -606,6 +615,12 @@ void parseOptions(int argc, char** argv) g_iOptions |= OPT_SET_CELLULAR_MODE; break; + case 'x': + if (optarg) + g_sDeltaFwPath = optarg; + g_iAuxOptions |= AOPT_DFU_UPLOAD; + break; + default: printf("OPTION: [%d] ABORTING!!\n", c); abort(); @@ -656,13 +671,14 @@ void printHelp(const std::string& sApp) { printf("\t--factory-default [ --msl ] : reset to factory defaults\n"); printf("\t--unlock-sim-card : unlock the SIM card using the PIN code provided\n"); printf("\t--reset-radio : reset the radio module using AT commands\n"); + printf("\t--delta-fwu-upload : upload a delta radio FWU file to the radio\n"); printf("\n"); printf("\t--printlvl (p) : sets the printlvl [0-100]\n"); printf("\t--version (v) : returns version\n"); printf("\t--help (?) : returns this message\n"); printf("\n"); printf("\tSupported Radios:\n"); - printf("\t\tLE910, HE910, GE910, DE910, CE910\n"); + printf("\t\tLE910, HE910, GE910, DE910, CE910, ME910, EG95\n"); } const char *code2str(MTS::IO::ICellularRadio::CODE code) { @@ -704,3 +720,16 @@ MTS::IO::ICellularRadio::CELLULAR_MODES cellularModeFlags(const std::string netw } return static_cast(result); } + +MTS::IO::ICellularRadio::CODE handleDeltaFwUpload(const std::string& sPath) { + int fd = open(sPath.c_str(), O_RDONLY); + if (fd < 0) { + printf("Failed to open file [%s]: %d\n", sPath.c_str(), errno); + return MTS::IO::ICellularRadio::CODE::ERROR; + } + + auto rc = g_apRadio->uploadDeltaFirmwareFile(fd, cb); + close(fd); + + return rc; +} -- cgit v1.2.3 From 5096792c46621b03572f406262dc3c7d855981bf Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Wed, 1 Jul 2020 11:34:34 +0300 Subject: [GP-675] Quectel Delta Radio Firmware Upgrade support - radio-cmd implementation Added an option to apply the delta upgrade file that was previously uploaded to the radio. --- main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.cpp b/main.cpp index ba8b268..eadf51b 100644 --- a/main.cpp +++ b/main.cpp @@ -114,6 +114,7 @@ const uint32_t OPT_RESET_RADIO = 0x40000000; int32_t g_iAuxOptions = 0; const uint32_t AOPT_OMA_DM_START = 0x00000001; const uint32_t AOPT_DFU_UPLOAD = 0x00000002; +const uint32_t AOPT_DFU_APPLY = 0x00000004; void handle_sigterm(int signum); void printHelp(const std::string& sApp); @@ -160,6 +161,7 @@ static struct option long_options[] = { { "set-cellular-mode", required_argument, 0, 'w' }, { "start-oma-dm", no_argument, 0, 'o' }, { "delta-fwu-upload", required_argument, 0, 'x' }, + { "delta-fwu-apply", no_argument, 0, 'F' }, { 0, 0, 0, 0 } }; @@ -399,6 +401,8 @@ int main(int argc, char** argv) { result = g_apRadio->startOmaDm(cb); } else if (g_iAuxOptions & AOPT_DFU_UPLOAD) { result = handleDeltaFwUpload(g_sDeltaFwPath); + } else if (g_iAuxOptions & AOPT_DFU_APPLY) { + result = g_apRadio->applyDeltaFirmwareFile(cb); } shutdown(); @@ -629,6 +633,10 @@ void parseOptions(int argc, char** argv) g_iAuxOptions |= AOPT_DFU_UPLOAD; break; + case 'F': + g_iAuxOptions |= AOPT_DFU_APPLY; + break; + default: printf("OPTION: [%d] ABORTING!!\n", c); abort(); @@ -681,6 +689,7 @@ void printHelp(const std::string& sApp) { printf("\t--reset-radio : reset the radio module using AT commands\n"); printf("\t--start-oma-dm : start the OMA DM procedure (selected radios and networks only)\n"); printf("\t--delta-fwu-upload : upload a delta radio FWU file to the radio\n"); + printf("\t--delta-fwu-apply : apply the delta radio FWU image that was already uploaded to the radio\n"); printf("\n"); printf("\t--printlvl (p) : sets the printlvl [0-100]\n"); printf("\t--version (v) : returns version\n"); -- cgit v1.2.3 From c992d0507a6018b0214011940f15c4780c9dccb2 Mon Sep 17 00:00:00 2001 From: Serhii Kostiuk Date: Fri, 3 Jul 2020 22:13:13 +0300 Subject: [GP-675] Quectel Delta Radio Firmware Upgrade support - radio-cmd implementation Switched to the new "updateFumoLocal" function as a replacement for the "uploadDeltaFile" and "applyDeltaFile". --- main.cpp | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index eadf51b..3ec00db 100644 --- a/main.cpp +++ b/main.cpp @@ -115,6 +115,7 @@ int32_t g_iAuxOptions = 0; const uint32_t AOPT_OMA_DM_START = 0x00000001; const uint32_t AOPT_DFU_UPLOAD = 0x00000002; const uint32_t AOPT_DFU_APPLY = 0x00000004; +const uint32_t AOPT_FUMO_LOCAL = 0x00000008; void handle_sigterm(int signum); void printHelp(const std::string& sApp); @@ -161,13 +162,15 @@ static struct option long_options[] = { { "set-cellular-mode", required_argument, 0, 'w' }, { "start-oma-dm", no_argument, 0, 'o' }, { "delta-fwu-upload", required_argument, 0, 'x' }, - { "delta-fwu-apply", no_argument, 0, 'F' }, + { "delta-fwu-apply", no_argument, 0, 'A' }, + { "init-fumo-local", required_argument, 0, 'F' }, { 0, 0, 0, 0 } }; Json::Value getStaticData(); Json::Value getNetworkData(); MTS::IO::ICellularRadio::CODE handleDeltaFwUpload(const std::string& sPath); +MTS::IO::ICellularRadio::CODE handleFumoLocal(const std::string& sPath); MTS::IO::ICellularRadio::UpdateCb cb = [](const Json::Value& s)->void { if(s.isString()) { @@ -402,7 +405,9 @@ int main(int argc, char** argv) { } else if (g_iAuxOptions & AOPT_DFU_UPLOAD) { result = handleDeltaFwUpload(g_sDeltaFwPath); } else if (g_iAuxOptions & AOPT_DFU_APPLY) { - result = g_apRadio->applyDeltaFirmwareFile(cb); + result = g_apRadio->fumoLocalApply(cb); + } else if (g_iAuxOptions & AOPT_FUMO_LOCAL) { + result = handleFumoLocal(g_sDeltaFwPath); } shutdown(); @@ -633,10 +638,16 @@ void parseOptions(int argc, char** argv) g_iAuxOptions |= AOPT_DFU_UPLOAD; break; - case 'F': + case 'A': g_iAuxOptions |= AOPT_DFU_APPLY; break; + case 'F': + if (optarg) + g_sDeltaFwPath = optarg; + g_iAuxOptions |= AOPT_FUMO_LOCAL; + break; + default: printf("OPTION: [%d] ABORTING!!\n", c); abort(); @@ -688,8 +699,10 @@ void printHelp(const std::string& sApp) { printf("\t--unlock-sim-card : unlock the SIM card using the PIN code provided\n"); printf("\t--reset-radio : reset the radio module using AT commands\n"); printf("\t--start-oma-dm : start the OMA DM procedure (selected radios and networks only)\n"); - printf("\t--delta-fwu-upload : upload a delta radio FWU file to the radio\n"); - printf("\t--delta-fwu-apply : apply the delta radio FWU image that was already uploaded to the radio\n"); + printf("\t--init-fumo-local : perform the radio firmware upgrade using the provided image file\n"); + // Undocumented: use for debugging and testing purposes + // printf("\t--delta-fwu-upload : upload a delta radio FWU file to the radio\n"); + // printf("\t--delta-fwu-apply : apply the delta radio FWU image that was already uploaded to the radio\n"); printf("\n"); printf("\t--printlvl (p) : sets the printlvl [0-100]\n"); printf("\t--version (v) : returns version\n"); @@ -746,7 +759,21 @@ MTS::IO::ICellularRadio::CODE handleDeltaFwUpload(const std::string& sPath) { return MTS::IO::ICellularRadio::CODE::ERROR; } - auto rc = g_apRadio->uploadDeltaFirmwareFile(fd, cb); + auto rc = g_apRadio->fumoLocalInject(fd, cb); + close(fd); + + return rc; +} + + +MTS::IO::ICellularRadio::CODE handleFumoLocal(const std::string& sPath) { + int fd = open(sPath.c_str(), O_RDONLY); + if (fd < 0) { + printf("FUMO Error: failed to open file [%s]: %d\n", sPath.c_str(), errno); + return MTS::IO::ICellularRadio::CODE::ERROR; + } + + auto rc = g_apRadio->updateFumoLocal(fd, cb); close(fd); return rc; -- cgit v1.2.3