From 322f90d0a470482290120becaa715db5287576a9 Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Tue, 7 Apr 2026 17:59:37 +0200 Subject: [PATCH] meta-digi-arm: add u-boot environment partition to WIC images Switch ccimx8/ccimx9 wic images to a layout with a u-boot-env partition. Use a fixed PARTUUID for SD rootfs. https://onedigi.atlassian.net/browse/DUB-1119 Signed-off-by: Javier Viguera --- .../conf/machine/include/imx-digi-base.inc | 4 ++-- .../u-boot/u-boot-dey/ccimx6qpsbc/boot.txt | 6 +++--- .../u-boot/u-boot-dey/ccimx6sbc/boot.txt | 6 +++--- .../u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt | 9 ++++----- .../u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt | 8 ++++---- .../u-boot-dey/ccimx8x-sbc-express/boot.txt | 8 ++++---- .../u-boot-dey/ccimx8x-sbc-pro/boot.txt | 8 ++++---- .../u-boot/u-boot-dey/ccimx9/boot.txt | 10 +++++----- .../u-boot/u-boot-dey/ccimx95/boot.txt | 10 +++++----- .../imx-imx-boot-bootpart-uboot-env.wks.in | 19 +++++++++++++++++++ 10 files changed, 53 insertions(+), 35 deletions(-) create mode 100644 meta-digi-arm/wic/imx-imx-boot-bootpart-uboot-env.wks.in diff --git a/meta-digi-arm/conf/machine/include/imx-digi-base.inc b/meta-digi-arm/conf/machine/include/imx-digi-base.inc index af2830ce1..2eee65fb2 100644 --- a/meta-digi-arm/conf/machine/include/imx-digi-base.inc +++ b/meta-digi-arm/conf/machine/include/imx-digi-base.inc @@ -390,8 +390,8 @@ WKS_FILE_DEPENDS:append:mx8-nxp-bsp = " imx-boot" WKS_FILE_DEPENDS:append:mx9-nxp-bsp = " 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:mx9-generic-bsp ?= "imx-imx-boot-bootpart.wks.in" +SOC_DEFAULT_WKS_FILE:mx8-generic-bsp ?= "imx-imx-boot-bootpart-uboot-env.wks.in" +SOC_DEFAULT_WKS_FILE:mx9-generic-bsp ?= "imx-imx-boot-bootpart-uboot-env.wks.in" WKS_FILE ?= "${SOC_DEFAULT_WKS_FILE}" diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt index cef688b71..692f34a39 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt @@ -12,8 +12,8 @@ if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then bootattempt="(boot attempt ${bootcount}/${bootlimit})" fi -# Dual boot update verification -if test "${dualboot}" = "yes"; then +# Dual boot update verification (only on EMMC) +if test "${mmcbootdev}" = "${emmc_dev}" && test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system in ${active_system} ${bootattempt}" else @@ -52,7 +52,7 @@ else setenv boot_initrd true setenv initrd_file uramdisk-recovery.img else - # We are booting from the SD card. + # SD boot (MBR partition table) setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi if test "${upgrade_available}" = "1"; then diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt index 4248d9327..bf7bb57f6 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt @@ -12,8 +12,8 @@ if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then bootattempt="(boot attempt ${bootcount}/${bootlimit})" fi -# Dual boot update verification -if test "${dualboot}" = "yes"; then +# Dual boot update verification (only on EMMC) +if test "${mmcbootdev}" = "${emmc_dev}" && test "${dualboot}" = "yes"; then if test "${upgrade_available}" = "1"; then echo "Update detected; Booting new system in ${active_system} ${bootattempt}" else @@ -52,7 +52,7 @@ else setenv boot_initrd true setenv initrd_file uramdisk-recovery.img else - # We are booting from the SD card. + # SD boot (MBR partition table) setenv mmcroot /dev/mmcblk${mmcbootdev}p2 fi if test "${upgrade_available}" = "1"; then diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt index 06bcbf94e..6f3869eb3 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mm-dvk/boot.txt @@ -11,8 +11,8 @@ if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then bootattempt="(boot attempt ${bootcount}/${bootlimit})" fi -# Dual boot verification -if test "${dualboot}" = "yes"; then +# Dual boot (only on EMMC) +if test "${mmcbootdev}" = "${emmc_dev}" && test "${dualboot}" = "yes"; then if test "${active_system}" = "linux_a"; then echo "Booting from system A ${bootattempt}" part number mmc ${mmcbootdev} linux_a tmp_mmcpart @@ -48,12 +48,11 @@ else setenv boot_initrd true setenv initrd_file uramdisk-recovery.img else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # SD boot (use SD specific rootfs partition uuid) + setenv mmcroot PARTUUID=b74d3700-a3c2-4806-8cb6-4e0fed784c7f fi fi - # Back up environment variables setenv ORIG_overlays ${overlays} setenv ORIG_extra_bootargs ${extra_bootargs} diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index a4ec3f14f..dc0d7b966 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -11,8 +11,8 @@ if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then bootattempt="(boot attempt ${bootcount}/${bootlimit})" fi -# Dual boot verification -if test "${dualboot}" = "yes"; then +# Dual boot (only on EMMC) +if test "${mmcbootdev}" = "${emmc_dev}" && test "${dualboot}" = "yes"; then if test "${active_system}" = "linux_a"; then echo "Booting from system A ${bootattempt}" part number mmc ${mmcbootdev} linux_a tmp_mmcpart @@ -48,8 +48,8 @@ else setenv boot_initrd true setenv initrd_file uramdisk-recovery.img else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # SD boot (use SD specific rootfs partition uuid) + setenv mmcroot PARTUUID=b74d3700-a3c2-4806-8cb6-4e0fed784c7f fi fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt index 6ee083228..fa1720903 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-express/boot.txt @@ -11,8 +11,8 @@ if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then bootattempt="(boot attempt ${bootcount}/${bootlimit})" fi -# Dual boot verification -if test "${dualboot}" = "yes"; then +# Dual boot (only on EMMC) +if test "${mmcbootdev}" = "${emmc_dev}" && test "${dualboot}" = "yes"; then if test "${active_system}" = "linux_a"; then echo "Booting from system A ${bootattempt}" part number mmc ${mmcbootdev} linux_a tmp_mmcpart @@ -48,8 +48,8 @@ else setenv boot_initrd true setenv initrd_file uramdisk-recovery.img else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # SD boot (use SD specific rootfs partition uuid) + setenv mmcroot PARTUUID=b74d3700-a3c2-4806-8cb6-4e0fed784c7f fi fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt index fcfd3c7eb..ce3e2553f 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x-sbc-pro/boot.txt @@ -11,8 +11,8 @@ if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then bootattempt="(boot attempt ${bootcount}/${bootlimit})" fi -# Dual boot verification -if test "${dualboot}" = "yes"; then +# Dual boot (only on EMMC) +if test "${mmcbootdev}" = "${emmc_dev}" && test "${dualboot}" = "yes"; then if test "${active_system}" = "linux_a"; then echo "Booting from system A ${bootattempt}" part number mmc ${mmcbootdev} linux_a tmp_mmcpart @@ -48,8 +48,8 @@ else setenv boot_initrd true setenv initrd_file uramdisk-recovery.img else - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 + # SD boot (use SD specific rootfs partition uuid) + setenv mmcroot PARTUUID=b74d3700-a3c2-4806-8cb6-4e0fed784c7f fi fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx9/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx9/boot.txt index 8040238d9..b15cbe7f4 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx9/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx9/boot.txt @@ -11,11 +11,8 @@ if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then bootattempt="(boot attempt ${bootcount}/${bootlimit})" fi -# Pre step: check if we boot from uSD. -if test "${mmcbootdev}" = "1"; then - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 -elif test "${dualboot}" = "yes"; then +# Dual boot (only on EMMC) +if test "${mmcbootdev}" = "${emmc_dev}" && test "${dualboot}" = "yes"; then if test "${active_system}" = "linux_a"; then echo "Booting from system A ${bootattempt}" part number mmc ${mmcbootdev} linux_a tmp_mmcpart @@ -50,6 +47,9 @@ else # We are booting from the eMMC using 'recovery'. setenv boot_initrd true setenv initrd_file uramdisk-recovery.img + else + # SD boot (use SD specific rootfs partition uuid) + setenv mmcroot PARTUUID=b74d3700-a3c2-4806-8cb6-4e0fed784c7f fi fi diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx95/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx95/boot.txt index 1d09cc0ae..500a7849a 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx95/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx95/boot.txt @@ -11,11 +11,8 @@ if test "${bootlimit}" -gt 0 && test "${bootcount}" -gt 0; then bootattempt="(boot attempt ${bootcount}/${bootlimit})" fi -# Pre step: check if we boot from uSD. -if test "${mmcbootdev}" = "1"; then - # We are booting from the SD card. - setenv mmcroot /dev/mmcblk${mmcbootdev}p2 -elif test "${dualboot}" = "yes"; then +# Dual boot (only on EMMC) +if test "${mmcbootdev}" = "${emmc_dev}" && test "${dualboot}" = "yes"; then if test "${active_system}" = "linux_a"; then echo "Booting from system A ${bootattempt}" part number mmc ${mmcbootdev} linux_a tmp_mmcpart @@ -50,6 +47,9 @@ else # We are booting from the eMMC using 'recovery'. setenv boot_initrd true setenv initrd_file uramdisk-recovery.img + else + # SD boot (use SD specific rootfs partition uuid) + setenv mmcroot PARTUUID=b74d3700-a3c2-4806-8cb6-4e0fed784c7f fi fi diff --git a/meta-digi-arm/wic/imx-imx-boot-bootpart-uboot-env.wks.in b/meta-digi-arm/wic/imx-imx-boot-bootpart-uboot-env.wks.in new file mode 100644 index 000000000..466fd5137 --- /dev/null +++ b/meta-digi-arm/wic/imx-imx-boot-bootpart-uboot-env.wks.in @@ -0,0 +1,19 @@ +# short-description: Create a bootable SD card image +# long-description: Create a bootable SD card image with bootloader, +# environment partition, and boot and rootfs partitions. +# +# The disk layout used is: +# - ---------- ------------ -------------- -------------- +# | | imx-boot | u-boot-env | boot | rootfs | +# - ---------- ------------ -------------- -------------- +# ^ ^ ^ ^ ^ +# | | | | | +# 0 | 8MiB - 32kiB 8MiB 264MiB +# ${IMX_BOOT_SEEK} 32 or 33kiB, see reference manual +# +part imxboot --source rawcopy --sourceparams="file=imx-boot.tagged" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} +part u-boot-env --source empty --ondisk mmcblk --size 32k --offset 8160k --part-name u-boot-env --part-type 3DE21764-95BD-54BD-A5C3-4ABE786F38A8 +part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 8192 --fixed-size 256 +part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 8192 --uuid b74d3700-a3c2-4806-8cb6-4e0fed784c7f + +bootloader --ptable gpt