Avoid custom GPT location (#2386)

Currently the only board supporting GPT partition table and SPL is the
ASUS Tinker board. Its Rockchip boot loader is stored at LBA 0x40 (64)
which is well past the last LBA of a regular GPT partition table which
is at LBA 33). Therefor a custom GPT main partition table location (via
sgdisk -j, --adjust-main-table=sector) is not necessary.

Technically we could copy anything after LBA 34 from the SPL image, but
since we don't support a board which needs that space for its SPL let's
stick with the well aligned Rockchip start at LBA 64.

Note: To preserve the layout we still add the SPL size to the regular
offset. Technically we could start the boot partition at LBA 16384, but
this would mean a different partition table compared to before and
different offset of subsequent partitions compared to other GPT
platforms.
This commit is contained in:
Stefan Agner 2023-03-07 00:52:16 +01:00 committed by GitHub
parent 923c22ff9e
commit 9ce0766353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -41,7 +41,7 @@ install_spl() {
fi
if [ "${PART_LABEL}" = "gpt" ]; then
dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc ${FLAGS} bs=512 seek=2 skip=2
dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc ${FLAGS} bs=512 seek=64 skip=64
else
dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc ${FLAGS} bs=1 count=440
dd if="${RAUC_IMAGE_NAME}" of="${DEVICE_ROOT}" conv=notrunc ${FLAGS} bs=512 seek=1 skip=1

View File

@ -131,13 +131,12 @@ function _create_disk_gpt() {
##
# Partition layout
# SPL
if [ "${BOOT_SPL}" == "true" ]; then
sgdisk -j 16384 "${hdd_img}"
fi
# boot
boot_offset="$(sgdisk -F "${hdd_img}")"
if [ "${BOOT_SPL}" == "true" ]; then
# Make sure boot partition is shifted by SPL size
boot_offset=$((boot_offset+$(size2sectors "${BOOT_SPL_SIZE}")))
fi
sgdisk -n "0:${boot_offset}:+$(get_boot_size)" -c 0:"hassos-boot" -t 0:"C12A7328-F81F-11D2-BA4B-00A0C93EC93B" -u 0:${BOOT_UUID} "${hdd_img}"
# Kernel 0
@ -276,7 +275,9 @@ function _fix_disk_spl_gpt() {
sgdisk -t 1:"E3C9E316-0B5C-4DB8-817D-F92DF00215AE" "${hdd_img}"
dd if="${BR2_EXTERNAL_HASSOS_PATH}/bootloader/mbr-spl.img" of="${hdd_img}" conv=notrunc bs=512 count=1
dd if="${spl_img}" of="${hdd_img}" conv=notrunc bs=512 seek=2 skip=2
# Copy SPL, make sure to not overwrite GPT
dd if="${spl_img}" of="${hdd_img}" conv=notrunc bs=512 seek=64 skip=64
}