Command Line Interface
Relevant source files
The following files were used as context for generating this wiki page:
The Command Line Interface (CLI) of the safe64switch project is centered around a Bash script designed to facilitate a safe transition of Raspberry Pi OS from a 32-bit architecture to a 64-bit architecture. The interface is intentionally minimalist, prioritizing automation, safety checks, and system integrity through configuration backups.
The CLI operates by modifying system-level boot configurations while providing real-time feedback to the user via standard output. It ensures that the execution environment is compatible before performing any persistent changes to the hardware configuration.
Sources: README.md:1-10, safe64.sh:1-5
Execution Flow and Architecture
The CLI follows a linear execution model with strict error handling. By utilizing the set -e directive, the interface ensures that any command failure results in an immediate termination of the process, preventing partial or corrupt configuration states.
The following diagram illustrates the logical flow of the CLI execution:
The CLI validates the hardware environment by checking /proc/device-tree/model and proceeds to modify the boot configuration only if a Raspberry Pi is detected.
Sources: safe64.sh:7-15, safe64.sh:18-22
Core Components and Commands
Environment Validation
The CLI performs a hardware check to prevent execution on incompatible systems. It specifically searches for the string "Raspberry Pi" within the system device tree.
| Step | Action | Logic |
|---|---|---|
| Check | Hardware Validation | grep -q "Raspberry Pi" /proc/device-tree/model |
| Safety | Immediate Exit | set -e ensures failure on any command error |
Sources: safe64.sh:7-15
Configuration Management
The primary function of the CLI is the manipulation of the /boot/config.txt file. Before making changes, it creates a recovery point by copying the existing configuration to a .bak file.
This sequence shows how the script interacts with the filesystem to ensure a safe rollback capability is established before modification.
Sources: safe64.sh:17-33, README.md:14-17
Usage and Syntax
The CLI is designed to be executed with superuser privileges to allow modification of protected boot files.
| Command | Description |
|---|---|
chmod +x safe64.sh | Grants execution permissions to the script |
sudo ./safe64.sh | Executes the script with root privileges to modify /boot/config.txt |
Sources: README.md:20-23
Configuration Parameters
The CLI injects specific key-value pairs into the system configuration to enable 64-bit mode and optimize performance for the new architecture.
| Parameter | Value | Purpose |
|---|---|---|
arm_64bit | 1 | Forces the Raspberry Pi firmware to load the 64-bit kernel |
gpu_mem | 16 | Minimizes GPU memory allocation to maximize CPU-available RAM |
Sources: safe64.sh:25-34
Summary
The safe64switch Command Line Interface provides a robust, single-command solution for upgrading Raspberry Pi systems. By automating environment checks and file backups, it reduces the risk of manual configuration errors and provides a clear path for system performance optimization.