Skip to content

Feature/rdkemw 14720 unify#17

Open
Saranya2421 wants to merge 7 commits into
developfrom
feature/RDKEMW-14720-unify
Open

Feature/rdkemw 14720 unify#17
Saranya2421 wants to merge 7 commits into
developfrom
feature/RDKEMW-14720-unify

Conversation

@Saranya2421
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 17, 2026 13:05
@rdkcmf-jenkins
Copy link
Copy Markdown
Contributor

b'## Blackduck scan failure details

Summary: 0 violations, 0 files pending approval, 2 files pending identification.

  • Protex Server Path: /home/blackduck/github/reboot-manager/17/rdkcentral/reboot-manager

  • Commit: c148831

Report detail: gist'

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR appears to unify and expand the reboot-manager codebase by adding a new reboot-reason-fetcher C implementation for updating previous reboot information, adding/adjusting unit + functional tests around reboot reason persistence, and updating build/test orchestration and systemd units/scripts.

Changes:

  • Add reboot-reason-fetcher module (C sources + header + autotools build) to derive/classify/persist previous reboot context and update Parodus/keypress artifacts.
  • Add extensive new GTest and pytest functional scenarios validating previous reboot JSON/parodus/log behaviors and hardware reason detection.
  • Update autotools project layout (SUBDIRS, configure.ac) and test runners (unit_test.sh, run_l2.sh) to include the new components/tests.

Reviewed changes

