From dac745f4f0b191d538cfb60514f0caa7119bd1ca Mon Sep 17 00:00:00 2001 From: dianjixz <18637716021@163.com> Date: Thu, 25 Jun 2026 16:42:08 +0800 Subject: [PATCH 1/4] fix: clean cardputerzero cmdline --- stage2/05-cardputerzero/02-run.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stage2/05-cardputerzero/02-run.sh b/stage2/05-cardputerzero/02-run.sh index 87d2311b28..37aaeee139 100755 --- a/stage2/05-cardputerzero/02-run.sh +++ b/stage2/05-cardputerzero/02-run.sh @@ -111,6 +111,15 @@ sed -i '1i kernel=u-boot.bin' ${ROOTFS_DIR}/boot/firmware/config.txt sed -i 's/$/ quiet splash plymouth.ignore-serial-consoles fbcon=map:off cfg80211.ieee80211_regdom=AE/' \ "${ROOTFS_DIR}/boot/firmware/cmdline.txt" +# Remove serial console from CardputerZero images only. +sed -i -E \ + -e 's/(^|[[:space:]])console=serial0,115200([[:space:]]|$)/ /g' \ + -e 's/(^|[[:space:]])splash([[:space:]]|$)/ /g' \ + -e 's/(^|[[:space:]])plymouth\.ignore-serial-consoles([[:space:]]|$)/ /g' \ + -e 's/[[:space:]]+/ /g' \ + -e 's/^ //; s/ $//' \ + "${ROOTFS_DIR}/boot/firmware/cmdline.txt" + # Module load config cat > "${ROOTFS_DIR}/etc/modules-load.d/cardputerzero.conf" << 'EOF' i2c-dev From a9e646bf10f4a80f01f31fe00638b94452c990b1 Mon Sep 17 00:00:00 2001 From: dianjixz <18637716021@163.com> Date: Thu, 25 Jun 2026 17:11:29 +0800 Subject: [PATCH 2/4] test: update cmdline checks for cardputerzero cleanup --- tools/verify-image.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tools/verify-image.sh b/tools/verify-image.sh index bb3e2fab56..d98a48463d 100755 --- a/tools/verify-image.sh +++ b/tools/verify-image.sh @@ -92,10 +92,28 @@ else fi # Check cmdline.txt -if grep -q "quiet splash" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then - pass "cmdline.txt: quiet splash" +if grep -q "\bquiet\b" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then + pass "cmdline.txt: quiet present" else - fail "cmdline.txt: missing quiet splash" + fail "cmdline.txt: quiet missing" +fi + +if grep -q "\bsplash\b" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then + fail "cmdline.txt: splash should be removed for CardputerZero" +else + pass "cmdline.txt: splash removed" +fi + +if grep -q "plymouth.ignore-serial-consoles" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then + fail "cmdline.txt: plymouth.ignore-serial-consoles should be removed for CardputerZero" +else + pass "cmdline.txt: plymouth.ignore-serial-consoles removed" +fi + +if grep -q "console=serial0,115200" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then + fail "cmdline.txt: console=serial0,115200 should be removed for CardputerZero" +else + pass "cmdline.txt: console=serial0,115200 removed" fi umount "$TMPDIR/boot" 2>/dev/null || true From a0d05f13772b42017897e84e50c88ee3f318a4c0 Mon Sep 17 00:00:00 2001 From: dianjixz <18637716021@163.com> Date: Thu, 25 Jun 2026 17:44:27 +0800 Subject: [PATCH 3/4] fix: sanitize cardputerzero cmdline tokens via awk filter --- stage2/05-cardputerzero/02-run.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/stage2/05-cardputerzero/02-run.sh b/stage2/05-cardputerzero/02-run.sh index 37aaeee139..b7f03cc916 100755 --- a/stage2/05-cardputerzero/02-run.sh +++ b/stage2/05-cardputerzero/02-run.sh @@ -107,18 +107,26 @@ sed -i '1i kernel=u-boot.bin' ${ROOTFS_DIR}/boot/firmware/config.txt -# Append cmdline.txt parameters -sed -i 's/$/ quiet splash plymouth.ignore-serial-consoles fbcon=map:off cfg80211.ieee80211_regdom=AE/' \ +# Append custom cmdline parameters for CardputerZero. +sed -i 's/$/ quiet fbcon=map:off cfg80211.ieee80211_regdom=AE/' \ "${ROOTFS_DIR}/boot/firmware/cmdline.txt" -# Remove serial console from CardputerZero images only. -sed -i -E \ - -e 's/(^|[[:space:]])console=serial0,115200([[:space:]]|$)/ /g' \ - -e 's/(^|[[:space:]])splash([[:space:]]|$)/ /g' \ - -e 's/(^|[[:space:]])plymouth\.ignore-serial-consoles([[:space:]]|$)/ /g' \ - -e 's/[[:space:]]+/ /g' \ - -e 's/^ //; s/ $//' \ - "${ROOTFS_DIR}/boot/firmware/cmdline.txt" +# Clean up CardputerZero cmdline tokens. +for cmd in "${ROOTFS_DIR}/boot/firmware/cmdline.txt" "${ROOTFS_DIR}/boot/cmdline.txt"; do + [ -f "$cmd" ] || continue + awk ' + { + out = "" + for (i = 1; i <= NF; i++) { + if ($i != "console=serial0,115200" && $i != "splash" && $i != "plymouth.ignore-serial-consoles") { + out = out (out == "" ? "" : " ") $i + } + } + print out + } + ' "$cmd" > "${cmd}.tmp" + mv "${cmd}.tmp" "$cmd" +done # Module load config cat > "${ROOTFS_DIR}/etc/modules-load.d/cardputerzero.conf" << 'EOF' From 84b06de4688faa2eaf06049320dfcd147836cf4e Mon Sep 17 00:00:00 2001 From: dianjixz <18637716021@163.com> Date: Thu, 25 Jun 2026 17:45:48 +0800 Subject: [PATCH 4/4] fix: final export sanitize cmdline for cardputerzero --- export-image/04-set-partuuid/00-run.sh | 19 +++++++++++++++++ tools/verify-image.sh | 28 ++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/export-image/04-set-partuuid/00-run.sh b/export-image/04-set-partuuid/00-run.sh index 99500f36fb..e528c3bfde 100755 --- a/export-image/04-set-partuuid/00-run.sh +++ b/export-image/04-set-partuuid/00-run.sh @@ -11,3 +11,22 @@ sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/boot/firmware/cmdline.txt" + +# Normalize CardputerZero cmdline for this image and keep console/splash/plymouth out. +if grep -q "dtoverlay=cardputerzero" "${ROOTFS_DIR}/boot/firmware/config.txt" 2>/dev/null; then + awk ' + { + out = "" + for (i = 1; i <= NF; i++) { + if ($i != "console=serial0,115200" && $i != "splash" && $i != "plymouth.ignore-serial-consoles") { + out = out (out == "" ? "" : " ") $i + } + } + print out + } + ' "${ROOTFS_DIR}/boot/firmware/cmdline.txt" > "${ROOTFS_DIR}/boot/firmware/cmdline.txt.tmp" + mv "${ROOTFS_DIR}/boot/firmware/cmdline.txt.tmp" "${ROOTFS_DIR}/boot/firmware/cmdline.txt" + + # Keep boot/cmdline.txt aligned with the file actually mounted in verify. + cp "${ROOTFS_DIR}/boot/firmware/cmdline.txt" "${ROOTFS_DIR}/boot/cmdline.txt" +fi diff --git a/tools/verify-image.sh b/tools/verify-image.sh index d98a48463d..547f1c584c 100755 --- a/tools/verify-image.sh +++ b/tools/verify-image.sh @@ -92,13 +92,37 @@ else fi # Check cmdline.txt -if grep -q "\bquiet\b" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then +if awk ' +{ + for (i = 1; i <= NF; i++) { + if ($i == "quiet") { + ok = 1 + break + } + } +} +END { + exit (ok ? 0 : 1) +} +' "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then pass "cmdline.txt: quiet present" else fail "cmdline.txt: quiet missing" fi -if grep -q "\bsplash\b" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then +if awk ' +{ + for (i = 1; i <= NF; i++) { + if ($i == "splash") { + ok = 1 + break + } + } +} +END { + exit (ok ? 0 : 1) +} +' "$TMPDIR/boot/cmdline.txt" >/dev/null 2>&1; then fail "cmdline.txt: splash should be removed for CardputerZero" else pass "cmdline.txt: splash removed"