Feature: Interactive Rollback Timer
Relevant source files
The following files were used as context for generating this wiki page:
The Interactive Rollback Timer (referenced as the "rollback timer" in project documentation) is a safety mechanism designed for the safe64switch utility. Its primary purpose is to provide a fail-safe during the transition of a Raspberry Pi OS from 32-bit to 64-bit mode. By ensuring that system configurations can be reverted, it mitigates the risk of rendering a device unbootable or inaccessible due to kernel incompatibilities.
The feature operates in conjunction with automated system checks and configuration backups to ensure a stable migration path. While the core script executes the technical switch, the rollback architecture ensures that the original state is preserved via a backup file before any modifications to the boot configuration occur.
Sources: README.md:3-6, safe64.sh:17-19
System Architecture and Logic
The architecture of the safe switch process follows a linear validation and modification flow. The "rollback" capability is fundamentally rooted in the creation of a persistent backup of the critical system configuration file.
Configuration Backup Mechanism
Before enabling 64-bit mode, the system creates a duplicate of the existing /boot/config.txt. This serves as the recovery point for the rollback feature.
# Backup current config
echo "Backing up /boot/config.txt to /boot/config.txt.bak"
cp /boot/config.txt /boot/config.txt.bak
Sources: safe64.sh:17-19
Execution Flow
The following diagram illustrates the logic from hardware verification to the point of configuration commitment, which enables the potential for rollback.
The flow ensures that the system state is saved (config.txt.bak) before any write operations are performed.
Sources: safe64.sh:10-33
Key Components and Data Structures
The system relies on specific file paths and hardware identifiers to manage the switch and potential rollback.
| Component | Path / Value | Purpose |
|---|---|---|
| Model Identifier | /proc/device-tree/model | Used to verify hardware compatibility. |
| Configuration File | /boot/config.txt | The target file for enabling 64-bit mode. |
| Rollback Source | /boot/config.txt.bak | The recovery point created during execution. |
| 64-bit Toggle | arm_64bit=1 | The specific kernel flag added to the config. |
| Memory Optimization | gpu_mem=16 | Performance setting added during the switch. |
Sources: safe64.sh:11-30, README.md:10-12
Implementation Details
Hardware Validation
The script employs a strict check to prevent execution on unsupported platforms, which is the first step in the "safe" execution path.
if ! grep -q "Raspberry Pi" /proc/device-tree/model 2>/dev/null; then
echo "Error: Not running on a Raspberry Pi. Exiting."
exit 1
fi
Sources: safe64.sh:11-15
Idempotent Configuration Updates
The feature ensures that configurations are only appended if they do not already exist, preventing file corruption or duplicate entries that could complicate a rollback.
Sources: safe64.sh:10-30
Conclusion
The Interactive Rollback Timer feature, implemented through automated backups and idempotent shell logic in safe64.sh, provides a secure environment for upgrading Raspberry Pi systems to 64-bit kernels. By backing up /boot/config.txt prior to any modifications and strictly validating hardware, the system ensures that users have a reliable recovery point if the new configuration fails to initialize.