Repository navigation
backup, upload, report: read partitions through /dev/mtdN (#283) - #284
Conversation
A NAND page that ECC cannot correct makes mtd_read() return -EBADMSG, with the data still read. /dev/mtdN's read() hands that data over; /dev/mtdblockN turns it into "Buffer I/O error". ipctool mapped mtdblock, so on a camera with such a page: - backup: fwrite() from the mapping stopped short at the page. The partition was cut, every later one shifted in the file, and the exit status was 0 (the 69 MB file of 128 MB in #283). - upload --backup: send() from the mapping failed, reported as "Could not reach openipc.ru (error 5)" -- not a network problem. - the report: examine_part() hashes every partition up to 16 MB through a mapping, and a bad page there is SIGBUS with no output at all. open_mtd_read() opens /dev/mtdN, falling back to /dev/mtdblockN for a /dev without the character nodes. Backup partitions are now streamed spans, as UBI volumes already were, so a read error on the fallback stops the backup by name instead of corrupting it. examine_part() reads the first two partitions whole (the U-Boot environment and XM crypto searches need them) and hashes the rest a piece at a time. save_file() fails on a short write. Verified on the qemu-bench T31 twin with the reporter's GD5F1GQ5UE and injected uncorrectable pages at the sectors the issue's log names (mtdblock3 sector 1496, mtdblock5 sector 3320): master's backup is corrupt from mtd3 on and its upload fails with "error 5"; with this change the backup and the upload are byte-identical to the flash, and the report, with a bad page in mtd1, gives the right SHA1s where master dies with SIGBUS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Summary by QodoRead MTD partitions through character devices for backup and reporting
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1.
|
Qodo's review: when examine_part() could not read a partition, the report left out its sha1 with no word, the same as for a partition left out on purpose (over 16 MB, or mounted rw). It now adds read_error: the device, the error and the 64K piece it came from. Both reads, whole and streamed, go through one loop, so the offset is right for either. The /dev/mtdblockN fallback in open_mtd_read() could never run: enum_mtd_info() lists only partitions whose /dev/mtdN opens and answers MEMGETINFO, so a partition without the node never reaches the backup or the report. Seen on the twin with /dev/mtd1 removed. Re-verified on the qemu-bench T31 twin with uncorrectable pages in mtd1, mtd3 and mtd5: the report has every sha1, and the backup is byte-identical to the flash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed Qodo's finding in 7ea3801: a partition that can't be read now gets Also removed the Re-verified on the twin with uncorrectable pages in mtd1, mtd3 and mtd5: every sha1 is in the report and the backup is byte-identical to the flash. |
…ges (#312) * ingenic-spinand: gd5f1gq5ue, and ecc-fail= to report uncorrectable pages On-die ECC never reported an error, so nothing could test what a host does with a bad NAND page. ecc-fail="p[-q],..." lists absolute pages whose page read sets the status ECC bits 5:4 to 10b (uncorrectable) while ECC is enabled; the data still reaches the cache, as on a part. The 3.10 jz_sfc_nand returns -EBADMSG from mtd_read for it, which mtdblock turns into "Buffer I/O error" and /dev/mtdN's read() ignores. gd5f1gq5ue (C8 51, 2048 + 128, 1024 blocks) is the part in OpenIPC/ipctool#283. It is in the 3.10 kernel's table, not the SPL's or U-Boot's, so it boots with -kernel, and only by flash-type=: its 136 MiB image is gd5f1gq4ub's size. With -global gd5f1gq5ue.ecc-fail=4470,16190 the twin logs the issue's exact "mtdblock3, sector 1496 / logical block 187" and "mtdblock5, sector 3320 / logical block 415", and reproduced its corrupt backup and "Could not reach (error 5)" upload, fixed in OpenIPC/ipctool#284. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ingenic-spinand: ecc-fail= pages are decimal or 0x, never octal or empty Qodo's review: strtoul(..., 0) read ecc-fail=010 as octal page 8, and an empty range end ("0-") passed as page 0. A page is now decimal, or hex after 0x, and must start with a digit, so an empty end, a sign or a space is refused rather than taken for page 0. Checked: 010, 08, 0x10, 0-5, 65535 accepted; 0-, -5, " 5", 0x, 65536, 5-3 refused; on the T31 twin ecc-fail=0612 fails page 612. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Closes #283.
What was wrong
A NAND page that ECC cannot correct makes
mtd_read()return-EBADMSG, with the data still read./dev/mtdN'sread()returns that data (which is whydd if=/dev/mtd3worked in the issue)./dev/mtdblockNturns it intoBuffer I/O error. ipctool mapped mtdblock, so:ipctool backupipctool upload --backupCould not reach openipc.ru (error 5), though the network is fineipctool(report)Change
open_mtd_read()opens/dev/mtdN(enumeration already requires that node, so mtdblock needs no fallback).examine_part()reads instead of mapping: whole for partitions 0/1 (env / XM crypto search), piece by piece into the SHA1 for the rest.save_file()fails on a short write.read_errorinstead of silently losing its sha1.Verified on the qemu-bench digital twin
A T31 running the 3.10
jz_sfc_nanddriver, with the reporter's GD5F1GQ5UE (C8 51) and uncorrectable pages injected so that the kernel logs exactly the issue'smtdblock3, sector 1496 / logical block 187andmtdblock5, sector 3320 / logical block 415. The model change is OpenIPC/qemu-bench (spinandecc-fail=).backup, bad pages in mtd3 and mtd5upload --backupto a bench receiverCould not reach … (error 5)Native unit tests pass and the mips32 build is clean; arm32/arm64 are left to CI. Not yet tried on a real camera with a bad NAND page.