diff --git a/projects/ROCKNIX/packages/rocknix/sources/scripts/updateabl b/projects/ROCKNIX/packages/rocknix/sources/scripts/updateabl new file mode 100755 index 0000000000..6fed093903 --- /dev/null +++ b/projects/ROCKNIX/packages/rocknix/sources/scripts/updateabl @@ -0,0 +1,43 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) +# +# This script will update the ABL on the internal UFS. + +set -euo pipefail + +case "$HW_DEVICE" in + SM8250|SM8550|SM8650) + ;; + *) + echo "This script is not compatible with this device!" + exit 1 + ;; +esac + +ELF="/usr/share/bootloader/rocknix_abl/abl_signed.elf" + +ABL_A="/dev/disk/by-partlabel/abl_a" +ABL_B="/dev/disk/by-partlabel/abl_b" + +# ---- Sanity checks ---- +if [ ! -b "${ABL_A}" ] || [ ! -b "${ABL_B}" ]; then + echo "Error: ABL partitions not found" + exit 1 +fi + +# ---- Get sector size ---- +SS="$(blockdev --getss "${ABL_A}")" +if [ -z "${SS}" ]; then + echo "Error: failed to get sector size" + exit 1 +fi + +# ---- Flash ---- +echo "Updating ABL partitions..." +dd if="${ELF}" of="${ABL_A}" bs="${SS}" conv=fsync,notrunc status=none +dd if="${ELF}" of="${ABL_B}" bs="${SS}" conv=fsync,notrunc status=none + +sync + +echo "ABL update completed successfully."