From a592fc986610fac9dbaec96f514ee616c1a44d17 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 10 Feb 2020 14:52:03 +0100 Subject: [PATCH] Change handling for SPL based images (#578) * Change handling for SPL based images * Fix script * Fix path for rauc-hook --- Documentation/development.md | 7 ++++++- buildroot-external/board/asus/tinker/meta | 3 ++- .../board/hardkernel/odroid-c2/meta | 1 + .../board/hardkernel/odroid-n2/meta | 1 + .../board/hardkernel/odroid-xu4/meta | 1 + buildroot-external/board/intel/nuc/meta | 1 + buildroot-external/board/intel/ova/meta | 1 + buildroot-external/board/raspberrypi/rpi/meta | 1 + .../board/raspberrypi/rpi0-w/meta | 1 + buildroot-external/board/raspberrypi/rpi2/meta | 1 + .../board/raspberrypi/rpi3-64/meta | 1 + buildroot-external/board/raspberrypi/rpi3/meta | 1 + .../board/raspberrypi/rpi4-64/meta | 1 + buildroot-external/board/raspberrypi/rpi4/meta | 1 + buildroot-external/{misc => ota}/dev-ca.pem | 0 .../{misc => ota}/provisioning-ca.pem | 0 buildroot-external/{misc => ota}/rauc-hook | 0 buildroot-external/{misc => ota}/rel-ca.pem | 0 buildroot-external/scripts/hdd-image.sh | 17 +++++++++++------ buildroot-external/scripts/ota.sh | 4 ++-- buildroot-external/scripts/rauc.sh | 8 ++++---- 21 files changed, 37 insertions(+), 14 deletions(-) rename buildroot-external/{misc => ota}/dev-ca.pem (100%) rename buildroot-external/{misc => ota}/provisioning-ca.pem (100%) rename buildroot-external/{misc => ota}/rauc-hook (100%) rename buildroot-external/{misc => ota}/rel-ca.pem (100%) diff --git a/Documentation/development.md b/Documentation/development.md index 6a165eef0..e790d42f4 100644 --- a/Documentation/development.md +++ b/Documentation/development.md @@ -5,7 +5,6 @@ `BOOT_SYS`: - efi - hyprid -- spl - mbr HassOS is basicly used GPT. But for use GPT we need own the first 1024 of @@ -13,6 +12,12 @@ boot drive. Is that not possible, you can use MBR for your device, they work als Hyprid and SPL use both a hyprid MBR/GPT table but SPL move the GPT header 8MB for give space to write SPL and boot images before. +`BOOT_SPL`: +- true +- false + +Enable SPL update handling. + `BOOTLOADER`: - uboot - barebox diff --git a/buildroot-external/board/asus/tinker/meta b/buildroot-external/board/asus/tinker/meta index 55c3992b7..1dd6137c8 100644 --- a/buildroot-external/board/asus/tinker/meta +++ b/buildroot-external/board/asus/tinker/meta @@ -3,5 +3,6 @@ BOARD_NAME="Asus TinkerBoard" CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage -BOOT_SYS=spl +BOOT_SYS=hyprid +BOOT_SPL=true BOOT_ENV_SIZE=0x8000 diff --git a/buildroot-external/board/hardkernel/odroid-c2/meta b/buildroot-external/board/hardkernel/odroid-c2/meta index ccb76c12b..2648f6f2c 100644 --- a/buildroot-external/board/hardkernel/odroid-c2/meta +++ b/buildroot-external/board/hardkernel/odroid-c2/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=mbr +BOOT_SPL=true BOOT_ENV_SIZE=0x2000 diff --git a/buildroot-external/board/hardkernel/odroid-n2/meta b/buildroot-external/board/hardkernel/odroid-n2/meta index fcf5c544b..92b657865 100644 --- a/buildroot-external/board/hardkernel/odroid-n2/meta +++ b/buildroot-external/board/hardkernel/odroid-n2/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=mbr +BOOT_SPL=true BOOT_ENV_SIZE=0x2000 diff --git a/buildroot-external/board/hardkernel/odroid-xu4/meta b/buildroot-external/board/hardkernel/odroid-xu4/meta index 41110e03d..18471a3ac 100644 --- a/buildroot-external/board/hardkernel/odroid-xu4/meta +++ b/buildroot-external/board/hardkernel/odroid-xu4/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=mbr +BOOT_SPL=true BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/intel/nuc/meta b/buildroot-external/board/intel/nuc/meta index 25be9438b..a1aa8d2d4 100644 --- a/buildroot-external/board/intel/nuc/meta +++ b/buildroot-external/board/intel/nuc/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=barebox KERNEL_FILE=bzImage BOOT_SYS=efi +BOOT_SPL=false DISK_SIZE=6 diff --git a/buildroot-external/board/intel/ova/meta b/buildroot-external/board/intel/ova/meta index a05605489..68a2e1baf 100644 --- a/buildroot-external/board/intel/ova/meta +++ b/buildroot-external/board/intel/ova/meta @@ -4,4 +4,5 @@ CHASSIS=vm BOOTLOADER=barebox KERNEL_FILE=bzImage BOOT_SYS=efi +BOOT_SPL=false DISK_SIZE=6 diff --git a/buildroot-external/board/raspberrypi/rpi/meta b/buildroot-external/board/raspberrypi/rpi/meta index 4e0cc9368..334bfb441 100644 --- a/buildroot-external/board/raspberrypi/rpi/meta +++ b/buildroot-external/board/raspberrypi/rpi/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hyprid +BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi0-w/meta b/buildroot-external/board/raspberrypi/rpi0-w/meta index 056946a6d..bf63c857c 100644 --- a/buildroot-external/board/raspberrypi/rpi0-w/meta +++ b/buildroot-external/board/raspberrypi/rpi0-w/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hyprid +BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi2/meta b/buildroot-external/board/raspberrypi/rpi2/meta index d24ec65c4..a33993f0a 100644 --- a/buildroot-external/board/raspberrypi/rpi2/meta +++ b/buildroot-external/board/raspberrypi/rpi2/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hyprid +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 b6dd5c2e4..9f0a0890e 100644 --- a/buildroot-external/board/raspberrypi/rpi3-64/meta +++ b/buildroot-external/board/raspberrypi/rpi3-64/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=hyprid +BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi3/meta b/buildroot-external/board/raspberrypi/rpi3/meta index 0f8810ab5..b49955963 100644 --- a/buildroot-external/board/raspberrypi/rpi3/meta +++ b/buildroot-external/board/raspberrypi/rpi3/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hyprid +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 6de3cd3f6..6a5b92cf7 100644 --- a/buildroot-external/board/raspberrypi/rpi4-64/meta +++ b/buildroot-external/board/raspberrypi/rpi4-64/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=Image BOOT_SYS=hyprid +BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/board/raspberrypi/rpi4/meta b/buildroot-external/board/raspberrypi/rpi4/meta index de2f55976..bdd2dc3b3 100644 --- a/buildroot-external/board/raspberrypi/rpi4/meta +++ b/buildroot-external/board/raspberrypi/rpi4/meta @@ -4,4 +4,5 @@ CHASSIS=embedded BOOTLOADER=uboot KERNEL_FILE=zImage BOOT_SYS=hyprid +BOOT_SPL=false BOOT_ENV_SIZE=0x4000 diff --git a/buildroot-external/misc/dev-ca.pem b/buildroot-external/ota/dev-ca.pem similarity index 100% rename from buildroot-external/misc/dev-ca.pem rename to buildroot-external/ota/dev-ca.pem diff --git a/buildroot-external/misc/provisioning-ca.pem b/buildroot-external/ota/provisioning-ca.pem similarity index 100% rename from buildroot-external/misc/provisioning-ca.pem rename to buildroot-external/ota/provisioning-ca.pem diff --git a/buildroot-external/misc/rauc-hook b/buildroot-external/ota/rauc-hook similarity index 100% rename from buildroot-external/misc/rauc-hook rename to buildroot-external/ota/rauc-hook diff --git a/buildroot-external/misc/rel-ca.pem b/buildroot-external/ota/rel-ca.pem similarity index 100% rename from buildroot-external/misc/rel-ca.pem rename to buildroot-external/ota/rel-ca.pem diff --git a/buildroot-external/scripts/hdd-image.sh b/buildroot-external/scripts/hdd-image.sh index aebd4a70c..1b9887c0a 100755 --- a/buildroot-external/scripts/hdd-image.sh +++ b/buildroot-external/scripts/hdd-image.sh @@ -45,7 +45,7 @@ function size2sectors() { function get_boot_size() { - if [ "${BOOT_SYS}" == "spl" ]; then + if [ "${BOOT_SPL}" == "true" ]; then echo "${BOOT_SIZE[1]}" else echo "${BOOT_SIZE[0]}" @@ -138,7 +138,7 @@ function _create_disk_gpt() { # Partition layout # SPL - if [ "${BOOT_SYS}" == "spl" ]; then + if [ "${BOOT_SPL}" == "true" ]; then sgdisk -j 16384 "${hdd_img}" fi @@ -180,10 +180,13 @@ function _create_disk_gpt() { dd if="${overlay_img}" of="${hdd_img}" conv=notrunc bs=512 seek="${overlay_offset}" dd if="${data_img}" of="${hdd_img}" conv=notrunc bs=512 seek="${data_offset}" - # Fix boot + # Set Hyprid partition if [ "${BOOT_SYS}" == "hyprid" ]; then _fix_disk_hyprid - elif [ "${BOOT_SYS}" == "spl" ]; then + fi + + # Write SPL + if [ "${BOOT_SPL}" == "true" ]; then _fix_disk_spl_gpt fi } @@ -255,8 +258,10 @@ function _create_disk_mbr() { dd if="${overlay_img}" of="${hdd_img}" conv=notrunc bs=512 seek="${overlay_offset}" dd if="${data_img}" of="${hdd_img}" conv=notrunc bs=512 seek="${data_offset}" - # Wripte SPL - _fix_disk_spl_mbr + # Write SPL + if [ "${BOOT_SPL}" == "true" ]; then + _fix_disk_spl_mbr + fi } diff --git a/buildroot-external/scripts/ota.sh b/buildroot-external/scripts/ota.sh index 4f6c101c7..f53cfe632 100755 --- a/buildroot-external/scripts/ota.sh +++ b/buildroot-external/scripts/ota.sh @@ -23,7 +23,7 @@ function create_ota_update() { cp -f "${kernel}" "${rauc_folder}/kernel.ext4" cp -f "${boot}" "${rauc_folder}/boot.vfat" cp -f "${rootfs}" "${rauc_folder}/rootfs.img" - cp -f "${BR2_EXTERNAL_HASSOS_PATH}/misc/rauc-hook" "${rauc_folder}/hook" + cp -f "${BR2_EXTERNAL_HASSOS_PATH}/ota/rauc-hook" "${rauc_folder}/hook" ( echo "[update]" @@ -41,7 +41,7 @@ function create_ota_update() { ) > "${rauc_folder}/manifest.raucm" # SPL - if [ "${BOOT_SYS}" == "spl" ]; then + if [ "${BOOT_SPL}" == "true" ]; then cp -f "${spl}" "${rauc_folder}/spl.img" ( diff --git a/buildroot-external/scripts/rauc.sh b/buildroot-external/scripts/rauc.sh index b06748b65..197dbfede 100755 --- a/buildroot-external/scripts/rauc.sh +++ b/buildroot-external/scripts/rauc.sh @@ -27,7 +27,7 @@ function _write_rauc_boot() { ) >> "${TARGET_DIR}/etc/rauc/system.conf" # SPL - if ! [[ "${BOOT_SYS}" =~ (spl|mbr) ]]; then + if ! [ "${BOOT_SPL}" == "true" ]; then return 0 fi @@ -69,9 +69,9 @@ function write_rauc_config() { function install_rauc_certs() { if [ "${DEPLOYMENT}" == "production" ]; then - cp "${BR2_EXTERNAL_HASSOS_PATH}/misc/rel-ca.pem" "${TARGET_DIR}/etc/rauc/keyring.pem" + cp "${BR2_EXTERNAL_HASSOS_PATH}/ota/rel-ca.pem" "${TARGET_DIR}/etc/rauc/keyring.pem" else - cp "${BR2_EXTERNAL_HASSOS_PATH}/misc/dev-ca.pem" "${TARGET_DIR}/etc/rauc/keyring.pem" + cp "${BR2_EXTERNAL_HASSOS_PATH}/ota/dev-ca.pem" "${TARGET_DIR}/etc/rauc/keyring.pem" fi } @@ -87,6 +87,6 @@ function install_bootloader_config() { # Fix MBR if [ "${BOOT_SYS}" == "mbr" ]; then mkdir -p "${TARGET_DIR}/usr/lib/udev/rules.d" - cp -f "${BR2_EXTERNAL_HASSOS_PATH}/misc/mbr-part.rules" "${TARGET_DIR}/usr/lib/udev/rules.d/" + cp -f "${BR2_EXTERNAL_HASSOS_PATH}/misc/mbr-part.rules" "${TARGET_DIR}/usr/lib/udev/rules.d/" fi }