feat: update partition script to include data partition
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
88c7b17237
commit
599b4df508
|
|
@ -1,18 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Assemble SPL, U-Boot, U-Boot environment, boot-resources, boot and rootfs
|
# Assemble SPL, U-Boot, U-Boot environment, boot-resources, boot, rootfs
|
||||||
# images into a final H700 bootable sdcard image.
|
# and data images into a final H700 bootable sdcard image.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [[ $# -lt 7 ]] ; then
|
if [[ $# -lt 8 ]] ; then
|
||||||
echo "Usage: $0 SDCARD SPL UBOOT ENV BOOT-RESOURCE BOOT ROOTFS"
|
echo "Usage: $0 SDCARD SPL UBOOT ENV BOOT-RESOURCE BOOT ROOTFS DATA"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mb() {
|
mb() {
|
||||||
# Return the file size in MiB (rounded up)
|
# Return the file size in MiB (rounded up)
|
||||||
local file_size
|
local file_size
|
||||||
file_size="$(stat -c "%s" "$1")"
|
file_size="$(stat -c "%s" "$1")"
|
||||||
echo "$(( (file_size + 1024 ** 2 - 1) / 1024 ** 2 ))M"
|
echo "$(( (file_size + 1024 ** 2 - 1) / 1024 ** 2 ))M"
|
||||||
}
|
}
|
||||||
|
|
||||||
sgdisk --move-main-table=73696 -I \
|
sgdisk --move-main-table=73696 -I \
|
||||||
|
|
@ -20,18 +20,19 @@ sgdisk --move-main-table=73696 -I \
|
||||||
--new="0:0:+$(mb "$5")" --change-name=0:boot-resource --attributes=0:=:c000000000000001 --typecode=0:0700 \
|
--new="0:0:+$(mb "$5")" --change-name=0:boot-resource --attributes=0:=:c000000000000001 --typecode=0:0700 \
|
||||||
--new="0:0:+$(mb "$6")" --change-name=0:boot --attributes=0:=:c000000000000001 --typecode=0:a002 \
|
--new="0:0:+$(mb "$6")" --change-name=0:boot --attributes=0:=:c000000000000001 --typecode=0:a002 \
|
||||||
--new="0:0:+$(mb "$7")" --change-name=0:rootfs --attributes=0:=:c000000000000001 --typecode=0:8305 \
|
--new="0:0:+$(mb "$7")" --change-name=0:rootfs --attributes=0:=:c000000000000001 --typecode=0:8305 \
|
||||||
|
--new="0:0:+$(mb "$8")" --change-name=0:data --attributes=0:=:c000000000000001 --typecode=0:0700 \
|
||||||
"$1"
|
"$1"
|
||||||
|
|
||||||
part_table="$(sgdisk -p artifacts/alpine-h700.img | awk '/^ +[0-9]+ +[0-9]+ +[0-9]+/{print $2 / 2}' | xargs)"
|
part_table="$(sgdisk -p "$1" | awk '/^ +[0-9]+ +[0-9]+ +[0-9]+/{print $2 / 2}' | xargs)"
|
||||||
read -r -a offsets <<<"$part_table"
|
read -r -a offsets <<<"$part_table"
|
||||||
|
|
||||||
images=("$2" "$3" "$4" "$5" "$6" "$7")
|
images=("$2" "$3" "$4" "$5" "$6" "$7" "$8")
|
||||||
offsets=(8 16400 "${offsets[@]}")
|
offsets=(8 16400 "${offsets[@]}")
|
||||||
|
|
||||||
for i in "${!images[@]}"; do
|
for i in "${!images[@]}"; do
|
||||||
img="${images[$i]}"
|
img="${images[$i]}"
|
||||||
off="${offsets[$i]}"
|
off="${offsets[$i]}"
|
||||||
echo "Writing $img at offset ${off}KiB"
|
echo "Writing $img at offset ${off}KiB"
|
||||||
dd if="$img" of="$1" bs=1K seek="${off}" conv=sparse,notrunc status=none
|
dd if="$img" of="$1" bs=1K seek="${off}" conv=sparse,notrunc status=none
|
||||||
done
|
done
|
||||||
echo "Your bootable SD image is $1"
|
echo "Your bootable SD image is $1"
|
||||||
Loading…
Reference in New Issue