Repository navigation
mtd: spinand: add FORESEE F35SQA512M 512Mbit SPI NAND - #335
Conversation
The Reolink E340 (NT98566) carries a FORESEE F35SQA512M, JEDEC ID cd 70. The driver only accepts chips listed in its own table, so the flash is not usable without an entry. The chip's on-die ECC corrects one bit per segment of 512 bytes of data plus 16 bytes of spare (datasheet rev 1.1, section 11.4). Set strength and bitflip threshold to 1, as is done for the Fudan chip, so that a corrected read makes UBI move the data. With the generic values (4 and 3) a degrading block would never be scrubbed. Tested on a Reolink E340: the chip is detected as 64 MiB with 128 KiB blocks and 2 KiB pages, ecc_strength and bitflip_threshold read 1, and UBI attach, UBIFS mount, erase and write work. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR Summary by Qodomtd: spinand: support FORESEE F35SQA512M
AI Description
Merge Risk
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can turn these tips off under Display > Comment parts |
openipc-ai
left a comment
There was a problem hiding this comment.
Approving. I checked it against the driver and the datasheet:
cd 70and the geometry (2 KiB pages, 64 MiB, 128 KiB blocks, 64-byte OOB) match the F35SQA512M. Mainline'sdrivers/mtd/nand/spi/foresee.cgives the same ID andNAND_ECCREQ(1, 512).- The chip has no corrected-bit count to read, so
spinand_read_page_hwecc()takes the genericelsearm and returns 1 onECC_CORRECTED. Withbitflip_threshold = 1that is-EUCLEAN, and UBI scrubs the block. The default arm (strength 4, threshold 3) would never get there. This is the FM25S01A fix from #330, applied to a chip with the same 1-bit ECC. 0xCDdoesn't collide with anyMFG_ID_*already in the header, and FORESEE takes no other vendor-specific arm (OOB layout, quad enable, ECC status), which matches your erase/write/UBIFS test.
You're right about the sizeof(spinand_flash_ids) loop in drv_nand_read_id(). It counts bytes, not entries, so an unlisted chip reads past the end of the table. A separate one-line PR changing it to ARRAY_SIZE() would be welcome.
Adds the FORESEE F35SQA512M (JEDEC ID
cd 70, 64 MiB, 2 KiB pages, 128 KiB blocks, 64-byte OOB) to the Novatek SPI NAND driver, and sets ECC strength and bitflip threshold to 1 for FORESEE, as is done for the Fudan chip.The 1-bit strength is from the F35SQA512M datasheet (rev 1.1, section 11.4): one bit corrected per 512 bytes of data plus 16 bytes of spare.
Tested on a Reolink E340 (NT98566): chip detected with the geometry above,
ecc_strengthandbitflip_thresholdread 1, UBI attach, UBIFS mount, erase and write work.Not changed here: the ID lookup loop iterates over
sizeof(spinand_flash_ids)rather than the number of entries.🤖 Generated with Claude Code