Had moment to try unpatched kernel botting from NFS:
[ 0.601805] Bad block table found at page 262080, version 0x01
[ 0.608337] Bad block table found at page 262016, version 0x01
[ 0.614464] nand_bbt: ECC error in BBT at 0x00001ffe0005
[ 0.620033] nand_bbt: ECC error in BBT at 0x00001ffc0005
^^^ kernel was unable to read former bad block table, kernel's trying to recreate it:
[ 0.625418] Scanning device for bad blocks
[ 0.645584] Bad eraseblock 158 at 0x0000013c0000
[ 0.941525] Bad eraseblock 3040 at 0x000017c00000
[ 1.010477] Bad eraseblock 3676 at 0x00001cb80000
[ 1.030436] Bad eraseblock 3827 at 0x00001de60000
[ 1.039603] Bad eraseblock 3871 at 0x00001e3e0000
[ 1.045144] Bad eraseblock 3879 at 0x00001e4e0000
[ 1.057730] Bad eraseblock 3957 at 0x00001eea0000
[ 1.077674] Bad block table written to 0x00001ffe0000, version 0x01
[ 1.085144] Bad block table written to 0x00001ffc0000, version 0x01
as well zilion of UBI read errors past UBI MTD attach, like this
[ 1.620384] ubi0: attaching mtd3
[ 1.624624] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
[ 1.636719] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
[ 1.648187] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
[ 1.659643] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read 64 bytes
[ 1.669676] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.20 #17 VOLUNTARY
[ 1.677403] Hardware name: Freescale Vybrid VF5xx/VF6xx (Device Tree)
[ 1.683885] Call trace:
[ 1.683916] unwind_backtrace from show_stack+0xb/0xc
[ 1.691594] show_stack from dump_stack_lvl+0x23/0x2a
[ 1.696711] dump_stack_lvl from ubi_io_read+0x105/0x280
[ 1.702086] ubi_io_read from ubi_io_read_ec_hdr+0x45/0x218
[ 1.707724] ubi_io_read_ec_hdr from scan_peb+0x59/0x5ac
[ 1.713105] scan_peb from scan_all+0x95/0x918
[ 1.717615] scan_all from ubi_attach+0x5b/0x344
[ 1.722293] ubi_attach from ubi_attach_mtd_dev+0x56f/0xcec
[ 1.727928] ubi_attach_mtd_dev from ubi_init_attach+0xab/0xdc
[ 1.733831] ubi_init_attach from do_one_initcall+0x29/0x1ac
[ 1.739565] do_one_initcall from kernel_init_freeable+0x17f/0x1e4
[ 1.745816] kernel_init_freeable from kernel_init+0x1b/0xec
[ 1.751544] kernel_init from ret_from_fork+0x11/0x1c
[ 1.756650] Exception stack(0x90819fb0 to 0x90819ff8)
[ 1.761752] 9fa0: 00000000 00000000 00000000 00000000
[ 1.769985] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 1.778219] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 1.785197] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:2048, read only 64 bytes, retry
[ 1.796921] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:2048, read only 6
These two changes can make it compatible with Toradex BSP:
static int vf610_nfc_read_page(struct nand_chip *chip, uint8_t *buf,
int oob_required, int page)
{
struct vf610_nfc *nfc = chip_to_nfc(chip);
struct mtd_info *mtd = nand_to_mtd(chip);
int trfr_sz = mtd->writesize + mtd->oobsize;
u32 row = 0, cmd1 = 0, cmd2 = 0, code = 0;
int stat;
//>>> Add this
if ( unlikely(mtd->oobsize > OOB_64) )
{
dev_info(nfc->dev,
"Using 64 bytes of NAND chip provided %u bytes OOB\n",
mtd->oobsize);
mtd->oobsize = OOB_64;
}
//<<<<
....
In vf610_nfc_attach_chip() remove useless, though perhaps required to be removed lines. At least without them flash works as expected.
//if (mtd->oobsize > 64)
// mtd->oobsize = 64;
As well, if you wish fix undocumented VF family erased page bitflip bug in 60-byte ECC mode, you may add this
static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat,
uint8_t *oob, int page)
{
struct vf610_nfc *nfc = chip_to_nfc(chip);
struct mtd_info *mtd = nand_to_mtd(chip);
u32 ecc_status_off = NFC_MAIN_AREA(0) + ECC_SRAM_ADDR + ECC_STATUS;
u8 ecc_status;
u8 ecc_count;
int flips_threshold = nfc->chip.ecc.strength / 2;
ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff;
ecc_count = ecc_status & ECC_STATUS_ERR_COUNT;
if (!(ecc_status & ECC_STATUS_MASK))
return ecc_count;
//>>>>>>> add this
/* ECC not OK, perhaps it is erased page.
60 byte mode leads to ECC flip */
if(nfc->ecc_mode == ECC_60_BYTE)
dat[0x5FD] ^= 0x20;
//<<<<<<<<<<
...