Customizing Script Parameters
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The safe64switch project provides a utility designed to migrate Raspberry Pi OS installations from a 32-bit kernel to a 64-bit kernel environment safely. The primary mechanism for this transition is the safe64.sh shell script, which automates hardware verification, configuration backups, and the injection of specific boot parameters.
Customizing script parameters within this project involves modifying the safe64.sh script to alter how it interacts with the system's /boot/config.txt file. This includes enabling the 64-bit mode and applying performance-related optimizations like memory allocation for the GPU.
Sources: README.md:1-10, safe64.sh:1-5
Core Script Logic and Configuration
The script operates by directly manipulating the Raspberry Pi boot configuration. It follows a sequential execution path to ensure system integrity before making permanent changes.
Hardware Validation
Before any parameters are customized or applied, the script validates the execution environment by checking the device tree model. This ensures that the script only runs on supported Raspberry Pi hardware.
Sources: safe64.sh:11-15
Configuration Backup
To facilitate recovery, the script performs an automated backup of the existing configuration file before applying any customizations.
Sources: safe64.sh:18-19
The following flowchart illustrates the logical flow of parameter application within the script:
The diagram shows the decision-making process for hardware validation, backup, and the conditional application of the 64-bit and performance parameters.
Sources: safe64.sh:11-33
Configurable Parameters
The script manages specific parameters within the /boot/config.txt file. These can be customized by a developer to suit different hardware requirements or performance targets.
| Parameter | Type | Default Value | Description |
|---|---|---|---|
arm_64bit | Boolean (0/1) | 1 | Enables the 64-bit kernel mode on supported ARM processors. |
gpu_mem | Integer | 16 | Sets the amount of RAM in megabytes assigned to the GPU. |
Sources: safe64.sh:22-31, README.md:12-15
Enabling 64-Bit Kernel
The primary customization is the arm_64bit flag. The script uses grep to check for the existence of this parameter to avoid duplicate entries before appending it to the configuration file.
Sources: safe64.sh:22-27
Performance Adjustments
The script includes an optional section for performance settings. Currently, it implements a minimal GPU memory footprint to maximize available system RAM for 64-bit operations.
Sources: safe64.sh:30-31
# Example of parameter injection logic
# File: safe64.sh
# Line 31:
grep -qxF "gpu_mem=16" /boot/config.txt || echo "gpu_mem=16" >> /boot/config.txt
Sources: safe64.sh:31
Development and Environment
The project maintains script quality through automated linting using ShellCheck, ensuring that any parameter customizations adhere to shell scripting best practices.
The sequence diagram details the continuous integration process that validates script changes.
Sources: .github/workflows/shellcheck.yml:1-15
Summary
Customizing script parameters in the safe64switch utility is centered around the modification of the /boot/config.txt file via the safe64.sh script. By controlling the arm_64bit and gpu_mem parameters, the script transitions the system to a 64-bit environment while maintaining a safety net through automated backups and hardware validation checks.