From 923c22ff9e54e3fa7ffe100e5ea84eab18ed6902 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 6 Mar 2023 23:06:45 +0100 Subject: [PATCH] Support custom sized SPL/raw boot region (#2385) * Support custom sized SPL/raw boot region This is required for Rockchip which by default stores the U-Boot FIT image at the 8MiB offset. * Ignore shellcheck warning --- .../board/arm-uefi/generic-aarch64/meta | 1 + buildroot-external/board/asus/tinker/meta | 2 ++ buildroot-external/board/hardkernel/odroid-c2/meta | 2 ++ buildroot-external/board/hardkernel/odroid-c4/meta | 2 ++ buildroot-external/board/hardkernel/odroid-n2/meta | 2 ++ .../board/hardkernel/odroid-xu4/meta | 2 ++ buildroot-external/board/khadas/vim3/meta | 2 ++ buildroot-external/board/pc/generic-x86-64/meta | 1 + buildroot-external/board/pc/ova/meta | 1 + buildroot-external/board/raspberrypi/rpi2/meta | 1 + buildroot-external/board/raspberrypi/rpi3-64/meta | 1 + buildroot-external/board/raspberrypi/rpi3/meta | 1 + buildroot-external/board/raspberrypi/rpi4-64/meta | 1 + buildroot-external/board/raspberrypi/rpi4/meta | 1 + buildroot-external/board/raspberrypi/yellow/meta | 1 + buildroot-external/scripts/hdd-image.sh | 14 ++++++-------- 16 files changed, 27 insertions(+), 8 deletions(-) diff --git a/buildroot-external/board/arm-uefi/generic-aarch64/meta b/buildroot-external/board/arm-uefi/generic-aarch64/meta index 52c938087..e4938191a 100644 --- a/buildroot-external/board/arm-uefi/generic-aarch64/meta +++ b/buildroot-external/board/arm-uefi/generic-aarch64/meta @@ -4,6 +4,7 @@ CHASSIS=embedded BOOTLOADER=grub KERNEL_FILE=Image BOOT_SYS=efi +BOOT_SIZE=32M BOOT_SPL=false DISK_SIZE=6 SUPERVISOR_MACHINE=qemuarm-64 diff --git a/buildroot-external/board/asus/tinker/meta b/buildroot-external/board/asus/tinker/meta index e1fbf89ab..9683ec268 100644 --- a/buildroot-external/board/asus/tinker/meta +++ b/buildroot-external/board/asus/tinker/meta @@ -4,7 +4,9 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hybrid +BOOT_SIZE=24M BOOT_SPL=true +BOOT_SPL_SIZE=8M BOOT_ENV_SIZE=0x8000 SUPERVISOR_MACHINE=tinker SUPERVISOR_ARCH=armv7 diff --git a/buildroot-external/board/hardkernel/odroid-c2/meta b/buildroot-external/board/hardkernel/odroid-c2/meta index 13c9d5a47..ec650e475 100644 --- a/buildroot-external/board/hardkernel/odroid-c2/meta +++ b/buildroot-external/board/hardkernel/odroid-c2/meta @@ -4,7 +4,9 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=mbr +BOOT_SIZE=24M BOOT_SPL=true +BOOT_SPL_SIZE=8M BOOT_ENV_SIZE=0x2000 SUPERVISOR_MACHINE=odroid-c2 SUPERVISOR_ARCH=aarch64 diff --git a/buildroot-external/board/hardkernel/odroid-c4/meta b/buildroot-external/board/hardkernel/odroid-c4/meta index 3b23846fb..29de0068f 100644 --- a/buildroot-external/board/hardkernel/odroid-c4/meta +++ b/buildroot-external/board/hardkernel/odroid-c4/meta @@ -4,7 +4,9 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=mbr +BOOT_SIZE=24M BOOT_SPL=true +BOOT_SPL_SIZE=8M BOOT_ENV_SIZE=0x2000 SUPERVISOR_MACHINE=odroid-c4 SUPERVISOR_ARCH=aarch64 diff --git a/buildroot-external/board/hardkernel/odroid-n2/meta b/buildroot-external/board/hardkernel/odroid-n2/meta index 2a5cd960d..a33c3fa3f 100644 --- a/buildroot-external/board/hardkernel/odroid-n2/meta +++ b/buildroot-external/board/hardkernel/odroid-n2/meta @@ -4,7 +4,9 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=mbr +BOOT_SIZE=24M BOOT_SPL=true +BOOT_SPL_SIZE=8M BOOT_ENV_SIZE=0x2000 SUPERVISOR_MACHINE=odroid-n2 SUPERVISOR_ARCH=aarch64 diff --git a/buildroot-external/board/hardkernel/odroid-xu4/meta b/buildroot-external/board/hardkernel/odroid-xu4/meta index 4885ec078..f6886392e 100644 --- a/buildroot-external/board/hardkernel/odroid-xu4/meta +++ b/buildroot-external/board/hardkernel/odroid-xu4/meta @@ -4,7 +4,9 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=mbr +BOOT_SIZE=24M BOOT_SPL=true +BOOT_SPL_SIZE=8M BOOT_ENV_SIZE=0x4000 SUPERVISOR_MACHINE=odroid-xu SUPERVISOR_ARCH=armv7 diff --git a/buildroot-external/board/khadas/vim3/meta b/buildroot-external/board/khadas/vim3/meta index 97328fe48..facf0fd2c 100644 --- a/buildroot-external/board/khadas/vim3/meta +++ b/buildroot-external/board/khadas/vim3/meta @@ -4,7 +4,9 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=mbr +BOOT_SIZE=24M BOOT_SPL=true +BOOT_SPL_SIZE=8M BOOT_ENV_SIZE=0x2000 SUPERVISOR_MACHINE=khadas-vim3 SUPERVISOR_ARCH=aarch64 diff --git a/buildroot-external/board/pc/generic-x86-64/meta b/buildroot-external/board/pc/generic-x86-64/meta index bd5cd1a5d..0283b2cc2 100644 --- a/buildroot-external/board/pc/generic-x86-64/meta +++ b/buildroot-external/board/pc/generic-x86-64/meta @@ -4,6 +4,7 @@ CHASSIS=embedded BOOTLOADER=grub KERNEL_FILE=bzImage BOOT_SYS=efi +BOOT_SIZE=32M BOOT_SPL=false DISK_SIZE=6 SUPERVISOR_MACHINE=generic-x86-64 diff --git a/buildroot-external/board/pc/ova/meta b/buildroot-external/board/pc/ova/meta index 1b55573eb..10f8d56c8 100644 --- a/buildroot-external/board/pc/ova/meta +++ b/buildroot-external/board/pc/ova/meta @@ -4,6 +4,7 @@ CHASSIS=vm BOOTLOADER=grub KERNEL_FILE=bzImage BOOT_SYS=efi +BOOT_SIZE=32M BOOT_SPL=false DISK_SIZE=32 SUPERVISOR_MACHINE=qemux86-64 diff --git a/buildroot-external/board/raspberrypi/rpi2/meta b/buildroot-external/board/raspberrypi/rpi2/meta index 644a6c8f0..643dfd75f 100644 --- a/buildroot-external/board/raspberrypi/rpi2/meta +++ b/buildroot-external/board/raspberrypi/rpi2/meta @@ -4,6 +4,7 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hybrid +BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 SUPERVISOR_MACHINE=raspberrypi2 diff --git a/buildroot-external/board/raspberrypi/rpi3-64/meta b/buildroot-external/board/raspberrypi/rpi3-64/meta index 35238ade7..ee1a6c8ff 100644 --- a/buildroot-external/board/raspberrypi/rpi3-64/meta +++ b/buildroot-external/board/raspberrypi/rpi3-64/meta @@ -4,6 +4,7 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=hybrid +BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 SUPERVISOR_MACHINE=raspberrypi3-64 diff --git a/buildroot-external/board/raspberrypi/rpi3/meta b/buildroot-external/board/raspberrypi/rpi3/meta index f5709778a..66f7b8123 100644 --- a/buildroot-external/board/raspberrypi/rpi3/meta +++ b/buildroot-external/board/raspberrypi/rpi3/meta @@ -4,6 +4,7 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hybrid +BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 SUPERVISOR_MACHINE=raspberrypi3 diff --git a/buildroot-external/board/raspberrypi/rpi4-64/meta b/buildroot-external/board/raspberrypi/rpi4-64/meta index f59e98217..7f95185b1 100644 --- a/buildroot-external/board/raspberrypi/rpi4-64/meta +++ b/buildroot-external/board/raspberrypi/rpi4-64/meta @@ -4,6 +4,7 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=hybrid +BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 SUPERVISOR_MACHINE=raspberrypi4-64 diff --git a/buildroot-external/board/raspberrypi/rpi4/meta b/buildroot-external/board/raspberrypi/rpi4/meta index 488d792c4..bb4fa2e03 100644 --- a/buildroot-external/board/raspberrypi/rpi4/meta +++ b/buildroot-external/board/raspberrypi/rpi4/meta @@ -4,6 +4,7 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hybrid +BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 SUPERVISOR_MACHINE=raspberrypi4 diff --git a/buildroot-external/board/raspberrypi/yellow/meta b/buildroot-external/board/raspberrypi/yellow/meta index e0f250819..373ab9ab1 100644 --- a/buildroot-external/board/raspberrypi/yellow/meta +++ b/buildroot-external/board/raspberrypi/yellow/meta @@ -4,6 +4,7 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=hybrid +BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 SUPERVISOR_MACHINE=yellow diff --git a/buildroot-external/scripts/hdd-image.sh b/buildroot-external/scripts/hdd-image.sh index 934512f82..07e7a6fa2 100755 --- a/buildroot-external/scripts/hdd-image.sh +++ b/buildroot-external/scripts/hdd-image.sh @@ -10,7 +10,6 @@ KERNEL1_UUID="fc02a4f0-5350-406f-93a2-56cbed636b5f" OVERLAY_UUID="f1326040-5236-40eb-b683-aaa100a9afcf" DATA_UUID="a52a4597-fa3a-4851-aefd-2fbe9f849079" -BOOT_SIZE=(32M 24M) BOOTSTATE_SIZE=8M SYSTEM_SIZE=256M KERNEL_SIZE=24M @@ -45,11 +44,8 @@ function size2sectors() { function get_boot_size() { - if [ "${BOOT_SPL}" == "true" ]; then - echo "${BOOT_SIZE[1]}" - else - echo "${BOOT_SIZE[0]}" - fi + # shellcheck disable=SC2153 + echo "${BOOT_SIZE}" } @@ -57,7 +53,7 @@ function create_spl_image() { local boot_img="$(path_spl_img)" rm -f "${boot_img}" - truncate --size=8M "${boot_img}" + truncate --size="${BOOT_SPL_SIZE}" "${boot_img}" } @@ -199,7 +195,9 @@ function _create_disk_mbr() { local hdd_img="$(hassos_image_name img)" local hdd_count=${DISK_SIZE:-2} local disk_layout="${BINARIES_DIR}/disk.layout" - local boot_start=$(size2sectors "8M") + + # All boards with MBR disk layout have SPL + local boot_start=$(size2sectors "${BOOT_SPL_SIZE}") local boot_size=$(size2sectors "$(get_boot_size)") local kernel0_size=$(size2sectors "$KERNEL_SIZE")