From 9ce0766353ddebfb4a361fc1fbce6bced8e2c146 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 7 Mar 2023 00:52:16 +0100 Subject: [PATCH] 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. --- buildroot-external/ota/rauc-hook | 2 +- buildroot-external/scripts/hdd-image.sh | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/buildroot-external/ota/rauc-hook b/buildroot-external/ota/rauc-hook index fbf374765..60af25393 100755 --- a/buildroot-external/ota/rauc-hook +++ b/buildroot-external/ota/rauc-hook @@ -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 diff --git a/buildroot-external/scripts/hdd-image.sh b/buildroot-external/scripts/hdd-image.sh index 07e7a6fa2..96e8d954f 100755 --- a/buildroot-external/scripts/hdd-image.sh +++ b/buildroot-external/scripts/hdd-image.sh @@ -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 }