Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EEPROM: Ensure config is always set #26

Merged
merged 4 commits into from Jun 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/pt-eeprom
Expand Up @@ -56,20 +56,27 @@ read_eeprom_settings() {
rpi-eeprom-config --out "${bootloader_config_file}"
}

force_conf_entry() {
local field="${1}"
local value="${2}"
local file="${3}"

# Delete existing entries
sed -i "/^${field}=/d" "${file}"
# Append forced entry
echo "${field}=${value}" >>"${file}"
}

set_eeprom_installation_directory() {
sed -i '/BOOTFS/d' /etc/default/rpi-eeprom-update
if [[ -d "/recovery" ]]; then
BOOTFS=/recovery
else
BOOTFS=/boot
fi
echo "BOOTFS=${BOOTFS}" >>/etc/default/rpi-eeprom-update
bootfs_entry="/boot"
[[ -d "/recovery" ]] && bootfs_entry="/recovery"
force_conf_entry BOOTFS "${bootfs_entry}" "/etc/default/rpi-eeprom-update"
}

patch_eeprom() {
sed -i "s/^WAKE_ON_GPIO=.*/WAKE_ON_GPIO=0/1" ${tmp_dir}/boot.conf
sed -i "s/^POWER_OFF_ON_HALT=.*/POWER_OFF_ON_HALT=1/1" ${tmp_dir}/boot.conf
rpi-eeprom-config --apply ${tmp_dir}/boot.conf
force_conf_entry WAKE_ON_GPIO 0 "${tmp_dir}/boot.conf"
force_conf_entry POWER_OFF_ON_HALT 1 "${tmp_dir}/boot.conf"
rpi-eeprom-config --apply "${tmp_dir}/boot.conf"
}

if ! is_raspberry_pi_4; then
Expand Down