Copilot reviewed 65 out of 75 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
reboot-reason-fetcher/include/update-reboot-info.h Introduces shared constants, structs, and APIs for reboot info derivation/persistence.
reboot-reason-fetcher/src/rebootreason_main.c Adds the new updater binary main orchestration flow.
reboot-reason-fetcher/src/platform_hal.c Implements SOC-based and fallback hardware reboot-reason detection.
reboot-reason-fetcher/src/log_parser.c Adds device property parsing, legacy log parsing, and hardware readers.
reboot-reason-fetcher/src/json.c Adds JSON persistence + flock-based lock helpers.
reboot-reason-fetcher/src/parodus_log_update.c Adds Parodus log/file handling and keypress copying.
reboot-reason-fetcher/src/Makefile.am Adds automake target for update-prev-reboot-info.
reboot-helper/src/* + reboot-helper/include/* Renames/includes and adds RBUS interface implementation.
configure.ac, Makefile.am Changes project structure to build multiple subdirectories.
unittest/*.cpp, unit_test.sh Adds new unit test sources and updates test runner list.
tests/functional_tests/test/*, tests/functional_tests/features/* Adds/updates functional scenario tests and feature specs.
scripts/update_previous_reboot_info.sh, scripts/reboot.sh Adds shell scripts for updater/reboot flows.
services/update-reboot-info.service, services/update-reboot-info.path Adds systemd units to trigger updater on /tmp/stt_received.
run_l2.sh Updates functional test execution and environment setup.
Comments suppressed due to low confidence (1)

reboot-helper/src/Makefile.am:25

  • AM_CFLAGS adds -I./reboot-helper/include, but this Makefile.am lives under reboot-helper/src, so that relative path resolves to reboot-helper/src/reboot-helper/include (nonexistent). Remove the incorrect relative include or replace it with a correct path (e.g., -I$(top_srcdir)/reboot-helper/include or -I$(srcdir)/../include) to avoid build failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread unittest/reboot_platform_hal_gtest.cpp
Comment thread reboot-reason-fetcher/src/rebootreason_main.c
Comment thread configure.ac

AC_INIT([REBOOT], [1.0], [saranya_elango@comcast.com])
AC_CONFIG_SRCDIR([rebootnow/src/main.c])
AC_CONFIG_SRCDIR([reboot-helper/src/reboot_main.c], [reboot-reason-fetcher/src/rebootreason_main.c])
Comment thread unit_test.sh
Comment on lines +33 to +39
./reboot_main_gtest \
./reboot_json_gtest \
./reboot_parodus_gtest \
./reboot_platform_hal_gtest \
./reboot_log_parser_gtest \
./reboot_classify_gtest \
./rebootreason_main_gtest
Comment thread run_l2.sh
Comment on lines 34 to +50
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_reboot_triggered.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_bootup_reboot_files_and_log_created.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_hard_reboot_unknown_defaults_to_null_mapping.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_hard_reboot_updates_hardpower_and_previousreboot.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_hardware_detection_paths_defined.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_kernel_panic_oops_is_logged_in_messages.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_kernel_panic_oops_updates_reboot_files_via_reboot_binary.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_parodus_log_contains_reboot_reason.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_previous_parodus_file_has_software_reboot_info.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_previous_reboot_info_json_format.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_previous_reboot_info_string_in_messages.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_reboot_info_log_previous_fields_present.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_soft_reboot_category_classification_matrix.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_soft_reboot_updates_reboot_log_and_previous_reboot_info.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_update_prev_reboot_generates_previous_files_and_flags.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_update_prev_reboot_service_flow_after_stt_flag.py
pytest --json-report --json-report-summary --json-report-file $RESULT_DIR/rebootTest.json tests/functional_tests/test/test_scenario_update_prev_reboot_skips_when_flags_missing.py
bin_PROGRAMS = update-prev-reboot-info

AM_CPPFLAGS = -I$(top_srcdir)/reboot-reason-fetcher/include
AM_CFLAGS = -std=c99 -Wall -Wextra -Werror -O2 -I./reboot-reason-fetcher/include -DRDK_LOGGER_ENABLED
Comment on lines +1 to +70
#!/bin/sh
##############################################################################
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2020 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.
##############################################################################

# Source Variable
. /etc/device.properties
if [ -f /lib/rdk/t2Shared_api.sh ]; then
source /lib/rdk/t2Shared_api.sh
fi

# Define logfiles and flags
REBOOT_INFO_LOG_FILE="/opt/logs/rebootInfo.log"
KERNEL_LOG_FILE="/opt/logs/messages.txt"
UIMGR_LOG_FILE="/opt/logs/PreviousLogs/uimgr_log.txt"
OCAPRI_LOG_FILE="/opt/logs/PreviousLogs/ocapri_log.txt"
ECM_CRASH_LOG_FILE="/opt/logs/PreviousLogs/messages-ecm.txt"
PSTORE_CONSOLE_LOG_FILE="/sys/fs/pstore/console-ramoops-0"
KERNEL_PANIC_SEARCH_STRING="PREVIOUS_KERNEL_OOPS_DUMP"
KERNEL_PANIC_SEARCH_STRING_01="Kernel panic - not syncing"
KERNEL_PANIC_SEARCH_STRING_02="Oops - undefined instruction"
KERNEL_PANIC_SEARCH_STRING_03="Oops - bad syscall"
KERNEL_PANIC_SEARCH_STRING_04="branch through zero"
KERNEL_PANIC_SEARCH_STRING_05="unknown data abort code"
KERNEL_PANIC_SEARCH_STRING_06="Illegal memory access"
ECM_CRASH_SEARCH_STRING="\*\*\*\* CRASH \*\*\*\*"
MAX_REBOOT_STRING="Box has rebooted 10 times"
POWERON_STRING="POWER_ON"
REBOOT_INFO_DIR="/opt/secure/reboot"
REBOOT_INFO_FILE="/opt/secure/reboot/reboot.info"
PARODUS_REBOOT_INFO_FILE="/opt/secure/reboot/parodusreboot.info"
KEYPRESS_INFO_FILE="/opt/secure/reboot/keypress.info"
PREVIOUS_REBOOT_INFO_FILE="/opt/secure/reboot/previousreboot.info"
PREVIOUS_PARODUSREBOOT_INFO_FILE="/opt/secure/reboot/previousparodusreboot.info"
PREVIOUS_HARD_REBOOT_INFO_FILE="/opt/secure/reboot/hardpower.info"
PREVIOUS_KEYPRESS_INFO_FILE="/opt/secure/reboot/previouskeypress.info"
STT_FLAG="/tmp/stt_received"
REBOOT_INFO_FLAG="/tmp/rebootInfo_Updated"
UPDATE_REBOOT_INFO_INVOKED_FLAG="/tmp/Update_rebootInfo_invoked"
LOCK_DIR="/tmp/rebootInfo.lock"
PARODUS_LOG="/opt/logs/parodus.log"

#Use log framework to pring timestamp and source script name
rebootLog()
{
echo "$0: $*"
}

rebootLog "Start of Reboot Reason Script"

# Define Reasons for APP_TRIGGERED, OPS_TRIGGERED and MAINTENANCE_TRIGGERED cases
APP_TRIGGERED_REASONS=(Servicemanager systemservice_legacy WarehouseReset WarehouseService HrvInitWHReset HrvColdInitReset HtmlDiagnostics InstallTDK StartTDK TR69Agent SystemServices Bsu_GUI SNMP CVT_CDL Nxserver DRM_Netflix_Initialize hrvinit )
OPS_TRIGGERED_REASONS=(ScheduledReboot RebootSTB.sh FactoryReset UpgradeReboot_restore XFS wait_for_pci0_ready websocketproxyinit NSC_IR_EventReboot host_interface_dma_bus_wait usbhotplug Receiver_MDVRSet Receiver_VidiPath_Enabled Receiver_Toggle_Optimus S04init_ticket Network-Service monitorMfrMgr.sh vlAPI_Caller_Upgrade ImageUpgrade_rmf_osal ImageUpgrade_mfr_api ImageUpgrade_userInitiatedFWDnld.sh ClearSICache tr69hostIfReset hostIf_utils hostifDeviceInfo HAL_SYS_Reboot UpgradeReboot_deviceInitiatedFWDnld.sh UpgradeReboot_rdkvfwupgrader UpgradeReboot_ipdnl.sh PowerMgr_Powerreset PowerMgr_coldFactoryReset DeepSleepMgr PowerMgr_CustomerReset PowerMgr_PersonalityReset Power_Thermmgr PowerMgr_Plat HAL_CDL_notify_mgr_event vldsg_estb_poll_ecm_operational_state SASWatchDog BP3_Provisioning eMMC_FW_UPGRADE BOOTLOADER_UPGRADE cdl_service docsis_mode_check.sh Receiver CANARY_Update)
MAINTENANCE_TRIGGERED_REASONS=(AutoReboot.sh PwrMgr)

Comment thread scripts/reboot.sh
Comment on lines +1 to +81
#!/bin/sh
##########################################################################
# If not stated otherwise in this file or this component's LICENSE
# file the following copyright and licenses apply:
#
# Copyright 2026 Comcast Cable Communications Management, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################

. /etc/include.properties
. /etc/device.properties
. /etc/env_setup.sh

# The reboot cmd is aliased to "reboot -f" in env_setup.sh. Remove force reboot as it causing HDD corruption.
if [ -f /etc/os-release ];then
alias reboot='/sbin/reboot'
fi

if [ -f /lib/rdk/t2Shared_api.sh ]; then
source /lib/rdk/t2Shared_api.sh
fi

REBOOT_REASON_LOGFILE="/opt/logs/rebootreason.log"
rebootLog() {
echo "`/bin/timestamp` :$0: $*" >> $REBOOT_REASON_LOGFILE
}

#Usage: rebootNow.sh [-c "<crash>" | -s "<source>"][-r "<custom reason>"][-o "<other reason>"]
usage()
{
rebootLog "USAGE: rebootNow.sh -c/-s <crash/source> -r <custom reason> -o <other reason>"
rebootLog " -s <source> : Source Module or Script Name"
rebootLog " -c <crash> : Crash Process Name"
rebootLog " -r <custom reason> : Reason to specify for any particular reason: default=Unknown"
rebootLog " -o <other reason> : Reason to request for the reboot: default=Unknown"
}

if [ $# -lt 2 ]; then
rebootLog "Exiting as no argument specified to identify source of reboot!!!"
usage
exit 1
elif [[ "$3" == "-s" || "$3" == "-c" ]]; then
rebootLog "Exiting as invalid arguments found!!!"
usage
exit 1
fi

# Save reboot details in /opt/secure/reboot folder.
REBOOT_INFO_DIR="/opt/secure/reboot"
REBOOT_INFO_FILE="/opt/secure/reboot/reboot.info"
PREVIOUSREBOOT_INFO_FILE="/opt/secure/reboot/previousreboot.info"
PARODUS_REBOOT_INFO_FILE="/opt/secure/reboot/parodusreboot.info"
REBOOTINFO_LOGFILE="/opt/logs/rebootInfo.log"
REBOOTNOW_FLAG="/opt/secure/reboot/rebootNow"
REBOOTSTOP_FLAG="/opt/secure/reboot/rebootStop"
REBOOT_COUNTER="/opt/secure/reboot/rebootCounter"
REBOOTSTOP_DURATION=$(tr181 Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.Duration 2>&1 > /dev/null)
REBOOTSTOP_DETECTION=$(tr181 Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.Detection 2>&1 > /dev/null)
REBOOT_WINDOW=10
REBOOT_WINDOW_SECS=$((REBOOT_WINDOW * 60))
REBOOT_CYCLE_THRESHOLD=5
CYCLIC_REBOOT_SOURCE="rebootNow.sh"
CYCLIC_REBOOT_REASON="Rebooting device after expiry of Cyclic reboot pause window"
CDLFILE=$(cat /opt/cdl_flashed_file_name)
PREV_CDLFILE=$(cat /tmp/currently_running_image_name)
# Define Reasons for APP_TRIGGERED, OPS_TRIGGERED and MAINTENANCE_TRIGGERED cases
APP_TRIGGERED_REASONS=(Servicemanager systemservice_legacy WarehouseReset WarehouseService HrvInitWHReset HrvColdInitReset HtmlDiagnostics InstallTDK StartTDK TR69Agent SystemServices Bsu_GUI SNMP CVT_CDL Nxserver DRM_Netflix_Initialize hrvinit PaceMFRLibrary)
OPS_TRIGGERED_REASONS=(ScheduledReboot RebootSTB.sh FactoryReset UpgradeReboot_firmwareDwnld.sh UpgradeReboot_restore XFS wait_for_pci0_ready websocketproxyinit NSC_IR_EventReboot host_interface_dma_bus_wait usbhotplug Receiver_MDVRSet Receiver_VidiPath_Enabled Receiver_Toggle_Optimus S04init_ticket Network-Service monitor.sh ecmIpMonitor.sh monitorMfrMgr.sh vlAPI_Caller_Upgrade ImageUpgrade_rmf_osal ImageUpgrade_mfr_api ImageUpgrade_updateNewImage.sh ImageUpgrade_userInitiatedFWDnld.sh ClearSICache tr69hostIfReset hostIf_utils hostifDeviceInfo HAL_SYS_Reboot UpgradeReboot_deviceInitiatedFWDnld.sh UpgradeReboot_rdkvfwupgrader UpgradeReboot_ipdnl.sh PowerMgr_Powerreset PowerMgr_coldFactoryReset DeepSleepMgr PowerMgr_CustomerReset PowerMgr_PersonalityReset Power_Thermmgr PowerMgr_Plat HAL_CDL_notify_mgr_event vldsg_estb_poll_ecm_operational_state BcmIndicateEcmReset SASWatchDog BP3_Provisioning eMMC_FW_UPGRADE BOOTLOADER_UPGRADE cdl_service BCMCommandHandler BRCM_Image_Validate docsis_mode_check.sh tch_nvram.sh Receiver CANARY_Update boot_FSR)
MAINTENANCE_TRIGGERED_REASONS=(AutoReboot.sh PwrMgr)
pid_file="/tmp/.rebootNow.pid"
Comment thread reboot-reason-fetcher/src/parodus_log_update.c
Comment thread run_l2.sh

mkdir -p "$RESULT_DIR"

touch /opt/logs/messages.txt
Copy link
Copy Markdown

@mhughesacn mhughesacn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Saranya2421 : Similar comment as PR#16 please.

# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
#
# Copyright 2020 RDK Management
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on PR#16 - add credit to NOTICE for RDK if correct; otherwise use Comcast copyright.

# If not stated otherwise in this file or this component's LICENSE
# file the following copyright and licenses apply:
#
# Copyright 2018 RDK Management
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other file header comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants