From 656de28c6e05f3589aeb0a6eb711026ba83e6641 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Tue, 2 Jun 2026 10:24:39 +0000 Subject: [PATCH 01/10] RDKC-16494: XHC1 crashupload support --- c_sourcecode/common/types.h | 1 + c_sourcecode/configure.ac | 2 +- c_sourcecode/rdk_build.sh | 201 +++++++++++++++++++ c_sourcecode/src/archive/archive.c | 33 +++ c_sourcecode/src/config/config_manager.c | 21 ++ c_sourcecode/src/rfcInterface/rfcinterface.c | 56 +++++- c_sourcecode/src/rfcInterface/rfcinterface.h | 20 +- c_sourcecode/src/upload/upload.c | 19 ++ c_sourcecode/src/utils/prerequisites.c | 2 +- 9 files changed, 348 insertions(+), 7 deletions(-) create mode 100755 c_sourcecode/rdk_build.sh diff --git a/c_sourcecode/common/types.h b/c_sourcecode/common/types.h index 463f6c4..a7e7258 100644 --- a/c_sourcecode/common/types.h +++ b/c_sourcecode/common/types.h @@ -51,6 +51,7 @@ typedef enum { DEVICE_TYPE_VIDEO, DEVICE_TYPE_EXTENDER, DEVICE_TYPE_MEDIACLIENT, + DEVICE_TYPE_XHC1, DEVICE_TYPE_UNKNOWN } device_type_t; diff --git a/c_sourcecode/configure.ac b/c_sourcecode/configure.ac index 2243f90..19d08c0 100644 --- a/c_sourcecode/configure.ac +++ b/c_sourcecode/configure.ac @@ -47,7 +47,7 @@ AC_FUNC_MALLOC AC_CHECK_FUNCS([gettimeofday memset strchr strdup strerror]) # Compiler flags -CFLAGS="$CFLAGS -Wall -Werror -O2 -DT2_EVENT_ENABLED" +CFLAGS="$CFLAGS -Wall -Werror -O2" #CFLAGS="$CFLAGS -Wall -Werror -O2 -std=c11" #CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200809L" diff --git a/c_sourcecode/rdk_build.sh b/c_sourcecode/rdk_build.sh new file mode 100755 index 0000000..2baa183 --- /dev/null +++ b/c_sourcecode/rdk_build.sh @@ -0,0 +1,201 @@ +#!/bin/bash +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2025 RDK Management +# +# 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. +########################################################################## + +####################################### +# +# Build Framework standard script for +# +# crashupload C binary component + +# use -e to fail on any shell issue +# -e is the requirement from Build Framework +set -ex + +# default PATHs - use `man readlink` for more info +# the path to combined build +export RDK_PROJECT_ROOT_PATH="${RDK_PROJECT_ROOT_PATH-$(readlink -m ..)}" +export COMBINED_ROOT="$RDK_PROJECT_ROOT_PATH" + +# path to build script (this script) +export RDK_SCRIPTS_PATH="${RDK_SCRIPTS_PATH-$(readlink -m "$0" | xargs dirname)}" + +# path to components sources and target +export RDK_SOURCE_PATH="${RDK_SOURCE_PATH-$RDK_SCRIPTS_PATH}" +export RDK_TARGET_PATH="${RDK_TARGET_PATH-$RDK_SOURCE_PATH}" + +# fsroot and toolchain (valid for all devices) +export RDK_FSROOT_PATH="${RDK_FSROOT_PATH-$(readlink -m "$RDK_PROJECT_ROOT_PATH/sdk/fsroot/ramdisk")}" +export RDK_TOOLCHAIN_PATH="${RDK_TOOLCHAIN_PATH-$(readlink -m "$RDK_PROJECT_ROOT_PATH/sdk/toolchain/arm-linux-gnueabihf")}" + +# default component name +export RDK_COMPONENT_NAME="${RDK_COMPONENT_NAME-$(basename "$RDK_SOURCE_PATH")}" + +# Setup cross-compilation toolchain +if [ -f ${RDK_PROJECT_ROOT_PATH}/build/components/amba/sdk/setenv2 ]; then + source ${RDK_PROJECT_ROOT_PATH}/build/components/amba/sdk/setenv2 +else + export CC=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-gcc + export CXX=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-g++ + export AR=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-ar + export LD=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-ld + export NM=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-nm + export RANLIB=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-ranlib + export STRIP=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-strip + export LINK=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-g++ +fi + +# parse arguments +INITIAL_ARGS=$@ + +function usage() +{ + set +x + echo "Usage: $(basename "$0") [-h|--help] [-v|--verbose] [action]" + echo " -h --help : this help" + echo " -v --verbose : verbose output" + echo + echo "Supported actions:" + echo " configure, clean, build (DEFAULT), rebuild, install" +} + +# options may be followed by one colon to indicate they have a required argument +if ! GETOPT=$(getopt -n "build.sh" -o hv -l help,verbose -- "$@") +then + usage + exit 1 +fi + +eval set -- "$GETOPT" + +while true; do + case "$1" in + -h | --help ) usage; exit 0 ;; + -v | --verbose ) set -x ;; + -- ) shift; break;; + * ) break;; + esac + shift +done + +ARGS=$@ + +# functional modules +function configure() +{ + pd=$(pwd) + cd ${RDK_SOURCE_PATH} + + aclocal + libtoolize --automake + autoheader + automake --foreign --add-missing + rm -f configure + autoconf + + configure_options="--host=arm-linux --target=arm-linux" + + export CFLAGS="${CFLAGS} -I${RDK_FSROOT_PATH}/usr/include \ + -I${RDK_FSROOT_PATH}/usr/include/rbus \ + -I${RDK_FSROOT_PATH}/usr/include/rfc \ + -I${RDK_PROJECT_ROOT_PATH}/common_utilities/dwnlutils \ + -I${RDK_PROJECT_ROOT_PATH}/common_utilities/parsejson \ + -I${RDK_PROJECT_ROOT_PATH}/common_utilities/utils" + + export LDFLAGS="${LDFLAGS} -L${RDK_FSROOT_PATH}/usr/lib \ + -Wl,-rpath-link,${RDK_FSROOT_PATH}/usr/lib \ + -lrdkloggers -ldwnlutil -lfwutils -lsecure_wrapper -lparsejson \ + -lpthread -lcrypto -larchive -lrfcapi -ltelemetry_msgsender \ + -lt2utils -lrbus -lcurl" + + ./configure --prefix=${RDK_FSROOT_PATH}/usr --sysconfdir=${RDK_FSROOT_PATH}/etc $configure_options + + cd $pd +} + +function clean() +{ + pd=$(pwd) + cd ${RDK_SOURCE_PATH} + if [ -f Makefile ]; then + make distclean-am + make clean + fi + rm -f configure + rm -rf aclocal.m4 autom4te.cache config.log config.status libtool + find . -iname "Makefile.in" -exec rm -f {} \; + find . -iname "Makefile" | xargs rm -f + cd $pd +} + +function build() +{ + cd ${RDK_SOURCE_PATH} + make +} + +function rebuild() +{ + clean + configure + build +} + +function install() +{ + cd ${RDK_SOURCE_PATH} + + # Install the crashupload binary + mkdir -p $RDK_FSROOT_PATH/usr/bin + install -m 0755 src/crashupload $RDK_FSROOT_PATH/usr/bin/crashupload + + # Install the shell script as fallback + mkdir -p $RDK_FSROOT_PATH/lib/rdk + if [ -f ${RDK_SOURCE_PATH}/../uploadDumps.sh ]; then + install -m 0755 ${RDK_SOURCE_PATH}/../uploadDumps.sh $RDK_FSROOT_PATH/lib/rdk/uploadDumps.sh + fi + + # Install RFC defaults + CPC_PATH=${CPC_PATH-$RDK_PROJECT_ROOT_PATH/cpg-utils} + if [ -f "$CPC_PATH/rfcdefaults/crashupload.ini" ]; then + mkdir -p $RDK_FSROOT_PATH/etc/rfcdefaults + install -m 0644 $CPC_PATH/rfcdefaults/crashupload.ini $RDK_FSROOT_PATH/etc/rfcdefaults/crashupload.ini + fi +} + +# run the logic +HIT=false + +for i in "$ARGS"; do + case $i in + configure) HIT=true; configure ;; + clean) HIT=true; clean ;; + build) HIT=true; build ;; + rebuild) HIT=true; rebuild ;; + install) HIT=true; install ;; + *) + #skip unknown + ;; + esac +done + +# Default action - build +if ! $HIT; then + build +fi diff --git a/c_sourcecode/src/archive/archive.c b/c_sourcecode/src/archive/archive.c index a59f8c9..5896c19 100644 --- a/c_sourcecode/src/archive/archive.c +++ b/c_sourcecode/src/archive/archive.c @@ -396,6 +396,39 @@ int archive_create_smart(const dump_file_t *dump, const config_t *config, CRASHUPLOAD_INFO("core log file=%s\n", arch_files_list[2]); tar_status = create_tarball(true, target_file_name, arch_files_list, no_of_files); } + else if (config->device_type == DEVICE_TYPE_XHC1) + { + /* XHC1 (RDKC Camera) minidump archive: + * Matches script uploadDumps.sh line 917 for DEVICE_TYPE=XHC1 + * Archive: dumpName + version.txt + core_log.txt + * Non-prod: also receiver.log and thread.log if present + */ + snprintf(arch_files_list[0], 256, "%s", new_dump_name); + snprintf(arch_files_list[1], 256, "%s", "/version.txt"); + snprintf(arch_files_list[2], 256, "%s", config->core_log_file); + + if (config->build_type != BUILD_TYPE_PROD) + { + char receiver_log[64] = {0}; + char thread_log[64] = {0}; + snprintf(receiver_log, sizeof(receiver_log), "%s/receiver.log", config->log_path); + snprintf(thread_log, sizeof(thread_log), "%s/thread.log", config->log_path); + if (0 == (filePresentCheck(receiver_log))) + { + snprintf(arch_files_list[no_of_files], 256, "%s", receiver_log); + CRASHUPLOAD_INFO("XHC1 adding receiver.log=%s\n", arch_files_list[no_of_files]); + no_of_files++; + } + if (0 == (filePresentCheck(thread_log))) + { + snprintf(arch_files_list[no_of_files], 256, "%s", thread_log); + CRASHUPLOAD_INFO("XHC1 adding thread.log=%s\n", arch_files_list[no_of_files]); + no_of_files++; + } + } + CRASHUPLOAD_INFO("XHC1 tar file:%s files=%d\n", target_file_name, no_of_files); + tar_status = create_tarball(true, target_file_name, arch_files_list, no_of_files); + } } if (!tar_status) { diff --git a/c_sourcecode/src/config/config_manager.c b/c_sourcecode/src/config/config_manager.c index 32a60c6..7b42710 100644 --- a/c_sourcecode/src/config/config_manager.c +++ b/c_sourcecode/src/config/config_manager.c @@ -123,6 +123,13 @@ int config_init_load(config_t *config, int argc, char *argv[]) config->device_type = DEVICE_TYPE_EXTENDER; strcpy(config->core_log_file, "/var/log/messages"); } + else if (0 == (strncmp(device_prop_data, "XHC1", 4))) + { + config->device_type = DEVICE_TYPE_XHC1; + CRASHUPLOAD_INFO("device type XHC1=%d\n", config->device_type); + snprintf(config->core_log_file, sizeof(config->core_log_file), "%s/%s", log_path, "core_log.txt"); + CRASHUPLOAD_INFO("core log=%s\n", config->core_log_file); + } else { config->device_type = DEVICE_TYPE_UNKNOWN; @@ -147,6 +154,20 @@ int config_init_load(config_t *config, int argc, char *argv[]) strcpy(config->core_path, "/var/lib/systemd/coredump"); strcpy(config->minidump_path, "/opt/minidumps"); } + /* Override paths for non-systemd RDKC camera (XHC1) */ + if (config->upload_mode == UPLOAD_MODE_NORMAL && + config->device_type == DEVICE_TYPE_XHC1) + { + strcpy(config->core_path, "/opt/corefiles"); + /* minidump_path remains /opt/minidumps - already correct for RDKC */ + } + /* BOX_TYPE fallback for RDKC camera (no BOX_TYPE in device.properties) */ + if (strcmp(config->box_type, "UNKNOWN") == 0 && + config->device_type == DEVICE_TYPE_XHC1) + { + strcpy(config->box_type, "xcam"); + CRASHUPLOAD_INFO("BOX_TYPE defaulted to xcam for XHC1\n"); + } if (argc >= 3) { if (0 == atoi(argv[2])) diff --git a/c_sourcecode/src/rfcInterface/rfcinterface.c b/c_sourcecode/src/rfcInterface/rfcinterface.c index 30f55f5..87adfec 100644 --- a/c_sourcecode/src/rfcInterface/rfcinterface.c +++ b/c_sourcecode/src/rfcInterface/rfcinterface.c @@ -24,13 +24,61 @@ #endif #if defined(RFC_API_ENABLED) + +#if defined(RDKC) +/* RDKC uses 2-param getRFCParameter that reads from ini files. + * Returns int: SUCCESS(0) or FAILURE(1). No setRFCParameter available. */ +int read_RFCProperty(const char *type, const char *key, char *out_value, size_t datasize) +{ + RFC_ParamData_t param; + int data_len; + int ret = READ_RFC_FAILURE; + + if (key == NULL || out_value == NULL || datasize == 0) + { + CRASHUPLOAD_ERROR("read_RFCProperty() one or more input values are invalid\n"); + return ret; + } + int status = getRFCParameter(key, ¶m); + if (status == SUCCESS) + { + data_len = strlen(param.value); + if (data_len >= 2 && (param.value[0] == '"') && (param.value[data_len - 1] == '"')) + { + // remove quotes around data + snprintf(out_value, datasize, "%s", ¶m.value[1]); + *(out_value + data_len - 2) = 0; + } + else + { + snprintf(out_value, datasize, "%s", param.value); + } + CRASHUPLOAD_INFO("read_RFCProperty() name=%s,value=%s\n", param.name, param.value); + ret = READ_RFC_SUCCESS; + } + else + { + CRASHUPLOAD_ERROR("error:read_RFCProperty(): status=%d key=%s\n", status, key); + *out_value = 0; + } + return ret; +} + +int write_RFCProperty(const char *type, const char *key, const char *value, RFCVALDATATYPE datatype) +{ + /* RDKC rfcapi does not support setRFCParameter */ + CRASHUPLOAD_INFO("%s: Not supported on RDKC\n", __FUNCTION__); + return WRITE_RFC_NOTAPPLICABLE; +} + +#else /* !RDKC — Standard STB path (3-param version with WDMP_STATUS) */ /* Description: Reading rfc data * @param type : rfc type * @param key: rfc key * @param data : Store rfc value * @return int 1 READ_RFC_SUCCESS on success and READ_RFC_FAILURE -1 on failure * */ -int read_RFCProperty(char *type, const char *key, char *out_value, size_t datasize) +int read_RFCProperty(const char *type, const char *key, char *out_value, size_t datasize) { RFC_ParamData_t param; int data_len; @@ -74,7 +122,7 @@ int read_RFCProperty(char *type, const char *key, char *out_value, size_t datasi * @param datatype: data type of value parameter * @return int 1 WRITE_RFC_SUCCESS on success and WRITE_RFC_FAILURE -1 on failure * */ -int write_RFCProperty(char *type, const char *key, const char *value, RFCVALDATATYPE datatype) +int write_RFCProperty(const char *type, const char *key, const char *value, RFCVALDATATYPE datatype) { WDMP_STATUS status = WDMP_FAILURE; int ret = WRITE_RFC_FAILURE; @@ -106,7 +154,9 @@ int write_RFCProperty(char *type, const char *key, const char *value, RFCVALDATA } return ret; } -#else +#endif /* RDKC */ + +#else /* !RFC_API_ENABLED */ /* Description: Below function should be implement Reading rfc data for RDK-M * @param type : rfc type * @param key: rfc key diff --git a/c_sourcecode/src/rfcInterface/rfcinterface.h b/c_sourcecode/src/rfcInterface/rfcinterface.h index c0e3f80..77e2e4d 100644 --- a/c_sourcecode/src/rfcInterface/rfcinterface.h +++ b/c_sourcecode/src/rfcInterface/rfcinterface.h @@ -24,9 +24,25 @@ // platforms without this api or an alternative interface such as rbus or ccspbus or xmidt #if defined(RFC_API_ENABLED) #ifndef GTEST_ENABLE +#if defined(RDKC) +/* RDKC rfcapi: 2-param ini-file-based API (from rfc-fork). + * We declare the interface directly to avoid rfcapi.h header issues + * (header declares 3-param WDMP_STATUS version but library exports 2-param int). */ +#ifndef MAX_PARAM_LEN +#define MAX_PARAM_LEN (2*1024) +#endif +typedef enum { SUCCESS=0, FAILURE, NONE, EMPTY } DATA_TYPE; +typedef struct _RFC_Param_t { + char name[MAX_PARAM_LEN]; + char value[MAX_PARAM_LEN]; + DATA_TYPE type; +} RFC_ParamData_t; +int getRFCParameter(const char* pcParameterName, RFC_ParamData_t *pstParamData); +#else #include "rfcapi.h" #endif #endif +#endif #include #include @@ -75,8 +91,8 @@ typedef enum #define RFC_CRASH_PORTAL_ENDPOINT_URL "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.CrashportalEndpoint.URL" #if defined(RFC_API_ENABLED) -int read_RFCProperty(char *type, const char *key, char *data, size_t datasize); -int write_RFCProperty(char *type, const char *key, const char *data, RFCVALDATATYPE datatype); +int read_RFCProperty(const char *type, const char *key, char *data, size_t datasize); +int write_RFCProperty(const char *type, const char *key, const char *data, RFCVALDATATYPE datatype); #else int read_RFCProperty(const char *type, const char *key, char *data, size_t datasize); int write_RFCProperty(const char *type, const char *key, const char *data, RFCVALDATATYPE datatype); diff --git a/c_sourcecode/src/upload/upload.c b/c_sourcecode/src/upload/upload.c index 34c9154..a279c71 100644 --- a/c_sourcecode/src/upload/upload.c +++ b/c_sourcecode/src/upload/upload.c @@ -422,6 +422,25 @@ int upload_process(archive_info_t *archive, const config_t *config, const platfo CRASHUPLOAD_INFO("Read rfc Success crashportalEndpointUrl:\n Overriding the S3 Amazon Signing URL:%s\n", crashportalEndpointUrl); } } + else if (config->device_type == DEVICE_TYPE_XHC1) + { + /* XHC1 (RDKC Camera) upload flow: + * Matches script uploadDumps.sh - encryptionEnable=false (no /etc/os-release) + * S3 URL from device.properties S3_AMAZON_SIGNING_URL + * Portal URL: crashportal.stb.r53.xcal.tv + */ + strcpy(encryptionEnable, "false"); + strcpy(portal_url, "crashportal.stb.r53.xcal.tv"); + request_type = 17; + CRASHUPLOAD_INFO("XHC1: request_type=%d\n", request_type); + ret = get_crashupload_s3signed_url(crashportalEndpointUrl, sizeof(crashportalEndpointUrl)); + if (ret < 0) + { + CRASHUPLOAD_ERROR("XHC1: Unable to get the S3 server url. So exit\n"); + return ret; + } + CRASHUPLOAD_INFO("XHC1: S3 signing URL=%s\n", crashportalEndpointUrl); + } else if (config->device_type == DEVICE_TYPE_BROADBAND) { ret = -1; diff --git a/c_sourcecode/src/utils/prerequisites.c b/c_sourcecode/src/utils/prerequisites.c index 2c365f8..84351b7 100644 --- a/c_sourcecode/src/utils/prerequisites.c +++ b/c_sourcecode/src/utils/prerequisites.c @@ -44,7 +44,7 @@ void defer_upload_if_needed(device_type_t device_type) { int ret = -1; - if (device_type == DEVICE_TYPE_MEDIACLIENT) + if (device_type == DEVICE_TYPE_MEDIACLIENT || device_type == DEVICE_TYPE_XHC1) { FILE *fp = fopen(UPTIME_FILE, "r"); if (!fp) From 88f543eced857afdeeb0c13530f92533f5807de0 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Tue, 9 Jun 2026 15:13:08 +0000 Subject: [PATCH 02/10] RDKC-16494: Fix mtls upload failure & get partnerid --- c_sourcecode/src/upload/upload.c | 65 ++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/c_sourcecode/src/upload/upload.c b/c_sourcecode/src/upload/upload.c index a279c71..0a98538 100644 --- a/c_sourcecode/src/upload/upload.c +++ b/c_sourcecode/src/upload/upload.c @@ -26,6 +26,8 @@ #include "common_device_api.h" #endif #include "mtls_upload.h" +#include "uploadUtil.h" +#include "downloadUtil.h" #include "upload_status.h" #include "ratelimit.h" #include @@ -37,6 +39,10 @@ #define RETRY_DELAY_SECONDS 5 #define SIZE_POSTFIELD_BUF 2048 +#ifdef RDKC +#define RDKC_PARTNER_ID_FILE "/opt/usr_config/partnerid.txt" +#endif + #if 0 /* FULL IMPLEMENTATION - Progress callback for upload monitoring */ static int upload_progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, @@ -61,7 +67,7 @@ int get_crashupload_s3signed_url(char *url, size_t size_buf) ret = read_RFCProperty("S3SignedUrl", RFC_CRASHUPLOAD_S3URL, url, size_buf); if ((ret == READ_RFC_FAILURE) || (url[0] == '\0')) { - CRASHUPLOAD_WARN("Read rfc failed For S3SignedUrl. Reading From device.properies file\n"); + CRASHUPLOAD_WARN("Read rfc failed For S3SignedUrl. Reading From device.properties file\n"); ret = getDevicePropertyData("S3_AMAZON_SIGNING_URL", url, size_buf); if (ret == UTILS_SUCCESS) { @@ -220,12 +226,39 @@ int upload_file(const char *filepath, const char *url, const char *dump_name, co char s3_url_file_saved[sizeof(s3_url_file)]; memcpy(s3_url_file_saved, s3_url_file, sizeof(s3_url_file)); #endif - ret = performMetadataPostWithCertRotationEx(url, s3_url_file, post_filed, &sec_out, &http_code); + if (device_type == DEVICE_TYPE_XHC1) + { + /* XHC1/RDKC: Plain HTTPS POST without mTLS client cert + * (matches shell script uploadDumps.sh behavior) */ + void *curl_handle = doCurlInit(); + if (curl_handle) + { + FileUpload_t file_upload; + memset(&file_upload, 0, sizeof(FileUpload_t)); + file_upload.url = (char *)url; + file_upload.pathname = s3_url_file; + file_upload.pPostFields = post_filed; + file_upload.sslverify = 0; + file_upload.hashData = NULL; + ret = performHttpMetadataPost(curl_handle, &file_upload, NULL, &http_code); + doStopUpload(curl_handle); + CRASHUPLOAD_INFO("After performHttpMetadataPost (no mTLS) ret=%d=>http code=%lu\n", ret, http_code); + } + else + { + ret = -1; + CRASHUPLOAD_ERROR("XHC1: doCurlInit failed\n"); + } + } + else + { + ret = performMetadataPostWithCertRotationEx(url, s3_url_file, post_filed, &sec_out, &http_code); #if defined(L2_TEST) - if (s3_url_file[0] == '\0') - memcpy(s3_url_file, s3_url_file_saved, sizeof(s3_url_file)); + if (s3_url_file[0] == '\0') + memcpy(s3_url_file, s3_url_file_saved, sizeof(s3_url_file)); #endif - CRASHUPLOAD_INFO("After performMetadataPostWithCertRotationEx ret=%d=>http code=%lu\n", ret, http_code); + CRASHUPLOAD_INFO("After performMetadataPostWithCertRotationEx ret=%d=>http code=%lu\n", ret, http_code); + } __uploadutil_get_status(&http_code, &curl_ret); CRASHUPLOAD_INFO("Curl Connected to $FQDN:%s\n", url); CRASHUPLOAD_INFO("Curl return code :%d, HTTP SIGN URL Response:%lu\n", curl_ret, http_code); @@ -262,7 +295,9 @@ int upload_file(const char *filepath, const char *url, const char *dump_name, co CRASHUPLOAD_INFO("extractS3PresignedUrl ret=%d=>out_url=%s\n", ret, out_url); if (ret == 0 && out_url[0] != '\0') { - ret = performS3PutUpload(out_url, filepath, &sec_out); + /* XHC1: plain HTTPS PUT (no mTLS), others: use cert from Stage 1 */ + ret = performS3PutUpload(out_url, filepath, + (device_type == DEVICE_TYPE_XHC1) ? NULL : &sec_out); CRASHUPLOAD_INFO("performS3PutUpload return ret=%d\n", ret); http_code = 0; curl_ret = -1; @@ -369,8 +404,24 @@ int upload_process(archive_info_t *archive, const config_t *config, const platfo char md5sum[128] = {0}; char dump_name[16] = {0}; char crash_fw_version[128] = {0}; - // size_t GetPartnerId( char *pPartnerId, size_t szBufSize ); +#ifdef RDKC + { + FILE *fp = fopen(RDKC_PARTNER_ID_FILE, "r"); + if (fp) + { + if (fgets(pPartnerId, sizeof(pPartnerId), fp)) + { + size_t plen = strlen(pPartnerId); + if (plen > 0 && pPartnerId[plen - 1] == '\n') + pPartnerId[plen - 1] = '\0'; + } + fclose(fp); + } + ret = (pPartnerId[0] != '\0') ? 1 : 0; + } +#else ret = GetPartnerId(pPartnerId, sizeof(pPartnerId)); +#endif if (ret == 0) { strcpy(pPartnerId, "comcast"); From 18b2deec09754edc3ddbe65cb678c71a3eebd5a9 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Tue, 9 Jun 2026 16:05:07 +0000 Subject: [PATCH 03/10] RDKC-16494: cleaned rfc usage --- c_sourcecode/configure.ac | 2 +- c_sourcecode/src/rfcInterface/rfcinterface.c | 4 +- c_sourcecode/src/rfcInterface/rfcinterface.h | 21 +-- rdk_build.sh | 184 ------------------- 4 files changed, 8 insertions(+), 203 deletions(-) delete mode 100755 rdk_build.sh diff --git a/c_sourcecode/configure.ac b/c_sourcecode/configure.ac index 19d08c0..2243f90 100644 --- a/c_sourcecode/configure.ac +++ b/c_sourcecode/configure.ac @@ -47,7 +47,7 @@ AC_FUNC_MALLOC AC_CHECK_FUNCS([gettimeofday memset strchr strdup strerror]) # Compiler flags -CFLAGS="$CFLAGS -Wall -Werror -O2" +CFLAGS="$CFLAGS -Wall -Werror -O2 -DT2_EVENT_ENABLED" #CFLAGS="$CFLAGS -Wall -Werror -O2 -std=c11" #CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200809L" diff --git a/c_sourcecode/src/rfcInterface/rfcinterface.c b/c_sourcecode/src/rfcInterface/rfcinterface.c index 87adfec..31ac79f 100644 --- a/c_sourcecode/src/rfcInterface/rfcinterface.c +++ b/c_sourcecode/src/rfcInterface/rfcinterface.c @@ -78,7 +78,7 @@ int write_RFCProperty(const char *type, const char *key, const char *value, RFCV * @param data : Store rfc value * @return int 1 READ_RFC_SUCCESS on success and READ_RFC_FAILURE -1 on failure * */ -int read_RFCProperty(const char *type, const char *key, char *out_value, size_t datasize) +int read_RFCProperty(char *type, const char *key, char *out_value, size_t datasize) { RFC_ParamData_t param; int data_len; @@ -122,7 +122,7 @@ int read_RFCProperty(const char *type, const char *key, char *out_value, size_t * @param datatype: data type of value parameter * @return int 1 WRITE_RFC_SUCCESS on success and WRITE_RFC_FAILURE -1 on failure * */ -int write_RFCProperty(const char *type, const char *key, const char *value, RFCVALDATATYPE datatype) +int write_RFCProperty(char *type, const char *key, const char *value, RFCVALDATATYPE datatype) { WDMP_STATUS status = WDMP_FAILURE; int ret = WRITE_RFC_FAILURE; diff --git a/c_sourcecode/src/rfcInterface/rfcinterface.h b/c_sourcecode/src/rfcInterface/rfcinterface.h index 77e2e4d..c21d667 100644 --- a/c_sourcecode/src/rfcInterface/rfcinterface.h +++ b/c_sourcecode/src/rfcInterface/rfcinterface.h @@ -24,25 +24,9 @@ // platforms without this api or an alternative interface such as rbus or ccspbus or xmidt #if defined(RFC_API_ENABLED) #ifndef GTEST_ENABLE -#if defined(RDKC) -/* RDKC rfcapi: 2-param ini-file-based API (from rfc-fork). - * We declare the interface directly to avoid rfcapi.h header issues - * (header declares 3-param WDMP_STATUS version but library exports 2-param int). */ -#ifndef MAX_PARAM_LEN -#define MAX_PARAM_LEN (2*1024) -#endif -typedef enum { SUCCESS=0, FAILURE, NONE, EMPTY } DATA_TYPE; -typedef struct _RFC_Param_t { - char name[MAX_PARAM_LEN]; - char value[MAX_PARAM_LEN]; - DATA_TYPE type; -} RFC_ParamData_t; -int getRFCParameter(const char* pcParameterName, RFC_ParamData_t *pstParamData); -#else #include "rfcapi.h" #endif #endif -#endif #include #include @@ -91,9 +75,14 @@ typedef enum #define RFC_CRASH_PORTAL_ENDPOINT_URL "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.CrashportalEndpoint.URL" #if defined(RFC_API_ENABLED) +#if defined(RDKC) int read_RFCProperty(const char *type, const char *key, char *data, size_t datasize); int write_RFCProperty(const char *type, const char *key, const char *data, RFCVALDATATYPE datatype); #else +int read_RFCProperty(char *type, const char *key, char *data, size_t datasize); +int write_RFCProperty(char *type, const char *key, const char *data, RFCVALDATATYPE datatype); +#endif +#else int read_RFCProperty(const char *type, const char *key, char *data, size_t datasize); int write_RFCProperty(const char *type, const char *key, const char *data, RFCVALDATATYPE datatype); #endif diff --git a/rdk_build.sh b/rdk_build.sh deleted file mode 100755 index 7a96cf9..0000000 --- a/rdk_build.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash -########################################################################## -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2016 RDK Management -# -# 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. -########################################################################## - -####################################### -# -# Build Framework standard script for -# -# Flashplayer component - -# use -e to fail on any shell issue -# -e is the requirement from Build Framework -set -ex - -# default PATHs - use `man readlink` for more info -# the path to combined build -export RDK_PROJECT_ROOT_PATH="${RDK_PROJECT_ROOT_PATH-$(readlink -m ..)}" -export COMBINED_ROOT="$RDK_PROJECT_ROOT_PATH" - -# path to build script (this script) -export RDK_SCRIPTS_PATH="${RDK_SCRIPTS_PATH-$(readlink -m "$0" | xargs dirname)}" - -# path to components sources and target -export RDK_SOURCE_PATH="${RDK_SOURCE_PATH-$RDK_SCRIPTS_PATH/..}" -export RDK_TARGET_PATH="${RDK_TARGET_PATH-$RDK_SOURCE_PATH}" - -# fsroot and toolchain (valid for all devices) -export RDK_FSROOT_PATH="${RDK_FSROOT_PATH-$(readlink -m "$RDK_PROJECT_ROOT_PATH/sdk/fsroot/ramdisk")}" -#export RDK_TOOLCHAIN_PATH=${RDK_TOOLCHAIN_PATH-`readlink -m $RDK_PROJECT_ROOT_PATH/sdk/toolchain/staging_dir`} - -# default component name -export RDK_COMPONENT_NAME="${RDK_COMPONENT_NAME-$(basename "$RDK_SOURCE_PATH")}" - -#DEBUG=0 -#COMBINED=1 -#UPLOAD=0 -#REBUILD=0 -#JOBS_NUM=0 # 0 means detect automatically -#PROJECT_CONFIG=() - -# parse arguments -INITIAL_ARGS=$@ - -function usage() -{ - set +x - echo "Usage: $(basename "$0") [-h|--help] [-v|--verbose] [action]" - echo " -h --help : this help" - echo " -v --verbose : verbose output" - echo - echo "Supported actions:" - echo " configure, clean, build (DEFAULT), rebuild, install" -} - -# options may be followed by one colon to indicate they have a required argument -if ! GETOPT=$(getopt -n "build.sh" -o hv:h -l help,verbose -- "$@") -then - usage - exit 1 -fi - -eval set -- "$GETOPT" - -while true; do - case "$1" in - -h | --help ) usage; exit 0 ;; - -v | --verbose ) set -x ;; - -- ) shift; break;; - * ) break;; - esac - shift -done - -ARGS=$@ - - -# component-specific vars -#export TOOLCHAIN_DIR=$COMBINED_ROOT/sdk/toolchain/staging_dir -src_file=uploadDumps.sh -src_file_hdd=uploadDumpsHDD.sh -install_dir=$RDK_FSROOT_PATH/lib/rdk -src_generic=$RDK_SOURCE_PATH/generic/$src_file -src_generic_hdd=$RDK_SOURCE_PATH/generic/$src_file_hdd -src_devspec=$RDK_SOURCE_PATH/devspec/$src_file -dst=$install_dir/$src_file - -# functional modules - -function configure() -{ - true -} - -function clean() -{ - true -} - -function build() -{ - : - #pushd $RDK_SOURCE_PATH/generic/upload-dumps-2 - #./unit_test.sh - #popd -} - -function rebuild() -{ - build -} - -function install() -{ -# # Avoid unnecessary copying and stripping. -# if [ -f $dst ]; then -# echo "$src_file is present in $install_dir already. Nothing to install." -# return -# fi - - # Install the library to fsroot. - echo "Installing $src_file to $install_dir" - mkdir -p "$install_dir" - - # only xg1 devices have HDD. - HDD_DEVICES="xg1" - - for device in $HDD_DEVICES - do - if [ "$device" = "$RDK_PLATFORM_DEVICE" ] ; then - HAS_HDD="true" - fi - done - - if [ "$HAS_HDD" = "true" -a -f "$src_generic_hdd" ]; then - echo "Copying uploadDumpsHDD file $src_generic_hdd" - cp "$src_generic_hdd" "$dst" - elif [ -f "$src_generic" ]; then - echo "Copy generic $src_file." - cp "$src_generic" "$dst" - fi - - if [! -f "$src_generic" -o ! -f "$src_generic_hdd" ]; then - echo "Missing $src_file...!" - exit 1 - fi -} - -# run the logic - -HIT=false - -for i in $ARGS; do - case $i in - configure) HIT=true; configure ;; - clean) HIT=true; clean ;; - build) HIT=true; build ;; - rebuild) HIT=true; rebuild ;; - install) HIT=true; install ;; - *) - #skip unknown - ;; - esac -done - -# if not HIT do install by default -if ! $HIT; then - install -fi From f6b4049da5294d062f935b8e51e73f8f9507b5ff Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Tue, 9 Jun 2026 16:08:51 +0000 Subject: [PATCH 04/10] RDKC-16494: added rdk_build.sh --- rdk_build.sh | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 rdk_build.sh diff --git a/rdk_build.sh b/rdk_build.sh new file mode 100644 index 0000000..7a96cf9 --- /dev/null +++ b/rdk_build.sh @@ -0,0 +1,184 @@ +#!/bin/bash +########################################################################## +# If not stated otherwise in this file or this component's LICENSE +# file the following copyright and licenses apply: +# +# Copyright 2016 RDK Management +# +# 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. +########################################################################## + +####################################### +# +# Build Framework standard script for +# +# Flashplayer component + +# use -e to fail on any shell issue +# -e is the requirement from Build Framework +set -ex + +# default PATHs - use `man readlink` for more info +# the path to combined build +export RDK_PROJECT_ROOT_PATH="${RDK_PROJECT_ROOT_PATH-$(readlink -m ..)}" +export COMBINED_ROOT="$RDK_PROJECT_ROOT_PATH" + +# path to build script (this script) +export RDK_SCRIPTS_PATH="${RDK_SCRIPTS_PATH-$(readlink -m "$0" | xargs dirname)}" + +# path to components sources and target +export RDK_SOURCE_PATH="${RDK_SOURCE_PATH-$RDK_SCRIPTS_PATH/..}" +export RDK_TARGET_PATH="${RDK_TARGET_PATH-$RDK_SOURCE_PATH}" + +# fsroot and toolchain (valid for all devices) +export RDK_FSROOT_PATH="${RDK_FSROOT_PATH-$(readlink -m "$RDK_PROJECT_ROOT_PATH/sdk/fsroot/ramdisk")}" +#export RDK_TOOLCHAIN_PATH=${RDK_TOOLCHAIN_PATH-`readlink -m $RDK_PROJECT_ROOT_PATH/sdk/toolchain/staging_dir`} + +# default component name +export RDK_COMPONENT_NAME="${RDK_COMPONENT_NAME-$(basename "$RDK_SOURCE_PATH")}" + +#DEBUG=0 +#COMBINED=1 +#UPLOAD=0 +#REBUILD=0 +#JOBS_NUM=0 # 0 means detect automatically +#PROJECT_CONFIG=() + +# parse arguments +INITIAL_ARGS=$@ + +function usage() +{ + set +x + echo "Usage: $(basename "$0") [-h|--help] [-v|--verbose] [action]" + echo " -h --help : this help" + echo " -v --verbose : verbose output" + echo + echo "Supported actions:" + echo " configure, clean, build (DEFAULT), rebuild, install" +} + +# options may be followed by one colon to indicate they have a required argument +if ! GETOPT=$(getopt -n "build.sh" -o hv:h -l help,verbose -- "$@") +then + usage + exit 1 +fi + +eval set -- "$GETOPT" + +while true; do + case "$1" in + -h | --help ) usage; exit 0 ;; + -v | --verbose ) set -x ;; + -- ) shift; break;; + * ) break;; + esac + shift +done + +ARGS=$@ + + +# component-specific vars +#export TOOLCHAIN_DIR=$COMBINED_ROOT/sdk/toolchain/staging_dir +src_file=uploadDumps.sh +src_file_hdd=uploadDumpsHDD.sh +install_dir=$RDK_FSROOT_PATH/lib/rdk +src_generic=$RDK_SOURCE_PATH/generic/$src_file +src_generic_hdd=$RDK_SOURCE_PATH/generic/$src_file_hdd +src_devspec=$RDK_SOURCE_PATH/devspec/$src_file +dst=$install_dir/$src_file + +# functional modules + +function configure() +{ + true +} + +function clean() +{ + true +} + +function build() +{ + : + #pushd $RDK_SOURCE_PATH/generic/upload-dumps-2 + #./unit_test.sh + #popd +} + +function rebuild() +{ + build +} + +function install() +{ +# # Avoid unnecessary copying and stripping. +# if [ -f $dst ]; then +# echo "$src_file is present in $install_dir already. Nothing to install." +# return +# fi + + # Install the library to fsroot. + echo "Installing $src_file to $install_dir" + mkdir -p "$install_dir" + + # only xg1 devices have HDD. + HDD_DEVICES="xg1" + + for device in $HDD_DEVICES + do + if [ "$device" = "$RDK_PLATFORM_DEVICE" ] ; then + HAS_HDD="true" + fi + done + + if [ "$HAS_HDD" = "true" -a -f "$src_generic_hdd" ]; then + echo "Copying uploadDumpsHDD file $src_generic_hdd" + cp "$src_generic_hdd" "$dst" + elif [ -f "$src_generic" ]; then + echo "Copy generic $src_file." + cp "$src_generic" "$dst" + fi + + if [! -f "$src_generic" -o ! -f "$src_generic_hdd" ]; then + echo "Missing $src_file...!" + exit 1 + fi +} + +# run the logic + +HIT=false + +for i in $ARGS; do + case $i in + configure) HIT=true; configure ;; + clean) HIT=true; clean ;; + build) HIT=true; build ;; + rebuild) HIT=true; rebuild ;; + install) HIT=true; install ;; + *) + #skip unknown + ;; + esac +done + +# if not HIT do install by default +if ! $HIT; then + install +fi From 53dd1c76d8a2b8227cae72360ea9834fbec6a5c9 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Wed, 10 Jun 2026 14:15:02 +0000 Subject: [PATCH 05/10] RDKC-16494: removed RDKC device specific rdk_build.sh --- c_sourcecode/rdk_build.sh | 201 -------------------------------------- 1 file changed, 201 deletions(-) delete mode 100755 c_sourcecode/rdk_build.sh diff --git a/c_sourcecode/rdk_build.sh b/c_sourcecode/rdk_build.sh deleted file mode 100755 index 2baa183..0000000 --- a/c_sourcecode/rdk_build.sh +++ /dev/null @@ -1,201 +0,0 @@ -#!/bin/bash -########################################################################## -# If not stated otherwise in this file or this component's LICENSE -# file the following copyright and licenses apply: -# -# Copyright 2025 RDK Management -# -# 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. -########################################################################## - -####################################### -# -# Build Framework standard script for -# -# crashupload C binary component - -# use -e to fail on any shell issue -# -e is the requirement from Build Framework -set -ex - -# default PATHs - use `man readlink` for more info -# the path to combined build -export RDK_PROJECT_ROOT_PATH="${RDK_PROJECT_ROOT_PATH-$(readlink -m ..)}" -export COMBINED_ROOT="$RDK_PROJECT_ROOT_PATH" - -# path to build script (this script) -export RDK_SCRIPTS_PATH="${RDK_SCRIPTS_PATH-$(readlink -m "$0" | xargs dirname)}" - -# path to components sources and target -export RDK_SOURCE_PATH="${RDK_SOURCE_PATH-$RDK_SCRIPTS_PATH}" -export RDK_TARGET_PATH="${RDK_TARGET_PATH-$RDK_SOURCE_PATH}" - -# fsroot and toolchain (valid for all devices) -export RDK_FSROOT_PATH="${RDK_FSROOT_PATH-$(readlink -m "$RDK_PROJECT_ROOT_PATH/sdk/fsroot/ramdisk")}" -export RDK_TOOLCHAIN_PATH="${RDK_TOOLCHAIN_PATH-$(readlink -m "$RDK_PROJECT_ROOT_PATH/sdk/toolchain/arm-linux-gnueabihf")}" - -# default component name -export RDK_COMPONENT_NAME="${RDK_COMPONENT_NAME-$(basename "$RDK_SOURCE_PATH")}" - -# Setup cross-compilation toolchain -if [ -f ${RDK_PROJECT_ROOT_PATH}/build/components/amba/sdk/setenv2 ]; then - source ${RDK_PROJECT_ROOT_PATH}/build/components/amba/sdk/setenv2 -else - export CC=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-gcc - export CXX=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-g++ - export AR=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-ar - export LD=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-ld - export NM=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-nm - export RANLIB=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-ranlib - export STRIP=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-strip - export LINK=${RDK_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-g++ -fi - -# parse arguments -INITIAL_ARGS=$@ - -function usage() -{ - set +x - echo "Usage: $(basename "$0") [-h|--help] [-v|--verbose] [action]" - echo " -h --help : this help" - echo " -v --verbose : verbose output" - echo - echo "Supported actions:" - echo " configure, clean, build (DEFAULT), rebuild, install" -} - -# options may be followed by one colon to indicate they have a required argument -if ! GETOPT=$(getopt -n "build.sh" -o hv -l help,verbose -- "$@") -then - usage - exit 1 -fi - -eval set -- "$GETOPT" - -while true; do - case "$1" in - -h | --help ) usage; exit 0 ;; - -v | --verbose ) set -x ;; - -- ) shift; break;; - * ) break;; - esac - shift -done - -ARGS=$@ - -# functional modules -function configure() -{ - pd=$(pwd) - cd ${RDK_SOURCE_PATH} - - aclocal - libtoolize --automake - autoheader - automake --foreign --add-missing - rm -f configure - autoconf - - configure_options="--host=arm-linux --target=arm-linux" - - export CFLAGS="${CFLAGS} -I${RDK_FSROOT_PATH}/usr/include \ - -I${RDK_FSROOT_PATH}/usr/include/rbus \ - -I${RDK_FSROOT_PATH}/usr/include/rfc \ - -I${RDK_PROJECT_ROOT_PATH}/common_utilities/dwnlutils \ - -I${RDK_PROJECT_ROOT_PATH}/common_utilities/parsejson \ - -I${RDK_PROJECT_ROOT_PATH}/common_utilities/utils" - - export LDFLAGS="${LDFLAGS} -L${RDK_FSROOT_PATH}/usr/lib \ - -Wl,-rpath-link,${RDK_FSROOT_PATH}/usr/lib \ - -lrdkloggers -ldwnlutil -lfwutils -lsecure_wrapper -lparsejson \ - -lpthread -lcrypto -larchive -lrfcapi -ltelemetry_msgsender \ - -lt2utils -lrbus -lcurl" - - ./configure --prefix=${RDK_FSROOT_PATH}/usr --sysconfdir=${RDK_FSROOT_PATH}/etc $configure_options - - cd $pd -} - -function clean() -{ - pd=$(pwd) - cd ${RDK_SOURCE_PATH} - if [ -f Makefile ]; then - make distclean-am - make clean - fi - rm -f configure - rm -rf aclocal.m4 autom4te.cache config.log config.status libtool - find . -iname "Makefile.in" -exec rm -f {} \; - find . -iname "Makefile" | xargs rm -f - cd $pd -} - -function build() -{ - cd ${RDK_SOURCE_PATH} - make -} - -function rebuild() -{ - clean - configure - build -} - -function install() -{ - cd ${RDK_SOURCE_PATH} - - # Install the crashupload binary - mkdir -p $RDK_FSROOT_PATH/usr/bin - install -m 0755 src/crashupload $RDK_FSROOT_PATH/usr/bin/crashupload - - # Install the shell script as fallback - mkdir -p $RDK_FSROOT_PATH/lib/rdk - if [ -f ${RDK_SOURCE_PATH}/../uploadDumps.sh ]; then - install -m 0755 ${RDK_SOURCE_PATH}/../uploadDumps.sh $RDK_FSROOT_PATH/lib/rdk/uploadDumps.sh - fi - - # Install RFC defaults - CPC_PATH=${CPC_PATH-$RDK_PROJECT_ROOT_PATH/cpg-utils} - if [ -f "$CPC_PATH/rfcdefaults/crashupload.ini" ]; then - mkdir -p $RDK_FSROOT_PATH/etc/rfcdefaults - install -m 0644 $CPC_PATH/rfcdefaults/crashupload.ini $RDK_FSROOT_PATH/etc/rfcdefaults/crashupload.ini - fi -} - -# run the logic -HIT=false - -for i in "$ARGS"; do - case $i in - configure) HIT=true; configure ;; - clean) HIT=true; clean ;; - build) HIT=true; build ;; - rebuild) HIT=true; rebuild ;; - install) HIT=true; install ;; - *) - #skip unknown - ;; - esac -done - -# Default action - build -if ! $HIT; then - build -fi From 8cccacbc781090297e4771cb92688814fed11595 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Wed, 17 Jun 2026 11:59:05 +0000 Subject: [PATCH 06/10] fixed issues and cleaned up code --- c_sourcecode/common/types.h | 2 +- c_sourcecode/src/archive/archive.c | 16 ++++++++-------- c_sourcecode/src/config/config_manager.c | 12 ++++++------ c_sourcecode/src/rfcInterface/rfcinterface.c | 8 +++++++- c_sourcecode/src/upload/upload.c | 20 ++++++++++---------- c_sourcecode/src/utils/prerequisites.c | 2 +- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/c_sourcecode/common/types.h b/c_sourcecode/common/types.h index a7e7258..4760139 100644 --- a/c_sourcecode/common/types.h +++ b/c_sourcecode/common/types.h @@ -51,7 +51,7 @@ typedef enum { DEVICE_TYPE_VIDEO, DEVICE_TYPE_EXTENDER, DEVICE_TYPE_MEDIACLIENT, - DEVICE_TYPE_XHC1, + DEVICE_TYPE_RDKC, DEVICE_TYPE_UNKNOWN } device_type_t; diff --git a/c_sourcecode/src/archive/archive.c b/c_sourcecode/src/archive/archive.c index 5896c19..e78a5be 100644 --- a/c_sourcecode/src/archive/archive.c +++ b/c_sourcecode/src/archive/archive.c @@ -396,10 +396,10 @@ int archive_create_smart(const dump_file_t *dump, const config_t *config, CRASHUPLOAD_INFO("core log file=%s\n", arch_files_list[2]); tar_status = create_tarball(true, target_file_name, arch_files_list, no_of_files); } - else if (config->device_type == DEVICE_TYPE_XHC1) + else if (config->device_type == DEVICE_TYPE_RDKC) { - /* XHC1 (RDKC Camera) minidump archive: - * Matches script uploadDumps.sh line 917 for DEVICE_TYPE=XHC1 + /* RDKC Camera minidump archive: + * Matches script uploadDumps.sh line 917 for DEVICE_TYPE=RDKC * Archive: dumpName + version.txt + core_log.txt * Non-prod: also receiver.log and thread.log if present */ @@ -409,24 +409,24 @@ int archive_create_smart(const dump_file_t *dump, const config_t *config, if (config->build_type != BUILD_TYPE_PROD) { - char receiver_log[64] = {0}; - char thread_log[64] = {0}; + char receiver_log[PATH_MAX] = {0}; + char thread_log[PATH_MAX] = {0}; snprintf(receiver_log, sizeof(receiver_log), "%s/receiver.log", config->log_path); snprintf(thread_log, sizeof(thread_log), "%s/thread.log", config->log_path); if (0 == (filePresentCheck(receiver_log))) { snprintf(arch_files_list[no_of_files], 256, "%s", receiver_log); - CRASHUPLOAD_INFO("XHC1 adding receiver.log=%s\n", arch_files_list[no_of_files]); + CRASHUPLOAD_INFO("RDKC adding receiver.log=%s\n", arch_files_list[no_of_files]); no_of_files++; } if (0 == (filePresentCheck(thread_log))) { snprintf(arch_files_list[no_of_files], 256, "%s", thread_log); - CRASHUPLOAD_INFO("XHC1 adding thread.log=%s\n", arch_files_list[no_of_files]); + CRASHUPLOAD_INFO("RDKC adding thread.log=%s\n", arch_files_list[no_of_files]); no_of_files++; } } - CRASHUPLOAD_INFO("XHC1 tar file:%s files=%d\n", target_file_name, no_of_files); + CRASHUPLOAD_INFO("RDKC tar file:%s files=%d\n", target_file_name, no_of_files); tar_status = create_tarball(true, target_file_name, arch_files_list, no_of_files); } } diff --git a/c_sourcecode/src/config/config_manager.c b/c_sourcecode/src/config/config_manager.c index 7b42710..c2e49a8 100644 --- a/c_sourcecode/src/config/config_manager.c +++ b/c_sourcecode/src/config/config_manager.c @@ -125,8 +125,8 @@ int config_init_load(config_t *config, int argc, char *argv[]) } else if (0 == (strncmp(device_prop_data, "XHC1", 4))) { - config->device_type = DEVICE_TYPE_XHC1; - CRASHUPLOAD_INFO("device type XHC1=%d\n", config->device_type); + config->device_type = DEVICE_TYPE_RDKC; + CRASHUPLOAD_INFO("device type RDKC=%d\n", config->device_type); snprintf(config->core_log_file, sizeof(config->core_log_file), "%s/%s", log_path, "core_log.txt"); CRASHUPLOAD_INFO("core log=%s\n", config->core_log_file); } @@ -154,19 +154,19 @@ int config_init_load(config_t *config, int argc, char *argv[]) strcpy(config->core_path, "/var/lib/systemd/coredump"); strcpy(config->minidump_path, "/opt/minidumps"); } - /* Override paths for non-systemd RDKC camera (XHC1) */ + /* Override paths for non-systemd RDKC camera */ if (config->upload_mode == UPLOAD_MODE_NORMAL && - config->device_type == DEVICE_TYPE_XHC1) + config->device_type == DEVICE_TYPE_RDKC) { strcpy(config->core_path, "/opt/corefiles"); /* minidump_path remains /opt/minidumps - already correct for RDKC */ } /* BOX_TYPE fallback for RDKC camera (no BOX_TYPE in device.properties) */ if (strcmp(config->box_type, "UNKNOWN") == 0 && - config->device_type == DEVICE_TYPE_XHC1) + config->device_type == DEVICE_TYPE_RDKC) { strcpy(config->box_type, "xcam"); - CRASHUPLOAD_INFO("BOX_TYPE defaulted to xcam for XHC1\n"); + CRASHUPLOAD_INFO("BOX_TYPE defaulted to xcam for RDKC\n"); } if (argc >= 3) { diff --git a/c_sourcecode/src/rfcInterface/rfcinterface.c b/c_sourcecode/src/rfcInterface/rfcinterface.c index 31ac79f..8829bfc 100644 --- a/c_sourcecode/src/rfcInterface/rfcinterface.c +++ b/c_sourcecode/src/rfcInterface/rfcinterface.c @@ -33,6 +33,7 @@ int read_RFCProperty(const char *type, const char *key, char *out_value, size_t RFC_ParamData_t param; int data_len; int ret = READ_RFC_FAILURE; + (void)type; if (key == NULL || out_value == NULL || datasize == 0) { @@ -47,7 +48,8 @@ int read_RFCProperty(const char *type, const char *key, char *out_value, size_t { // remove quotes around data snprintf(out_value, datasize, "%s", ¶m.value[1]); - *(out_value + data_len - 2) = 0; + size_t term_idx = (size_t)(data_len - 2) < (datasize - 1) ? (size_t)(data_len - 2) : (datasize - 1); + out_value[term_idx] = '\0'; } else { @@ -66,6 +68,10 @@ int read_RFCProperty(const char *type, const char *key, char *out_value, size_t int write_RFCProperty(const char *type, const char *key, const char *value, RFCVALDATATYPE datatype) { + (void)type; + (void)key; + (void)value; + (void)datatype; /* RDKC rfcapi does not support setRFCParameter */ CRASHUPLOAD_INFO("%s: Not supported on RDKC\n", __FUNCTION__); return WRITE_RFC_NOTAPPLICABLE; diff --git a/c_sourcecode/src/upload/upload.c b/c_sourcecode/src/upload/upload.c index 0a98538..8abae22 100644 --- a/c_sourcecode/src/upload/upload.c +++ b/c_sourcecode/src/upload/upload.c @@ -226,9 +226,9 @@ int upload_file(const char *filepath, const char *url, const char *dump_name, co char s3_url_file_saved[sizeof(s3_url_file)]; memcpy(s3_url_file_saved, s3_url_file, sizeof(s3_url_file)); #endif - if (device_type == DEVICE_TYPE_XHC1) + if (device_type == DEVICE_TYPE_RDKC) { - /* XHC1/RDKC: Plain HTTPS POST without mTLS client cert + /* RDKC: Plain HTTPS POST without mTLS client cert * (matches shell script uploadDumps.sh behavior) */ void *curl_handle = doCurlInit(); if (curl_handle) @@ -247,7 +247,7 @@ int upload_file(const char *filepath, const char *url, const char *dump_name, co else { ret = -1; - CRASHUPLOAD_ERROR("XHC1: doCurlInit failed\n"); + CRASHUPLOAD_ERROR("RDKC: doCurlInit failed\n"); } } else @@ -295,9 +295,9 @@ int upload_file(const char *filepath, const char *url, const char *dump_name, co CRASHUPLOAD_INFO("extractS3PresignedUrl ret=%d=>out_url=%s\n", ret, out_url); if (ret == 0 && out_url[0] != '\0') { - /* XHC1: plain HTTPS PUT (no mTLS), others: use cert from Stage 1 */ + /* RDKC: plain HTTPS PUT (no mTLS), others: use cert from Stage 1 */ ret = performS3PutUpload(out_url, filepath, - (device_type == DEVICE_TYPE_XHC1) ? NULL : &sec_out); + (device_type == DEVICE_TYPE_RDKC) ? NULL : &sec_out); CRASHUPLOAD_INFO("performS3PutUpload return ret=%d\n", ret); http_code = 0; curl_ret = -1; @@ -473,9 +473,9 @@ int upload_process(archive_info_t *archive, const config_t *config, const platfo CRASHUPLOAD_INFO("Read rfc Success crashportalEndpointUrl:\n Overriding the S3 Amazon Signing URL:%s\n", crashportalEndpointUrl); } } - else if (config->device_type == DEVICE_TYPE_XHC1) + else if (config->device_type == DEVICE_TYPE_RDKC) { - /* XHC1 (RDKC Camera) upload flow: + /* RDKC Camera upload flow: * Matches script uploadDumps.sh - encryptionEnable=false (no /etc/os-release) * S3 URL from device.properties S3_AMAZON_SIGNING_URL * Portal URL: crashportal.stb.r53.xcal.tv @@ -483,14 +483,14 @@ int upload_process(archive_info_t *archive, const config_t *config, const platfo strcpy(encryptionEnable, "false"); strcpy(portal_url, "crashportal.stb.r53.xcal.tv"); request_type = 17; - CRASHUPLOAD_INFO("XHC1: request_type=%d\n", request_type); + CRASHUPLOAD_INFO("RDKC: request_type=%d\n", request_type); ret = get_crashupload_s3signed_url(crashportalEndpointUrl, sizeof(crashportalEndpointUrl)); if (ret < 0) { - CRASHUPLOAD_ERROR("XHC1: Unable to get the S3 server url. So exit\n"); + CRASHUPLOAD_ERROR("RDKC: Unable to get the S3 server url. So exit\n"); return ret; } - CRASHUPLOAD_INFO("XHC1: S3 signing URL=%s\n", crashportalEndpointUrl); + CRASHUPLOAD_INFO("RDKC: S3 signing URL=%s\n", crashportalEndpointUrl); } else if (config->device_type == DEVICE_TYPE_BROADBAND) { diff --git a/c_sourcecode/src/utils/prerequisites.c b/c_sourcecode/src/utils/prerequisites.c index 84351b7..bc1eeba 100644 --- a/c_sourcecode/src/utils/prerequisites.c +++ b/c_sourcecode/src/utils/prerequisites.c @@ -44,7 +44,7 @@ void defer_upload_if_needed(device_type_t device_type) { int ret = -1; - if (device_type == DEVICE_TYPE_MEDIACLIENT || device_type == DEVICE_TYPE_XHC1) + if (device_type == DEVICE_TYPE_MEDIACLIENT || device_type == DEVICE_TYPE_RDKC) { FILE *fp = fopen(UPTIME_FILE, "r"); if (!fp) From 47819a76580660c6f7802ab90e71a7b7d0cc3be8 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Thu, 18 Jun 2026 16:48:23 +0000 Subject: [PATCH 07/10] RDKC-16494: RDKC use mTLS cert rotation via rdkcertselector --- c_sourcecode/src/upload/upload.c | 39 ++++---------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/c_sourcecode/src/upload/upload.c b/c_sourcecode/src/upload/upload.c index 8abae22..8f7e99b 100644 --- a/c_sourcecode/src/upload/upload.c +++ b/c_sourcecode/src/upload/upload.c @@ -226,39 +226,12 @@ int upload_file(const char *filepath, const char *url, const char *dump_name, co char s3_url_file_saved[sizeof(s3_url_file)]; memcpy(s3_url_file_saved, s3_url_file, sizeof(s3_url_file)); #endif - if (device_type == DEVICE_TYPE_RDKC) - { - /* RDKC: Plain HTTPS POST without mTLS client cert - * (matches shell script uploadDumps.sh behavior) */ - void *curl_handle = doCurlInit(); - if (curl_handle) - { - FileUpload_t file_upload; - memset(&file_upload, 0, sizeof(FileUpload_t)); - file_upload.url = (char *)url; - file_upload.pathname = s3_url_file; - file_upload.pPostFields = post_filed; - file_upload.sslverify = 0; - file_upload.hashData = NULL; - ret = performHttpMetadataPost(curl_handle, &file_upload, NULL, &http_code); - doStopUpload(curl_handle); - CRASHUPLOAD_INFO("After performHttpMetadataPost (no mTLS) ret=%d=>http code=%lu\n", ret, http_code); - } - else - { - ret = -1; - CRASHUPLOAD_ERROR("RDKC: doCurlInit failed\n"); - } - } - else - { - ret = performMetadataPostWithCertRotationEx(url, s3_url_file, post_filed, &sec_out, &http_code); + ret = performMetadataPostWithCertRotationEx(url, s3_url_file, post_filed, &sec_out, &http_code); #if defined(L2_TEST) - if (s3_url_file[0] == '\0') - memcpy(s3_url_file, s3_url_file_saved, sizeof(s3_url_file)); + if (s3_url_file[0] == '\0') + memcpy(s3_url_file, s3_url_file_saved, sizeof(s3_url_file)); #endif - CRASHUPLOAD_INFO("After performMetadataPostWithCertRotationEx ret=%d=>http code=%lu\n", ret, http_code); - } + CRASHUPLOAD_INFO("After performMetadataPostWithCertRotationEx ret=%d=>http code=%lu\n", ret, http_code); __uploadutil_get_status(&http_code, &curl_ret); CRASHUPLOAD_INFO("Curl Connected to $FQDN:%s\n", url); CRASHUPLOAD_INFO("Curl return code :%d, HTTP SIGN URL Response:%lu\n", curl_ret, http_code); @@ -295,9 +268,7 @@ int upload_file(const char *filepath, const char *url, const char *dump_name, co CRASHUPLOAD_INFO("extractS3PresignedUrl ret=%d=>out_url=%s\n", ret, out_url); if (ret == 0 && out_url[0] != '\0') { - /* RDKC: plain HTTPS PUT (no mTLS), others: use cert from Stage 1 */ - ret = performS3PutUpload(out_url, filepath, - (device_type == DEVICE_TYPE_RDKC) ? NULL : &sec_out); + ret = performS3PutUpload(out_url, filepath, &sec_out); CRASHUPLOAD_INFO("performS3PutUpload return ret=%d\n", ret); http_code = 0; curl_ret = -1; From c3c7e0af412639ef3e191d48f4f97d714362f828 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Mon, 22 Jun 2026 13:05:55 +0000 Subject: [PATCH 08/10] RDKC-16494: update docs after crashupload RDKC support openspec --- .../flowcharts/uploadDumps-flowcharts.md | 243 +++++++---- .../diagrams/sequence/uploadDumps-sequence.md | 291 +++++++++---- docs/migration/hld/uploadDumps-hld.md | 94 ++-- docs/migration/lld/uploadDumps-lld.md | 404 +++++++++++------- .../requirements/uploadDumps-requirements.md | 27 +- 5 files changed, 704 insertions(+), 355 deletions(-) diff --git a/docs/migration/diagrams/flowcharts/uploadDumps-flowcharts.md b/docs/migration/diagrams/flowcharts/uploadDumps-flowcharts.md index 9a9af50..1b94633 100644 --- a/docs/migration/diagrams/flowcharts/uploadDumps-flowcharts.md +++ b/docs/migration/diagrams/flowcharts/uploadDumps-flowcharts.md @@ -10,70 +10,70 @@ flowchart TD ParseArgs --> LoadConfig[Load Configuration Files] LoadConfig --> InitPlatform[Initialize Platform] InitPlatform --> AcquireLock{Acquire Lock} - + AcquireLock -->|Lock Exists & Exit Mode| LogExit[Log: Another instance running] LogExit --> End1([Exit 0]) - + AcquireLock -->|Lock Exists & Wait Mode| WaitLock[Wait for Lock Release] WaitLock --> AcquireLock - + AcquireLock -->|Lock Acquired| CreateLock[Create Lock Directory] CreateLock --> DeferBoot{Uptime < 480s AND Video Device?} - + DeferBoot -->|Yes| SleepDefer[Sleep Until 480s Uptime] SleepDefer --> CheckNetwork - + DeferBoot -->|No| CheckNetwork{Network Available?} - + CheckNetwork -->|Wait for Network| NetworkLoop[Network Check Loop] NetworkLoop --> CheckNetwork - + CheckNetwork -->|Available| CheckTime{System Time Synced?} - + CheckTime -->|Wait for Time| TimeLoop[Time Sync Loop] TimeLoop --> CheckTime - + CheckTime -->|Synced| CheckMediaClient{DEVICE_TYPE = MEDIACLIENT?} - + CheckMediaClient -->|Yes| FetchPrivacy[get_privacy_control_mode via RBUS] FetchPrivacy --> CheckPrivacy{Privacy Mode = DO_NOT_SHARE?} CheckPrivacy -->|Yes| DoNotSharePath[Scan Dumps, Skip Archiving, Delete Dump Files] DoNotSharePath --> ReleaseLock1[Release Lock] ReleaseLock1 --> End2([Exit 0]) - + CheckMediaClient -->|No| Cleanup[Cleanup Old Files] CheckPrivacy -->|No| Cleanup - + CheckPrivacy -->|No| Cleanup[Cleanup Old Files] Cleanup --> ScanDumps[Scan for Dump Files] ScanDumps --> CheckDumps{Dumps Found?} - + CheckDumps -->|No| LogNoDumps[Log: No dumps found] LogNoDumps --> ReleaseLock2[Release Lock] ReleaseLock2 --> End3([Exit 0]) - + CheckDumps -->|Yes| ProcessLoop{More Dumps to Process?} - + ProcessLoop -->|Yes| CheckRecovery{Recovery Time Reached?} - + CheckRecovery -->|No| ShiftRecovery[Shift Recovery Time] ShiftRecovery --> RemoveDumps2[Remove Pending Dumps] RemoveDumps2 --> ReleaseLock3[Release Lock] ReleaseLock3 --> End4([Exit 0]) - + CheckRecovery -->|Yes| CheckRateLimit{Upload Limit Exceeded?} - + CheckRateLimit -->|Yes| CreateCrashloop[Create Crashloop Marker] CreateCrashloop --> UploadCrashloop[Upload Crashloop Dump] UploadCrashloop --> SetRecovery[Set Recovery Time] SetRecovery --> RemoveDumps2 - + CheckRateLimit -->|No| ProcessDump[Process Single Dump] ProcessDump --> ProcessLoop - + ProcessLoop -->|No| ReleaseLock4[Release Lock] ReleaseLock4 --> End5([Exit 0]) - + style Start fill:#90EE90 style End1 fill:#FFB6C1 style End2 fill:#FFB6C1 @@ -92,104 +92,104 @@ flowchart TD ```mermaid flowchart TD Start([Start Process Dump]) --> ValidateFile{File Exists & Valid?} - + ValidateFile -->|No| LogSkip[Log: Skip invalid file] LogSkip --> Return1([Return]) - + ValidateFile -->|Yes| CheckProcessed{Already Processed?} - + CheckProcessed -->|Yes, is .tgz| LogAlready[Log: Already processed] LogAlready --> Return2([Return]) - + CheckProcessed -->|No| SanitizeFilename[Sanitize Filename] SanitizeFilename --> CheckContainer{Contains Container Delimiter?} - + CheckContainer -->|Yes| ParseContainer[Parse Container Info] ParseContainer --> SendTelemetry[Send Container Telemetry] SendTelemetry --> GetMetadata - + CheckContainer -->|No| GetMetadata[Get File Metadata] - + GetMetadata --> GetMtime[Get Modification Time] GetMtime --> CheckZeroSize{File Size = 0?} - + CheckZeroSize -->|Yes| LogZeroSize[Log & Send Zero-Size Telemetry] LogZeroSize --> GenerateArchiveName - + CheckZeroSize -->|No| GenerateArchiveName[Generate Archive Name] - + GenerateArchiveName --> AddMetadata[Add SHA1, MAC, Date, Box, Model] AddMetadata --> CheckLength{Filename Length >= 135?} - + CheckLength -->|Yes| RemovePrefix[Remove SHA1 Prefix] RemovePrefix --> CheckLength2{Still >= 135?} - + CheckLength2 -->|Yes| TruncateProcess[Truncate Process Name to 20 chars] TruncateProcess --> CollectFiles - + CheckLength2 -->|No| CollectFiles[Collect Files for Archive] CheckLength -->|No| CollectFiles - + CollectFiles --> AddDumpFile[Add Dump File] AddDumpFile --> AddVersion[Add version.txt] AddVersion --> AddCoreLog[Add core_log.txt] AddCoreLog --> CheckDumpType{Dump Type?} - + CheckDumpType -->|Minidump| GetLogFiles[Get Process Log Files] GetLogFiles --> AddLogFiles[Add Log Files to Archive] AddLogFiles --> CheckTmpUsage - + CheckDumpType -->|Coredump| CheckTmpUsage{/tmp Usage > 70%?} - + CheckTmpUsage -->|Yes| CompressDirect[Compress Directly] CompressDirect --> CheckCompression1{Compression Success?} - + CheckTmpUsage -->|No| CreateTempDir[Create Temp Directory in /tmp] CreateTempDir --> CopyToTemp[Copy Files to Temp] CopyToTemp --> CompressFromTemp[Compress from /tmp] CompressFromTemp --> CheckCompression2{Compression Success?} - + CheckCompression1 -->|No| SendFailTelemetry[Send Compression Fail Telemetry] SendFailTelemetry --> TryTempFallback[Try /tmp Fallback] TryTempFallback --> CheckCompression2 - + CheckCompression2 -->|No| LogCompressionFail[Log: Compression Failed] LogCompressionFail --> CleanupTemp[Cleanup Temp Files] CleanupTemp --> Return3([Return Error]) - + CheckCompression1 -->|Yes| RemoveOriginal[Remove Original Dump] CheckCompression2 -->|Yes| RemoveOriginal - + RemoveOriginal --> CheckBoxReboot{Box Rebooting?} - + CheckBoxReboot -->|Yes| LogRebootSkip[Log: Skip upload, box rebooting] LogRebootSkip --> CleanupTemp - + CheckBoxReboot -->|No| StartUpload[Start Upload Process] StartUpload --> UploadWithRetry[Upload with Retry 3x] UploadWithRetry --> CheckUpload{Upload Success?} - + CheckUpload -->|Yes| RecordTimestamp[Record Upload Timestamp] RecordTimestamp --> RemoveArchive[Remove Archive File] RemoveArchive --> LogSuccess[Log: Upload Success] LogSuccess --> SendUploadTelemetry[Send Upload Success Telemetry] SendUploadTelemetry --> CleanupTemp2[Cleanup Temp Files] CleanupTemp2 --> Return4([Return Success]) - + CheckUpload -->|No & Minidump| SaveDump[Save Dump for Later] SaveDump --> CheckDumpCount{Dump Count > 5?} - + CheckDumpCount -->|Yes| RemoveOldest[Remove Oldest Dumps] RemoveOldest --> CleanupTemp3[Cleanup Temp Files] CleanupTemp3 --> Return5([Return Error]) - + CheckDumpCount -->|No| CleanupTemp3 - + CheckUpload -->|No & Coredump| RemoveFailedArchive[Remove Failed Archive] RemoveFailedArchive --> LogUploadFail[Log: Upload Failed] LogUploadFail --> CleanupTemp4[Cleanup Temp Files] CleanupTemp4 --> Return6([Return Error]) - + style Start fill:#90EE90 style Return1 fill:#FFB6C1 style Return2 fill:#FFB6C1 @@ -210,39 +210,39 @@ flowchart TD flowchart TD Start([Start Upload]) --> InitAttempt[Attempt = 1] InitAttempt --> CheckNetwork{Network Available?} - + CheckNetwork -->|No| LogNoNetwork[Log: No network] LogNoNetwork --> ReturnFail([Return Failure]) - + CheckNetwork -->|Yes| PrepareUpload[Prepare Upload Request] PrepareUpload --> SetURL[Set Portal URL] SetURL --> SetHeaders[Set HTTP Headers] SetHeaders --> SetTLS[Configure TLS 1.2] SetTLS --> SetTimeout[Set Timeout 45s] SetTimeout --> SetOCSP{OCSP Enabled?} - + SetOCSP -->|Yes| EnableOCSP[Enable OCSP Validation] EnableOCSP --> InitCurl - + SetOCSP -->|No| InitCurl[Initialize CURL] - + InitCurl --> PerformUpload[Perform Upload] PerformUpload --> CheckHTTP{HTTP Code?} - + CheckHTTP -->|200-299| LogSuccess[Log: Upload Success] LogSuccess --> ReturnSuccess([Return Success]) - + CheckHTTP -->|Other| LogFailure[Log: Upload Failed] LogFailure --> IncrementAttempt[Attempt++] IncrementAttempt --> CheckAttempts{Attempt <= 3?} - + CheckAttempts -->|Yes| SleepRetry[Sleep 2 seconds] SleepRetry --> LogRetry[Log: Retry attempt] LogRetry --> PrepareUpload - + CheckAttempts -->|No| LogMaxRetries[Log: Max retries reached] LogMaxRetries --> ReturnFail - + style Start fill:#90EE90 style ReturnSuccess fill:#90EE90 style ReturnFail fill:#FF6B6B @@ -256,26 +256,26 @@ flowchart TD ```mermaid flowchart TD Start([Start Cleanup]) --> CheckWorkDir{Working Dir Valid?} - + CheckWorkDir -->|No/Empty| LogError[Log: Working dir invalid] LogError --> Return1([Return]) - + CheckWorkDir -->|Yes| FindOldFiles[Find Files > 2 Days Old] FindOldFiles --> CheckOldFiles{Old Files Found?} - + CheckOldFiles -->|Yes| DeleteOldFiles[Delete Old Files] DeleteOldFiles --> LogDeleted[Log: Deleted files] LogDeleted --> CheckStartup - + CheckOldFiles -->|No| CheckStartup{On Startup?} - + CheckStartup -->|No| DeleteVersion[Delete version.txt] DeleteVersion --> Return2([Return]) - + CheckStartup -->|Yes| CheckCleanupMarker{Cleanup Marker Exists?} - + CheckCleanupMarker -->|Yes| Return3([Return - Already cleaned]) - + CheckCleanupMarker -->|No| FindUnfinished[Find Unfinished Files] FindUnfinished --> DeleteUnfinished[Delete *_mac*_dat* Files] DeleteUnfinished --> LogUnfinished[Log: Deleted unfinished] @@ -284,16 +284,16 @@ flowchart TD DeleteNonDumps --> LogNonDumps[Log: Deleted non-dumps] LogNonDumps --> CountFiles[Count Dump Files] CountFiles --> CheckCount{Count > MAX_CORE_FILES?} - + CheckCount -->|Yes| SortByTime[Sort Files by Time] SortByTime --> CalcDelete[Calculate Files to Delete] CalcDelete --> DeleteOldest[Delete Oldest Files] DeleteOldest --> LogOldest[Log: Deleted oldest] LogOldest --> CreateMarker - + CheckCount -->|No| CreateMarker[Create Cleanup Marker] CreateMarker --> Return4([Return]) - + style Start fill:#90EE90 style Return1 fill:#FFB6C1 style Return2 fill:#FFB6C1 @@ -489,6 +489,105 @@ START Process Dump +--[No & coredump]--> Remove archive --> Log error --> RETURN(error) ``` +## RDK-C Platform Flows + +### RDK-C Platform Initialization + +```mermaid +flowchart TD + Start([Platform Init]) --> ReadDeviceProps[Read /etc/device.properties] + ReadDeviceProps --> GetDeviceType[Get DEVICE_TYPE field] + GetDeviceType --> CheckXHC1{Starts with 'XHC1'?} + + CheckXHC1 -->|Yes| SetRDKC[Set device_type = DEVICE_TYPE_RDKC] + SetRDKC --> SetLogFile["Set core_log_file = $LOG_PATH/core_log.txt"] + SetLogFile --> CheckUploadMode{upload_mode == NORMAL?} + + CheckUploadMode -->|Yes| SetCorePath["Set core_path = /opt/corefiles"] + SetCorePath --> CheckBoxType + CheckUploadMode -->|No| CheckBoxType{box_type == UNKNOWN?} + + CheckBoxType -->|Yes| DefaultBoxType["Set box_type = 'xcam'"] + DefaultBoxType --> Done([Platform Init Complete]) + CheckBoxType -->|No| Done + + CheckXHC1 -->|No| OtherPlatform[Continue with other platform detection] + OtherPlatform --> DoneOther([Other Platform Path]) + + style Start fill:#90EE90 + style Done fill:#90EE90 + style DoneOther fill:#87CEEB + style SetRDKC fill:#FFD700 +``` + +### RDK-C Archive Creation Flow + +```mermaid +flowchart TD + Start([RDKC Archive Start]) --> AddDump[Add dump file to archive list] + AddDump --> AddVersion["Add /version.txt"] + AddVersion --> AddCoreLog["Add core_log.txt"] + AddCoreLog --> CheckBuild{build_type == PROD?} + + CheckBuild -->|Yes| CreateTar[Create tarball with 3 files] + CheckBuild -->|No| CheckReceiver{"$LOG_PATH/receiver.log exists?"} + + CheckReceiver -->|Yes| AddReceiver[Add receiver.log to archive list] + AddReceiver --> CheckThread + CheckReceiver -->|No| CheckThread{"$LOG_PATH/thread.log exists?"} + + CheckThread -->|Yes| AddThread[Add thread.log to archive list] + AddThread --> CreateTarAll[Create tarball with all collected files] + CheckThread -->|No| CreateTarAll + + CreateTar --> Done([Archive Created]) + CreateTarAll --> Done + + style Start fill:#90EE90 + style Done fill:#90EE90 + style AddReceiver fill:#DDA0DD + style AddThread fill:#DDA0DD +``` + +### RDK-C Upload Flow + +```mermaid +flowchart TD + Start([RDKC Upload Start]) --> SetEncrypt["Set encryptionEnable = false"] + SetEncrypt --> SetPortal["Set portal_url = crashportal.stb.r53.xcal.tv"] + SetPortal --> SetReqType["Set request_type = 17"] + SetReqType --> GetS3URL[Get S3 Signing URL] + + GetS3URL --> TryRFC[Try RFC: CrashUpload.S3SigningUrl] + TryRFC --> CheckRFC{RFC read success?} + + CheckRFC -->|Yes| GotURL[Use RFC S3 URL] + CheckRFC -->|No| TryDeviceProps[Try device.properties: S3_AMAZON_SIGNING_URL] + TryDeviceProps --> CheckProps{Read success?} + + CheckProps -->|Yes| GotURL + CheckProps -->|No| ErrorExit[Log error: Unable to get S3 URL] + ErrorExit --> ReturnFail([Return Failure]) + + GotURL --> GetPartnerID["Read partner ID from /opt/usr_config/partnerid.txt"] + GetPartnerID --> SetupMTLS[Setup mTLS via rdkcertselector] + SetupMTLS --> PerformUpload[Perform S3 PUT upload] + PerformUpload --> CheckResult{Upload success?} + + CheckResult -->|Yes| ReturnSuccess([Return Success]) + CheckResult -->|No| Retry{Retries remaining?} + + Retry -->|Yes| SleepRetry[Sleep retry delay] + SleepRetry --> PerformUpload + Retry -->|No| ReturnFail + + style Start fill:#90EE90 + style ReturnSuccess fill:#90EE90 + style ReturnFail fill:#FF6B6B + style PerformUpload fill:#87CEEB + style SetupMTLS fill:#FFD700 +``` + ## Summary of Flowchart Components ### Key Decision Points: diff --git a/docs/migration/diagrams/sequence/uploadDumps-sequence.md b/docs/migration/diagrams/sequence/uploadDumps-sequence.md index 35ba8fd..76d524f 100644 --- a/docs/migration/diagrams/sequence/uploadDumps-sequence.md +++ b/docs/migration/diagrams/sequence/uploadDumps-sequence.md @@ -18,20 +18,20 @@ sequenceDiagram participant Upload as Upload Manager participant Portal as Crash Portal participant Log as Logging System - + User->>Main: Start uploadDumps Main->>Config: Load configuration Config->>Config: Read device.properties Config->>Config: Read include.properties Config->>Config: Load environment vars Config-->>Main: Configuration loaded - + Main->>Platform: Initialize platform Platform->>Platform: Detect device type Platform->>Platform: Get MAC address Platform->>Platform: Get model & SHA1 Platform-->>Main: Platform initialized - + Main->>Lock: Acquire lock Lock->>Lock: Check lock exists alt Lock exists & exit mode @@ -45,28 +45,28 @@ sequenceDiagram Lock->>Lock: Create lock directory Lock-->>Main: Lock acquired end - + Main->>Network: Wait for network Network->>Network: Check route available loop Until available or timeout Network->>Network: Sleep & retry end Network-->>Main: Network ready - + Main->>Network: Wait for system time Network->>Network: Check stt_received flag Network-->>Main: Time synced - + Main->>Scanner: Scan for dumps Scanner->>Scanner: Find *.dmp or *_core*.gz Scanner->>Scanner: Filter processed files Scanner-->>Main: Dump list - + loop For each dump Main->>RateLimit: Check rate limit RateLimit->>RateLimit: Load timestamps RateLimit->>RateLimit: Check recovery time - + alt Recovery time not reached RateLimit-->>Main: Upload denied Main->>RateLimit: Shift recovery time @@ -74,9 +74,9 @@ sequenceDiagram Main->>Lock: Release lock Main->>User: Exit(0) end - + RateLimit->>RateLimit: Check 10 uploads in 10 min - + alt Rate limit exceeded RateLimit-->>Main: Limit exceeded Main->>Archive: Create crashloop marker @@ -91,29 +91,29 @@ sequenceDiagram Main->>User: Exit(0) else Rate limit OK RateLimit-->>Main: Upload allowed - + Main->>Archive: Create archive Archive->>Archive: Generate filename Archive->>Archive: Parse container info (if present) Archive->>Log: Send telemetry Archive->>Archive: Collect log files Archive->>Archive: Create tar.gz - + alt Compression fails Archive->>Archive: Try /tmp fallback Archive->>Log: Send failure telemetry end - + Archive-->>Main: Archive created - + Main->>Upload: Upload archive Upload->>Upload: Prepare HTTPS request Upload->>Upload: Set TLS 1.2 Upload->>Upload: Set timeout 45s - + loop Retry up to 3 times Upload->>Portal: POST archive.tgz - + alt Upload success Portal-->>Upload: HTTP 200 Upload-->>Main: Success @@ -127,7 +127,7 @@ sequenceDiagram Upload->>Upload: Retry end end - + alt All retries failed Upload-->>Main: Upload failed alt Dump is minidump @@ -140,7 +140,7 @@ sequenceDiagram end end end - + Main->>Lock: Release lock Main->>User: Exit(0) ``` @@ -158,13 +158,13 @@ sequenceDiagram participant Compress as Compression participant Telemetry as Telemetry System participant TmpMgr as Temp Manager - + Main->>Archive: Create archive for dump Archive->>File: Get file modification time File-->>Archive: Timestamp - + Archive->>Archive: Check filename for delimiter - + alt Contains <#=#> delimiter Archive->>Container: Parse container info Container->>Container: Extract container name @@ -177,44 +177,44 @@ sequenceDiagram Archive->>Telemetry: Send crashedContainerAppname Archive->>Telemetry: Send APP_ERROR_Crashed end - + Archive->>Archive: Generate archive filename Archive->>Archive: Format: SHA1_macMAC_datDATE_boxTYPE_modMODEL - + alt Filename length >= 135 Archive->>Archive: Remove SHA1 prefix alt Still >= 135 Archive->>Archive: Truncate process name to 20 chars end end - + Archive->>Archive: Sanitize filename Archive->>Archive: Collect files for archive Archive->>Archive: Add dump file Archive->>Archive: Add version.txt Archive->>Archive: Add core_log.txt - + alt Dump type is minidump Archive->>File: Get crashed log files File->>File: Read logmapper config File->>File: Find matching log files File-->>Archive: Log file list - + loop For each log file Archive->>File: Tail log file (5000/500 lines) File-->>Archive: Log content Archive->>Archive: Add to archive list end end - + Archive->>TmpMgr: Check /tmp usage TmpMgr-->>Archive: Usage percentage - + alt Usage > 70% Archive->>Compress: Compress directly Compress->>Compress: nice -n 19 tar -zcvf Compress-->>Archive: Result - + alt Compression failed Archive->>Telemetry: Send SYST_WARN_CompFail Archive->>TmpMgr: Create temp directory @@ -222,7 +222,7 @@ sequenceDiagram Archive->>TmpMgr: Copy files to /tmp Archive->>Compress: Compress from /tmp Compress-->>Archive: Result - + alt Still failed Archive->>Telemetry: Send SYST_ERR_CompFail Archive-->>Main: Error @@ -235,13 +235,13 @@ sequenceDiagram Archive->>Compress: Compress from /tmp Compress-->>Archive: Result end - + Archive->>File: Check file size - + alt File size is 0 Archive->>Telemetry: Send SYST_ERR_MINIDPZEROSIZE end - + Archive->>File: Remove original dump Archive->>TmpMgr: Cleanup temp directory Archive-->>Main: Archive path @@ -259,14 +259,14 @@ sequenceDiagram participant CURL as libcurl participant Portal as Crash Portal participant Log as Logging System - + Main->>Upload: Upload archive Upload->>Network: Check network available Network-->>Upload: Network OK - + Upload->>Upload: Initialize attempt counter Upload->>Upload: Set attempt = 1 - + loop While attempt <= 3 Upload->>Upload: Prepare request Upload->>Upload: Build portal URL @@ -277,14 +277,14 @@ sequenceDiagram Upload->>CURL: curl_easy_setopt(READDATA) Upload->>CURL: curl_easy_setopt(TIMEOUT, 45) Upload->>CURL: curl_easy_setopt(SSLVERSION, TLSv1.2) - + alt OCSP enabled Upload->>CURL: curl_easy_setopt(SSL_VERIFYSTATUS) end - + Upload->>CURL: curl_easy_perform() CURL->>Portal: HTTPS POST archive.tgz - + alt Upload successful Portal-->>CURL: HTTP 200 OK CURL-->>Upload: CURLE_OK @@ -300,7 +300,7 @@ sequenceDiagram CURL-->>Upload: Error code Upload->>Log: Log failure with attempt number Upload->>CURL: curl_easy_cleanup() - + alt Attempt < 3 Upload->>Upload: Increment attempt Upload->>Upload: Sleep 2 seconds @@ -325,19 +325,19 @@ sequenceDiagram participant Archive as Archive Creator participant Upload as Upload Manager participant Portal as Crash Portal - + Main->>RateLimit: Check if upload allowed RateLimit->>File: Read timestamp file File-->>RateLimit: Timestamp list RateLimit->>RateLimit: Parse timestamps - + RateLimit->>File: Read deny_uploads_till file File-->>RateLimit: Recovery time - + alt Recovery time set RateLimit->>RateLimit: Get current time RateLimit->>RateLimit: Compare with recovery time - + alt Current time > recovery time RateLimit->>File: Remove deny_uploads_till RateLimit->>RateLimit: Clear recovery time @@ -350,39 +350,39 @@ sequenceDiagram Main-->>Main: Exit end end - + RateLimit->>RateLimit: Count timestamps - + alt Count < 10 RateLimit-->>Main: Upload allowed else Count >= 10 RateLimit->>RateLimit: Get 10th newest timestamp RateLimit->>RateLimit: Get current time RateLimit->>RateLimit: Calculate time difference - + alt Difference < 600 seconds RateLimit-->>Main: Rate limit exceeded - + Main->>Archive: Create crashloop marker Archive->>Archive: Rename dump.tgz to crashloop.dmp.tgz Archive-->>Main: Crashloop marker - + Main->>Upload: Upload crashloop marker Upload->>Portal: POST crashloop.dmp.tgz Portal-->>Upload: HTTP 200 Upload-->>Main: Upload success - + Main->>RateLimit: Set recovery time RateLimit->>RateLimit: Set recovery = now + 600s RateLimit->>File: Write deny_uploads_till - + Main->>File: Remove all pending dumps Main-->>Main: Exit else Difference >= 600 seconds RateLimit-->>Main: Upload allowed end end - + Main->>Main: Process dump normally Main->>RateLimit: Record upload timestamp RateLimit->>RateLimit: Add current time to list @@ -404,17 +404,17 @@ sequenceDiagram participant Network as Network Utils participant File as File Utils participant Device as Device Info - + Main->>Platform: Initialize platform - + Platform->>Config: Get DEVICE_TYPE Config-->>Platform: Device type (broadband/video/extender) - + alt Device type is broadband Platform->>Platform: Set CORE_PATH=/minidumps Platform->>Platform: Set LOG_PATH=/rdklogs/logs Platform->>Config: Get MULTI_CORE - + alt Multi-core enabled Platform->>Network: Get interface from function else Single-core @@ -428,25 +428,25 @@ sequenceDiagram Platform->>Platform: Set CORE_PATH=/minidumps Platform->>Platform: Set LOG_PATH=/var/log/messages end - + Platform->>File: Read /tmp/.macAddress File-->>Platform: MAC address - + alt MAC is empty Platform->>Network: Get MAC address Network->>Network: Query all interfaces Network-->>Platform: MAC address - + alt Still empty Platform->>Platform: Set MAC=000000000000 end end - + Platform->>Platform: Format MAC (uppercase, no colons) - + Platform->>Config: Get MODEL_NUM Config-->>Platform: Model number - + alt Model number empty alt Device type is broadband Platform->>Device: Call dmcli @@ -458,24 +458,24 @@ sequenceDiagram Platform->>Device: Call getDeviceDetails.sh Device-->>Platform: Model from script end - + alt Still empty Platform->>Platform: Set MODEL=UNKNOWN end end - + Platform->>File: Calculate SHA1 of /version.txt File->>File: Read version.txt File->>File: Calculate SHA1 hash File-->>Platform: SHA1 hash - + alt SHA1 empty Platform->>Platform: Set SHA1=0000...0000 end - + Platform->>Config: Get BOX_TYPE Config-->>Platform: Box type - + Platform-->>Main: Platform initialized ``` @@ -488,7 +488,7 @@ User -> Main: Start uploadDumps Main -> Config: Load configuration Config -> Config: Read device.properties -Config -> Config: Read include.properties +Config -> Config: Read include.properties Config -> Config: Load environment Config -> Main: Configuration loaded @@ -533,16 +533,16 @@ LOOP for each dump: Main -> RateLimit: Check rate limit RateLimit -> RateLimit: Load timestamps RateLimit -> RateLimit: Check recovery time - + IF recovery time not reached: RateLimit -> Main: Upload denied Main -> RateLimit: Shift recovery time Main -> Scanner: Remove pending dumps Main -> Lock: Release lock Main -> User: Exit(0) - + RateLimit -> RateLimit: Check 10 in 10 min - + IF rate limit exceeded: RateLimit -> Main: Limit exceeded Main -> Archive: Create crashloop marker @@ -555,31 +555,31 @@ LOOP for each dump: Main -> Scanner: Remove pending dumps Main -> Lock: Release lock Main -> User: Exit(0) - + IF rate limit OK: RateLimit -> Main: Upload allowed - + Main -> Archive: Create archive Archive -> Archive: Generate filename Archive -> Archive: Parse container info Archive -> Log: Send telemetry Archive -> Archive: Collect log files Archive -> Archive: Create tar.gz - + IF compression fails: Archive -> Archive: Try /tmp fallback Archive -> Log: Send failure telemetry - + Archive -> Main: Archive created - + Main -> Upload: Upload archive Upload -> Upload: Prepare HTTPS request Upload -> Upload: Set TLS 1.2 Upload -> Upload: Set timeout 45s - + LOOP retry up to 3 times: Upload -> Portal: POST archive.tgz - + IF upload success: Portal -> Upload: HTTP 200 Upload -> Main: Success @@ -588,15 +588,15 @@ LOOP for each dump: Main -> Log: Log success Main -> Log: Send upload telemetry BREAK - + IF upload fails: Portal -> Upload: HTTP error Upload -> Upload: Wait 2 seconds Upload -> Upload: Retry - + IF all retries failed: Upload -> Main: Upload failed - + IF dump is minidump: Main -> Archive: Save dump locally Main -> Log: Log save @@ -643,7 +643,7 @@ IF dump type is minidump: File -> File: Read logmapper config File -> File: Find matching log files File -> Archive: Log file list - + LOOP for each log file: Archive -> File: Tail log file (5000/500 lines) File -> Archive: Log content @@ -656,7 +656,7 @@ IF usage > 70%: Archive -> Compress: Compress directly Compress -> Compress: nice -n 19 tar -zcvf Compress -> Archive: Result - + IF compression failed: Archive -> Telemetry: Send SYST_WARN_CompFail Archive -> TmpMgr: Create temp directory @@ -664,7 +664,7 @@ IF usage > 70%: Archive -> TmpMgr: Copy files to /tmp Archive -> Compress: Compress from /tmp Compress -> Archive: Result - + IF still failed: Archive -> Telemetry: Send SYST_ERR_CompFail Archive -> Main: Error @@ -685,6 +685,129 @@ Archive -> TmpMgr: Cleanup temp directory Archive -> Main: Archive path ``` +## RDK-C Platform Sequences + +### RDK-C Platform Initialization Sequence + +```mermaid +sequenceDiagram + participant Main as Main Controller + participant Config as Config Manager + participant Props as device.properties + participant Platform as Platform Layer + + Main->>Config: Load configuration + Config->>Props: Read DEVICE_TYPE field + Props-->>Config: "XHC1..." + Config->>Config: strncmp(data, "XHC1", 4) == 0 + Config->>Config: Set device_type = DEVICE_TYPE_RDKC + Config->>Config: Set core_log_file = $LOG_PATH/core_log.txt + + Config->>Config: Check upload_mode == NORMAL + alt NORMAL mode + Config->>Config: Set core_path = /opt/corefiles + end + + Config->>Config: Check box_type == "UNKNOWN" + alt box_type unknown + Config->>Config: Set box_type = "xcam" + end + + Config-->>Main: Configuration loaded (RDKC) + Main->>Platform: Initialize platform + Platform->>Platform: Get MAC address + Platform->>Platform: Get model & SHA1 + Platform-->>Main: Platform initialized +``` + +### RDK-C Archive Creation Sequence + +```mermaid +sequenceDiagram + participant Main as Main Controller + participant Archive as Archive Creator + participant FS as Filesystem + participant Log as Logger + + Main->>Archive: Create archive for RDKC device + Archive->>Archive: Set arch_files_list[0] = dump file (renamed) + Archive->>Archive: Set arch_files_list[1] = /version.txt + Archive->>Archive: Set arch_files_list[2] = core_log.txt + Archive->>Archive: no_of_files = 3 + + alt build_type != PROD + Archive->>FS: Check $LOG_PATH/receiver.log exists + alt receiver.log exists + FS-->>Archive: File found + Archive->>Archive: Add receiver.log to list + Archive->>Log: "RDKC adding receiver.log" + Archive->>Archive: no_of_files++ + end + + Archive->>FS: Check $LOG_PATH/thread.log exists + alt thread.log exists + FS-->>Archive: File found + Archive->>Archive: Add thread.log to list + Archive->>Log: "RDKC adding thread.log" + Archive->>Archive: no_of_files++ + end + end + + Archive->>Log: "RDKC tar file: files=" + Archive->>Archive: create_tarball(compress=true, target, files, count) + Archive-->>Main: Archive created +``` + +### RDK-C Upload Sequence + +```mermaid +sequenceDiagram + participant Main as Main Controller + participant Upload as Upload Manager + participant RFC as RFC Interface (2-param) + participant Props as device.properties + participant Cert as rdkcertselector + participant S3 as S3 / Crash Portal + participant Log as Logger + + Main->>Upload: Upload archive (DEVICE_TYPE_RDKC) + Upload->>Upload: Set encryptionEnable = "false" + Upload->>Upload: Set portal_url = "crashportal.stb.r53.xcal.tv" + Upload->>Upload: Set request_type = 17 + + Upload->>RFC: getRFCParameter("CrashUpload.S3SigningUrl", buf) + alt RFC success + RFC-->>Upload: S3 signing URL + else RFC failure + Upload->>Props: getDevicePropertyData("S3_AMAZON_SIGNING_URL") + alt Properties success + Props-->>Upload: S3 signing URL + else Properties failure + Upload->>Log: "RDKC: Unable to get the S3 server url" + Upload-->>Main: Return error + end + end + + Upload->>Upload: Read partner ID from /opt/usr_config/partnerid.txt + Upload->>Cert: Get mTLS certificate (rdkcertselector) + Cert-->>Upload: Client cert + key + + loop Retry up to MAX_RETRIES + Upload->>S3: S3 PUT (mTLS, request_type=17) + alt HTTP 200-299 + S3-->>Upload: Success + Upload->>Log: Upload success + Upload-->>Main: Return success + else HTTP error + S3-->>Upload: Failure + Upload->>Log: Upload failed, retrying + end + end + + Upload->>Log: "Max retries reached" + Upload-->>Main: Return failure +``` + ## Summary of Interactions ### Key Sequences: diff --git a/docs/migration/hld/uploadDumps-hld.md b/docs/migration/hld/uploadDumps-hld.md index d1b5385..bacf7c9 100644 --- a/docs/migration/hld/uploadDumps-hld.md +++ b/docs/migration/hld/uploadDumps-hld.md @@ -96,7 +96,7 @@ typedef struct { **Purpose**: Isolate platform-specific code and provide unified interface **Responsibilities**: -- Device type detection (broadband, extender, hybrid, mediaclient) +- Device type detection (broadband, extender, hybrid, mediaclient, rdkc) - Platform-specific path configuration - Interface name resolution - Platform-specific feature flags @@ -125,6 +125,30 @@ typedef struct { } platform_config_t; ``` +**Platform Support Matrix**: + +| Aspect | Broadband | Extender | Hybrid | Mediaclient | RDK-C (Camera) | +|--------|-----------|----------|--------|-------------|----------------| +| Detection Key | — | — | — | — | XHC1 | +| Core Path | /minidumps | /minidumps | systemd default | systemd default | /opt/corefiles | +| Minidump Path | /minidumps | /minidumps | /opt/minidumps | /opt/minidumps | /opt/minidumps | +| BOX_TYPE | from props | from props | from props | from props | defaults to "xcam" | +| Upload Auth | mTLS | mTLS | mTLS | mTLS | mTLS via rdkcertselector | +| Encryption | configurable | configurable | configurable | configurable | disabled | +| RFC Variant | 3-param (WDMP) | 3-param (WDMP) | 3-param (WDMP) | 3-param (WDMP) | 2-param (INI-backed) | +| Request Type | — | — | — | 18 | 17 | +| Partner ID Source | account file | account file | device props | device props | /opt/usr_config/partnerid.txt | + +#### 2.2.1 RDK-C Platform Characteristics + +The RDK-C (camera) platform is identified by the `XHC1` value in the `DEVICE_TYPE` field of `/etc/device.properties`. Key platform-specific behaviors: + +- **Path Configuration**: Uses `/opt/corefiles` for coredumps (non-systemd) and `/opt/minidumps` for minidumps. +- **RFC Interface**: Uses a 2-parameter `getRFCParameter` variant that reads from INI files. `setRFCParameter` is not supported on this platform. +- **Upload Flow**: Uses S3 signed URL with `request_type=17`, portal `crashportal.stb.r53.xcal.tv`, encryption disabled. Authentication via mTLS with cert rotation managed by `rdkcertselector`. +- **Archive Composition**: Base archive includes dump + `/version.txt` + `core_log.txt`. Non-production builds additionally include `receiver.log` and `thread.log` from `$LOG_PATH` if present. +- **BOX_TYPE Default**: Falls back to `"xcam"` if not explicitly set in device properties. + ### 2.3 Configuration Manager **Purpose**: Load and manage configuration from multiple sources @@ -202,7 +226,7 @@ typedef struct { **Key Interfaces**: ```c -int archive_create(const dump_file_t *dump, const config_t *config, +int archive_create(const dump_file_t *dump, const config_t *config, char *archive_path, size_t path_len); int archive_add_metadata(archive_t *archive, const config_t *config); int archive_add_logs(archive_t *archive, const char *process_name); @@ -238,9 +262,9 @@ typedef struct { **Key Interfaces**: ```c int upload_init(upload_config_t *config); -int upload_file(const char *filepath, const upload_config_t *config, +int upload_file(const char *filepath, const upload_config_t *config, upload_result_t *result); -int upload_retry(const char *filepath, const upload_config_t *config, +int upload_retry(const char *filepath, const upload_config_t *config, int max_retries, upload_result_t *result); bool upload_check_privacy_mode(void); void upload_cleanup(upload_config_t *config); @@ -359,7 +383,7 @@ int file_get_sha1(const char *path, char *hash, size_t len); int string_sanitize(const char *input, char *output, size_t len); int string_format_mac(const char *mac, char *output, size_t len); int string_format_timestamp(time_t time, char *output, size_t len); -int string_generate_filename(const char *sha1, const char *mac, +int string_generate_filename(const char *sha1, const char *mac, const char *timestamp, const char *box_type, const char *model, const char *original, char *output, size_t len); @@ -596,7 +620,7 @@ function create_lock_or_wait(lock_path, mode): log("Waiting for lock...") sleep(2) continue - + if create_directory(lock_path) == SUCCESS: return SUCCESS else: @@ -613,27 +637,27 @@ function create_lock_or_wait(lock_path, mode): ``` function generate_dump_filename(sha1, mac, timestamp, box_type, model, original): # Format: sha1_macMAC_datDATE_boxTYPE_modMODEL_original - + # Check if already processed if original contains "_mac" and "_dat" and "_box" and "_mod": return original # Already has metadata - + # Generate base name - filename = sha1 + "_mac" + mac + "_dat" + timestamp + + filename = sha1 + "_mac" + mac + "_dat" + timestamp + "_box" + box_type + "_mod" + model + "_" + original - + # Handle filename length limit (135 chars for ecryptfs) if length(filename) >= 135: # Remove SHA1 prefix filename = remove_prefix(filename, sha1 + "_") - + if length(filename) >= 135: # Truncate process name to 20 chars filename = truncate_process_name(filename, 20) - + # Sanitize filename = sanitize(filename) - + return filename ``` @@ -642,13 +666,13 @@ function generate_dump_filename(sha1, mac, timestamp, box_type, model, original) ``` function is_upload_limit_reached(): timestamps = read_timestamp_file() - + if count(timestamps) < 10: return false # Not enough uploads yet - + oldest_timestamp = timestamps[0] # First entry current_time = now() - + if (current_time - oldest_timestamp) < 600: # 10 minutes return true # Rate limit exceeded else: @@ -661,22 +685,22 @@ function is_upload_limit_reached(): function create_archive(dump_file, config): # Generate archive name archive_name = generate_dump_filename(...) - + # Parse container info if present if dump_file contains "<#=#>": container_info = parse_container_crash(dump_file) send_telemetry(container_info) - + # Collect files to archive files = [] files.add(dump_file) files.add("version.txt") files.add("core_log.txt") - + if dump_type == MINIDUMP: log_files = get_crashed_log_files(dump_file) files.add(log_files) - + # Check /tmp usage tmp_usage = get_disk_usage("/tmp") if tmp_usage > 70%: @@ -686,7 +710,7 @@ function create_archive(dump_file, config): temp_dir = create_temp_directory() copy_files_to_temp(files, temp_dir) files = temp_dir_files - + # Create compressed archive try: create_tar_gz(archive_name, files) @@ -698,10 +722,10 @@ function create_archive(dump_file, config): create_tar_gz(archive_name, temp_dir_files) else: raise error - + # Cleanup remove_temp_files() - + return archive_name ``` @@ -711,13 +735,13 @@ function create_archive(dump_file, config): function parse_container_crash(filename): delimiter = "<#=#>" backward_delimiter = "-" - + if not contains(filename, delimiter): return null # Not a container crash - + # Split by delimiter parts = split(filename, delimiter) - + if count(parts) == 3: # Format: processname_appname<#=#>status<#=#>timestamp.dmp container_name = parts[0] @@ -728,15 +752,15 @@ function parse_container_crash(filename): container_name = parts[0] container_status = "unknown" container_time = parts[1] - + # Extract app name and process name name_parts = split(container_name, "_") process_name = name_parts[0] app_name = join(name_parts[1:], "_") - + # Create normalized filename normalized = container_name + backward_delimiter + container_time - + return { container_name: container_name, container_status: container_status, @@ -865,7 +889,7 @@ if (device_type == DEVICE_TYPE_BROADBAND) { #### 5.5.2 Video Platform ```c -if (device_type == DEVICE_TYPE_HYBRID || +if (device_type == DEVICE_TYPE_HYBRID || device_type == DEVICE_TYPE_MEDIACLIENT) { // Defer processing if uptime < 480 seconds if (get_uptime() < 480) { @@ -915,21 +939,21 @@ typedef enum { void cleanup_and_exit(int exit_code) { // Remove lock lock_remove(lock_path); - + // Close log file log_cleanup(); - + // Free allocated memory config_cleanup(&config); - + // Remove temp files file_cleanup_temp_dir(temp_dir); - + // Set crash reboot flag if broadband if (device_type == DEVICE_TYPE_BROADBAND) { touch("/tmp/crash_reboot"); } - + exit(exit_code); } ``` diff --git a/docs/migration/lld/uploadDumps-lld.md b/docs/migration/lld/uploadDumps-lld.md index 8fda060..ef498a5 100644 --- a/docs/migration/lld/uploadDumps-lld.md +++ b/docs/migration/lld/uploadDumps-lld.md @@ -60,6 +60,7 @@ typedef enum { DEVICE_TYPE_EXTENDER, DEVICE_TYPE_HYBRID, DEVICE_TYPE_MEDIACLIENT, + DEVICE_TYPE_RDKC, DEVICE_TYPE_UNKNOWN } device_type_t; @@ -90,21 +91,21 @@ typedef struct { dump_type_t dump_type; upload_mode_t upload_mode; lock_mode_t lock_mode; - + char working_dir[PATH_MAX]; char log_path[PATH_MAX]; char core_path[PATH_MAX]; char minidumps_path[PATH_MAX]; - + char portal_url[URL_MAX_LEN]; char partner_id[PARTNER_ID_LEN]; char rdk_path[PATH_MAX]; - + bool telemetry_enabled; bool multi_core; bool enable_ocsp; bool enable_ocsp_stapling; - + int max_core_files; int upload_timeout; int max_retries; @@ -225,7 +226,7 @@ typedef struct { /** * @brief Main entry point - * + * * @param argc Argument count * @param argv Argument vector * argv[1]: Reserved (not used, previously CRASHTS) @@ -238,7 +239,7 @@ int main(int argc, char *argv[]); /** * @brief Parse command line arguments - * + * * @param argc Argument count * @param argv Argument vector * @param config Configuration structure to populate @@ -248,7 +249,7 @@ int parse_arguments(int argc, char *argv[], config_t *config); /** * @brief Initialize all subsystems - * + * * @param config Configuration structure * @param platform Platform configuration * @return 0 on success, error code on failure @@ -257,7 +258,7 @@ int initialize_system(const config_t *config, platform_config_t *platform); /** * @brief Main processing loop - * + * * @param config Configuration structure * @param platform Platform configuration * @return 0 on success, error code on failure @@ -266,14 +267,14 @@ int process_dumps_loop(const config_t *config, const platform_config_t *platform /** * @brief Cleanup and exit - * + * * @param exit_code Exit code to return */ void cleanup_and_exit(int exit_code) __attribute__((noreturn)); /** * @brief Signal handler - * + * * @param signum Signal number */ void signal_handler(int signum); @@ -286,7 +287,7 @@ void signal_handler(int signum); /** * @brief Load configuration from all sources - * + * * @param config Configuration structure to populate * @return 0 on success, error code on failure */ @@ -294,7 +295,7 @@ int config_load(config_t *config); /** * @brief Load configuration from a file - * + * * @param path File path * @param config Configuration structure to update * @return 0 on success, error code on failure @@ -303,7 +304,7 @@ int config_load_file(const char *path, config_t *config); /** * @brief Load configuration from environment variables - * + * * @param config Configuration structure to update * @return 0 on success, error code on failure */ @@ -311,7 +312,7 @@ int config_load_environment(config_t *config); /** * @brief Validate configuration - * + * * @param config Configuration structure to validate * @return 0 if valid, error code otherwise */ @@ -319,18 +320,18 @@ int config_validate(const config_t *config); /** * @brief Get string value from configuration - * + * * @param config Configuration structure * @param key Configuration key * @param default_val Default value if not found * @return Configuration value or default */ -const char* config_get_string(const config_t *config, const char *key, +const char* config_get_string(const config_t *config, const char *key, const char *default_val); /** * @brief Get integer value from configuration - * + * * @param config Configuration structure * @param key Configuration key * @param default_val Default value if not found @@ -340,7 +341,7 @@ int config_get_int(const config_t *config, const char *key, int default_val); /** * @brief Free configuration resources - * + * * @param config Configuration structure to free */ void config_cleanup(config_t *config); @@ -353,7 +354,7 @@ void config_cleanup(config_t *config); /** * @brief Initialize platform configuration - * + * * @param config Global configuration * @param platform Platform configuration to populate * @return 0 on success, error code on failure @@ -362,19 +363,19 @@ int platform_init(const config_t *config, platform_config_t *platform); /** * @brief Get dump directory path for device type - * + * * @param device_type Device type * @param secure Secure mode flag * @param path Buffer to store path * @param len Buffer length * @return 0 on success, error code on failure */ -int platform_get_dump_path(device_type_t device_type, bool secure, +int platform_get_dump_path(device_type_t device_type, bool secure, char *path, size_t len); /** * @brief Get log directory path for device type - * + * * @param device_type Device type * @param path Buffer to store path * @param len Buffer length @@ -384,18 +385,18 @@ int platform_get_log_path(device_type_t device_type, char *path, size_t len); /** * @brief Get network interface name for device type - * + * * @param device_type Device type * @param interface Buffer to store interface name * @param len Buffer length * @return 0 on success, error code on failure */ -int platform_get_interface_name(device_type_t device_type, +int platform_get_interface_name(device_type_t device_type, char *interface, size_t len); /** * @brief Check if platform supports a feature - * + * * @param feature Feature to check * @return true if supported, false otherwise */ @@ -403,7 +404,7 @@ bool platform_supports_feature(platform_feature_t feature); /** * @brief Get device MAC address - * + * * @param platform Platform configuration * @return 0 on success, error code on failure */ @@ -411,7 +412,7 @@ int platform_get_mac_address(platform_config_t *platform); /** * @brief Get device model number - * + * * @param platform Platform configuration * @return 0 on success, error code on failure */ @@ -419,13 +420,94 @@ int platform_get_model_number(platform_config_t *platform); /** * @brief Get build SHA1 hash - * + * * @param platform Platform configuration * @return 0 on success, error code on failure */ int platform_get_sha1(platform_config_t *platform); ``` +#### 3.3.1 RDK-C Platform Configuration + +The RDK-C (camera) platform uses the following configuration values when `DEVICE_TYPE_RDKC` is detected: + +| Field | Value | Notes | +|-------|-------|-------| +| `core_path` | `/opt/corefiles` | Non-systemd coredump location | +| `minidumps_path` | `/opt/minidumps` | Standard minidump location | +| `core_log_file` | `$LOG_PATH/core_log.txt` | Same convention as mediaclient | +| `box_type` | `xcam` | Default when not set in device.properties | +| Partner ID file | `/opt/usr_config/partnerid.txt` | RDKC-specific location | + +**Detection Logic** (in `config_manager.c`): +```c +// XHC1 prefix in DEVICE_TYPE field triggers RDKC classification +if (strncmp(device_prop_data, "XHC1", 4) == 0) { + config->device_type = DEVICE_TYPE_RDKC; +} +``` + +**Path Override** (applied after initial config load): +```c +if (config->upload_mode == UPLOAD_MODE_NORMAL && + config->device_type == DEVICE_TYPE_RDKC) { + strcpy(config->core_path, "/opt/corefiles"); + /* minidump_path remains /opt/minidumps */ +} +``` + +**BOX_TYPE Fallback**: +```c +if (strcmp(config->box_type, "UNKNOWN") == 0 && + config->device_type == DEVICE_TYPE_RDKC) { + strcpy(config->box_type, "xcam"); +} +``` + +#### 3.3.2 RDK-C RFC Interface + +RDK-C uses a 2-parameter `getRFCParameter` variant (INI-file backed). The standard 3-parameter WDMP-based version used by STB platforms is not available. + +```c +#if defined(RDKC) +/* 2-param: getRFCParameter(param_name, output_buf) — reads from INI files */ +int read_RFCProperty(const char *key, const char *rfc_param, char *value, size_t len); +/* setRFCParameter is NOT supported on RDKC */ +#else +/* 3-param: getRFCParameter(param_name, output_buf, wdmp_status) — TR-181 based */ +int read_RFCProperty(const char *key, const char *rfc_param, char *value, size_t len); +int write_RFCProperty(const char *rfc_param, const char *value); +#endif +``` + +#### 3.3.3 RDK-C Archive Composition + +For `DEVICE_TYPE_RDKC` minidump archives: + +``` +Archive contents (production): + [0] dump file (renamed with metadata prefix) + [1] /version.txt + [2] $LOG_PATH/core_log.txt + +Archive contents (non-production, additional): + [3] $LOG_PATH/receiver.log (if file exists) + [4] $LOG_PATH/thread.log (if file exists) +``` + +#### 3.3.4 RDK-C Upload Flow + +```c +/* RDKC upload parameters */ +encryptionEnable = "false"; +portal_url = "crashportal.stb.r53.xcal.tv"; +request_type = 17; +/* S3 signing URL from RFC (CrashUpload.S3SigningUrl) or + device.properties (S3_AMAZON_SIGNING_URL) */ +``` + +Authentication uses mTLS with certificate rotation via `rdkcertselector`. + ### 3.4 Scanner Module ```c @@ -433,7 +515,7 @@ int platform_get_sha1(platform_config_t *platform); /** * @brief Initialize scanner - * + * * @param directory Directory to scan * @return Scanner handle or NULL on error */ @@ -441,18 +523,18 @@ scanner_t* scanner_init(const char *directory); /** * @brief Find dump files matching pattern - * + * * @param scanner Scanner handle * @param pattern File pattern (e.g., "*.dmp*") * @param list List to populate with results * @return 0 on success, error code on failure */ -int scanner_find_dumps(scanner_t *scanner, const char *pattern, +int scanner_find_dumps(scanner_t *scanner, const char *pattern, dump_list_t *list); /** * @brief Check if file is already processed - * + * * @param filename Filename to check * @return true if processed, false otherwise */ @@ -460,7 +542,7 @@ bool scanner_is_processed(const char *filename); /** * @brief Filter dump list by criteria - * + * * @param list Dump list * @param filter_func Filter function * @return Number of items remaining @@ -469,21 +551,21 @@ int scanner_filter(dump_list_t *list, bool (*filter_func)(const dump_file_t*)); /** * @brief Sort dump list by modification time - * + * * @param list Dump list to sort */ void scanner_sort_by_time(dump_list_t *list); /** * @brief Free scanner resources - * + * * @param scanner Scanner handle */ void scanner_cleanup(scanner_t *scanner); /** * @brief Free dump list - * + * * @param list Dump list to free */ void dump_list_free(dump_list_t *list); @@ -496,19 +578,19 @@ void dump_list_free(dump_list_t *list); /** * @brief Create new archive - * + * * @param dump Dump file to archive * @param config Global configuration * @param platform Platform configuration * @return Archive handle or NULL on error */ -archive_t* archive_create(const dump_file_t *dump, +archive_t* archive_create(const dump_file_t *dump, const config_t *config, const platform_config_t *platform); /** * @brief Parse container information from filename - * + * * @param filename Dump filename * @param info Container info structure to populate * @return 0 on success, error code on failure @@ -517,7 +599,7 @@ int archive_parse_container_info(const char *filename, container_info_t *info); /** * @brief Generate archive filename with metadata - * + * * @param dump Dump file * @param platform Platform configuration * @param filename Buffer to store filename @@ -530,7 +612,7 @@ int archive_generate_filename(const dump_file_t *dump, /** * @brief Add file to archive - * + * * @param archive Archive handle * @param filepath File to add * @return 0 on success, error code on failure @@ -539,7 +621,7 @@ int archive_add_file(archive_t *archive, const char *filepath); /** * @brief Add log files for crashed process - * + * * @param archive Archive handle * @param process_name Process name * @param config Global configuration @@ -550,7 +632,7 @@ int archive_add_log_files(archive_t *archive, const char *process_name, /** * @brief Finalize and compress archive - * + * * @param archive Archive handle * @return 0 on success, error code on failure */ @@ -558,7 +640,7 @@ int archive_finalize(archive_t *archive); /** * @brief Get archive path - * + * * @param archive Archive handle * @return Archive file path */ @@ -566,7 +648,7 @@ const char* archive_get_path(const archive_t *archive); /** * @brief Free archive resources - * + * * @param archive Archive handle */ void archive_cleanup(archive_t *archive); @@ -579,7 +661,7 @@ void archive_cleanup(archive_t *archive); /** * @brief Initialize upload configuration - * + * * @param config Upload configuration * @param global_config Global configuration * @return 0 on success, error code on failure @@ -588,7 +670,7 @@ int upload_init(upload_config_t *config, const config_t *global_config); /** * @brief Upload file to server - * + * * @param filepath File to upload * @param config Upload configuration * @param result Upload result structure @@ -599,7 +681,7 @@ int upload_file(const char *filepath, const upload_config_t *config, /** * @brief Upload file with retry logic - * + * * @param filepath File to upload * @param config Upload configuration * @param max_retries Maximum retry attempts @@ -611,14 +693,14 @@ int upload_retry(const char *filepath, const upload_config_t *config, /** * @brief Check if privacy mode is enabled - * + * * @return true if enabled, false otherwise */ bool upload_check_privacy_mode(void); /** * @brief Free upload configuration - * + * * @param config Upload configuration */ void upload_cleanup(upload_config_t *config); @@ -631,7 +713,7 @@ void upload_cleanup(upload_config_t *config); /** * @brief Initialize rate limiter - * + * * @param timestamp_file Timestamp file path * @return Rate limiter handle or NULL on error */ @@ -639,7 +721,7 @@ ratelimit_t* ratelimit_init(const char *timestamp_file); /** * @brief Check if upload limit is exceeded - * + * * @param limiter Rate limiter handle * @return true if exceeded, false otherwise */ @@ -647,7 +729,7 @@ bool ratelimit_is_exceeded(ratelimit_t *limiter); /** * @brief Check if recovery time has been reached - * + * * @param limiter Rate limiter handle * @return true if reached, false otherwise */ @@ -655,7 +737,7 @@ bool ratelimit_is_recovery_time_reached(ratelimit_t *limiter); /** * @brief Record upload timestamp - * + * * @param limiter Rate limiter handle * @return 0 on success, error code on failure */ @@ -663,7 +745,7 @@ int ratelimit_record_upload(ratelimit_t *limiter); /** * @brief Set recovery time - * + * * @param limiter Rate limiter handle * @param seconds Seconds from now * @return 0 on success, error code on failure @@ -672,7 +754,7 @@ int ratelimit_set_recovery_time(ratelimit_t *limiter, int seconds); /** * @brief Free rate limiter resources - * + * * @param limiter Rate limiter handle */ void ratelimit_cleanup(ratelimit_t *limiter); @@ -685,7 +767,7 @@ void ratelimit_cleanup(ratelimit_t *limiter); /** * @brief Check if network is available - * + * * @param interface Network interface name * @return true if available, false otherwise */ @@ -693,7 +775,7 @@ bool network_is_available(const char *interface); /** * @brief Wait for network connection - * + * * @param max_iterations Maximum wait iterations * @param delay_seconds Delay between iterations * @return 0 if available, error code on timeout @@ -702,14 +784,14 @@ int network_wait_for_connection(int max_iterations, int delay_seconds); /** * @brief Check if route is available - * + * * @return true if available, false otherwise */ bool network_check_route_available(void); /** * @brief Wait for system time synchronization - * + * * @param max_iterations Maximum wait iterations * @param delay_seconds Delay between iterations * @return 0 if synced, error code on timeout @@ -718,7 +800,7 @@ int network_wait_for_system_time(int max_iterations, int delay_seconds); /** * @brief Check network communication status (broadband-specific) - * + * * @return 0 if OK, error code otherwise */ int network_commn_status(void); @@ -731,7 +813,7 @@ int network_commn_status(void); /** * @brief Check if file exists - * + * * @param path File path * @return true if exists, false otherwise */ @@ -739,7 +821,7 @@ bool file_exists(const char *path); /** * @brief Get file modification time as formatted string - * + * * @param path File path * @param timestamp Buffer to store timestamp * @param len Buffer length @@ -749,7 +831,7 @@ int file_get_mtime_string(const char *path, char *timestamp, size_t len); /** * @brief Get file modification time - * + * * @param path File path * @return Modification time or 0 on error */ @@ -757,7 +839,7 @@ time_t file_get_mtime(const char *path); /** * @brief Delete file safely with validation - * + * * @param path File path * @return 0 on success, error code on failure */ @@ -765,7 +847,7 @@ int file_delete_safely(const char *path); /** * @brief Sanitize filename (remove invalid characters) - * + * * @param input Input filename * @param output Output buffer * @param len Buffer length @@ -775,7 +857,7 @@ int file_sanitize_name(const char *input, char *output, size_t len); /** * @brief Create temporary directory - * + * * @param path Buffer to store path * @param len Buffer length * @return 0 on success, error code on failure @@ -784,14 +866,14 @@ int file_create_temp_dir(char *path, size_t len); /** * @brief Cleanup temporary directory - * + * * @param path Directory path */ void file_cleanup_temp_dir(const char *path); /** * @brief Calculate SHA1 hash of file - * + * * @param path File path * @param hash Buffer to store hash * @param len Buffer length (must be >= 41) @@ -801,7 +883,7 @@ int file_get_sha1(const char *path, char *hash, size_t len); /** * @brief Get disk usage percentage - * + * * @param path Mount point or directory * @return Usage percentage (0-100) or -1 on error */ @@ -809,7 +891,7 @@ int file_get_disk_usage(const char *path); /** * @brief Copy file - * + * * @param src Source file path * @param dst Destination file path * @return 0 on success, error code on failure @@ -818,7 +900,7 @@ int file_copy(const char *src, const char *dst); /** * @brief Tail file (get last N lines) - * + * * @param path File path * @param lines Number of lines * @param output Buffer to store output @@ -835,7 +917,7 @@ int file_tail(const char *path, int lines, char *output, size_t len); /** * @brief Sanitize string (remove non-alphanumeric characters) - * + * * @param input Input string * @param output Output buffer * @param len Buffer length @@ -845,19 +927,19 @@ int string_sanitize(const char *input, char *output, size_t len); /** * @brief Format MAC address - * + * * @param mac Input MAC address * @param output Output buffer * @param len Buffer length * @param with_colons Include colons flag * @return 0 on success, error code on failure */ -int string_format_mac(const char *mac, char *output, size_t len, +int string_format_mac(const char *mac, char *output, size_t len, bool with_colons); /** * @brief Format timestamp - * + * * @param time Time value * @param output Output buffer * @param len Buffer length @@ -869,7 +951,7 @@ int string_format_timestamp(time_t time, char *output, size_t len, /** * @brief Generate dump filename with metadata - * + * * @param sha1 SHA1 hash * @param mac MAC address * @param timestamp Timestamp @@ -887,7 +969,7 @@ int string_generate_filename(const char *sha1, const char *mac, /** * @brief Replace substring in string - * + * * @param str Input/output string * @param len String buffer length * @param old Old substring @@ -898,7 +980,7 @@ int string_replace(char *str, size_t len, const char *old, const char *new); /** * @brief Check if string contains substring - * + * * @param str String to search * @param substr Substring to find * @return true if found, false otherwise @@ -913,7 +995,7 @@ bool string_contains(const char *str, const char *substr); /** * @brief Create lock - * + * * @param lock_path Lock directory path * @param mode Lock mode (exit or wait) * @return 0 on success, error code on failure @@ -922,7 +1004,7 @@ int lock_create(const char *lock_path, lock_mode_t mode); /** * @brief Check if lock exists - * + * * @param lock_path Lock directory path * @return true if exists, false otherwise */ @@ -930,7 +1012,7 @@ bool lock_exists(const char *lock_path); /** * @brief Remove lock - * + * * @param lock_path Lock directory path * @return 0 on success, error code on failure */ @@ -938,7 +1020,7 @@ int lock_remove(const char *lock_path); /** * @brief Wait for lock to be released - * + * * @param lock_path Lock directory path * @param timeout_seconds Maximum wait time * @return 0 on success, error code on timeout @@ -960,7 +1042,7 @@ typedef enum { /** * @brief Initialize logging system - * + * * @param log_file Log file path * @param device_type Device type (affects format) * @return 0 on success, error code on failure @@ -969,7 +1051,7 @@ int log_init(const char *log_file, device_type_t device_type); /** * @brief Log message - * + * * @param level Log level * @param format Format string (printf-style) * @param ... Variable arguments @@ -978,7 +1060,7 @@ void log_message(log_level_t level, const char *format, ...); /** * @brief Log TLS error - * + * * @param format Format string (printf-style) * @param ... Variable arguments */ @@ -986,7 +1068,7 @@ void log_tls_error(const char *format, ...); /** * @brief Send telemetry event - * + * * @param event_name Event name * @param value Event value (optional) * @return 0 on success, error code on failure @@ -995,7 +1077,7 @@ int log_telemetry_event(const char *event_name, const char *value); /** * @brief Send telemetry count notification - * + * * @param event_name Event name * @return 0 on success, error code on failure */ @@ -1003,7 +1085,7 @@ int log_telemetry_count(const char *event_name); /** * @brief Send telemetry value notification - * + * * @param event_name Event name * @param value Event value * @return 0 on success, error code on failure @@ -1028,92 +1110,92 @@ function process_dumps_loop(config, platform): if config.device_type != BROADBAND: # Save dumps for later (video devices) return ERROR_NETWORK_UNAVAILABLE - + if not network_wait_for_system_time(10, 1): log_message("System time not synced") # Continue anyway - + # Privacy check (MEDIACLIENT only) if config.device_type == MEDIACLIENT: config.privacy_mode = get_privacy_control_mode() # RBUS: Device.X_RDKCENTRAL-COM_Privacy.PrivacyMode # Returns SHARE (default) or DO_NOT_SHARE # Defaults to SHARE if RBUS is unavailable - + # Cleanup old files (always runs, regardless of privacy mode) cleanup_old_files(config.working_dir) - + # Scan for dumps scanner = scanner_init(config.working_dir) dump_list = [] - + if config.dump_type == COREDUMP: scanner_find_dumps(scanner, "*_core*.gz*", dump_list) else: scanner_find_dumps(scanner, "*.dmp*", dump_list) - + if dump_list.count == 0: log_message("No dumps found") return SUCCESS - + # Archive phase: process each dump (skip archiving if DO_NOT_SHARE) for dump in dump_list: get_mtime(dump) - + if config.privacy_mode == DO_NOT_SHARE: continue # skip archive creation for this dump - + # Rename dump file and create archive process_single_dump_archive(dump, config, platform) - + # If DO_NOT_SHARE: delete dump files and exit without uploading if config.privacy_mode == DO_NOT_SHARE: cleanup_dump_files(config.working_dir) # cleanup_batch(do_not_share_cleanup=true) return SUCCESS - + # Upload phase: rate limit check then upload each archive ratelimiter = ratelimit_init(timestamp_file) - + for dump in dump_list: # Check if box is rebooting if file_exists("/tmp/set_crash_reboot_flag"): log_message("Box rebooting, exit") break - + # Check recovery time if not ratelimit_is_recovery_time_reached(ratelimiter): log_message("Recovery time not reached") ratelimit_set_recovery_time(ratelimiter, 600) scanner_remove_pending_dumps() break - + # Check rate limit if ratelimit_is_exceeded(ratelimiter): log_message("Rate limit exceeded") - + # Create crashloop marker crashloop_file = create_crashloop_marker(dump) - + # Upload crashloop upload_config = upload_init(config) upload_result = {} upload_file(crashloop_file, upload_config, upload_result) - + # Set recovery time ratelimit_set_recovery_time(ratelimiter, 600) scanner_remove_pending_dumps() break - + # Upload archived dump result = upload_single_dump(dump, config, platform) - + if result == SUCCESS: ratelimit_record_upload(ratelimiter) - + # Cleanup scanner_cleanup(scanner) ratelimit_cleanup(ratelimiter) - + return SUCCESS ``` @@ -1124,35 +1206,35 @@ function process_single_dump(dump, config, platform): # Validate dump file if not file_exists(dump.full_path): return ERROR_FILE_NOT_FOUND - + # Check if already processed if scanner_is_processed(dump.filename): log_message("Already processed") return SUCCESS - + # Sanitize filename sanitized_name = file_sanitize_name(dump.filename) - + # Parse container info if present if string_contains(dump.filename, "<#=#>"): container_info = archive_parse_container_info(dump.filename) log_telemetry_value("crashedContainerName_split", container_info.container_name) log_telemetry_value("crashedContainerStatus_split", container_info.container_status) # ... more telemetry - + # Create archive archive = archive_create(dump, config, platform) if not archive: return ERROR_ARCHIVE_CREATE_FAILED - + # Add metadata files archive_add_file(archive, "version.txt") archive_add_file(archive, config.log_path + "/core_log.txt") - + # Add process logs for minidumps if config.dump_type == MINIDUMP: archive_add_log_files(archive, dump.process_name, config) - + # Finalize archive (compress) result = archive_finalize(archive) if result != SUCCESS: @@ -1163,15 +1245,15 @@ function process_single_dump(dump, config, platform): log_telemetry_count("SYST_ERR_CompFail") archive_cleanup(archive) return ERROR_COMPRESSION_FAILED - + # Get archive path archive_path = archive_get_path(archive) - + # Upload with retry upload_config = upload_init(config) upload_result = {} result = upload_retry(archive_path, upload_config, 3, upload_result) - + if result == SUCCESS: log_message("Upload success") log_telemetry_count("SYST_INFO_minidumpUpld") @@ -1185,11 +1267,11 @@ function process_single_dump(dump, config, platform): else: # Remove coredump file_delete_safely(archive_path) - + # Cleanup archive_cleanup(archive) upload_cleanup(upload_config) - + return result ``` @@ -1201,42 +1283,42 @@ function archive_generate_filename(dump, platform): mtime_str = file_get_mtime_string(dump.full_path) if not mtime_str: mtime_str = "2000-01-01-00-00-00" - + # Check if already has metadata - if string_contains(dump.filename, "_mac") and + if string_contains(dump.filename, "_mac") and string_contains(dump.filename, "_dat") and string_contains(dump.filename, "_box") and string_contains(dump.filename, "_mod"): return dump.filename # Already processed - + # Generate filename - filename = platform.sha1 + "_mac" + platform.mac_address + - "_dat" + mtime_str + "_box" + platform.box_type + + filename = platform.sha1 + "_mac" + platform.mac_address + + "_dat" + mtime_str + "_box" + platform.box_type + "_mod" + platform.model_number + "_" + dump.filename - + # Check length limit (ecryptfs limitation) if len(filename) >= 135: # Remove SHA1 prefix filename = filename.replace(platform.sha1 + "_", "") - + if len(filename) >= 135: # Truncate process name process_name = extract_process_name(filename) truncated = process_name[0:20] filename = filename.replace(process_name, truncated) - + # Sanitize filename = file_sanitize_name(filename) - + # Replace container delimiter filename = string_replace(filename, "<#=#>", "_") - + # Add extension if config.dump_type == COREDUMP: filename += ".core.tgz" else: filename += ".tgz" - + return filename ``` @@ -1245,32 +1327,32 @@ function archive_generate_filename(dump, platform): ``` function upload_retry(filepath, config, max_retries, result): attempts = 0 - + while attempts < max_retries: attempts += 1 - + # Initialize CURL curl = curl_easy_init() if not curl: return ERROR_CURL_INIT_FAILED - + # Set options curl_easy_setopt(curl, CURLOPT_URL, config.portal_url) curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) curl_easy_setopt(curl, CURLOPT_READDATA, file_handle) curl_easy_setopt(curl, CURLOPT_TIMEOUT, config.timeout_seconds) curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2) - + if config.enable_ocsp: curl_easy_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1) - + # Perform upload res = curl_easy_perform(curl) - + if res == CURLE_OK: # Get HTTP code curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &result.http_code) - + if result.http_code >= 200 and result.http_code < 300: # Success curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, result.remote_ip) @@ -1279,14 +1361,14 @@ function upload_retry(filepath, config, max_retries, result): result.attempts = attempts curl_easy_cleanup(curl) return SUCCESS - + # Failed - log and retry log_message("Upload attempt %d failed: %s", attempts, curl_easy_strerror(res)) curl_easy_cleanup(curl) - + if attempts < max_retries: sleep(2) # Wait before retry - + # All retries failed result.success = false result.attempts = attempts @@ -1318,13 +1400,13 @@ Use dynamic allocation only when necessary: dump_list_t* dump_list_create(size_t initial_capacity) { dump_list_t *list = malloc(sizeof(dump_list_t)); if (!list) return NULL; - + list->files = calloc(initial_capacity, sizeof(dump_file_t)); if (!list->files) { free(list); return NULL; } - + list->count = 0; list->capacity = initial_capacity; return list; @@ -1347,25 +1429,25 @@ int process_dump(const dump_file_t *dump) { archive_t *archive = NULL; upload_config_t upload_cfg = {0}; int result = ERROR; - + archive = archive_create(dump, &config, &platform); if (!archive) { result = ERROR_ARCHIVE_CREATE_FAILED; goto cleanup; } - + result = archive_finalize(archive); if (result != SUCCESS) { goto cleanup; } - + result = upload_init(&upload_cfg, &config); if (result != SUCCESS) { goto cleanup; } - + // ... more processing - + cleanup: if (archive) archive_cleanup(archive); upload_cleanup(&upload_cfg); @@ -1402,19 +1484,19 @@ typedef enum { ```c int function_that_can_fail() { int result; - + result = subfunc1(); if (result != SUCCESS) { log_message(LOG_LEVEL_ERROR, "subfunc1 failed: %d", result); return result; } - + result = subfunc2(); if (result != SUCCESS) { log_message(LOG_LEVEL_ERROR, "subfunc2 failed: %d", result); return result; } - + return SUCCESS; } ``` @@ -1429,13 +1511,13 @@ int function_that_can_fail() { void test_generate_filename() { char output[PATH_MAX]; int result; - + result = string_generate_filename( "abc123", "AABBCCDDEE", "2024-01-01-12-00-00", "XG1", "XG1v4", "process.dmp", output, sizeof(output) ); - + assert(result == SUCCESS); assert(strcmp(output, "abc123_macAABBCCDDEE_dat2024-01-01-12-00-00_boxXG1_modXG1v4_process.dmp") == 0); } @@ -1443,19 +1525,19 @@ void test_generate_filename() { void test_filename_length_limit() { char output[PATH_MAX]; char long_process[256]; - + // Create very long process name memset(long_process, 'A', 200); long_process[200] = '\0'; strcat(long_process, ".dmp"); - + int result = string_generate_filename( "1234567890123456789012345678901234567890", // 40 char SHA1 "AABBCCDDEE", "2024-01-01-12-00-00", "XG1", "XG1v4", long_process, output, sizeof(output) ); - + assert(result == SUCCESS); assert(strlen(output) < 135); // Must be under limit } @@ -1472,15 +1554,15 @@ void test_full_dump_processing() { config_t config = load_test_config(); platform_config_t platform = {0}; platform_init(&config, &platform); - + // Execute int result = process_dumps_loop(&config, &platform); - + // Verify assert(result == SUCCESS); assert(!file_exists("test.dmp")); // Original removed // Check upload was called (mock verification) - + // Cleanup cleanup_test_environment(); } diff --git a/docs/migration/requirements/uploadDumps-requirements.md b/docs/migration/requirements/uploadDumps-requirements.md index c88c940..f5f7f59 100644 --- a/docs/migration/requirements/uploadDumps-requirements.md +++ b/docs/migration/requirements/uploadDumps-requirements.md @@ -60,6 +60,27 @@ The `uploadDumps.sh` script is responsible for processing and uploading crash du - Extender devices - Hybrid devices - Media client devices + - RDK-C (camera) devices +- **Priority**: High + +##### FR-5.1: RDK-C (Camera) Platform Requirements +- **Device Detection**: Identified by `XHC1` value in the `DEVICE_TYPE` field of `/etc/device.properties` +- **Filesystem Paths**: + - Coredumps: `/opt/corefiles` + - Minidumps: `/opt/minidumps` + - Core log: `$LOG_PATH/core_log.txt` +- **Partner ID**: Read from `/opt/usr_config/partnerid.txt` +- **BOX_TYPE**: Defaults to `xcam` when not explicitly set +- **Upload Configuration**: + - S3 signed URL from RFC (`CrashUpload.S3SigningUrl`) or device.properties (`S3_AMAZON_SIGNING_URL`) + - Request type: 17 + - Portal: `crashportal.stb.r53.xcal.tv` + - Encryption: disabled (`encryptionEnable=false`) + - Authentication: mTLS via `rdkcertselector` (cert rotation supported) +- **RFC Interface**: 2-parameter `getRFCParameter` variant reading from INI files; `setRFCParameter` not supported +- **Archive Contents**: + - Base: dump file + `/version.txt` + `core_log.txt` + - Non-production builds: additionally includes `receiver.log` and `thread.log` (if present in `$LOG_PATH`) - **Priority**: High #### FR-6: Configuration Loading @@ -328,7 +349,7 @@ The `uploadDumps.sh` script is responsible for processing and uploading crash du #### EC-4: Long Filenames - **Scenario**: Generated filename exceeds 135 characters -- **Handling**: +- **Handling**: - Remove SHA1 prefix - Truncate process name to 20 characters if still too long @@ -378,7 +399,7 @@ The `uploadDumps.sh` script is responsible for processing and uploading crash du #### ERR-4: Compression Failure - **Error**: tar/gzip command fails -- **Handling**: +- **Handling**: - First: Copy files to /tmp and retry - Second: Log error, send telemetry event - **Recovery**: Continue processing other dumps @@ -390,7 +411,7 @@ The `uploadDumps.sh` script is responsible for processing and uploading crash du #### ERR-6: Rate Limit Exceeded - **Error**: More than 10 uploads in 10 minutes -- **Handling**: +- **Handling**: - Create crashloop marker dump - Upload crashloop dump to portal - Set 10-minute recovery time From 104a9f5d93b03cc3dfd32a34eaf3389ae34e5e61 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Tue, 23 Jun 2026 11:12:46 +0000 Subject: [PATCH 09/10] RDKC-16494: added regression testing log and removed unused headers --- c_sourcecode/src/main.c | 1 + c_sourcecode/src/upload/upload.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/c_sourcecode/src/main.c b/c_sourcecode/src/main.c index a0f7602..111acb8 100644 --- a/c_sourcecode/src/main.c +++ b/c_sourcecode/src/main.c @@ -155,6 +155,7 @@ int main_test(int argc, char *argv[]) #endif } CRASHUPLOAD_INFO("System initialization successful\n"); + CRASHUPLOAD_INFO("CrashUpload build includes RDKC platform support for regression testing\n"); /* Step 2: Lock Acquisition */ int lock_sec = (config.lock_mode == LOCK_MODE_WAIT) ? 5 : 0; lock_fd = lock_acquire(lock_file_path, lock_sec, config.t2_enabled); diff --git a/c_sourcecode/src/upload/upload.c b/c_sourcecode/src/upload/upload.c index 8f7e99b..4fb1868 100644 --- a/c_sourcecode/src/upload/upload.c +++ b/c_sourcecode/src/upload/upload.c @@ -26,8 +26,6 @@ #include "common_device_api.h" #endif #include "mtls_upload.h" -#include "uploadUtil.h" -#include "downloadUtil.h" #include "upload_status.h" #include "ratelimit.h" #include From 25e29b6669064b1df2572100ed10515b661d9986 Mon Sep 17 00:00:00 2001 From: jbasi196 Date: Fri, 17 Jul 2026 13:28:06 +0000 Subject: [PATCH 10/10] RDKC-16494: removed regression testing log --- c_sourcecode/src/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/c_sourcecode/src/main.c b/c_sourcecode/src/main.c index 111acb8..a0f7602 100644 --- a/c_sourcecode/src/main.c +++ b/c_sourcecode/src/main.c @@ -155,7 +155,6 @@ int main_test(int argc, char *argv[]) #endif } CRASHUPLOAD_INFO("System initialization successful\n"); - CRASHUPLOAD_INFO("CrashUpload build includes RDKC platform support for regression testing\n"); /* Step 2: Lock Acquisition */ int lock_sec = (config.lock_mode == LOCK_MODE_WAIT) ? 5 : 0; lock_fd = lock_acquire(lock_file_path, lock_sec, config.t2_enabled);