From 4c26b9a9676e897eb8b716844e30b1a46dad96cf Mon Sep 17 00:00:00 2001 From: Tomaz Zaman Date: Mon, 10 Aug 2026 21:53:24 +0200 Subject: [PATCH 24/77] mono: GPT within 4K; cmm gets VLAN_FILTER The firmware update tool rewrites the entire 4K-32M eMMC window, so the earlier entry-array-at-5M layout would be destroyed by it. The whole GPT now fits in the first 4K: protective MBR, header, 8-entry array (a header-declared count the kernel and U-Boot honor; verified by kernel loop-mount at device size). Partition extents unchanged. ptgen replaced by an inline writer since it cannot emit small arrays. Flashing simplifies to: dd count=8, then dd skip=32 seek=32. cmm: build with -DVLAN_FILTER to match cdx and dpa_app - same flag-mismatch class as the dpa_app LS1043 sizeof bug. Co-Authored-By: Claude Fable 5 --- package/ask/cmm/Makefile | 2 +- .../layerscape/image/gen_mono_emmc_img.sh | 105 ++++++++++++++---- 2 files changed, 86 insertions(+), 21 deletions(-) diff --git a/package/ask/cmm/Makefile b/package/ask/cmm/Makefile index dcdc2b13cc..550d9a589b 100644 --- a/package/ask/cmm/Makefile +++ b/package/ask/cmm/Makefile @@ -44,7 +44,7 @@ define Build/Compile +CFLAGS="$(TARGET_CFLAGS)" \ $(MAKE) -C $(PKG_BUILD_DIR)/fci/lib \ CC="$(TARGET_CC)" AR="$(TARGET_AR)" - +CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \ + +CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -DVLAN_FILTER" \ LDFLAGS="$(TARGET_LDFLAGS)" \ $(MAKE) -C $(PKG_BUILD_DIR)/cmm \ CC="$(TARGET_CC)" \ diff --git a/target/linux/layerscape/image/gen_mono_emmc_img.sh b/target/linux/layerscape/image/gen_mono_emmc_img.sh index 215cba8230..65c2b4a587 100755 --- a/target/linux/layerscape/image/gen_mono_emmc_img.sh +++ b/target/linux/layerscape/image/gen_mono_emmc_img.sh @@ -2,12 +2,16 @@ # SPDX-License-Identifier: GPL-2.0-only # # Mono Gateway eMMC image: -# - 8-entry-equivalent GPT: header at LBA0/1, entry array relocated to -# 5 MiB (-e 5120) so the LS1046A boot firmware region stays clear: -# PBL@4K, FIP@1M, U-Boot env@3M, FMan ucode@4M (raw, dd'd by the -# factory flow / write_uboot_platform - NOT part of this image) +# - complete GPT within the first 4 KiB: protective MBR (LBA0), +# header (LBA1), 8-entry partition array (LBA2-3). The firmware +# update tool owns EVERYTHING from 4 KiB to 32 MiB and rewrites it +# wholesale, so no GPT structure may live there. 8 entries instead +# of the customary 128 is a header-declared value the kernel and +# U-Boot honor (ptgen cannot emit small arrays, hence the inline +# writer below). # - partition 1 (boot, ext4: /boot/extlinux + Image.gz + dtb) at 32 MiB -# - partition 2 (rootfs) right after +# - partition 2 (rootfs) right after, partition sized to the full +# eMMC; the filesystem inside is smaller and grows on first boot # set -ex [ $# -eq 5 ] || { @@ -21,11 +25,6 @@ ROOTFS="$3" BOOTFSSIZE="$4" ROOTFSPARTSIZE="$5" -# The rootfs PARTITION is created at its final (full-eMMC) size; the -# filesystem image inside is smaller and resize2fs grows it on first -# boot. This avoids any on-device GPT rewrite, which standard tools -# would relocate over the raw boot-firmware region. -# # make_ext4fs output cannot be grown online (its reserved-GDT layout is # rejected by the kernel resizer: "reserved block not at offset"). # e2fsck plus ONE offline grow on the host rebuilds the resize metadata; @@ -36,19 +35,85 @@ truncate -s 384M "$OUTPUT.rootfs" resize2fs "$OUTPUT.rootfs" ROOTFS="$OUTPUT.rootfs" -set $(ptgen -o $OUTPUT -v -g -e 5120 \ - -N boot -p ${BOOTFSSIZE}M@32M \ - -N rootfs -p ${ROOTFSPARTSIZE}M) +rm -f "$OUTPUT" +python3 - "$OUTPUT" "$BOOTFSSIZE" "$ROOTFSPARTSIZE" <<'PYEOF' +import struct, sys, uuid, zlib + +out, bootmb, rootmb = sys.argv[1], int(sys.argv[2]), int(sys.argv[3]) +SEC = 512 +ENTRIES = 8 +ENTRY_SZ = 128 +# DK eMMC: 31080448 KiB. Only informational fields derive from this; +# partitions themselves fit any device at least this large. +DISK_LAST = 31080448 * 2 - 1 + +def guid(s): + return uuid.UUID(s).bytes_le + +LINUX_FS = guid("0FC63DAF-8483-4772-8E79-3D69D8477DE4") +# Fixed GUIDs for reproducible images +DISK_GUID = guid("6D6F6E6F-1046-4000-8000-4D6F6E6F0000") +PART_GUIDS = [guid("6D6F6E6F-1046-4000-8000-4D6F6E6F0001"), + guid("6D6F6E6F-1046-4000-8000-4D6F6E6F0002")] + +boot_first = 32 * 2048 # 32 MiB, in sectors +boot_last = boot_first + bootmb * 2048 - 1 +root_first = boot_last + 1 +root_last = root_first + rootmb * 2048 - 1 + +def entry(type_guid, part_guid, first, last, name): + e = type_guid + part_guid + struct.pack("= end of the entry array (LBA 4). Use the 32 MiB +# boundary so the table itself documents the firmware reserve. +def header2(entries_crc): + h = bytearray(header(entries_crc)) + struct.pack_into("