reboot-manager is the RDK component that controls how software-initiated reboots are handled on device.
At runtime, the rebootnow binary does more than just call reboot:
- identifies who triggered the reboot and why,
- classifies reboot reason into operational categories,
- persists reboot metadata for post-reboot consumers,
- detects potential reboot loops and can defer reboot safely,
- performs housekeeping before reboot,
- executes reboot with a fallback chain.
This README explains what the component does, how files are used, and how to build/test/debug it.
In production devices, reboot requests can come from many software paths (application trigger, crash path, maintenance window, firmware-related path). A plain reboot command does not provide enough context for:
- post-reboot analysis,
- loop prevention,
- telemetry and operations visibility,
- coordinated pre-reboot cleanup.
reboot-manager is the control point that standardizes these behaviors.
When rebootnow is invoked:
- Initializes logger, telemetry hooks (if enabled), and RBUS.
- Enforces single instance via PID guard.
- Parses CLI input (
-s/-c/-r/-o). - Classifies reason (
APP_TRIGGERED,OPS_TRIGGERED,MAINTENANCE_REBOOT,FIRMWARE_FAILURE). - Writes reboot metadata to log + JSON files.
- Applies cyclic reboot logic using RFC flags + previous reboot state.
- If allowed, executes cleanup and reboot flow.
- If reboot command fails, escalates fallback (
reboot→systemctl reboot→reboot -f).
reboot-manager/
├── rebootnow/
│ ├── include/
│ │ ├── rebootnow.h
│ │ └── rbus_interface.h
│ └── src/
│ ├── main.c # CLI parsing + orchestration
│ ├── cyclic_reboot.c # loop detection/defer policy
│ ├── system_cleanup.c # pre-reboot cleanup + PID guard
│ ├── rbus_interface.c # RBUS wrappers
│ └── utils.c # timestamp/log/T2 helpers
├── unittest/ # L1 gtest suites
├── tests/functional_tests/ # L2 functional tests
├── docs/ # HLD/LLD/testing/diagrams
├── unit_test.sh # unit + coverage runner
└── run_l2.sh # functional runner
main.c: command handling, reason classification, metadata persistence, reboot orchestration.cyclic_reboot.c: compares current vs previous reboot context and controls defer behavior.system_cleanup.c: signals key services, syncs/cleans resources, and owns PID guard implementation.rbus_interface.c: stable typed wrappers aroundrbus_get/rbus_set.utils.c: shared utility functions.
flowchart LR
A[Trigger source] --> B[rebootnow]
B --> C[Reason classification]
B --> D[Metadata write]
B --> E[Cyclic reboot policy]
E -->|defer| F[Exit without immediate reboot]
E -->|proceed| G[cleanup_services]
G --> H[reboot -> systemctl reboot -> reboot -f]
-s <source>: source process for standard reboot path.-c <source>: source process for crash-trigger path.-r <custom_reason>: optional custom category value.-o <other_reason>: optional free-text context.
Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.DetectionDevice.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.DurationDevice.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RebootStop.EnableDevice.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.ManageableNotification.Enable
/opt/logs/rebootreason.log: operational logs./opt/logs/rebootInfo.log: current reboot detail fields./opt/secure/reboot/reboot.info: current reboot JSON payload./opt/secure/reboot/previousreboot.info: persisted reboot JSON for next-cycle comparison./opt/secure/reboot/parodusreboot.info: previous reboot line consumed by downstream integration./opt/secure/reboot/rebootNow: marker that rebootnow initiated reboot path./opt/secure/reboot/rebootStop: marker for loop protection mode./opt/secure/reboot/rebootCounter: loop detection counter.
- T2 telemetry markers (when enabled).
- RBUS set for reboot stop and manageable notification behavior.
- Scheduled deferred reboot cron entry in cyclic loop conditions.
Source process names are matched against predefined lists:
- App-trigger list →
APP_TRIGGERED - Ops-trigger list →
OPS_TRIGGERED - Maintenance-trigger list →
MAINTENANCE_REBOOT - No match →
FIRMWARE_FAILURE
If custom reason is MAINTENANCE_REBOOT for app-triggered source, maintenance classification is preserved.
The cyclic logic prevents repeated reboot storms for the same cause.
- Detection enable RFC.
- Previous reboot context from
/opt/secure/reboot/previousreboot.info. - Uptime window check (short-window repeated reboot behavior).
- Same-cause match: source + reason + customReason + otherReason.
- Reboot counter threshold.
-
If same-cause reboot repeats inside window:
- increments reboot counter,
- once threshold is reached, enables stop mode,
- sets stop RFC,
- emits cyclic telemetry marker,
- schedules deferred reboot after configured pause duration.
-
If reason differs or window is exceeded:
- resets counter,
- clears stop mode,
- removes any existing deferred reboot cron entry.
cleanup_services() performs pre-reboot stabilization tasks such as:
- signaling
telemetry2_0andparodus, - selected service stops when applicable,
- log synchronization and temp/resource cleanup paths,
- final
sync()before reboot transition.
Build requires autotools and standard C toolchain:
autoconf,automake,libtool,make,gcc
Runtime/link dependencies are provided by RDK platform layers (for example: rbus,
secure_wrapper, rdkloggers, fwutils).
autoreconf -fi
./configure
make -j$(nproc)- Enable telemetry markers:
./configure --enable-t2api- Enable breakpad integration:
./configure --enable-breakpad- Enable CPC companion binary:
./configure --enable-cpcrebootnow options:
-s <source> source process triggering reboot (normal)
-c <source> source process triggering reboot (crash)
-r <custom> custom reason (example: MAINTENANCE_REBOOT)
-o <other> additional reason context
-h help
Examples:
rebootnow -s HtmlDiagnostics -o "User requested reboot"
rebootnow -c dsMgrMain -r MAINTENANCE_REBOOT -o "Crash detected"rebootInfo.logis reset per invocation before writing current reboot fields.write_rebootinfo_logis append-based, so the reset step in orchestration is required for latest-only content.- PID guard path prevents two
rebootnowinstances from running concurrently.
Run all GTest binaries and generate coverage:
./unit_test.shRun without coverage instrumentation:
./unit_test.sh --disable-cov./run_l2.shThis executes pytest-based tests in tests/functional_tests/test and writes JSON reports
under /tmp/l2_test_report.
- Check cyclic reboot stop state files under
/opt/secure/reboot/. - Verify RFC detection/stop params via RBUS/TR-181.
- Inspect
rebootreason.logandrebootInfo.log.
- Check invocation arguments (
-s/-c/-r/-o) and source naming. - Validate
previousreboot.infocontent if cyclic comparison is active.
- This is expected when initial reboot command does not complete within wait path.
- Review logs for transition from
reboottosystemctl reboottoreboot -f.
- Documentation index
- Component architecture
- Build and test guide
- High-Level Design
- Low-Level Design
- Flowchart
- Sequence diagram
See CONTRIBUTING.md.