Script Execution Lifecycle
Relevant source files
The following files were used as context for generating this wiki page:
The Script Execution Lifecycle of the safe64switch project defines the sequential steps required to safely transition a Raspberry Pi operating system from a 32-bit to a 64-bit kernel environment. The lifecycle is designed with safety as a priority, ensuring hardware compatibility checks and configuration backups are performed before any system modifications occur.
The process is encapsulated within a shell script that automates the modification of system boot parameters, specifically targeting the /boot/config.txt file. This lifecycle ensures that the system remains bootable by providing a backup mechanism and verifying the execution environment before proceeding with performance optimizations and kernel architecture switches.
Sources: README.md:1-10, safe64.sh:1-5
Execution Phases
The lifecycle follows a linear progression from environment validation to final system notification.
1. Environment Validation
The script begins by setting strict execution rules and verifying the hardware. It uses set -e to ensure that the script terminates immediately if any command returns a non-zero exit status. The primary validation check determines if the hardware is a Raspberry Pi by inspecting the device tree model description.
Sources: safe64.sh:6-15
2. Data Preservation
Before any modifications are made to the system configuration, the current state of the boot configuration is preserved. The script copies the existing /boot/config.txt to a backup file named /boot/config.txt.bak.
Sources: safe64.sh:17-19
3. Kernel Configuration
The core of the lifecycle involves modifying the boot configuration to enable the 64-bit kernel. The script checks for the existence of the arm_64bit=1 directive. If absent, it appends the command to the configuration file.
Sources: safe64.sh:21-27
4. Optimization and Completion
Following the kernel switch, the script applies performance-related settings, such as limiting GPU memory to 16MB to maximize available system RAM. The lifecycle concludes by notifying the user that a reboot is required to initialize the new kernel settings.
Sources: safe64.sh:29-34
Logic Flow Diagram
The following flowchart illustrates the decision logic and sequential operations performed during the script execution.
The diagram shows the validation gate (Hardware Check) and the conditional logic for kernel enablement.
Sources: safe64.sh:1-35
System Modifications
The script interacts with specific files and configuration keys to achieve the 64-bit switch.
| Component | Target Path | Modification | Purpose |
|---|---|---|---|
| Backup File | /boot/config.txt.bak | Creation | Preservation of original settings |
| Boot Config | /boot/config.txt | Append arm_64bit=1 | Activates 64-bit kernel mode |
| Memory Config | /boot/config.txt | Append gpu_mem=16 | Optimizes RAM for 64-bit tasks |
Sources: safe64.sh:18-32, README.md:12-16
Operational Sequence
The interaction between the user, the script, and the system files is detailed in the sequence diagram below.
This diagram highlights the dependency on the /proc filesystem for hardware identification and the file-level operations on /boot/config.txt.
Sources: safe64.sh:10-35
Summary
The safe64switch lifecycle provides a structured approach to system architecture migration. By prioritizing environment validation and automated backups, it mitigates the risks associated with manual configuration of the Raspberry Pi boot sequence. The final state requires a manual system reboot to transition from the 32-bit execution environment to the 64-bit kernel.
Sources: README.md:18-23, safe64.sh:34-35