From c3de76272c3db540d1c4e45c3bc908673d81f07e Mon Sep 17 00:00:00 2001 From: Tom Hochstein Date: Wed, 11 Sep 2024 09:46:22 -0700 Subject: [PATCH] boot: Fix UUU tagging, extend to fslc Using the UUU-tagged bootloader image directly with UUU can cause UUU to hang. The bootloader image is split on a certain transmit size, and the hang occurs if the tag does not fit with the final bytes of the bootloader image and must be split into a new transmit package. The UUU tag is needed by UUU only in the SD Card image file itself so that UUU can find the end of the boot partition. Rework the design so the default bootloader and the default imx-boot binaries are not tagged. Also, extend the UUU tagging to fslc so it can gain the same benefit. Fixes: https://github.com/Freescale/meta-freescale/pull/1762 Fixes: https://github.com/nxp-imx/mfgtools/issues/416 Co-authored-by: Otavio Salvador Signed-off-by: Tom Hochstein --- classes/imx-boot-container.bbclass | 2 +- classes/uuu_bootloader_tag.bbclass | 24 +++++++++++++++-------- conf/machine/include/imx-base.inc | 4 ++-- recipes-bsp/imx-mkimage/imx-boot_1.0.bb | 4 +--- recipes-bsp/u-boot/u-boot-fslc_2024.07.bb | 5 +++-- recipes-bsp/u-boot/u-boot-imx_2024.04.bb | 13 ++++-------- wic/imx-imx-boot-bootpart.wks.in | 2 +- wic/imx-imx-boot.wks.in | 2 +- wic/imx-uboot-bootpart.wks.in | 2 +- wic/imx-uboot-spl-bootpart.wks.in | 2 +- wic/imx-uboot-spl.wks.in | 2 +- wic/imx-uboot.wks | 2 +- 12 files changed, 33 insertions(+), 31 deletions(-) diff --git a/classes/imx-boot-container.bbclass b/classes/imx-boot-container.bbclass index 8ba32cac73..b0d3dc1fb9 100644 --- a/classes/imx-boot-container.bbclass +++ b/classes/imx-boot-container.bbclass @@ -96,7 +96,7 @@ do_deploy:append() { if [ ! -f "${DEPLOYDIR}/imx-boot" ]; then ln -sf flash.bin-${MACHINE}-${type} flash.bin ln -sf flash.bin-${MACHINE}-${type} imx-boot - + ln -sf flash.bin.tagged imx-boot.tagged else bbwarn "Use custom wks.in for $UBOOT_CONFIG = $type" fi diff --git a/classes/uuu_bootloader_tag.bbclass b/classes/uuu_bootloader_tag.bbclass index 87745660c2..b41d22a92f 100644 --- a/classes/uuu_bootloader_tag.bbclass +++ b/classes/uuu_bootloader_tag.bbclass @@ -1,12 +1,20 @@ -# Append a tag to the bootloader image used in the SD card image. The tag -# contains the size of the bootloader image so UUU can easily find the end of -# the bootloader in the SD card image. +# Create a tagged boot partition file for the SD card image file. The tag +# contains the size of the boot partition image so UUU can easily find +# the end of it in the SD card image file. +# +# IMPORTANT: The tagged boot partition file should never be used directly with +# UUU, as it can cause UUU to hang. + +UUU_BOOTLOADER = "${UBOOT_BINARY}" +UUU_BOOTLOADER:mx8-generic-bsp = "${@d.getVar('UBOOT_PROVIDES_BOOT_CONTAINER') == '0' and 'imx-boot' or 'flash.bin'}" +UUU_BOOTLOADER:mx9-generic-bsp = "${@d.getVar('UBOOT_PROVIDES_BOOT_CONTAINER') == '0' and 'imx-boot' or 'flash.bin'}" + do_deploy:append() { if [ "${UUU_BOOTLOADER}" != "" ]; then - cp ${DEPLOYDIR}/${UUU_BOOTLOADER} ${DEPLOYDIR}/${UUU_BOOTLOADER_TAGGED} - cp ${DEPLOYDIR}/${UUU_BOOTLOADER} ${DEPLOYDIR}/${UUU_BOOTLOADER_UNTAGGED} - ln -sf ${UUU_BOOTLOADER_TAGGED} ${DEPLOYDIR}/${UUU_BOOTLOADER} - stat -L -cUUUBURNXXOEUZX7+A-XY5601QQWWZ%sEND ${DEPLOYDIR}/${UUU_BOOTLOADER_TAGGED} \ - >> ${DEPLOYDIR}/${UUU_BOOTLOADER_TAGGED} + cp ${DEPLOYDIR}/${UUU_BOOTLOADER} \ + ${DEPLOYDIR}/${UUU_BOOTLOADER}.tagged + stat -L -cUUUBURNXXOEUZX7+A-XY5601QQWWZ%sEND \ + ${DEPLOYDIR}/${UUU_BOOTLOADER}.tagged \ + >> ${DEPLOYDIR}/${UUU_BOOTLOADER}.tagged fi } diff --git a/conf/machine/include/imx-base.inc b/conf/machine/include/imx-base.inc index 43d62756bf..b127cee45a 100644 --- a/conf/machine/include/imx-base.inc +++ b/conf/machine/include/imx-base.inc @@ -653,9 +653,9 @@ WKS_FILE_DEPENDS:append:imx-generic-bsp:mx9-generic-bsp = " \ ${@oe.utils.ifelse(d.getVar('UBOOT_PROVIDES_BOOT_CONTAINER') == '0', 'imx-boot', '')} \ " -SOC_DEFAULT_WKS_FILE ?= "imx-uboot-bootpart.wks.in" -SOC_DEFAULT_WKS_FILE:mx8-generic-bsp ?= "imx-imx-boot-bootpart.wks.in" +SOC_DEFAULT_WKS_FILE ?= "imx-uboot-bootpart.wks.in" SOC_DEFAULT_WKS_FILE:mxs-generic-bsp ?= "imx-uboot-mxs-bootpart.wks.in" +SOC_DEFAULT_WKS_FILE:mx8-generic-bsp ?= "imx-imx-boot-bootpart.wks.in" SOC_DEFAULT_WKS_FILE:mx9-generic-bsp ?= "imx-imx-boot-bootpart.wks.in" WKS_FILE ?= "${SOC_DEFAULT_WKS_FILE}" diff --git a/recipes-bsp/imx-mkimage/imx-boot_1.0.bb b/recipes-bsp/imx-mkimage/imx-boot_1.0.bb index 06832fc463..fb24991962 100644 --- a/recipes-bsp/imx-mkimage/imx-boot_1.0.bb +++ b/recipes-bsp/imx-mkimage/imx-boot_1.0.bb @@ -22,9 +22,7 @@ DEPENDS:append:mx93-generic-bsp = " u-boot-mkimage-native dtc-native" inherit deploy uuu_bootloader_tag -UUU_BOOTLOADER = "imx-boot" -UUU_BOOTLOADER_TAGGED = "imx-boot-tagged" -UUU_BOOTLOADER_UNTAGGED = "imx-boot-untagged" +UUU_BOOTLOADER = "imx-boot" # Add CFLAGS with native INCDIR & LIBDIR for imx-mkimage build CFLAGS = "-O2 -Wall -std=c99 -I ${STAGING_INCDIR_NATIVE} -L ${STAGING_LIBDIR_NATIVE}" diff --git a/recipes-bsp/u-boot/u-boot-fslc_2024.07.bb b/recipes-bsp/u-boot/u-boot-fslc_2024.07.bb index eba8876aa9..4dc6982191 100644 --- a/recipes-bsp/u-boot/u-boot-fslc_2024.07.bb +++ b/recipes-bsp/u-boot/u-boot-fslc_2024.07.bb @@ -6,8 +6,6 @@ order to provide support for some backported features and fixes, or because it \ was submitted for revision and it takes some time to become part of a stable \ version, or because it is not applicable for upstreaming." -inherit ${@oe.utils.ifelse(d.getVar('UBOOT_PROVIDES_BOOT_CONTAINER') == '1', 'imx-boot-container', '')} - DEPENDS += "bc-native dtc-native python3-setuptools-native gnutls-native" PROVIDES += "u-boot u-boot-mfgtool" @@ -21,5 +19,8 @@ EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CPPFLAGS}" \ HOSTLDFLAGS="${BUILD_LDFLAGS}" \ HOSTSTRIP=true' +inherit ${@oe.utils.ifelse(d.getVar('UBOOT_PROVIDES_BOOT_CONTAINER') == '1', 'imx-boot-container', '')} +inherit uuu_bootloader_tag + PACKAGE_ARCH = "${MACHINE_ARCH}" COMPATIBLE_MACHINE = "(imx-generic-bsp)" diff --git a/recipes-bsp/u-boot/u-boot-imx_2024.04.bb b/recipes-bsp/u-boot/u-boot-imx_2024.04.bb index 3d03c83495..aff04279c4 100644 --- a/recipes-bsp/u-boot/u-boot-imx_2024.04.bb +++ b/recipes-bsp/u-boot/u-boot-imx_2024.04.bb @@ -9,15 +9,10 @@ PROVIDES += "u-boot u-boot-mfgtool" inherit uuu_bootloader_tag -UUU_BOOTLOADER = "" -UUU_BOOTLOADER:mx6-generic-bsp = "${UBOOT_BINARY}" -UUU_BOOTLOADER:mx7-generic-bsp = "${UBOOT_BINARY}" -UUU_BOOTLOADER_TAGGED = "" -UUU_BOOTLOADER_TAGGED:mx6-generic-bsp = "u-boot-tagged.${UBOOT_SUFFIX}" -UUU_BOOTLOADER_TAGGED:mx7-generic-bsp = "u-boot-tagged.${UBOOT_SUFFIX}" -UUU_BOOTLOADER_UNTAGGED = "" -UUU_BOOTLOADER_UNTAGGED:mx6-generic-bsp = "u-boot-untagged.${UBOOT_SUFFIX}" -UUU_BOOTLOADER_UNTAGGED:mx7-generic-bsp = "u-boot-untagged.${UBOOT_SUFFIX}" +# The UUU tag goes on the boot partition 8+, the boot partition image is imx-boot, and UUU-tagging +# is disabled. +UUU_BOOTLOADER:mx8-generic-bsp = "" +UUU_BOOTLOADER:mx9-generic-bsp = "" do_deploy:append:mx8m-generic-bsp() { # Deploy u-boot-nodtb.bin and fsl-imx8m*-XX.dtb for mkimage to generate boot binary diff --git a/wic/imx-imx-boot-bootpart.wks.in b/wic/imx-imx-boot-bootpart.wks.in index b50364d1bc..20af7a6ad9 100644 --- a/wic/imx-imx-boot-bootpart.wks.in +++ b/wic/imx-imx-boot-bootpart.wks.in @@ -13,7 +13,7 @@ # 0 | 8MiB 72MiB 72MiB + rootfs + IMAGE_EXTRA_SPACE (default 10MiB) # ${IMX_BOOT_SEEK} 32 or 33kiB, see reference manual # -part u-boot --source rawcopy --sourceparams="file=imx-boot" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} +part u-boot --source rawcopy --sourceparams="file=imx-boot.tagged" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 8192 --size 64 part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 8192 diff --git a/wic/imx-imx-boot.wks.in b/wic/imx-imx-boot.wks.in index 8e78b5e357..fdb4118030 100644 --- a/wic/imx-imx-boot.wks.in +++ b/wic/imx-imx-boot.wks.in @@ -13,7 +13,7 @@ # 0 | 8MiB 8MiB + rootfs + IMAGE_EXTRA_SPACE (default 10MiB) # ${IMX_BOOT_SEEK} 32 or 33kiB, see reference manual # -part u-boot --source rawcopy --sourceparams="file=imx-boot" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} +part u-boot --source rawcopy --sourceparams="file=imx-boot.tagged" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 8192 bootloader --ptable msdos diff --git a/wic/imx-uboot-bootpart.wks.in b/wic/imx-uboot-bootpart.wks.in index 8fe019c010..4959d02dfe 100644 --- a/wic/imx-uboot-bootpart.wks.in +++ b/wic/imx-uboot-bootpart.wks.in @@ -12,7 +12,7 @@ # | | | | # 0 1kiB 4MiB 16MiB + rootfs + IMAGE_EXTRA_SPACE (default 10MiB) # -part u-boot --source rawcopy --sourceparams="file=${UBOOT_BINARY}" --ondisk mmcblk --no-table --align 1 +part u-boot --source rawcopy --sourceparams="file=${UBOOT_BINARY}.tagged" --ondisk mmcblk --no-table --align 1 part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 4096 --size 16 part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 4096 diff --git a/wic/imx-uboot-spl-bootpart.wks.in b/wic/imx-uboot-spl-bootpart.wks.in index 8062c51e69..be0f0fe03a 100644 --- a/wic/imx-uboot-spl-bootpart.wks.in +++ b/wic/imx-uboot-spl-bootpart.wks.in @@ -13,7 +13,7 @@ # 0 1kiB 69kiB 4MiB 16MiB + rootfs + IMAGE_EXTRA_SPACE (default 10MiB) # part SPL --source rawcopy --sourceparams="file=SPL" --ondisk mmcblk --no-table --align 1 -part u-boot --source rawcopy --sourceparams="file=${UBOOT_BINARY}" --ondisk mmcblk --no-table --align 69 +part u-boot --source rawcopy --sourceparams="file=${UBOOT_BINARY}.tagged" --ondisk mmcblk --no-table --align 69 part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 4096 --size 16 part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 4096 diff --git a/wic/imx-uboot-spl.wks.in b/wic/imx-uboot-spl.wks.in index db2f89ddba..c6c9aaa2c5 100644 --- a/wic/imx-uboot-spl.wks.in +++ b/wic/imx-uboot-spl.wks.in @@ -13,7 +13,7 @@ # 0 1kiB 69kiB 4MiB + rootfs + IMAGE_EXTRA_SPACE (default 10MiB) # part SPL --source rawcopy --sourceparams="file=SPL" --ondisk mmcblk --no-table --align 1 -part u-boot --source rawcopy --sourceparams="file=${UBOOT_BINARY}" --ondisk mmcblk --no-table --align 69 +part u-boot --source rawcopy --sourceparams="file=${UBOOT_BINARY}.tagged" --ondisk mmcblk --no-table --align 69 part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 4096 bootloader --ptable msdos diff --git a/wic/imx-uboot.wks b/wic/imx-uboot.wks index 60870c34e1..cde24798d0 100644 --- a/wic/imx-uboot.wks +++ b/wic/imx-uboot.wks @@ -12,7 +12,7 @@ # | | | | # 0 1kiB 4MiB + rootfs + IMAGE_EXTRA_SPACE (default 10MiB) # -part u-boot --source rawcopy --sourceparams="file=u-boot.imx" --ondisk mmcblk --no-table --align 1 +part u-boot --source rawcopy --sourceparams="file=${UBOOT_BINARY}.tagged" --ondisk mmcblk --no-table --align 1 part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 4096 bootloader --ptable msdos