diff --git a/buildroot-external/board/arm-uefi/generic-aarch64/meta b/buildroot-external/board/arm-uefi/generic-aarch64/meta index e4938191a..a7c53f40b 100644 --- a/buildroot-external/board/arm-uefi/generic-aarch64/meta +++ b/buildroot-external/board/arm-uefi/generic-aarch64/meta @@ -3,9 +3,9 @@ BOARD_NAME="Generic aarch64" CHASSIS=embedded BOOTLOADER=grub KERNEL_FILE=Image -BOOT_SYS=efi +PARTITION_TABLE_TYPE=gpt BOOT_SIZE=32M BOOT_SPL=false -DISK_SIZE=6 +DISK_SIZE=6G SUPERVISOR_MACHINE=qemuarm-64 SUPERVISOR_ARCH=aarch64 diff --git a/buildroot-external/board/asus/hassos-hook.sh b/buildroot-external/board/asus/hassos-hook.sh index 879117928..84d85bde6 100755 --- a/buildroot-external/board/asus/hassos-hook.sh +++ b/buildroot-external/board/asus/hassos-hook.sh @@ -3,7 +3,6 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local SPL_IMG="$(path_spl_img)" cp -t "${BOOT_DATA}" \ "${BINARIES_DIR}/boot.scr" \ @@ -14,11 +13,6 @@ function hassos_pre_image() { cp "${BINARIES_DIR}"/*.dtbo "${BOOT_DATA}/overlays/" cp "${BOARD_DIR}/boot-env.txt" "${BOOT_DATA}/haos-config.txt" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${BINARIES_DIR}/u-boot-rockchip.bin" of="${SPL_IMG}" conv=notrunc bs=512 seek=64 } diff --git a/buildroot-external/board/asus/tinker/image-spl-spl.cfg b/buildroot-external/board/asus/tinker/image-spl-spl.cfg new file mode 100644 index 000000000..98f092e0c --- /dev/null +++ b/buildroot-external/board/asus/tinker/image-spl-spl.cfg @@ -0,0 +1,13 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition uboot { + offset = 32k + image = "u-boot-rockchip.bin" + } +} diff --git a/buildroot-external/board/asus/tinker/meta b/buildroot-external/board/asus/tinker/meta index 9683ec268..6b1701109 100644 --- a/buildroot-external/board/asus/tinker/meta +++ b/buildroot-external/board/asus/tinker/meta @@ -3,7 +3,7 @@ BOARD_NAME="Asus TinkerBoard" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage -BOOT_SYS=hybrid +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=24M BOOT_SPL=true BOOT_SPL_SIZE=8M diff --git a/buildroot-external/board/asus/tinker/partition-spl-spl.cfg b/buildroot-external/board/asus/tinker/partition-spl-spl.cfg new file mode 100644 index 000000000..fcc6beff5 --- /dev/null +++ b/buildroot-external/board/asus/tinker/partition-spl-spl.cfg @@ -0,0 +1,7 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(0; 17k)"} +} diff --git a/buildroot-external/board/hardkernel/odroid-c2/hassos-hook.sh b/buildroot-external/board/hardkernel/odroid-c2/hassos-hook.sh index c9be21855..9913db2f6 100755 --- a/buildroot-external/board/hardkernel/odroid-c2/hassos-hook.sh +++ b/buildroot-external/board/hardkernel/odroid-c2/hassos-hook.sh @@ -3,9 +3,6 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local BL1="${BINARIES_DIR}/bl1.bin.hardkernel" - local UBOOT_GXBB="${BINARIES_DIR}/u-boot.gxbb" - local SPL_IMG="$(path_spl_img)" cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" cp "${BINARIES_DIR}/meson-gxbb-odroidc2.dtb" "${BOOT_DATA}/meson-gxbb-odroidc2.dtb" @@ -14,13 +11,6 @@ function hassos_pre_image() { cp "${BINARIES_DIR}"/*.dtbo "${BOOT_DATA}/overlays/" cp "${BOARD_DIR}/boot-env.txt" "${BOOT_DATA}/haos-config.txt" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${BL1}" of="${SPL_IMG}" conv=notrunc bs=1 count=440 - dd if="${BL1}" of="${SPL_IMG}" conv=notrunc bs=512 skip=1 seek=1 - dd if="${UBOOT_GXBB}" of="${SPL_IMG}" conv=notrunc bs=512 seek=97 } diff --git a/buildroot-external/board/hardkernel/odroid-c2/image-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-c2/image-spl-spl.cfg new file mode 100644 index 000000000..4936adddd --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-c2/image-spl-spl.cfg @@ -0,0 +1,20 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition bl1 { + in-partition-table = "no" + image = "bl1.bin.hardkernel" + offset = 0 + } + + partition u-boot { + in-partition-table = "no" + image = "u-boot.gxbb" + offset = 97s + } +} diff --git a/buildroot-external/board/hardkernel/odroid-c2/meta b/buildroot-external/board/hardkernel/odroid-c2/meta index e8683b420..378185a31 100644 --- a/buildroot-external/board/hardkernel/odroid-c2/meta +++ b/buildroot-external/board/hardkernel/odroid-c2/meta @@ -3,7 +3,7 @@ BOARD_NAME="Hardkernel ODROID-C2" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=mbr +PARTITION_TABLE_TYPE=mbr BOOT_SIZE=24M BOOT_SPL=true BOOT_SPL_SIZE=8M diff --git a/buildroot-external/board/hardkernel/odroid-c2/partition-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-c2/partition-spl-spl.cfg new file mode 100644 index 000000000..66b25d3e3 --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-c2/partition-spl-spl.cfg @@ -0,0 +1,8 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(440; 512)"} +} + diff --git a/buildroot-external/board/hardkernel/odroid-c4/hassos-hook.sh b/buildroot-external/board/hardkernel/odroid-c4/hassos-hook.sh index 34a71d51f..20910b685 100755 --- a/buildroot-external/board/hardkernel/odroid-c4/hassos-hook.sh +++ b/buildroot-external/board/hardkernel/odroid-c4/hassos-hook.sh @@ -3,8 +3,6 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local UBOOT_SM1="${BINARIES_DIR}/u-boot.sm1" - local SPL_IMG="$(path_spl_img)" cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" cp "${BINARIES_DIR}/meson-sm1-odroid-c4.dtb" "${BOOT_DATA}/meson-sm1-odroid-c4.dtb" @@ -13,11 +11,6 @@ function hassos_pre_image() { cp "${BINARIES_DIR}"/*.dtbo "${BOOT_DATA}/overlays/" cp "${BOARD_DIR}/boot-env.txt" "${BOOT_DATA}/haos-config.txt" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${UBOOT_SM1}" of="${SPL_IMG}" conv=notrunc bs=512 seek=1 } diff --git a/buildroot-external/board/hardkernel/odroid-c4/image-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-c4/image-spl-spl.cfg new file mode 100644 index 000000000..336450b4e --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-c4/image-spl-spl.cfg @@ -0,0 +1,13 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition uboot { + offset = 512 + image = "u-boot.sm1" + } +} diff --git a/buildroot-external/board/hardkernel/odroid-c4/meta b/buildroot-external/board/hardkernel/odroid-c4/meta index 52bb0e7c8..bc78074fe 100644 --- a/buildroot-external/board/hardkernel/odroid-c4/meta +++ b/buildroot-external/board/hardkernel/odroid-c4/meta @@ -3,7 +3,7 @@ BOARD_NAME="Hardkernel ODROID-C4" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=mbr +PARTITION_TABLE_TYPE=mbr BOOT_SIZE=24M BOOT_SPL=true BOOT_SPL_SIZE=8M diff --git a/buildroot-external/board/hardkernel/odroid-c4/partition-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-c4/partition-spl-spl.cfg new file mode 100644 index 000000000..8eb324b4b --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-c4/partition-spl-spl.cfg @@ -0,0 +1,7 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(0; 512)"} +} diff --git a/buildroot-external/board/hardkernel/odroid-m1/hassos-hook.sh b/buildroot-external/board/hardkernel/odroid-m1/hassos-hook.sh index 14c703f38..49f56dda6 100755 --- a/buildroot-external/board/hardkernel/odroid-m1/hassos-hook.sh +++ b/buildroot-external/board/hardkernel/odroid-m1/hassos-hook.sh @@ -3,18 +3,12 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local SPL_IMG="$(path_spl_img)" cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" cp "${BINARIES_DIR}"/*.dtb "${BOOT_DATA}/" cp "${BOARD_DIR}/boot-env.txt" "${BOOT_DATA}/haos-config.txt" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${BINARIES_DIR}/u-boot-rockchip.bin" of="${SPL_IMG}" conv=notrunc bs=512 seek=64 } diff --git a/buildroot-external/board/hardkernel/odroid-m1/image-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-m1/image-spl-spl.cfg new file mode 100644 index 000000000..98f092e0c --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-m1/image-spl-spl.cfg @@ -0,0 +1,13 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition uboot { + offset = 32k + image = "u-boot-rockchip.bin" + } +} diff --git a/buildroot-external/board/hardkernel/odroid-m1/meta b/buildroot-external/board/hardkernel/odroid-m1/meta index 4c7f16a9a..b152313a2 100644 --- a/buildroot-external/board/hardkernel/odroid-m1/meta +++ b/buildroot-external/board/hardkernel/odroid-m1/meta @@ -3,7 +3,7 @@ BOARD_NAME="Hardkernel ODROID-M1" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=gpt +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=16M BOOT_SPL=true BOOT_SPL_SIZE=16M diff --git a/buildroot-external/board/hardkernel/odroid-m1/partition-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-m1/partition-spl-spl.cfg new file mode 100644 index 000000000..5db7ebff8 --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-m1/partition-spl-spl.cfg @@ -0,0 +1,17 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(0; 17k)", "(8M; 16M)"} +} + +partition uboot { + size = 8M + offset = 8M + # FIXME: hdd-image intended to use the following, but the next one + # is in the img because of the _fix_disk_spl_gpt function + # partition-type-uuid = "21686148-6449-6e6f-744e-656564454649" + partition-type-uuid = "e3c9e316-0b5c-4db8-817d-f92df00215ae" + # no image here - already contains data from spl.img +} diff --git a/buildroot-external/board/hardkernel/odroid-m1s/hassos-hook.sh b/buildroot-external/board/hardkernel/odroid-m1s/hassos-hook.sh index 14c703f38..49f56dda6 100755 --- a/buildroot-external/board/hardkernel/odroid-m1s/hassos-hook.sh +++ b/buildroot-external/board/hardkernel/odroid-m1s/hassos-hook.sh @@ -3,18 +3,12 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local SPL_IMG="$(path_spl_img)" cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" cp "${BINARIES_DIR}"/*.dtb "${BOOT_DATA}/" cp "${BOARD_DIR}/boot-env.txt" "${BOOT_DATA}/haos-config.txt" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${BINARIES_DIR}/u-boot-rockchip.bin" of="${SPL_IMG}" conv=notrunc bs=512 seek=64 } diff --git a/buildroot-external/board/hardkernel/odroid-m1s/image-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-m1s/image-spl-spl.cfg new file mode 100644 index 000000000..98f092e0c --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-m1s/image-spl-spl.cfg @@ -0,0 +1,13 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition uboot { + offset = 32k + image = "u-boot-rockchip.bin" + } +} diff --git a/buildroot-external/board/hardkernel/odroid-m1s/meta b/buildroot-external/board/hardkernel/odroid-m1s/meta index b73bb38e0..9c75b6f31 100644 --- a/buildroot-external/board/hardkernel/odroid-m1s/meta +++ b/buildroot-external/board/hardkernel/odroid-m1s/meta @@ -3,7 +3,7 @@ BOARD_NAME="Hardkernel ODROID-M1S" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=gpt +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=16M BOOT_SPL=true BOOT_SPL_SIZE=16M diff --git a/buildroot-external/board/hardkernel/odroid-m1s/partition-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-m1s/partition-spl-spl.cfg new file mode 100644 index 000000000..5db7ebff8 --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-m1s/partition-spl-spl.cfg @@ -0,0 +1,17 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(0; 17k)", "(8M; 16M)"} +} + +partition uboot { + size = 8M + offset = 8M + # FIXME: hdd-image intended to use the following, but the next one + # is in the img because of the _fix_disk_spl_gpt function + # partition-type-uuid = "21686148-6449-6e6f-744e-656564454649" + partition-type-uuid = "e3c9e316-0b5c-4db8-817d-f92df00215ae" + # no image here - already contains data from spl.img +} diff --git a/buildroot-external/board/hardkernel/odroid-n2/hassos-hook.sh b/buildroot-external/board/hardkernel/odroid-n2/hassos-hook.sh index 2beb6e245..a22915932 100755 --- a/buildroot-external/board/hardkernel/odroid-n2/hassos-hook.sh +++ b/buildroot-external/board/hardkernel/odroid-n2/hassos-hook.sh @@ -3,8 +3,6 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local UBOOT_G12B="${BINARIES_DIR}/u-boot.g12b" - local SPL_IMG="$(path_spl_img)" cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" cp "${BINARIES_DIR}"/*.dtb "${BOOT_DATA}/" @@ -13,11 +11,6 @@ function hassos_pre_image() { cp "${BINARIES_DIR}"/*.dtbo "${BOOT_DATA}/overlays/" cp "${BOARD_DIR}/boot-env.txt" "${BOOT_DATA}/haos-config.txt" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${UBOOT_G12B}" of="${SPL_IMG}" conv=notrunc bs=512 seek=1 } diff --git a/buildroot-external/board/hardkernel/odroid-n2/image-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-n2/image-spl-spl.cfg new file mode 100644 index 000000000..0bef44fa4 --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-n2/image-spl-spl.cfg @@ -0,0 +1,13 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition uboot { + offset = 512 + image = "u-boot.g12b" + } +} diff --git a/buildroot-external/board/hardkernel/odroid-n2/meta b/buildroot-external/board/hardkernel/odroid-n2/meta index a35e1c5c3..ac72f7edd 100644 --- a/buildroot-external/board/hardkernel/odroid-n2/meta +++ b/buildroot-external/board/hardkernel/odroid-n2/meta @@ -3,7 +3,7 @@ BOARD_NAME="Hardkernel ODROID-N2" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=mbr +PARTITION_TABLE_TYPE=mbr BOOT_SIZE=24M BOOT_SPL=true BOOT_SPL_SIZE=8M diff --git a/buildroot-external/board/hardkernel/odroid-n2/partition-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-n2/partition-spl-spl.cfg new file mode 100644 index 000000000..8eb324b4b --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-n2/partition-spl-spl.cfg @@ -0,0 +1,7 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(0; 512)"} +} diff --git a/buildroot-external/board/hardkernel/odroid-xu4/hassos-hook.sh b/buildroot-external/board/hardkernel/odroid-xu4/hassos-hook.sh index 437a39fb4..8614412d6 100644 --- a/buildroot-external/board/hardkernel/odroid-xu4/hassos-hook.sh +++ b/buildroot-external/board/hardkernel/odroid-xu4/hassos-hook.sh @@ -3,24 +3,10 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local BL1="${BINARIES_DIR}/bl1.bin.hardkernel" - local BL2="${BINARIES_DIR}/bl2.bin.hardkernel.720k_uboot" - local BLTZ="${BINARIES_DIR}/tzsw.bin.hardkernel" - local UBOOT="${BINARIES_DIR}/u-boot.bin" - local spl_img="$(path_spl_img)" cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" cp "${BINARIES_DIR}/exynos5422-odroidxu4.dtb" "${BOOT_DATA}/exynos5422-odroidxu4.dtb" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${BL1}" of="${spl_img}" conv=notrunc bs=512 seek=1 - dd if="${BL2}" of="${spl_img}" conv=notrunc bs=512 seek=31 - dd if="${UBOOT}" of="${spl_img}" conv=notrunc bs=512 seek=63 - dd if="${BLTZ}" of="${spl_img}" conv=notrunc bs=512 seek=1503 - dd if=/dev/zero of="${spl_img}" conv=notrunc bs=512 count=32 seek=2015 } diff --git a/buildroot-external/board/hardkernel/odroid-xu4/image-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-xu4/image-spl-spl.cfg new file mode 100644 index 000000000..239af3697 --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-xu4/image-spl-spl.cfg @@ -0,0 +1,33 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition 0 { + size = 512 + fill = "yes" + } + + partition bl1 { + image = "bl1.bin.hardkernel" + holes = {"(15360; 15616)"} # last 256 bytes are overwritten by bl2 + } + + partition bl2 { + offset = 31s + image = "bl2.bin.hardkernel.720k_uboot" + } + + partition uboot { + offset = 63s + image = "u-boot.bin" + } + + partition tzsw { + offset = 1503s + image = "tzsw.bin.hardkernel" + } +} diff --git a/buildroot-external/board/hardkernel/odroid-xu4/meta b/buildroot-external/board/hardkernel/odroid-xu4/meta index 4543d1b36..d87e987f1 100644 --- a/buildroot-external/board/hardkernel/odroid-xu4/meta +++ b/buildroot-external/board/hardkernel/odroid-xu4/meta @@ -3,7 +3,7 @@ BOARD_NAME="Hardkernel ODROID-XU4" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage -BOOT_SYS=mbr +PARTITION_TABLE_TYPE=mbr BOOT_SIZE=24M BOOT_SPL=true BOOT_SPL_SIZE=8M diff --git a/buildroot-external/board/hardkernel/odroid-xu4/partition-spl-spl.cfg b/buildroot-external/board/hardkernel/odroid-xu4/partition-spl-spl.cfg new file mode 100644 index 000000000..1e3ecfeba --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-xu4/partition-spl-spl.cfg @@ -0,0 +1,7 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(440; 512)"} +} diff --git a/buildroot-external/board/khadas/vim3/hassos-hook.sh b/buildroot-external/board/khadas/vim3/hassos-hook.sh index 627609133..b45a20d01 100755 --- a/buildroot-external/board/khadas/vim3/hassos-hook.sh +++ b/buildroot-external/board/khadas/vim3/hassos-hook.sh @@ -3,20 +3,12 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local UBOOT_GXL="${BINARIES_DIR}/u-boot.gxl" - local SPL_IMG="$(path_spl_img)" cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" cp "${BINARIES_DIR}/meson-g12b-s922x-khadas-vim3.dtb" "${BOOT_DATA}/meson-g12b-s922x-khadas-vim3.dtb" cp "${BOARD_DIR}/boot-env.txt" "${BOOT_DATA}/haos-config.txt" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${UBOOT_GXL}" of="${SPL_IMG}" conv=notrunc bs=1 count=444 - dd if="${UBOOT_GXL}" of="${SPL_IMG}" conv=notrunc bs=512 skip=1 seek=1 } diff --git a/buildroot-external/board/khadas/vim3/image-spl-spl.cfg b/buildroot-external/board/khadas/vim3/image-spl-spl.cfg new file mode 100644 index 000000000..a734a318a --- /dev/null +++ b/buildroot-external/board/khadas/vim3/image-spl-spl.cfg @@ -0,0 +1,16 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + # FIXME: May not be necessary, but keeping it for now for binary-identical output + exec-post = "dd if=/dev/zero of=${BINARIES_DIR}/spl.img seek=444 count=68 bs=1 conv=notrunc" + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition uboot { + offset = 0 + image = "u-boot.gxl" + } +} diff --git a/buildroot-external/board/khadas/vim3/meta b/buildroot-external/board/khadas/vim3/meta index facf0fd2c..7496e36a7 100644 --- a/buildroot-external/board/khadas/vim3/meta +++ b/buildroot-external/board/khadas/vim3/meta @@ -3,7 +3,7 @@ BOARD_NAME="Khadas VIM3" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=mbr +PARTITION_TABLE_TYPE=mbr BOOT_SIZE=24M BOOT_SPL=true BOOT_SPL_SIZE=8M diff --git a/buildroot-external/board/khadas/vim3/partition-spl-spl.cfg b/buildroot-external/board/khadas/vim3/partition-spl-spl.cfg new file mode 100644 index 000000000..1e3ecfeba --- /dev/null +++ b/buildroot-external/board/khadas/vim3/partition-spl-spl.cfg @@ -0,0 +1,7 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(440; 512)"} +} diff --git a/buildroot-external/board/nabucasa/green/hassos-hook.sh b/buildroot-external/board/nabucasa/green/hassos-hook.sh index 14c703f38..49f56dda6 100644 --- a/buildroot-external/board/nabucasa/green/hassos-hook.sh +++ b/buildroot-external/board/nabucasa/green/hassos-hook.sh @@ -3,18 +3,12 @@ function hassos_pre_image() { local BOOT_DATA="$(path_boot_dir)" - local SPL_IMG="$(path_spl_img)" cp "${BINARIES_DIR}/boot.scr" "${BOOT_DATA}/boot.scr" cp "${BINARIES_DIR}"/*.dtb "${BOOT_DATA}/" cp "${BOARD_DIR}/boot-env.txt" "${BOOT_DATA}/haos-config.txt" cp "${BOARD_DIR}/cmdline.txt" "${BOOT_DATA}/cmdline.txt" - - # SPL - create_spl_image - - dd if="${BINARIES_DIR}/u-boot-rockchip.bin" of="${SPL_IMG}" conv=notrunc bs=512 seek=64 } diff --git a/buildroot-external/board/nabucasa/green/image-spl-spl.cfg b/buildroot-external/board/nabucasa/green/image-spl-spl.cfg new file mode 100644 index 000000000..98f092e0c --- /dev/null +++ b/buildroot-external/board/nabucasa/green/image-spl-spl.cfg @@ -0,0 +1,13 @@ +image spl.img { + size = ${BOOT_SPL_SIZE} + + hdimage { + partition-table-type = "none" + fill = "yes" + } + + partition uboot { + offset = 32k + image = "u-boot-rockchip.bin" + } +} diff --git a/buildroot-external/board/nabucasa/green/meta b/buildroot-external/board/nabucasa/green/meta index 84f207e32..38b611ac0 100644 --- a/buildroot-external/board/nabucasa/green/meta +++ b/buildroot-external/board/nabucasa/green/meta @@ -3,7 +3,7 @@ BOARD_NAME="Home Assistant Green" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=gpt +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=16M BOOT_SPL=true BOOT_SPL_SIZE=16M diff --git a/buildroot-external/board/nabucasa/green/partition-spl-spl.cfg b/buildroot-external/board/nabucasa/green/partition-spl-spl.cfg new file mode 100644 index 000000000..fcc6beff5 --- /dev/null +++ b/buildroot-external/board/nabucasa/green/partition-spl-spl.cfg @@ -0,0 +1,7 @@ +partition spl { + size = ${BOOT_SPL_SIZE} + image = "spl.img" + in-partition-table = "no" + offset = 0 + holes = {"(0; 17k)"} +} diff --git a/buildroot-external/board/pc/generic-x86-64/meta b/buildroot-external/board/pc/generic-x86-64/meta index 0283b2cc2..6672e3a3e 100644 --- a/buildroot-external/board/pc/generic-x86-64/meta +++ b/buildroot-external/board/pc/generic-x86-64/meta @@ -3,9 +3,9 @@ BOARD_NAME="Generic x86-64" CHASSIS=embedded BOOTLOADER=grub KERNEL_FILE=bzImage -BOOT_SYS=efi +PARTITION_TABLE_TYPE=gpt BOOT_SIZE=32M BOOT_SPL=false -DISK_SIZE=6 +DISK_SIZE=6G SUPERVISOR_MACHINE=generic-x86-64 SUPERVISOR_ARCH=amd64 diff --git a/buildroot-external/board/pc/ova/meta b/buildroot-external/board/pc/ova/meta index 10f8d56c8..0250513b8 100644 --- a/buildroot-external/board/pc/ova/meta +++ b/buildroot-external/board/pc/ova/meta @@ -3,9 +3,9 @@ BOARD_NAME="Open Virtual Appliance" CHASSIS=vm BOOTLOADER=grub KERNEL_FILE=bzImage -BOOT_SYS=efi +PARTITION_TABLE_TYPE=gpt BOOT_SIZE=32M BOOT_SPL=false -DISK_SIZE=32 +DISK_SIZE=32G SUPERVISOR_MACHINE=qemux86-64 SUPERVISOR_ARCH=amd64 diff --git a/buildroot-external/board/raspberrypi/rpi2/meta b/buildroot-external/board/raspberrypi/rpi2/meta index 28dd227f0..59b08e4e8 100644 --- a/buildroot-external/board/raspberrypi/rpi2/meta +++ b/buildroot-external/board/raspberrypi/rpi2/meta @@ -3,7 +3,7 @@ BOARD_NAME="RaspberryPi 2" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage -BOOT_SYS=hybrid +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi3-64/meta b/buildroot-external/board/raspberrypi/rpi3-64/meta index ee1a6c8ff..831091c7a 100644 --- a/buildroot-external/board/raspberrypi/rpi3-64/meta +++ b/buildroot-external/board/raspberrypi/rpi3-64/meta @@ -3,7 +3,7 @@ BOARD_NAME="RaspberryPi 3 64bit" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=hybrid +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi3/meta b/buildroot-external/board/raspberrypi/rpi3/meta index 66f7b8123..f5031696a 100644 --- a/buildroot-external/board/raspberrypi/rpi3/meta +++ b/buildroot-external/board/raspberrypi/rpi3/meta @@ -3,7 +3,7 @@ BOARD_NAME="RaspberryPi 3" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage -BOOT_SYS=hybrid +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi4-64/meta b/buildroot-external/board/raspberrypi/rpi4-64/meta index 7f95185b1..75e834ea8 100644 --- a/buildroot-external/board/raspberrypi/rpi4-64/meta +++ b/buildroot-external/board/raspberrypi/rpi4-64/meta @@ -3,7 +3,7 @@ BOARD_NAME="RaspberryPi 4 64bit" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=hybrid +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi4/meta b/buildroot-external/board/raspberrypi/rpi4/meta index bb4fa2e03..7ea312c7a 100644 --- a/buildroot-external/board/raspberrypi/rpi4/meta +++ b/buildroot-external/board/raspberrypi/rpi4/meta @@ -3,7 +3,7 @@ BOARD_NAME="RaspberryPi 4" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage -BOOT_SYS=hybrid +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi5-64/meta b/buildroot-external/board/raspberrypi/rpi5-64/meta index dc41809d7..f6d6efcac 100644 --- a/buildroot-external/board/raspberrypi/rpi5-64/meta +++ b/buildroot-external/board/raspberrypi/rpi5-64/meta @@ -3,7 +3,7 @@ BOARD_NAME="RaspberryPi 5 64bit" CHASSIS=embedded BOOTLOADER=tryboot KERNEL_FILE=Image -BOOT_SYS=gpt +PARTITION_TABLE_TYPE=gpt BOOT_SIZE=64M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/yellow/meta b/buildroot-external/board/raspberrypi/yellow/meta index 373ab9ab1..cf124b26b 100644 --- a/buildroot-external/board/raspberrypi/yellow/meta +++ b/buildroot-external/board/raspberrypi/yellow/meta @@ -3,7 +3,7 @@ BOARD_NAME="Yellow" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image -BOOT_SYS=hybrid +PARTITION_TABLE_TYPE=hybrid BOOT_SIZE=32M BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/configs/generic_x86_64_defconfig b/buildroot-external/configs/generic_x86_64_defconfig index b09860485..ff3a3ba0d 100644 --- a/buildroot-external/configs/generic_x86_64_defconfig +++ b/buildroot-external/configs/generic_x86_64_defconfig @@ -164,6 +164,7 @@ BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI="boot linux ext2 fat squash4 part_msdos par BR2_TARGET_GRUB2_INSTALL_TOOLS=y BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/green_defconfig b/buildroot-external/configs/green_defconfig index 60a3f859b..3e86a6b20 100755 --- a/buildroot-external/configs/green_defconfig +++ b/buildroot-external/configs/green_defconfig @@ -149,6 +149,7 @@ BR2_TARGET_UBOOT_FORMAT_CUSTOM=y BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-rockchip.bin" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/khadas_vim3_defconfig b/buildroot-external/configs/khadas_vim3_defconfig index 6473378d2..cdf6813df 100644 --- a/buildroot-external/configs/khadas_vim3_defconfig +++ b/buildroot-external/configs/khadas_vim3_defconfig @@ -137,6 +137,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="khadas-vim3" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/khadas/vim3/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/odroid_c2_defconfig b/buildroot-external/configs/odroid_c2_defconfig index 9d23568ea..841e063e5 100644 --- a/buildroot-external/configs/odroid_c2_defconfig +++ b/buildroot-external/configs/odroid_c2_defconfig @@ -137,6 +137,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="odroid-c2" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/hardkernel/odroid-c2/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/odroid_c4_defconfig b/buildroot-external/configs/odroid_c4_defconfig index de65cf5fd..cc92be1d8 100644 --- a/buildroot-external/configs/odroid_c4_defconfig +++ b/buildroot-external/configs/odroid_c4_defconfig @@ -135,6 +135,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="odroid-c4" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/hardkernel/odroid-c4/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/odroid_m1_defconfig b/buildroot-external/configs/odroid_m1_defconfig index 9208b9e44..30fe08ae0 100644 --- a/buildroot-external/configs/odroid_m1_defconfig +++ b/buildroot-external/configs/odroid_m1_defconfig @@ -144,6 +144,7 @@ BR2_TARGET_UBOOT_FORMAT_CUSTOM=y BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-rockchip.bin" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/odroid_m1s_defconfig b/buildroot-external/configs/odroid_m1s_defconfig index 86af3d1a2..9a83c73ff 100644 --- a/buildroot-external/configs/odroid_m1s_defconfig +++ b/buildroot-external/configs/odroid_m1s_defconfig @@ -144,6 +144,7 @@ BR2_TARGET_UBOOT_FORMAT_CUSTOM=y BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-rockchip.bin" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/odroid_n2_defconfig b/buildroot-external/configs/odroid_n2_defconfig index c83380e8a..b21a8fba0 100644 --- a/buildroot-external/configs/odroid_n2_defconfig +++ b/buildroot-external/configs/odroid_n2_defconfig @@ -137,6 +137,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="odroid-n2" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/hardkernel/odroid-n2/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/odroid_xu4_defconfig b/buildroot-external/configs/odroid_xu4_defconfig index e0bdec1d0..7686fa78a 100644 --- a/buildroot-external/configs/odroid_xu4_defconfig +++ b/buildroot-external/configs/odroid_xu4_defconfig @@ -139,6 +139,7 @@ BR2_TARGET_UBOOT_NEEDS_DTC=y BR2_TARGET_UBOOT_FORMAT_DTB_BIN=y BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/ova_defconfig b/buildroot-external/configs/ova_defconfig index 030360ac6..829d210f8 100644 --- a/buildroot-external/configs/ova_defconfig +++ b/buildroot-external/configs/ova_defconfig @@ -165,6 +165,7 @@ BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI="boot linux ext2 fat squash4 part_msdos par BR2_TARGET_GRUB2_INSTALL_TOOLS=y BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/rpi2_defconfig b/buildroot-external/configs/rpi2_defconfig index b22fd9218..f6bb7adc3 100644 --- a/buildroot-external/configs/rpi2_defconfig +++ b/buildroot-external/configs/rpi2_defconfig @@ -1,7 +1,6 @@ BR2_arm=y BR2_cortex_a7=y BR2_ARM_FPU_VFPV4=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_6=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_DL_DIR="/cache/dl" BR2_CCACHE=y @@ -141,6 +140,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="rpi_2" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/rpi3_64_defconfig b/buildroot-external/configs/rpi3_64_defconfig index 4abd059e8..20003a1a5 100644 --- a/buildroot-external/configs/rpi3_64_defconfig +++ b/buildroot-external/configs/rpi3_64_defconfig @@ -1,6 +1,5 @@ BR2_aarch64=y BR2_ARM_FPU_VFPV4=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_6=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_DL_DIR="/cache/dl" BR2_CCACHE=y @@ -142,6 +141,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="rpi_3" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/rpi3_defconfig b/buildroot-external/configs/rpi3_defconfig index 8cff48c1c..a3794f063 100644 --- a/buildroot-external/configs/rpi3_defconfig +++ b/buildroot-external/configs/rpi3_defconfig @@ -1,7 +1,6 @@ BR2_arm=y BR2_cortex_a53=y BR2_ARM_FPU_VFPV4=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_6=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_DL_DIR="/cache/dl" BR2_CCACHE=y @@ -143,6 +142,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="rpi_3_32b" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/rpi4_64_defconfig b/buildroot-external/configs/rpi4_64_defconfig index a77949c06..7bf9ad2df 100644 --- a/buildroot-external/configs/rpi4_64_defconfig +++ b/buildroot-external/configs/rpi4_64_defconfig @@ -1,6 +1,5 @@ BR2_aarch64=y BR2_cortex_a72=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_6=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_DL_DIR="/cache/dl" BR2_CCACHE=y @@ -143,6 +142,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="rpi_4" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/rpi4-64/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/rpi4_defconfig b/buildroot-external/configs/rpi4_defconfig index e82a2a4e3..a20d03d1a 100644 --- a/buildroot-external/configs/rpi4_defconfig +++ b/buildroot-external/configs/rpi4_defconfig @@ -1,7 +1,6 @@ BR2_arm=y BR2_cortex_a72=y BR2_ARM_FPU_NEON_VFPV4=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_6=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_DL_DIR="/cache/dl" BR2_CCACHE=y @@ -142,6 +141,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="rpi_4_32b" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/rpi4/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/rpi5_64_defconfig b/buildroot-external/configs/rpi5_64_defconfig index a9d1256b8..a312282f7 100644 --- a/buildroot-external/configs/rpi5_64_defconfig +++ b/buildroot-external/configs/rpi5_64_defconfig @@ -1,6 +1,5 @@ BR2_aarch64=y BR2_cortex_a76=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_6=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_DL_DIR="/cache/dl" BR2_CCACHE=y @@ -135,6 +134,7 @@ BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y # BR2_TARGET_ROOTFS_TAR is not set BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/tinker_defconfig b/buildroot-external/configs/tinker_defconfig index 1afce47f3..ebb530c31 100644 --- a/buildroot-external/configs/tinker_defconfig +++ b/buildroot-external/configs/tinker_defconfig @@ -140,6 +140,7 @@ BR2_TARGET_UBOOT_FORMAT_CUSTOM=y BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-rockchip.bin" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/configs/yellow_defconfig b/buildroot-external/configs/yellow_defconfig index 3ab1d0c06..c553cf8e2 100644 --- a/buildroot-external/configs/yellow_defconfig +++ b/buildroot-external/configs/yellow_defconfig @@ -1,6 +1,5 @@ BR2_aarch64=y BR2_cortex_a72=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_6=y BR2_TOOLCHAIN_BUILDROOT_CXX=y BR2_DL_DIR="/cache/dl" BR2_CCACHE=y @@ -145,6 +144,7 @@ BR2_TARGET_UBOOT_BOARD_DEFCONFIG="rpi_4" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_HASSOS_PATH)/bootloader/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/uboot.config $(BR2_EXTERNAL_HASSOS_PATH)/board/raspberrypi/yellow/uboot.config" BR2_PACKAGE_HOST_DOSFSTOOLS=y BR2_PACKAGE_HOST_E2FSPROGS=y +BR2_PACKAGE_HOST_GENIMAGE=y BR2_PACKAGE_HOST_GPTFDISK=y BR2_PACKAGE_HOST_MTOOLS=y BR2_PACKAGE_HOST_RAUC=y diff --git a/buildroot-external/genimage/genimage.cfg b/buildroot-external/genimage/genimage.cfg new file mode 100644 index 000000000..fcd29a773 --- /dev/null +++ b/buildroot-external/genimage/genimage.cfg @@ -0,0 +1,15 @@ +include("images-os.cfg") + +image "${IMAGE_NAME}.img" { + size = "${DISK_SIZE:-2G}" + + include("hdimage-${PARTITION_TABLE_TYPE}.cfg") + + include("partition-spl-${BOOT_SPL_TYPE}.cfg") + + include("partitions-os-${PARTITION_TABLE_TYPE}.cfg") +} + +image "${IMAGE_NAME}.raucb" { + include("image-raucb-${BOOT_SPL_TYPE}.cfg") +} diff --git a/buildroot-external/genimage/hdimage-gpt.cfg b/buildroot-external/genimage/hdimage-gpt.cfg new file mode 100644 index 000000000..2cfe6af76 --- /dev/null +++ b/buildroot-external/genimage/hdimage-gpt.cfg @@ -0,0 +1,4 @@ +hdimage { + partition-table-type = "gpt" + align = 1M +} diff --git a/buildroot-external/genimage/hdimage-hybrid.cfg b/buildroot-external/genimage/hdimage-hybrid.cfg new file mode 100644 index 000000000..d9d14b44f --- /dev/null +++ b/buildroot-external/genimage/hdimage-hybrid.cfg @@ -0,0 +1,4 @@ +hdimage { + partition-table-type = "hybrid" + align = 1M +} diff --git a/buildroot-external/genimage/hdimage-mbr.cfg b/buildroot-external/genimage/hdimage-mbr.cfg new file mode 100644 index 000000000..69db2cc0a --- /dev/null +++ b/buildroot-external/genimage/hdimage-mbr.cfg @@ -0,0 +1,6 @@ +hdimage { + partition-table-type = "mbr" + align = 1M + disk-signature = 0x48617373 + extended-partition = 2 +} diff --git a/buildroot-external/genimage/image-raucb-nospl.cfg b/buildroot-external/genimage/image-raucb-nospl.cfg new file mode 100644 index 000000000..57697fb83 --- /dev/null +++ b/buildroot-external/genimage/image-raucb-nospl.cfg @@ -0,0 +1,10 @@ +rauc { + key = "/build/key.pem" + cert = "/build/cert.pem" + keyring = "${TARGET_DIR}/etc/rauc/keyring.pem" + manifest = "${RAUC_MANIFEST:-PLEASE_SPECIFY_RAUC_MANIFEST}" + file hook { image = "${BR2_EXTERNAL_HASSOS_PATH}/ota/rauc-hook" } + file boot.vfat { image = "boot.vfat" } + file kernel.img { image = "kernel.img" } + file rootfs.img { image = "rootfs.squashfs" } +} diff --git a/buildroot-external/genimage/image-raucb-spl.cfg b/buildroot-external/genimage/image-raucb-spl.cfg new file mode 100644 index 000000000..474497b7d --- /dev/null +++ b/buildroot-external/genimage/image-raucb-spl.cfg @@ -0,0 +1,11 @@ +rauc { + key = "/build/key.pem" + cert = "/build/cert.pem" + keyring = "${TARGET_DIR}/etc/rauc/keyring.pem" + manifest = "${RAUC_MANIFEST:-PLEASE_SPECIFY_RAUC_MANIFEST}" + file hook { image = "${BR2_EXTERNAL_HASSOS_PATH}/ota/rauc-hook" } + file spl.img { image = "spl.img" } + file boot.vfat { image = "boot.vfat" } + file kernel.img { image = "kernel.img" } + file rootfs.img { image = "rootfs.squashfs" } +} diff --git a/buildroot-external/genimage/image-spl-nospl.cfg b/buildroot-external/genimage/image-spl-nospl.cfg new file mode 100644 index 000000000..636bc1a8a --- /dev/null +++ b/buildroot-external/genimage/image-spl-nospl.cfg @@ -0,0 +1 @@ +# intentionally empty diff --git a/buildroot-external/genimage/images-boot.cfg b/buildroot-external/genimage/images-boot.cfg new file mode 100644 index 000000000..04d48197e --- /dev/null +++ b/buildroot-external/genimage/images-boot.cfg @@ -0,0 +1,9 @@ +image boot.vfat { + size = ${BOOT_SIZE:-PLEASE_SPECIFY_BOOT_SIZE} + + vfat { + label = "hassos-boot" + } +} + +include("image-spl-${BOOT_SPL_TYPE}.cfg") diff --git a/buildroot-external/genimage/images-os.cfg b/buildroot-external/genimage/images-os.cfg new file mode 100644 index 000000000..7a1eaeb87 --- /dev/null +++ b/buildroot-external/genimage/images-os.cfg @@ -0,0 +1,19 @@ +image kernel.img { + size = ${KERNEL_SIZE} + srcpath = "${BINARIES_DIR:-PLEASE_SPECIFY_BINARIES_DIR}/${KERNEL_FILE:-PLEASE_SPECIFY_KERNEL_FILE}" + + squashfs { + compression = "lzo" + } +} + +image overlay.ext4 { + size = ${OVERLAY_SIZE} + empty = "yes" + + ext4 { + use-mke2fs = "yes" + label = "hassos-overlay" + extraargs = "-I 256 -E lazy_itable_init=0,lazy_journal_init=0" + } +} diff --git a/buildroot-external/genimage/partition-gptboot-gpt.cfg b/buildroot-external/genimage/partition-gptboot-gpt.cfg new file mode 100644 index 000000000..872266c41 --- /dev/null +++ b/buildroot-external/genimage/partition-gptboot-gpt.cfg @@ -0,0 +1,6 @@ +partition hassos-boot { + size = ${BOOT_SIZE} + partition-type-uuid = "esp" + partition-uuid = "b3dd0952-733c-4c88-8cba-cab9b8b4377f" + image = "boot.vfat" +} diff --git a/buildroot-external/genimage/partition-gptboot-hybrid.cfg b/buildroot-external/genimage/partition-gptboot-hybrid.cfg new file mode 100644 index 000000000..27b2ede6b --- /dev/null +++ b/buildroot-external/genimage/partition-gptboot-hybrid.cfg @@ -0,0 +1,8 @@ +partition hassos-boot { + size = ${BOOT_SIZE} + partition-type = 0xc + # partition-type-uuid = "e3c9e316-0b5c-4db8-817d-f92df00215ae" # Microsoft reserved partition + partition-type-uuid = "esp" + partition-uuid = "b3dd0952-733c-4c88-8cba-cab9b8b4377f" + image = "boot.vfat" +} diff --git a/buildroot-external/genimage/partition-spl-nospl.cfg b/buildroot-external/genimage/partition-spl-nospl.cfg new file mode 100644 index 000000000..636bc1a8a --- /dev/null +++ b/buildroot-external/genimage/partition-spl-nospl.cfg @@ -0,0 +1 @@ +# intentionally empty diff --git a/buildroot-external/genimage/partitions-os-gpt.cfg b/buildroot-external/genimage/partitions-os-gpt.cfg new file mode 100644 index 000000000..e3ba0cef2 --- /dev/null +++ b/buildroot-external/genimage/partitions-os-gpt.cfg @@ -0,0 +1,47 @@ +include("partition-gptboot-${PARTITION_TABLE_TYPE}.cfg") + +partition hassos-kernel0 { + partition-type-uuid = "linux" + partition-uuid = "26700fc6-b0bc-4ccf-9837-ea1a4cba3e65" + size = ${KERNEL_SIZE} + image = "kernel.img" +} + +partition hassos-system0 { + partition-type-uuid = "linux" + partition-uuid = "8d3d53e3-6d49-4c38-8349-aff6859e82fd" + size = ${SYSTEM_SIZE} + image = "rootfs.squashfs" +} + +partition hassos-kernel1 { + partition-type-uuid = "linux" + partition-uuid = "fc02a4f0-5350-406f-93a2-56cbed636b5f" + size = ${KERNEL_SIZE} +} + +partition hassos-system1 { + partition-type-uuid = "linux" + partition-uuid = "a3ec664e-32ce-4665-95ea-7ae90ce9aa20" + size = ${SYSTEM_SIZE} +} + +partition hassos-bootstate { + partition-type-uuid = "linux" + partition-uuid = "33236519-7f32-4dff-8002-3390b62c309d" + size = ${BOOTSTATE_SIZE} +} + +partition hassos-overlay { + partition-type-uuid = "linux" + partition-uuid = "f1326040-5236-40eb-b683-aaa100a9afcf" + size = ${OVERLAY_SIZE} + image = "overlay.ext4" +} + +partition hassos-data { + partition-type-uuid = "linux" + partition-uuid = "a52a4597-fa3a-4851-aefd-2fbe9f849079" + size = ${DATA_SIZE} + image = "data.ext4" +} diff --git a/buildroot-external/genimage/partitions-os-hybrid.cfg b/buildroot-external/genimage/partitions-os-hybrid.cfg new file mode 120000 index 000000000..8380e68c2 --- /dev/null +++ b/buildroot-external/genimage/partitions-os-hybrid.cfg @@ -0,0 +1 @@ +partitions-os-gpt.cfg \ No newline at end of file diff --git a/buildroot-external/genimage/partitions-os-mbr.cfg b/buildroot-external/genimage/partitions-os-mbr.cfg new file mode 100644 index 000000000..f0afe1333 --- /dev/null +++ b/buildroot-external/genimage/partitions-os-mbr.cfg @@ -0,0 +1,47 @@ +partition hassos-boot { + size = ${BOOT_SIZE} + partition-type = 0xc + bootable = "yes" + image = "boot.vfat" +} + +partition hassos-kernel0 { + partition-type = 0x83 + size = ${KERNEL_SIZE} + image = "kernel.img" +} + +partition hassos-system0 { + partition-type = 0x83 + size = ${SYSTEM_SIZE} + image = "rootfs.squashfs" +} + +partition hassos-kernel1 { + partition-type = 0x83 + size = ${KERNEL_SIZE} +} + +partition hassos-system1 { + partition-type = 0x83 + size = ${SYSTEM_SIZE} +} + +partition hassos-bootstate { + partition-type = 0x83 + size = ${BOOTSTATE_SIZE} +} + +partition hassos-overlay { + partition-type = 0x83 + size = ${OVERLAY_SIZE} + image = "overlay.ext4" + forced-primary = "yes" +} + +partition hassos-data { + partition-type = 0x83 + size = ${DATA_SIZE} + image = "data.ext4" + forced-primary = "yes" +} diff --git a/buildroot-external/ota/system.conf.gtpl b/buildroot-external/ota/system.conf.gtpl index eb866ffef..4d15e371c 100644 --- a/buildroot-external/ota/system.conf.gtpl +++ b/buildroot-external/ota/system.conf.gtpl @@ -8,11 +8,7 @@ bootloader=custom bootloader={{ env "BOOTLOADER" }} {{- end }} {{- if eq (env "BOOTLOADER") "grub" }} -{{- if eq (env "BOOT_SYS") "efi" }} grubenv=/mnt/boot/EFI/BOOT/grubenv -{{- else }} -grubenv=/mnt/boot/grubenv -{{- end }} {{- end }} {{- if eq (env "BOOTLOADER") "tryboot" }} diff --git a/buildroot-external/patches/genimage/0001-image-hd-add-forced-primary-flag-for-higher-MBR-layo.patch b/buildroot-external/patches/genimage/0001-image-hd-add-forced-primary-flag-for-higher-MBR-layo.patch new file mode 100644 index 000000000..cf544e6c6 --- /dev/null +++ b/buildroot-external/patches/genimage/0001-image-hd-add-forced-primary-flag-for-higher-MBR-layo.patch @@ -0,0 +1,598 @@ +From 90f09d1766dfaad29f1c19c39f6b4b7a8483a86e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= +Date: Tue, 28 May 2024 15:49:32 +0200 +Subject: [PATCH] image-hd: add forced-primary flag for higher MBR layout + flexibility +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The current limitation of Genimage is that it is not able to create +MBR images that have primary partitions that start after a logical +partition. This can be useful for images that can be later resized based +on the actual device size - for this operation the partition must be at +the end of the device, and if it is present in a logical partition, it +must be resized first, making it a two-step process. + +This commit adds the "forced-primary" flag which can be used to indicate +that the partition should be put into the disk's MBR instead of creating +another logical partition. Validation ensures that this syntax allows to +create such partitions only after an existing logical partition, and +that the maximum number of MBR entries woudn't be exceeded by doing so. + +Test cases for valid and invalid configuiration has been added. Also +added few more details in the debug print to make it more obvious how +the MBR/EBR layout looks like. + +Signed-off-by: Jan Čermák +Upstream: https://github.com/pengutronix/genimage/pull/248 +--- + README.rst | 5 ++ + genimage.c | 2 + + genimage.h | 3 +- + image-hd.c | 116 +++++++++++++++++++---------- + test/hdimage-fail10.config | 33 ++++++++ + test/hdimage-fail11.config | 32 ++++++++ + test/hdimage-fail8.config | 28 +++++++ + test/hdimage-fail9.config | 27 +++++++ + test/hdimage-forced-primary.config | 47 ++++++++++++ + test/hdimage-forced-primary.fdisk | 10 +++ + test/hdimage.test | 14 +++- + 11 files changed, 275 insertions(+), 42 deletions(-) + create mode 100644 test/hdimage-fail10.config + create mode 100644 test/hdimage-fail11.config + create mode 100644 test/hdimage-fail8.config + create mode 100644 test/hdimage-fail9.config + create mode 100644 test/hdimage-forced-primary.config + create mode 100644 test/hdimage-forced-primary.fdisk + +diff --git a/README.rst b/README.rst +index d908ff5..7e2a0c5 100644 +--- a/README.rst ++++ b/README.rst +@@ -131,6 +131,11 @@ Partition options: + :bootable: Boolean specifying whether to set the bootable flag. + :in-partition-table: Boolean specifying whether to include this partition in + the partition table. Defaults to true. ++:forced-primary: Force this partition to be a primary partition in the ++ MBR partition table, useful when the extended partition should be ++ followed by primary partitions. If there are more partitions ++ defined after the first forced-primary, they must be also defined ++ as forced-primary. Defaults to false. + :partition-uuid: UUID string used by GPT partition tables to specify the partition + id. Defaults to a random value. + :partition-type-uuid: String used by GPT partition tables to specify the partition type. +diff --git a/genimage.c b/genimage.c +index 5bd235b..2fa9fa2 100644 +--- a/genimage.c ++++ b/genimage.c +@@ -96,6 +96,7 @@ static cfg_opt_t partition_opts[] = { + CFG_STR("align", NULL, CFGF_NONE), + CFG_INT("partition-type", 0, CFGF_NONE), + CFG_BOOL("bootable", cfg_false, CFGF_NONE), ++ CFG_BOOL("forced-primary", cfg_false, CFGF_NONE), + CFG_BOOL("read-only", cfg_false, CFGF_NONE), + CFG_BOOL("hidden", cfg_false, CFGF_NONE), + CFG_BOOL("no-automount", cfg_false, CFGF_NONE), +@@ -396,6 +397,7 @@ static int parse_partitions(struct image *image, cfg_t *imagesec) + part->align = cfg_getint_suffix(partsec, "align"); + part->partition_type = cfg_getint(partsec, "partition-type"); + part->bootable = cfg_getbool(partsec, "bootable"); ++ part->forced_primary = cfg_getbool(partsec, "forced-primary"); + part->read_only = cfg_getbool(partsec, "read-only"); + part->hidden = cfg_getbool(partsec, "hidden"); + part->no_automount = cfg_getbool(partsec, "no-automount"); +diff --git a/genimage.h b/genimage.h +index 8c86e77..b630984 100644 +--- a/genimage.h ++++ b/genimage.h +@@ -39,7 +39,8 @@ struct partition { + unsigned long long align; + unsigned char partition_type; + cfg_bool_t bootable; +- cfg_bool_t extended; ++ cfg_bool_t logical; ++ cfg_bool_t forced_primary; + cfg_bool_t read_only; + cfg_bool_t hidden; + cfg_bool_t no_automount; +diff --git a/image-hd.c b/image-hd.c +index 4ea55b6..6fb850f 100644 +--- a/image-hd.c ++++ b/image-hd.c +@@ -35,10 +35,12 @@ + #define TYPE_GPT 2 + #define TYPE_HYBRID (TYPE_MBR|TYPE_GPT) + ++#define PARTITION_TYPE_EXTENDED 0x0F ++ + struct hdimage { +- unsigned int extended_partition; ++ unsigned int extended_partition_index; ++ struct partition *extended_partition; + unsigned long long align; +- unsigned long long extended_lba; + uint32_t disksig; + const char *disk_uuid; + int table_type; +@@ -151,32 +153,24 @@ static int hdimage_insert_mbr(struct image *image, struct list_head *partitions) + list_for_each_entry(part, partitions, list) { + struct mbr_partition_entry *entry; + +- if (!part->in_partition_table) ++ if (!part->in_partition_table || part->logical) + continue; + + if (hd->table_type == TYPE_HYBRID && !part->partition_type) + continue; + +- if (hd->table_type == TYPE_HYBRID && part->extended) +- continue; +- + entry = &mbr.part_entry[i]; + + entry->boot = part->bootable ? 0x80 : 0x00; +- if (!part->extended) { +- entry->partition_type = part->partition_type; +- entry->relative_sectors = part->offset/512; +- entry->total_sectors = part->size/512; +- } +- else { +- entry->partition_type = 0x0F; +- entry->relative_sectors = (hd->extended_lba)/512; +- entry->total_sectors = (image->size - hd->extended_lba)/512; +- } ++ entry->partition_type = part->partition_type; ++ entry->relative_sectors = part->offset/512; ++ entry->total_sectors = part->size/512; + hdimage_setup_chs(entry); + +- if (part->extended) +- break; ++ image_debug(image, "[MBR entry %d]: type=%x start=%d size=%d\n", ++ i, entry->partition_type, ++ entry->relative_sectors, entry->total_sectors); ++ + i++; + } + +@@ -215,8 +209,9 @@ static int hdimage_insert_ebr(struct image *image, struct partition *part) + struct mbr_partition_entry *entry; + char ebr[4*sizeof(struct mbr_partition_entry)+2], *part_table; + int ret; ++ unsigned long long ebr_offset = part->offset - hd->align + 446; + +- image_info(image, "writing EBR\n"); ++ image_debug(image, "writing EBR to sector %llu\n", ebr_offset / 512); + + memset(ebr, 0, sizeof(ebr)); + part_table = ebr; +@@ -229,12 +224,12 @@ static int hdimage_insert_ebr(struct image *image, struct partition *part) + hdimage_setup_chs(entry); + struct partition *p = part; + list_for_each_entry_continue(p, &image->partitions, list) { +- if (!p->extended) ++ if (!p->logical) + continue; + ++entry; + entry->boot = 0x00; +- entry->partition_type = 0x0F; +- entry->relative_sectors = (p->offset - hd->align - hd->extended_lba)/512; ++ entry->partition_type = PARTITION_TYPE_EXTENDED; ++ entry->relative_sectors = (p->offset - hd->align - hd->extended_partition->offset)/512; + entry->total_sectors = (p->size + hd->align)/512; + hdimage_setup_chs(entry); + break; +@@ -245,7 +240,7 @@ static int hdimage_insert_ebr(struct image *image, struct partition *part) + part_table[1] = 0xaa; + + ret = insert_data(image, ebr, imageoutfile(image), sizeof(ebr), +- part->offset - hd->align + 446); ++ ebr_offset); + if (ret) { + image_error(image, "failed to write EBR\n"); + return ret; +@@ -577,13 +572,15 @@ static int hdimage_generate(struct image *image) + list_for_each_entry(part, &image->partitions, list) { + struct image *child; + +- image_info(image, "adding partition '%s'%s%s%s%s ...\n", part->name, ++ image_info(image, "adding %s partition '%s'%s%s%s%s ...\n", ++ part->logical ? "logical" : "primary", ++ part->name, + part->in_partition_table ? " (in MBR)" : "", + part->image ? " from '": "", + part->image ? part->image : "", + part->image ? "'" : ""); + +- if (part->extended) { ++ if (part->logical) { + ret = hdimage_insert_ebr(image, part); + if (ret) { + image_error(image, "failed to write EBR\n"); +@@ -756,13 +753,14 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + struct partition *autoresize_part = NULL; + int has_extended; + unsigned int partition_table_entries = 0, hybrid_entries = 0; ++ unsigned int mbr_entries = 0, forced_primary_entries = 0; + unsigned long long now = 0; + const char *disk_signature, *table_type; + struct hdimage *hd = xzalloc(sizeof(*hd)); + struct partition *gpt_backup = NULL; + + hd->align = cfg_getint_suffix(cfg, "align"); +- hd->extended_partition = cfg_getint(cfg, "extended-partition"); ++ hd->extended_partition_index = cfg_getint(cfg, "extended-partition"); + disk_signature = cfg_getstr(cfg, "disk-signature"); + table_type = cfg_getstr(cfg, "partition-table-type"); + hd->gpt_location = cfg_getint_suffix(cfg, "gpt-location"); +@@ -809,10 +807,10 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + if (!hd->align) + hd->align = hd->table_type == TYPE_NONE ? 1 : 512; + +- if (hd->extended_partition > 4) { ++ if (hd->extended_partition_index > 4) { + image_error(image, "invalid extended partition index (%i). must be " + "inferior or equal to 4 (0 for automatic)\n", +- hd->extended_partition); ++ hd->extended_partition_index); + return -EINVAL; + } + +@@ -821,11 +819,41 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + "multiple of 1 sector (512 bytes)\n", hd->align); + return -EINVAL; + } ++ if (hd->table_type == TYPE_MBR && hd->extended_partition_index) ++ mbr_entries = hd->extended_partition_index; ++ ++ has_extended = hd->extended_partition_index > 0; ++ + list_for_each_entry(part, &image->partitions, list) { + if (hd->table_type == TYPE_NONE) + part->in_partition_table = false; + if (part->in_partition_table) + ++partition_table_entries; ++ if (hd->table_type == TYPE_MBR && part->in_partition_table) { ++ if (!hd->extended_partition_index && partition_table_entries > 4) { ++ hd->extended_partition_index = mbr_entries = 4; ++ has_extended = true; ++ } ++ if (part->forced_primary) { ++ ++forced_primary_entries; ++ ++mbr_entries; ++ if (partition_table_entries <= hd->extended_partition_index) { ++ image_error(image, "partition %s: forced-primary can only be used for " ++ "partitions following the extended partition\n", ++ part->name); ++ return -EINVAL; ++ } ++ } else if (forced_primary_entries > 0) { ++ image_error(image, ++ "cannot create non-primary partition %s after forced-primary partition\n", ++ part->name); ++ return -EINVAL; ++ } ++ if (mbr_entries > 4) { ++ image_error(image, "too many primary partitions\n"); ++ return -EINVAL; ++ } ++ } + if (!part->align) + part->align = (part->in_partition_table || hd->table_type == TYPE_NONE) ? hd->align : 1; + if (part->in_partition_table && part->align % hd->align) { +@@ -834,10 +862,6 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + part->align, part->name, hd->align); + } + } +- if (hd->table_type == TYPE_MBR && !hd->extended_partition && +- partition_table_entries > 4) +- hd->extended_partition = 4; +- has_extended = hd->extended_partition > 0; + + if (hd->disk_uuid) { + if (!(hd->table_type & TYPE_GPT)) { +@@ -958,12 +982,12 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + if (part->partition_type) + ++hybrid_entries; + } +- /* reserve space for extended boot record if necessary */ + if (part->in_partition_table) + ++partition_table_entries; +- part->extended = has_extended && part->in_partition_table && +- (partition_table_entries >= hd->extended_partition); +- if (part->extended) { ++ part->logical = !part->forced_primary && has_extended && part->in_partition_table && ++ (partition_table_entries >= hd->extended_partition_index); ++ if (part->logical) { ++ /* reserve space for extended boot record */ + now += hd->align; + now = roundup(now, part->align); + } +@@ -978,8 +1002,6 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + if (!part->offset && (part->in_partition_table || hd->table_type == TYPE_NONE)) { + part->offset = roundup(now, part->align); + } +- if (part->extended && !hd->extended_lba) +- hd->extended_lba = part->offset - hd->align; + + if (part->offset % part->align) { + image_error(image, "part %s offset (%lld) must be a" +@@ -1027,7 +1049,7 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + part->name); + return -EINVAL; + } +- if (!part->extended) { ++ if (!part->logical) { + int ret = check_overlap(image, part); + if (ret) + return ret; +@@ -1051,8 +1073,22 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) + hd->file_size = part->offset + child->size; + } + } +- else if (part->extended) ++ else if (part->logical) + hd->file_size = part->offset - hd->align + 512; ++ ++ if (has_extended && hd->extended_partition_index == partition_table_entries) { ++ struct partition *p = fake_partition("[Extended]", now - hd->align - part->size, ++ 0); ++ p->in_partition_table = true; ++ p->partition_type = PARTITION_TYPE_EXTENDED; ++ ++ hd->extended_partition = p; ++ list_add_tail(&p->list, &part->list); ++ } ++ ++ if (part->logical) { ++ hd->extended_partition->size = now - hd->extended_partition->offset; ++ } + } + + if (hybrid_entries > 3) { +diff --git a/test/hdimage-fail10.config b/test/hdimage-fail10.config +new file mode 100644 +index 0000000..782c090 +--- /dev/null ++++ b/test/hdimage-fail10.config +@@ -0,0 +1,33 @@ ++image test.hdimage { ++ hdimage { ++ align = 1M ++ extended-partition = 3 ++ } ++ partition primary1 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition primary2 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition extended1 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition extended2 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition primary3 { ++ image = "part1.img" ++ partition-type = 0x83 ++ forced-primary = "yes" ++ } ++ partition primary4 { ++ image = "part1.img" ++ partition-type = 0x83 ++ /* would be 5th primary partition */ ++ forced-primary = "yes" ++ } ++} +diff --git a/test/hdimage-fail11.config b/test/hdimage-fail11.config +new file mode 100644 +index 0000000..06bf64b +--- /dev/null ++++ b/test/hdimage-fail11.config +@@ -0,0 +1,32 @@ ++image test.hdimage { ++ hdimage { ++ align = 1M ++ extended-partition = 1 ++ } ++ partition extended1 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition extended2 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition extended3 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition extended4 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition primary2 { ++ image = "part1.img" ++ partition-type = 0x83 ++ forced-primary = "yes" ++ } ++ partition extended5 { ++ image = "part1.img" ++ partition-type = 0x83 ++ /* extended partition would overlap the forced-primary one */ ++ } ++} +diff --git a/test/hdimage-fail8.config b/test/hdimage-fail8.config +new file mode 100644 +index 0000000..8f55faa +--- /dev/null ++++ b/test/hdimage-fail8.config +@@ -0,0 +1,28 @@ ++image test.hdimage { ++ hdimage { ++ align = 1M ++ extended-partition = 1 ++ } ++ partition part1 { ++ image = "part1.img" ++ partition-type = 0x83 ++ forced-primary = "yes" ++ /* forced-primary can be only used for partitions defined after the extended partition */ ++ } ++ partition part2 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition part3 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition part4 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition part5 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++} +diff --git a/test/hdimage-fail9.config b/test/hdimage-fail9.config +new file mode 100644 +index 0000000..d811b7b +--- /dev/null ++++ b/test/hdimage-fail9.config +@@ -0,0 +1,27 @@ ++image test.hdimage { ++ hdimage { ++ align = 1M ++ } ++ partition primary1 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition primary2 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition primary3 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition primary4 { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition primary5 { ++ image = "part1.img" ++ partition-type = 0x83 ++ /* part4 is implicitly extended -> too many primary entries */ ++ forced-primary = "yes" ++ } ++} +diff --git a/test/hdimage-forced-primary.config b/test/hdimage-forced-primary.config +new file mode 100644 +index 0000000..c15b3a5 +--- /dev/null ++++ b/test/hdimage-forced-primary.config +@@ -0,0 +1,47 @@ ++image test.hdimage { ++ hdimage { ++ align = 1M ++ disk-signature = 0x12345678 ++ extended-partition = 2 ++ } ++ partition part1 { ++ image = "part1.img" ++ partition-type = 0xc ++ bootable = "yes" ++ } ++ /* ++ * partition 2 will be the extended partition entry ++ * partitions 3-4 will be primary partitions at the end ++ * partition 5 is first logical partition of the extended partition ++ */ ++ partition part5-logical { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition part6-logical { ++ image = "part2.img" ++ partition-type = 0x83 ++ } ++ partition part7-logical { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition part8-logical { ++ image = "part2.img" ++ partition-type = 0x83 ++ } ++ partition part9-logical { ++ image = "part1.img" ++ partition-type = 0x83 ++ } ++ partition part3 { ++ image = "part1.img" ++ partition-type = 0x83 ++ forced-primary = "yes" ++ } ++ partition part4 { ++ image = "part2.img" ++ partition-type = 0x82 ++ forced-primary = "yes" ++ } ++} +diff --git a/test/hdimage-forced-primary.fdisk b/test/hdimage-forced-primary.fdisk +new file mode 100644 +index 0000000..ff0e903 +--- /dev/null ++++ b/test/hdimage-forced-primary.fdisk +@@ -0,0 +1,10 @@ ++Disk identifier: 0x12345678 ++images/test.hdimage1:start=2048,size=2048,type=c,bootable ++images/test.hdimage2:start=4096,size=20480,type=f ++images/test.hdimage3:start=24576,size=2048,type=83 ++images/test.hdimage4:start=26624,size=2048,type=82 ++images/test.hdimage5:start=6144,size=2048,type=83 ++images/test.hdimage6:start=10240,size=2048,type=83 ++images/test.hdimage7:start=14336,size=2048,type=83 ++images/test.hdimage8:start=18432,size=2048,type=83 ++images/test.hdimage9:start=22528,size=2048,type=83 +diff --git a/test/hdimage.test b/test/hdimage.test +index c284613..a81c3f1 100755 +--- a/test/hdimage.test ++++ b/test/hdimage.test +@@ -96,7 +96,11 @@ test_expect_success "hdimage syntax" " + test_must_fail run_genimage hdimage-fail4.config && + test_must_fail run_genimage hdimage-fail5.config && + test_must_fail run_genimage hdimage-fail6.config && +- test_must_fail run_genimage hdimage-fail7.config ++ test_must_fail run_genimage hdimage-fail7.config && ++ test_must_fail run_genimage hdimage-fail8.config && ++ test_must_fail run_genimage hdimage-fail9.config && ++ test_must_fail run_genimage hdimage-fail10.config && ++ test_must_fail run_genimage hdimage-fail11.config + " + + setup_gpt_files() { +@@ -163,6 +167,14 @@ test_expect_success "hdimage no-partition" " + test_cmp 'hdimage-nopart.hexdump' '${testdir}/hdimage-nopart.hexdump' + " + ++test_expect_success "hdimage forced-primary" " ++ setup_test_images && ++ run_genimage hdimage-forced-primary.config && ++ sfdisk_validate images/test.hdimage && ++ sanitized_fdisk_sfdisk images/test.hdimage > hdimage.fdisk && ++ test_cmp '${testdir}/hdimage-forced-primary.fdisk' hdimage.fdisk ++" ++ + test_done + + # vim: syntax=sh diff --git a/buildroot-external/scripts/hdd-image.sh b/buildroot-external/scripts/hdd-image.sh index 48cbc05d7..dcf625067 100755 --- a/buildroot-external/scripts/hdd-image.sh +++ b/buildroot-external/scripts/hdd-image.sh @@ -1,14 +1,4 @@ #!/bin/bash -# shellcheck disable=SC2155 - -BOOT_UUID="b3dd0952-733c-4c88-8cba-cab9b8b4377f" -BOOTSTATE_UUID="33236519-7F32-4DFF-8002-3390B62C309D" -SYSTEM0_UUID="8d3d53e3-6d49-4c38-8349-aff6859e82fd" -SYSTEM1_UUID="a3ec664e-32ce-4665-95ea-7ae90ce9aa20" -KERNEL0_UUID="26700fc6-b0bc-4ccf-9837-ea1a4cba3e65" -KERNEL1_UUID="fc02a4f0-5350-406f-93a2-56cbed636b5f" -OVERLAY_UUID="f1326040-5236-40eb-b683-aaa100a9afcf" -DATA_UUID="a52a4597-fa3a-4851-aefd-2fbe9f849079" BOOTSTATE_SIZE=8M SYSTEM_SIZE=256M @@ -16,315 +6,55 @@ KERNEL_SIZE=24M OVERLAY_SIZE=96M DATA_SIZE=1280M - -function size2sectors() { - local f=0 - for v in "${@}" - do - local p=$(echo "$v" | awk \ - 'BEGIN{IGNORECASE = 1} - function printsectors(n,b,p) {printf "%u\n", n*b^p/512} - /B$/{ printsectors($1, 1, 0)}; - /K(iB)?$/{printsectors($1, 2, 10)}; - /M(iB)?$/{printsectors($1, 2, 20)}; - /G(iB)?$/{printsectors($1, 2, 30)}; - /T(iB)?$/{printsectors($1, 2, 40)}; - /KB$/{ printsectors($1, 10, 3)}; - /MB$/{ printsectors($1, 10, 6)}; - /GB$/{ printsectors($1, 10, 9)}; - /TB$/{ printsectors($1, 10, 12)}') - for s in $p - do - f=$((f+s)) - done - - done - echo $f -} - - -function _check_image_size() { - local image="${1}" - local max_size="${2}" - - local image_size=$(stat -c %s "${image}") - local image_size_sectors=$((image_size / 512)) - local max_size_sectors=$(size2sectors "${max_size}") - - - if [ "${image_size_sectors}" -gt "${max_size_sectors}" ]; then - echo "Image ${image} is too big: ${image_size_sectors} sectors > ${max_size_sectors} sectors" >&2 - exit 1 - fi -} - - -function get_boot_size() { - # shellcheck disable=SC2153 - echo "${BOOT_SIZE}" -} - - -function create_spl_image() { - local boot_img="$(path_spl_img)" - - rm -f "${boot_img}" - truncate --size="${BOOT_SPL_SIZE}" "${boot_img}" -} - - -function create_boot_image() { - local boot_data="$(path_boot_dir)" - local boot_img="$(path_boot_img)" - - echo "mtools_skip_check=1" > ~/.mtoolsrc - rm -f "${boot_img}" - truncate --size="$(get_boot_size)" "${boot_img}" - mkfs.vfat -n "hassos-boot" "${boot_img}" - mcopy -i "${boot_img}" -sv "${boot_data}"/* :: - - _check_image_size "${boot_img}" "$(get_boot_size)" -} - - -function create_overlay_image() { - local overlay_img="$(path_overlay_img)" - - rm -f "${overlay_img}" - truncate --size="${OVERLAY_SIZE}" "${overlay_img}" - mkfs.ext4 -L "hassos-overlay" -I 256 -E lazy_itable_init=0,lazy_journal_init=0 "${overlay_img}" - - _check_image_size "${overlay_img}" "${OVERLAY_SIZE}" -} - - -function create_kernel_image() { - local kernel_img="$(path_kernel_img)" - # shellcheck disable=SC2153 - local kernel="${BINARIES_DIR}/${KERNEL_FILE}" - - # Make image - rm -f "${kernel_img}" - mksquashfs "${kernel}" "${kernel_img}" -comp lzo - - _check_image_size "${kernel_img}" "${KERNEL_SIZE}" -} - - -function _prepare_disk_image() { - _check_image_size "$(path_data_img)" "${DATA_SIZE}" - _check_image_size "$(path_rootfs_img)" "${SYSTEM_SIZE}" - - create_boot_image - create_overlay_image - create_kernel_image -} - - function create_disk_image() { - _prepare_disk_image - - if [ "${BOOT_SYS}" == "mbr" ]; then - _create_disk_mbr + if [ -f "${BOARD_DIR}/genimage.cfg" ]; then + echo "Using custom genimage.cfg from ${BOARD_DIR}" else - _create_disk_gpt - fi -} - - -function _create_disk_gpt() { - local boot_img="$(path_boot_img)" - local rootfs_img="$(path_rootfs_img)" - local overlay_img="$(path_overlay_img)" - local data_img="$(path_data_img)" - local kernel_img="$(path_kernel_img)" - local hdd_img="$(hassos_image_name img)" - local hdd_count=${DISK_SIZE:-2} - - local boot_offset=0 - local rootfs_offset=0 - local kernel_offset=0 - local overlay_offset=0 - local data_offset=0 - - ## - # Write new image & GPT - rm -f "${hdd_img}" - truncate --size="${hdd_count}G" "${hdd_img}" - sgdisk -o "${hdd_img}" - - ## - # Partition layout - - # 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 - if [ "${BOARD_ID}" == "odroid-m1" ] || [ "${BOARD_ID}" == "odroid-m1s" ]; then - # Create partition for U-Boot binary (required by Hardkernel SPL to boot - # using default petitboot SPI - sgdisk -n "0:16384:+8M" -c 0:"uboot" -t 0:"21686148-6449-6E6F-744E-656564454649" "${hdd_img}" - 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 - kernel_offset="$(sgdisk -F "${hdd_img}")" - sgdisk -n "0:0:+${KERNEL_SIZE}" -c 0:"hassos-kernel0" -t 0:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u "0:${KERNEL0_UUID}" "${hdd_img}" - - # System 0 - rootfs_offset="$(sgdisk -F "${hdd_img}")" - sgdisk -n "0:0:+${SYSTEM_SIZE}" -c 0:"hassos-system0" -t 0:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u "0:${SYSTEM0_UUID}" "${hdd_img}" - - # Kernel 1 - sgdisk -n "0:0:+${KERNEL_SIZE}" -c 0:"hassos-kernel1" -t 0:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u "0:${KERNEL1_UUID}" "${hdd_img}" - - # System 1 - sgdisk -n "0:0:+${SYSTEM_SIZE}" -c 0:"hassos-system1" -t 0:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u "0:${SYSTEM1_UUID}" "${hdd_img}" - - # Bootstate - sgdisk -n "0:0:+${BOOTSTATE_SIZE}" -c 0:"hassos-bootstate" -u 0:${BOOTSTATE_UUID} "${hdd_img}" - - # Overlay - overlay_offset="$(sgdisk -F "${hdd_img}")" - sgdisk -n "0:0:+${OVERLAY_SIZE}" -c 0:"hassos-overlay" -t 0:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u "0:${OVERLAY_UUID}" "${hdd_img}" - - # Data - data_offset="$(sgdisk -F "${hdd_img}")" - sgdisk -n "0:0:+${DATA_SIZE}" -c 0:"hassos-data" -t 0:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u "0:${DATA_UUID}" "${hdd_img}" - - ## - # Write Images - sgdisk -v "${hdd_img}" - dd if="${boot_img}" of"=${hdd_img}" conv=notrunc,sparse bs=512 seek="${boot_offset}" - dd if="${kernel_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${kernel_offset}" - dd if="${rootfs_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${rootfs_offset}" - dd if="${overlay_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${overlay_offset}" - dd if="${data_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${data_offset}" - - # Set Hyprid partition - if [ "${BOOT_SYS}" == "hybrid" ]; then - _fix_disk_hybrid + echo "Using default genimage.cfg" fi - # Write SPL - if [ "${BOOT_SPL}" == "true" ]; then - _fix_disk_spl_gpt - fi + export GENIMAGE_INPUTPATH="${BINARIES_DIR}" + export GENIMAGE_OUTPUTPATH="${BINARIES_DIR}" + export GENIMAGE_TMPPATH="${BUILD_DIR}/genimage.tmp" + + # variables from meta file + export DISK_SIZE BOOTLOADER KERNEL_FILE PARTITION_TABLE_TYPE BOOT_SIZE BOOT_SPL BOOT_SPL_SIZE + # variables used in raucb manifest template + ota_compatible="$(hassos_rauc_compatible)" + ota_version="$(hassos_version)" + export ota_compatible ota_version + # variables used in genimage configs + export BOOTSTATE_SIZE SYSTEM_SIZE KERNEL_SIZE OVERLAY_SIZE DATA_SIZE + RAUC_MANIFEST=$(tempio -template "${BR2_EXTERNAL_HASSOS_PATH}/ota/manifest.raucm.gtpl") + IMAGE_NAME="$(hassos_image_basename)" + BOOT_SPL_TYPE=$(test "$BOOT_SPL" == "true" && echo "spl" || echo "nospl") + export RAUC_MANIFEST IMAGE_NAME BOOT_SPL_TYPE + + trap 'rm -rf "${ROOTPATH_TMP}" "${GENIMAGE_TMPPATH}"' EXIT + ROOTPATH_TMP="$(mktemp -d)" + + rm -rf "${GENIMAGE_TMPPATH}" + # Generate boot FS image - run in a separate step with specific rootpath + genimage \ + --rootpath "$(path_boot_dir)" \ + --configdump - \ + --includepath "${BOARD_DIR}:${BR2_EXTERNAL_HASSOS_PATH}/genimage" \ + --config images-boot.cfg + + rm -rf "${GENIMAGE_TMPPATH}" + # Generate OS image (no files are copied to temporary rootpath here) + genimage \ + --rootpath "${ROOTPATH_TMP}" \ + --configdump - \ + --includepath "${BOARD_DIR}:${BR2_EXTERNAL_HASSOS_PATH}/genimage" } - -function _create_disk_mbr() { - local boot_img="$(path_boot_img)" - local rootfs_img="$(path_rootfs_img)" - local overlay_img="$(path_overlay_img)" - local data_img="$(path_data_img)" - local kernel_img="$(path_kernel_img)" - local hdd_img="$(hassos_image_name img)" - local hdd_count=${DISK_SIZE:-2} - local disk_layout="${BINARIES_DIR}/disk.layout" - - # 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") - local system0_size=$(size2sectors "$SYSTEM_SIZE") - local kernel1_size=$(size2sectors "$KERNEL_SIZE") - local system1_size=$(size2sectors "$SYSTEM_SIZE") - local bootstate_size=$(size2sectors "$BOOTSTATE_SIZE") - local overlay_size=$(size2sectors "$OVERLAY_SIZE") - local data_size=$(size2sectors "$DATA_SIZE") - local extended_size=$((kernel0_size+system0_size+kernel1_size+system1_size+bootstate_size+5*$(size2sectors "1M"))) - - # we add one here for the extended header. - local extended_start=$((boot_start+boot_size)) - local kernel0_start=$((extended_start+$(size2sectors "1M"))) - local system0_start=$((kernel0_start+kernel0_size+$(size2sectors "1M"))) - local kernel1_start=$((system0_start+system0_size+$(size2sectors "1M"))) - local system1_start=$((kernel1_start+kernel1_size+$(size2sectors "1M"))) - local bootstate_start=$((system1_start+system1_size+$(size2sectors "1M"))) - local overlay_start=$((extended_start+extended_size+$(size2sectors "1M"))) - local data_start=$((overlay_start+overlay_size+$(size2sectors "1M"))) - - local boot_offset=${boot_start} - local kernel_offset=${kernel0_start} - local rootfs_offset=${system0_start} - local overlay_offset=${overlay_start} - local data_offset=${data_start} - - # Write new image & MBR - rm -f "${hdd_img}" - truncate --size="${hdd_count}G" "${hdd_img}" - - # Update disk layout - ( - echo "label: dos" - echo "label-id: 0x48617373" - echo "unit: sectors" - echo "hassos-boot : start= ${boot_start}, size= ${boot_size}, type=c, bootable" #create the boot partition - echo "hassos-extended : start= ${extended_start}, size= ${extended_size}, type=5" #Make an extended partition - echo "hassos-kernel : start= ${kernel0_start}, size= ${kernel0_size}, type=83" #Make a logical Linux partition - echo "hassos-system : start= ${system0_start}, size= ${system0_size}, type=83" #Make a logical Linux partition - echo "hassos-kernel : start= ${kernel1_start} size= ${kernel1_size}, type=83" #Make a logical Linux partition - echo "hassos-system : start= ${system1_start}, size= ${system1_size}, type=83" #Make a logical Linux partition - echo "hassos-bootstate : start= ${bootstate_start}, size= ${bootstate_size}, type=83" #Make a logical Linux partition - echo "hassos-overlay : start= ${overlay_start}, size= ${overlay_size}, type=83" #Make a Linux partition - echo "hassos-data : start= ${data_start}, size= ${data_size}, type=83" #Make a Linux partition - ) > "${disk_layout}" - - # Update Labels - sfdisk "${hdd_img}" < "${disk_layout}" - - # Write Images - dd if="${boot_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${boot_offset}" - dd if="${kernel_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${kernel_offset}" - dd if="${rootfs_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${rootfs_offset}" - dd if="${overlay_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${overlay_offset}" - dd if="${data_img}" of="${hdd_img}" conv=notrunc,sparse bs=512 seek="${data_offset}" - - # Write SPL - if [ "${BOOT_SPL}" == "true" ]; then - _fix_disk_spl_mbr - fi -} - - -function _fix_disk_hybrid() { - local hdd_img="$(hassos_image_name img)" - - sgdisk -t 1:"E3C9E316-0B5C-4DB8-817D-F92DF00215AE" "${hdd_img}" - dd if="${BR2_EXTERNAL_HASSOS_PATH}/bootloader/mbr.img" of="${hdd_img}" conv=notrunc bs=512 count=1 -} - - -function _fix_disk_spl_gpt() { - local hdd_img="$(hassos_image_name img)" - local spl_img="$(path_spl_img)" - - 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 - - # Copy SPL, make sure to not overwrite GPT - dd if="${spl_img}" of="${hdd_img}" conv=notrunc bs=512 seek=64 skip=64 -} - - -function _fix_disk_spl_mbr() { - local hdd_img="$(hassos_image_name img)" - local spl_img="$(path_spl_img)" - - # backup MBR - dd if="${spl_img}" of="${hdd_img}" conv=notrunc bs=1 count=440 - dd if="${spl_img}" of="${hdd_img}" conv=notrunc bs=512 seek=1 skip=1 -} - - function convert_disk_image_virtual() { local hdd_ext="${1}" - local hdd_img="$(hassos_image_name img)" - local hdd_virt="$(hassos_image_name "${hdd_ext}")" + local hdd_img + hdd_img="$(hassos_image_name img)" + local hdd_virt + hdd_virt="$(hassos_image_name "${hdd_ext}")" local -a qemu_img_opts=() if [ "${hdd_ext}" == "vmdk" ]; then @@ -337,8 +67,10 @@ function convert_disk_image_virtual() { } function convert_disk_image_ova() { - local hdd_img="$(hassos_image_name img)" - local hdd_ova="$(hassos_image_name ova)" + local hdd_img + hdd_img="$(hassos_image_name img)" + local hdd_ova + hdd_ova="$(hassos_image_name ova)" local ova_data="${BINARIES_DIR}/ova" mkdir -p "${ova_data}" @@ -352,7 +84,8 @@ function convert_disk_image_ova() { function convert_disk_image_xz() { local hdd_ext=${1:-img} - local hdd_img="$(hassos_image_name "${hdd_ext}")" + local hdd_img + hdd_img="$(hassos_image_name "${hdd_ext}")" rm -f "${hdd_img}.xz" xz -3 -T0 "${hdd_img}" @@ -360,7 +93,8 @@ function convert_disk_image_xz() { function convert_disk_image_zip() { local hdd_ext=${1:-img} - local hdd_img="$(hassos_image_name "${hdd_ext}")" + local hdd_img + hdd_img="$(hassos_image_name "${hdd_ext}")" rm -f "${hdd_img}.zip" zip -j -m -q -r "${hdd_img}.zip" "${hdd_img}" diff --git a/buildroot-external/scripts/name.sh b/buildroot-external/scripts/name.sh index 0867c5212..b6a622d65 100755 --- a/buildroot-external/scripts/name.sh +++ b/buildroot-external/scripts/name.sh @@ -4,6 +4,10 @@ function hassos_image_name() { echo "${BINARIES_DIR}/${HASSOS_ID}_${BOARD_ID}-$(hassos_version).${1}" } +function hassos_image_basename() { + echo "${BINARIES_DIR}/${HASSOS_ID}_${BOARD_ID}-$(hassos_version)" +} + function hassos_rauc_compatible() { echo "${HASSOS_ID}-${BOARD_ID}" } @@ -16,10 +20,6 @@ function hassos_version() { fi } -function path_spl_img() { - echo "${BINARIES_DIR}/spl.img" -} - function path_kernel_img() { echo "${BINARIES_DIR}/kernel.img" } diff --git a/buildroot-external/scripts/ota.sh b/buildroot-external/scripts/ota.sh deleted file mode 100755 index 2a22254cf..000000000 --- a/buildroot-external/scripts/ota.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2155 - -function create_ota_update() { - local ota_file="$(hassos_image_name raucb)" - local ota_compatible="$(hassos_rauc_compatible)" - local ota_version="$(hassos_version)" - local rauc_folder="${BINARIES_DIR}/rauc" - local boot="${BINARIES_DIR}/boot.vfat" - local kernel="${BINARIES_DIR}/kernel.img" - local rootfs="${BINARIES_DIR}/rootfs.squashfs" - local spl="${BINARIES_DIR}/spl.img" - local key="/build/key.pem" - local cert="/build/cert.pem" - local keyring="${TARGET_DIR}/etc/rauc/keyring.pem" - - # Skip if no dev key is arround - if [ ! -f "${key}" ]; then - echo "Skip creating OTA update because of missing key ${key}" - return 0 - fi - - rm -rf "${rauc_folder}" "${ota_file}" - mkdir -p "${rauc_folder}" - - cp -f "${kernel}" "${rauc_folder}/kernel.img" - cp -f "${boot}" "${rauc_folder}/boot.vfat" - cp -f "${rootfs}" "${rauc_folder}/rootfs.img" - cp -f "${BR2_EXTERNAL_HASSOS_PATH}/ota/rauc-hook" "${rauc_folder}/hook" - - # SPL - if [ "${BOOT_SPL}" == "true" ]; then - cp -f "${spl}" "${rauc_folder}/spl.img" - fi - - export BOOTLOADER BOOT_SPL - export ota_compatible ota_version - ( - "${HOST_DIR}/bin/tempio" \ - -template "${BR2_EXTERNAL_HASSOS_PATH}/ota/manifest.raucm.gtpl" - ) > "${rauc_folder}/manifest.raucm" - - rauc bundle -d --cert="${cert}" --key="${key}" --keyring="${keyring}" "${rauc_folder}" "${ota_file}" -} diff --git a/buildroot-external/scripts/post-image.sh b/buildroot-external/scripts/post-image.sh index b1c174d0d..bad8480da 100755 --- a/buildroot-external/scripts/post-image.sh +++ b/buildroot-external/scripts/post-image.sh @@ -13,7 +13,6 @@ HOOK_FILE=${3} . "${SCRIPT_DIR}/rootfs-layer.sh" . "${SCRIPT_DIR}/name.sh" . "${SCRIPT_DIR}/rauc.sh" -. "${SCRIPT_DIR}/ota.sh" . "${HOOK_FILE}" # Cleanup @@ -25,7 +24,6 @@ hassos_pre_image # Disk & OTA create_disk_image -create_ota_update # Hook post image build stuff hassos_post_image diff --git a/buildroot-external/scripts/rauc.sh b/buildroot-external/scripts/rauc.sh index a5c23cbf5..a1e5fa594 100755 --- a/buildroot-external/scripts/rauc.sh +++ b/buildroot-external/scripts/rauc.sh @@ -20,7 +20,7 @@ function write_rauc_config() { ota_compatible="$(hassos_rauc_compatible)" export ota_compatible - export BOOTLOADER BOOT_SYS BOOT_SPL + export BOOTLOADER PARTITION_TABLE_TYPE BOOT_SPL ( "${HOST_DIR}/bin/tempio" \ @@ -50,13 +50,13 @@ function install_rauc_certs() { function install_bootloader_config() { if [ "${BOOTLOADER}" == "uboot" ]; then - # shellcheck disable=SC1117 + # shellcheck disable=SC1117 echo -e "/dev/disk/by-partlabel/hassos-bootstate\t0x0000\t${BOOT_ENV_SIZE}" > "${TARGET_DIR}/etc/fw_env.config" fi # Fix MBR - if [ "${BOOT_SYS}" == "mbr" ]; then + if [ "${PARTITION_TABLE_TYPE}" == "mbr" ]; then mkdir -p "${TARGET_DIR}/usr/lib/udev/rules.d" - cp -f "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/mbr-part.rules" "${TARGET_DIR}/usr/lib/udev/rules.d/" + cp -f "${BR2_EXTERNAL_HASSOS_PATH}/bootloader/mbr-part.rules" "${TARGET_DIR}/usr/lib/udev/rules.d/" fi }