ECC errors after UBI writes with brcmnand (Northstar with v6.1 controller)

Rafał Miłecki zajec5 at gmail.com
Tue Mar 22 10:53:19 PDT 2022


On 18.03.2022 19:02, Rafał Miłecki wrote:
> My problem is that ubifs complains about ECC errors. I spent some time
> debugging it and it seems that:
> 1. Initially all blocks written by bootloader can be read fine
> 2. Few blocks written by ubifs -> ubi -> brcmnand can't be read back
> 
> ubi0 error: ubi_io_write: Read back 90 FAILED from "ubi" at offset 0x61800 of length 2048: -74
> ubi0 error: ubi_io_write: Read back 92 FAILED from "ubi" at offset 0x81800 of length 2048: -74
> ubi0 error: ubi_io_write: Read back 97 FAILED from "ubi" at offset 0xa1800 of length 2048: -74
> ubi0 error: ubi_io_write: Read back 756 FAILED from "ubi" at offset 0xee4800 of length 2048: -74
> ubi0 error: ubi_io_write: Read back 840 FAILED from "ubi" at offset 0xee5000 of length 2048: -74
> ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 68 bytes from PEB 119:21944, read only 68 bytes, retry (addr:0xee55b8)
> ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 68 bytes from PEB 119:21944, read only 68 bytes, retry (addr:0xee55b8)
> ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 68 bytes from PEB 119:21944, read only 68 bytes, retry (addr:0xee55b8)
> ubi0 error: ubi_io_read: error -74 (ECC error) while reading 68 bytes from PEB 119:21944, read 68 bytes

I did a bit of extra debugging and I'll try to provide some extra
information though nothing exciting.


FWIW: OpenWrt 15.05 (correct: year 2015) used a port of NAND driver from
the Broadcom's SDK. I was wondering if it may behave any different.

First I booted that ancient OpenWrt 15.05 with kernel 3.18 on Netgear
R6250 (BCM4708) and dumped ECC layout. Sadly nothing unexpected here:
that driver used the same ECC layout and upstream brcmnand.

OOB ECC layout:
offset: 2 length: 14
offset: 18 length: 14
offset: 34 length: 14
offset: 50 length: 14

OOB free bytes:
offset: 1 length: 1
offset: 16 length: 2
offset: 32 length: 2
offset: 48 length: 2

Then I verified that the ancient / downstream / ported NAND driver
suffers from the same ECC errors as reported in this e-mail thread.

Dead end :(


I tested kernels 4.1, 4.14, 4.19, 5.4 and 5.10 with UBI & upstream
brcmnand driver. They all suffer from ECC errors.


Finally I realized something a bit more interesting. I've a following
custom init.d script:

# cat /etc/init.d/S39network
#!/bin/sh
machine="$(cat /proc/device-tree/compatible | tr '\0' '\t' | cut -f 1)"
interfaces="/usr/local/etc/network/interfaces.$machine"
[ -f "$interfaces" ] && cp "$interfaces" /etc/network/interfaces

(it copies device specific network config from /usr/ to /etc/network/)

With that init.d script executed on boot I get 9 ECC errors like:
ubi_io_read: error -74 (ECC error) while reading 68 bytes from

Without it I get 0 errors while booting. Also copying right file from
/usr/ to /etc/network/ manually - after init completion - doesn't cause
ECC error.

Does it mean UBI uses NAND differently during first boot, when there
aren't plently of empty (erased) blocks? Does it pack data in existing
blocks more aggressively?


No matter if I have my init.d script or not I can always see ECC errors:
1. One ECC error while reading rootfs for the first time
2. 5 ECC errors after executing "reboot"



More information about the linux-mtd mailing list