diff --git a/CHANGELOG.md b/CHANGELOG.md index 76cc5dd3..c61dae21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.1](https://github.com/rdkcentral/rdkfwupdater/compare/1.2.0...1.2.1) + +- RDKEMW-5212 Remove Test Binary from RDKFwupgrader [`#103`](https://github.com/rdkcentral/rdkfwupdater/pull/103) +- RDKEMW-876: Added MigrationStatus in JsonString for Xconf [`#94`](https://github.com/rdkcentral/rdkfwupdater/pull/94) +- Sync changes [`#98`](https://github.com/rdkcentral/rdkfwupdater/pull/98) +- RDKE-768 [platform-native container] rfc api returning garbage when reading rfc parameter [`#85`](https://github.com/rdkcentral/rdkfwupdater/pull/85) +- rebase topic branch [`#95`](https://github.com/rdkcentral/rdkfwupdater/pull/95) +- Merge tag '1.2.0' into develop [`439962c`](https://github.com/rdkcentral/rdkfwupdater/commit/439962c6d6598286480f855211d250a15b2d918f) + #### [1.2.0](https://github.com/rdkcentral/rdkfwupdater/compare/1.1.1...1.2.0) +> 7 May 2025 + - RDK-55908: [RDK-E] Data Collection Through T2 Events For Components Logging To swupdate.log [`#79`](https://github.com/rdkcentral/rdkfwupdater/pull/79) - RDKE-603 : Trigger RED state IARM event from FW download module [`#40`](https://github.com/rdkcentral/rdkfwupdater/pull/40) - RDKE-603: Rebase with Develop [`#89`](https://github.com/rdkcentral/rdkfwupdater/pull/89) @@ -13,9 +24,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - RDK-50905: Rebase with develop [`#78`](https://github.com/rdkcentral/rdkfwupdater/pull/78) - RDK-50905 - Rebase with Develop [`#67`](https://github.com/rdkcentral/rdkfwupdater/pull/67) - rebase wrt develop [`#54`](https://github.com/rdkcentral/rdkfwupdater/pull/54) +- 1.2.0 release changelog updates [`be62ae7`](https://github.com/rdkcentral/rdkfwupdater/commit/be62ae7f7f5e68b2e616fd012e0d999d908e8d2e) - Merge tag '1.1.1' into develop [`2e7cf8a`](https://github.com/rdkcentral/rdkfwupdater/commit/2e7cf8ab81efc41fae2c1a91c0278dfbc52b3568) - RDK-50905 : Trigger RED state IARM event from FW download module [`6cbc297`](https://github.com/rdkcentral/rdkfwupdater/commit/6cbc297163a127655700b9fac7b4b259959d5c05) -- Update basic_rdkv_main_gtest.cpp [`df15e89`](https://github.com/rdkcentral/rdkfwupdater/commit/df15e8997196bc8f1a470b097a8f0a29b34142f1) #### [1.1.1](https://github.com/rdkcentral/rdkfwupdater/compare/1.1.0...1.1.1) diff --git a/Makefile.am b/Makefile.am index 2c59866b..3ec845eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,8 +20,8 @@ AM_CFLAGS = $(TRACE_CFLAGS) AM_CFLAGS += -Wall -Werror $(cjson_CFLAGS) $(curl_CFLAGS) $(CFLAGS) AM_LDFLAGS = -L$(PKG_CONFIG_SYSROOT_DIR)/$(libdir) -AM_LDFLAGS += $(cjson_LIBS) $(curl_LIBS) -AM_LDFLAGS += -lrdkloggers -ldwnlutil -lfwutils -lsecure_wrapper -lparsejson -lpthread +AM_LDFLAGS += $(cjson_LIBS) $(curl_LIBS) +AM_LDFLAGS += -lrdkloggers -ldwnlutil -lfwutils -lsecure_wrapper -lparsejson -lpthread -lrbus bin_PROGRAMS= rdkvfwupgrader @@ -35,12 +35,14 @@ rdkvfwupgrader_SOURCES = \ ${top_srcdir}/src/download_status_helper.c \ ${top_srcdir}/src/iarmInterface/iarmInterface.c \ ${top_srcdir}/src/rfcInterface/rfcinterface.c \ + ${top_srcdir}/src/rbusInterface/rbusInterface.c \ ${top_srcdir}/src/deviceutils/device_api.c \ ${top_srcdir}/src/deviceutils/deviceutils.c rdkvfwupgrader_include_HEADERS = \ ${top_srcdir}/src/rfcInterface/rfcinterface.h \ ${top_srcdir}/src/iarmInterface/iarmInterface.h \ + ${top_srcdir}/src/rbusInterface/rbusInterface.h \ ${top_srcdir}/src/deviceutils/device_api.h \ ${top_srcdir}/src/deviceutils/deviceutils.h \ ${top_srcdir}/src/include/device_status_helper.h diff --git a/src/device_status_helper.c b/src/device_status_helper.c index 6583a16c..bc51e48a 100644 --- a/src/device_status_helper.c +++ b/src/device_status_helper.c @@ -1094,7 +1094,7 @@ bool checkForValidPCIUpgrade(int trigger_type, const char *myfwversion, const ch t2ValNotify("cloudFWFile_split", (char *)cloudFWFile); SWLOG_INFO("lastdwnlfile:%s\n", last_dwnl_img); SWLOG_INFO("currentImg:%s\n", current_img); - if (trigger_type == 1 || trigger_type == 4) { + if (trigger_type == 1 || trigger_type == 3 || trigger_type == 4) { if ((false == current_img_status) || (false == last_dwnl_status)) { SWLOG_INFO("Unable to fetch current running image file name or last download file\n"); SWLOG_INFO("Error identified with image file comparison !!! Proceeding with firmware version check.\n"); diff --git a/src/deviceutils/device_api.c b/src/deviceutils/device_api.c index ce7fc98a..37f316c6 100644 --- a/src/deviceutils/device_api.c +++ b/src/deviceutils/device_api.c @@ -283,6 +283,7 @@ size_t GetAdditionalFwVerInfo( char *pAdditionalFwVerInfo, size_t szBufSize ) { len += GetRemoteInfo( (pAdditionalFwVerInfo + len), (szBufSize - len) ); } + len = stripinvalidchar(pAdditionalFwVerInfo, len); // remove newline etc. } else { diff --git a/src/flash.c b/src/flash.c index c1e44695..921a4f34 100644 --- a/src/flash.c +++ b/src/flash.c @@ -17,19 +17,26 @@ */ #include +#include #include "rdkv_cdl.h" #include "rdkv_cdl_log_wrapper.h" #include "download_status_helper.h" #include "device_status_helper.h" #include "iarmInterface/iarmInterface.h" #ifndef GTEST_ENABLE +#include "urlHelper.h" +#include "json_parse.h" #include "rdk_fwdl_utils.h" #include "system_utils.h" +#include "rbusInterface/rbusInterface.h" #endif #include "rfcInterface/rfcinterface.h" #include #include "deviceutils.h" +extern int getTriggerType(); +extern void t2CountNotify(char *marker, int val); + /* Description:Use for Flashing the image * @param: server_url : server url * @param: upgrade_file : Image file to be flash @@ -138,10 +145,25 @@ int flashImage(const char *server_url, const char *upgrade_file, const char *reb snprintf(fwdls.status, sizeof(fwdls.status), "Status|Success\n"); snprintf(fwdls.FwUpdateState, sizeof(fwdls.FwUpdateState), "FwUpdateState|Validation complete\n"); snprintf(fwdls.failureReason, sizeof(fwdls.failureReason), "FailureReason|"); - if (((strncmp(maint, "true", 4)) == 0) && (0 == (strncmp(reboot_flag, "true", 4)))) { + char *pXconfCheckNow = calloc(10, sizeof(char)); + FILE *canFile = fopen("/tmp/xconfchecknow_val", "r"); + if (canFile != NULL) { + int fret = fscanf(canFile, "%9s", pXconfCheckNow); + if (fret <= 0) { + SWLOG_ERROR("Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: Error reading from file\n"); + } + fclose(canFile); + } + else { + SWLOG_INFO("Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: File does not exist\n"); + } + if (((strncmp(maint, "true", 4)) == 0) && (0 == (strncmp(reboot_flag, "true", 4))) && ((0 != strcasecmp("CANARY", pXconfCheckNow)) || (getTriggerType() != 3))) { eventManager("MaintenanceMGR", MAINT_CRITICAL_UPDATE); SWLOG_INFO("Posting Critical update"); } + if( pXconfCheckNow != NULL ) { + free(pXconfCheckNow); + } if (0 == filePresentCheck(upgrade_file)) { SWLOG_INFO("flashImage: Flashing completed. Deleting File:%s\n", upgrade_file); unlink(upgrade_file); @@ -276,6 +298,21 @@ int postFlash(const char *maint, const char *upgrade_file, int upgrade_type, con } sleep(5); sync(); + char* pXconfCheckNow = calloc(10, sizeof(char)); + if (pXconfCheckNow == NULL) { + SWLOG_ERROR("Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: CALLOC failure\n"); + return ret; + } + FILE *file = fopen("/tmp/xconfchecknow_val", "r"); + if (file != NULL) { + if (fscanf(file, "%9s", pXconfCheckNow) == EOF) { + SWLOG_ERROR("Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: Error reading file\n"); + } + fclose(file); + } + else { + SWLOG_INFO("Device_X_COMCAST_COM_Xcalibur_Client_xconfCheckNow: Error opening file for read\n"); + } if (0 != (filePresentCheck("/tmp/fw_preparing_to_reboot"))) { fp = fopen("/tmp/fw_preparing_to_reboot", "w"); if (fp == NULL) { @@ -284,7 +321,9 @@ int postFlash(const char *maint, const char *upgrade_file, int upgrade_type, con SWLOG_INFO("Creating flag for preparing to reboot event sent to AS/EPG\n"); fclose(fp); } - eventManager(FW_STATE_EVENT,FW_STATE_PREPARING_TO_REBOOT); + if ((0 != strcasecmp("CANARY", pXconfCheckNow)) || (getTriggerType() != 3)) { + eventManager(FW_STATE_EVENT,FW_STATE_PREPARING_TO_REBOOT); + } } if (upgrade_type == PDRI_UPGRADE) { SWLOG_INFO("Reboot Not Needed after PDRI Upgrade..!\n"); @@ -295,7 +334,75 @@ int postFlash(const char *maint, const char *upgrade_file, int upgrade_type, con fprintf(fp, "%s\n", upgrade_file); fclose(fp); } - if (0 == (strncmp(maint, "true", 4))) { + if ((0 == strcasecmp("CANARY", pXconfCheckNow)) && (getTriggerType() == 3)) { + + char post_data[] = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.System.getPowerState\"}"; + DownloadData DwnLoc = {NULL, 0, 0}; + JSON *pJson = NULL; + JSON *pItem = NULL; + JSON *res_val = NULL; + + if( MemDLAlloc( &DwnLoc, DEFAULT_DL_ALLOC ) == 0 ) { + if (0 != getJsonRpc(post_data, &DwnLoc)) { + SWLOG_INFO("%s :: isconnected JsonRpc call failed\n",__FUNCTION__); + free(pXconfCheckNow); + if (DwnLoc.pvOut != NULL) { + free(DwnLoc.pvOut); + } + return ret; + } + pJson = ParseJsonStr( (char *)DwnLoc.pvOut ); + if( pJson != NULL ) { + pItem = GetJsonItem( pJson, "result" ); + res_val = GetJsonItem( pItem, "powerState" ); + } + else { + SWLOG_INFO("%s :: isconnected JsonRpc response is empty\n",__FUNCTION__); + free(pXconfCheckNow); + if (DwnLoc.pvOut != NULL) { + free(DwnLoc.pvOut); + } + return ret; + } + } + + if(res_val != NULL) { + if(0 == strcasecmp("ON", res_val->valuestring)) { + SWLOG_INFO("Defer Reboot for Canary Firmware Upgrade since power state is ON\n"); + t2CountNotify("SYS_INFO_DEFER_CANARY_REBOOT", 1); + } +#ifndef GTEST_ENABLE + else { + // Call rbus method - Device.X_RDKCENTRAL-COM_T2.UploadDCMReport + if( RBUS_ERROR_SUCCESS != invokeRbusDCMReport()) { + SWLOG_ERROR("Error in uploading telemetry report\n"); + if( DwnLoc.pvOut != NULL ) { + free( DwnLoc.pvOut ); + } + if( pJson != NULL ) { + FreeJson( pJson ); + } + if ( pXconfCheckNow != NULL ) { + free(pXconfCheckNow); + } + return ret; + } + if (0 == (strncmp(reboot_flag, "true", 4))) { + SWLOG_INFO("Rebooting from RDK for Canary Firmware Upgrade\n"); + t2CountNotify("SYS_INFO_CANARY_Update", 1); + v_secure_system("sh /rebootNow.sh -s '%s' -o '%s'","CANARY_Update", "Rebooting the box from RDK for Pending Canary Firmware Upgrade..."); + } + } +#endif + } + if( DwnLoc.pvOut != NULL ) { + free( DwnLoc.pvOut ); + } + if( pJson != NULL ) { + FreeJson( pJson ); + } + } + else if (0 == (strncmp(maint, "true", 4))) { eventManager("MaintenanceMGR", MAINT_REBOOT_REQUIRED); if (0 == (strncmp(device_name, "PLATCO", 6)) && (0 == (strncmp(reboot_flag, "true", 4)))) { SWLOG_INFO("Send notification to reboot in 10mins due to critical upgrade\n"); @@ -324,5 +431,8 @@ int postFlash(const char *maint, const char *upgrade_file, int upgrade_type, con } } } + if( pXconfCheckNow != NULL ) { + free(pXconfCheckNow); + } return 0; } diff --git a/src/rbusInterface/rbusInterface.c b/src/rbusInterface/rbusInterface.c new file mode 100644 index 00000000..40abddfc --- /dev/null +++ b/src/rbusInterface/rbusInterface.c @@ -0,0 +1,69 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef GTEST_ENABLE +#include +#include "rbusInterface.h" + +/* Description:Use for Rbus callback + * @param: handle : rbus handle + * @param: methodName : Method name + * @param: error : rbus return value type + * @param: param : rbus object + * @return void : NA + * */ +static void t2EventHandler(rbusHandle_t handle, char const* methodName, rbusError_t error, rbusObject_t param) +{ + SWLOG_INFO("Got %s rbus callback\n", methodName); + if (RBUS_ERROR_SUCCESS == error) + { + rbusValue_t uploadStatus = rbusObject_GetValue(param, "UPLOAD_STATUS"); + if(uploadStatus) + { + SWLOG_INFO("Device.X_RDKCENTRAL-COM_T2.UploadDCMReport Upload Status = %s\n", rbusValue_GetString(uploadStatus, NULL)); + } + } +} + +/* Description: Trigger T2 upload + * @return rbusError_t : Return SUCCESS/FAILURE + * */ +rbusError_t invokeRbusDCMReport() +{ + rbusHandle_t rdkfwRbusHandle; + if (RBUS_ERROR_SUCCESS == rbus_open(&rdkfwRbusHandle, RDKFWUPGRADER_RBUS_HANDLE_NAME)) { + if (RBUS_ERROR_SUCCESS == rbusMethod_InvokeAsync(rdkfwRbusHandle, T2_UPLOAD, NULL, t2EventHandler, 0)) { + SWLOG_INFO("Waiting 60 sec to complete upload from Device.X_RDKCENTRAL-COM_T2.UploadDCMReport\n"); + sleep(60); + } + else { + SWLOG_ERROR("Error in calling Device.X_RDKCENTRAL-COM_T2.UploadDCMReport\n"); + return RBUS_ERROR_BUS_ERROR; + } + } + else { + SWLOG_ERROR("Error in opening rbus handle\n"); + return RBUS_ERROR_BUS_ERROR; + } + if (RBUS_ERROR_SUCCESS != rbus_close(rdkfwRbusHandle)) { + SWLOG_ERROR("Rbus termination failed\n"); + return RBUS_ERROR_BUS_ERROR; + } + return RBUS_ERROR_SUCCESS; +} +#endif diff --git a/src/rbusInterface/rbusInterface.h b/src/rbusInterface/rbusInterface.h new file mode 100644 index 00000000..f77a79ea --- /dev/null +++ b/src/rbusInterface/rbusInterface.h @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef GTEST_ENABLE +#include "rbus/rbus.h" +#include "rdkv_cdl_log_wrapper.h" + +#define RDKFWUPGRADER_RBUS_HANDLE_NAME "rdkfwRbus" +#define T2_UPLOAD "Device.X_RDKCENTRAL-COM_T2.UploadDCMReport" + +rbusError_t invokeRbusDCMReport(); +#endif diff --git a/src/rdkv_main.c b/src/rdkv_main.c index 4ff86117..5f71e2d5 100644 --- a/src/rdkv_main.c +++ b/src/rdkv_main.c @@ -86,6 +86,15 @@ static pthread_mutex_t app_mode_status = PTHREAD_MUTEX_INITIALIZER; static int app_mode = 1; // 1: fore ground and 0: background int force_exit = 0; //This use when rdkvfwupgrader rcv appmode background and thottle speed is set to zero. +/* Description: Get trigger type info. + * @param: NA + * @return: int + * */ +int getTriggerType() +{ + return trigger_type; +} + /* Description: Set App mode. * @param: state : set state * @return: void diff --git a/src/rfcInterface/rfcinterface.h b/src/rfcInterface/rfcinterface.h index f7085343..24fcf37b 100644 --- a/src/rfcInterface/rfcinterface.h +++ b/src/rfcInterface/rfcinterface.h @@ -87,6 +87,8 @@ typedef struct rfcdetails { #define RFC_FW_AUTO_EXCLUDE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.FWUpdate.AutoExcluded.Enable" #define RFC_DEBUGSRV "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Identity.DbgServices.Enable" +#define RFC_XCONF_CHECK_NOW "Device.X_COMCAST-COM_Xcalibur.Client.xconfCheckNow" + int getRFCSettings(Rfc_t *rfc_list); int read_RFCProperty(char* type, const char* key, char *data, size_t datasize);