summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Spooren2026-10-13 08:36:23 +0000
committerPaul Spooren2026-10-13 19:13:27 +0000
commitf6ef30a35e89141dd2f2ecba90339c04cdcbea14 (patch)
treee8fa73d79a2c23060c878f9fc7e9defc17d3b2b5
parentbeda530aac29ba17384fe964e482dc64f02e9856 (diff)
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 <mail@aparcar.org>
-rw-r--r--target/linux/ath79/image/nand.mk9
1 files changed, 5 insertions, 4 deletions
diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk
index ae7c728409..64d8e80409 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