Mt7621-nand all reads are ecc errors

When installing openwrt I get a lot of errors (ecc, squashfs corrupt data). There are no errors on the original firmware. I am trying to test nand.

original firmware:

/tmp # cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 07f80000 00020000 "ALL"
mtd1: 00080000 00020000 "Bootloader"
mtd2: 00080000 00020000 "Config"
mtd3: 00040000 00020000 "Factory"
mtd4: 001e0000 00020000 "Kernel"
mtd5: 00ce0000 00020000 "RootFS"
mtd6: 00ec0000 00020000 "Linux"
mtd7: 01140000 00020000 "Image"
/tmp # ./libc.so ./nandtest /dev/mtd4
ECC corrections: 0
ECC failures   : 0
Bad blocks     : 0
BBT blocks     : 0
001c0000: checking...of 4)...
Finished pass 1 successfully
/tmp # ./libc.so ./nandtest -r100 /dev/mtd4
ECC corrections: 0
ECC failures   : 0
Bad blocks     : 0
BBT blocks     : 0
001c0000: checking...0 of 100)...
Finished pass 1 successfully

bootlog: https://pastebin.com/raw/wQKBi94P

openwrt:

root@OpenWrt:~# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00080000 00020000 "u-boot"
mtd1: 00080000 00020000 "config"
mtd2: 00040000 00020000 "factory"
mtd3: 001e0000 00020000 "kernel"
mtd4: 00ce0000 00020000 "ubi"


root@OpenWrt:~# nandtest /dev/mtd3
ECC corrections: 147
ECC failures   : 141
Bad blocks     : 0
BBT blocks     : 0
00000000: reading (3 of 4)...
 3 bit(s) ECC corrected at 00000000
00000000: checking...
compare failed. seed 1588371387
Byte 0x18001 is 4a should be 4b
00000000: checking...read/check 1 of 4 failed. seed 1588371387
00020000: reading (3 of 4)...
ECC failed at 00020000
00040000: reading (3 of 4)...
ECC failed at 00040000
000e0000: reading (4 of 4)...
 3 bit(s) ECC corrected at 000e0000
000e0000: checking...
compare failed. seed 61368093
Byte 0x8001 is 68 should be 6c
read/check 1 of 4 failed. seed 61368093
00180000: reading (1 of 4)...
ECC failed at 00180000
001a0000: reading (1 of 4)...
ECC failed at 001a0000
001a0000: reading (2 of 4)...
ECC failed at 001a0000
001c0000: checking...of 4)...
Finished pass 1 successfully

[  335.112194] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 708.0
[  335.402025] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 821.0
[  337.761920] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 1463.0
[  338.021924] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 1529.0
[  338.051685] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 1482.0

bootlog: https://pastebin.com/raw/J0rFfwCn

I found the problem. It is an error in the wrong timings. I haven't found how to set them correctly, but the max ones work. I'll try to get them right later.

I have fidelix FMND1GXXX3D, chip: FMND1G08U3D The manual says tCLS/tALS min 12ns (that's mod 3-4) The core identifies the chip as mod 1, setting the timings to 25ns, which is ~4 cycles at 125mhz. The timings are much higher than what the manual says. It counts the timings correctly, but for some reason it doesn't work.

My English is bad, so I can't explain the problem better, sorry.