From 97f9633e522645db2fa3eea7aea5e26feaf5bb80 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta Date: Wed, 14 Feb 2024 17:32:05 +0530 Subject: [PATCH] Added support to keep config with firmware download --- .../libbbfdm_DeviceInfo_FirmwareImage.md | 31 +++++++++++++++++++ libbbfdm/dmtree/tr181/deviceinfo.c | 12 ++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/docs/guide/libbbfdm_DeviceInfo_FirmwareImage.md b/docs/guide/libbbfdm_DeviceInfo_FirmwareImage.md index a66b1e61..b39a3c4d 100644 --- a/docs/guide/libbbfdm_DeviceInfo_FirmwareImage.md +++ b/docs/guide/libbbfdm_DeviceInfo_FirmwareImage.md @@ -108,3 +108,34 @@ If the exit code from the idle script is zero then firmware image can be activat * This document is only target for Firmware management using USP. * TimeWindow.{i}.Mode = 'ConfirmationNeeded' is not supported. + + +## Vendor extension option to keep config while firmware download + +It deployments for some customers, its required to do a factory reset after doing a firmware upgrade to start the CPE from clean state and then provision it from ACS/Controller. + +As per standard datamodel, it's at-least 2 step time consuming process: +- Download the Firmware using 'Device.DeviceInfo.FirmwareImage.{i}.Download()' operate command with AutoActivate=1 +- Wait for the 'Device.Boot!' event +- Factory reset the CPE using 'Device.FactoryReset()' +- Wait for the Boot event and then start provisioning. + +We added an addition vendor specific input option which can be used by USP controller to factoryReset the CPE along with Firmware Upgrade, with this customer can save the cost of one additional reboot, which result into faster provisioning of the CPE. + +Below are the current input options defined for Download operate command +```bash +Device.DeviceInfo.FirmwareImage.{i}.Download() +Device.DeviceInfo.FirmwareImage.{i}.Download() input:AutoActivate +Device.DeviceInfo.FirmwareImage.{i}.Download() input:CheckSum +Device.DeviceInfo.FirmwareImage.{i}.Download() input:CheckSumAlgorithm +Device.DeviceInfo.FirmwareImage.{i}.Download() input:CommandKey +Device.DeviceInfo.FirmwareImage.{i}.Download() input:FileSize +Device.DeviceInfo.FirmwareImage.{i}.Download() input:Password +Device.DeviceInfo.FirmwareImage.{i}.Download() input:URL +Device.DeviceInfo.FirmwareImage.{i}.Download() input:Username +Device.DeviceInfo.FirmwareImage.{i}.Download() input:X_IOPSYS_EU_KeepConfig +``` + +Customer can use X_IOPSYS_EU_KeepConfig=0, to do factory reset(not copy the current config to next firmware) while doing the download. + +> Note: Default value of X_IOPSYS_EU_KeepConfig is 1, so in case this option not used, it keeps the config(as the default behavior of the CPE). diff --git a/libbbfdm/dmtree/tr181/deviceinfo.c b/libbbfdm/dmtree/tr181/deviceinfo.c index d2d7f466..51776c63 100644 --- a/libbbfdm/dmtree/tr181/deviceinfo.c +++ b/libbbfdm/dmtree/tr181/deviceinfo.c @@ -662,7 +662,7 @@ static void dmubus_receive_sysupgrade(struct ubus_context *ctx, struct ubus_even static int bbf_fw_image_download(const char *url, const char *auto_activate, const char *username, const char *password, const char *file_size, const char *checksum_algorithm, const char *checksum, - const char *bank_id, const char *command, const char *obj_path, const char *commandKey) + const char *bank_id, const char *command, const char *obj_path, const char *commandKey, char *keep) { char fw_image_path[256] = "/tmp/firmware-XXXXXX"; json_object *json_obj = NULL; @@ -726,8 +726,11 @@ static int bbf_fw_image_download(const char *url, const char *auto_activate, con goto end; } + // default state is to preserve the config over firmware upgrades + char *keep_config = DM_STRLEN((char *)keep) ? keep : "1"; + // Apply Firmware Image - dmubus_call_blocking("fwbank", "upgrade", UBUS_ARGS{{"path", fw_image_path, String}, {"auto_activate", act, Boolean}, {"bank", bank_id, Integer}}, 3, &json_obj); + dmubus_call_blocking("fwbank", "upgrade", UBUS_ARGS{{"path", fw_image_path, String}, {"auto_activate", act, Boolean}, {"bank", bank_id, Integer}, {"keep_settings", keep_config, Boolean}}, 4, &json_obj); if (json_obj == NULL) { res = 1; snprintf(fault_msg, sizeof(fault_msg), "Internal error occurred when applying the firmware"); @@ -1720,6 +1723,7 @@ static operation_args firmware_image_download_args = { "CheckSumAlgorithm", "CheckSum", "CommandKey", + BBF_VENDOR_PREFIX"KeepConfig", NULL } }; @@ -1755,11 +1759,11 @@ static int operate_DeviceInfoFirmwareImage_Download(char *refparam, struct dmctx char *checksum_algorithm = dmjson_get_value((json_object *)value, 1, "CheckSumAlgorithm"); char *checksum = dmjson_get_value((json_object *)value, 1, "CheckSum"); char *commandKey = dmjson_get_value((json_object *)value, 1, "CommandKey"); - + char *keep_config = dmjson_get_value((json_object *)value, 1, BBF_VENDOR_PREFIX"KeepConfig"); char *bank_id = dmjson_get_value((json_object *)data, 1, "id"); - int res = bbf_fw_image_download(url, auto_activate, username, password, file_size, checksum_algorithm, checksum, bank_id, command, obj_path, commandKey); + int res = bbf_fw_image_download(url, auto_activate, username, password, file_size, checksum_algorithm, checksum, bank_id, command, obj_path, commandKey, keep_config); if (res == 1) { bbfdm_set_fault_message(ctx, "Firmware validation failed");