From f6ef30a35e89141dd2f2ecba90339c04cdcbea14 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Tue, 13 Oct 2026 10:36:23 +0200 Subject: [PATCH] ath79: dongwon-header: don't read the CRC from a pipe with dd The factory image of the Dongwon DW02-412H sometimes carries a broken header CRC, as seen by the rebuilder: -Header CRC: 0X990A0000 +Header CRC: 0X990A9FB7 The CRC is written with printf piped into dd bs=4 count=1. Bash's printf writes its output line buffered, so a CRC holding a 0x0a byte is written in two parts: write(1, "\231\n", 2) = 2 write(1, "\237\267", 2) = 2 If dd reads the pipe between the two writes, it gets a short block, and with count=1 it stops there and leaves the rest of the CRC zero. This depends on the scheduling, so busy builders hit it while idle machines almost never do. Delaying the writes reproduces it every time: old: CRC be f8 0a 00 new: CRC be f8 0a 17 Put the header together by concatenation instead, so the image no longer goes through dd. Without the race, the output is the same as before (300 random kernels, all identical and with valid CRCs). Link: https://github.com/openwrt/openwrt/pull/25867 Signed-off-by: Paul Spooren --- target/linux/ath79/image/nand.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index ae7c728409c..64d8e804098 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -5,10 +5,11 @@ define Build/dongwon-header ( \ header_crc="$$(head -c 68 $@.tmp | gzip -c | \ tail -c 8 | od -An -N4 -tx4 --endian little | tr -d ' \n')"; \ - printf "$$(echo $$header_crc | sed 's/../\\x&/g')" | \ - dd of=$@.tmp bs=4 count=1 seek=1 conv=notrunc \ - ) - mv $@.tmp $@ + head -c 4 $@.tmp; \ + printf "$$(echo $$header_crc | sed 's/../\\x&/g')"; \ + tail -c +9 $@.tmp; \ + ) > $@ + rm -f $@.tmp endef define Build/meraki-header