mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* nand "BCH decoding failed" when using bch8_hw_romcode ecc mode
@ 2022-03-16 13:45 Tibault Damman
  2022-03-17  7:46 ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Tibault Damman @ 2022-03-16 13:45 UTC (permalink / raw)
  To: barebox

Hi all

Due to component shortages, I'm trying to move an old board from a Phytec Phycore omap4430 with 8bit nand (Micron MT29F4G08ABBDAH4) to an omap4460 variant with 16bit nand (Micron MT29F8G16ADBDAH4).

To be compatible with Linux 5.4, the rootfs nand (ubi) partition needs to be in BCH8_HW_ROMCODE ecc mode instead of the default BCH8_HW.
When I use ubiformat or ubiattach from barebox in this mode though, I get a bazillion "BCH decoding failed" prints (which I did not get on the omap4430)

> barebox@Phytec phyCORE-OMAP4460:/ ubiattach -O 2048 /dev/nand0.sys
> ...
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> nand0.root: error -74 (ECC error) while reading 512 bytes from PEB 887:0
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> nand0.root: error -74 (ECC error) while reading 512 bytes from PEB 888:0
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> ...

I tried these combinations:
* omap4430 (8bit nand) + BCH8_HW ecc: works (but not compatible with Linux)
* omap4430 (8bit nand) + BCH8_HW_ROMCODE ecc: works
* omap4460 (16bit nand) + BCH8_HW ecc: works (but not compatible with Linux)
* omap4460 (16bit nand) + BCH8_HW_ROMCODE ecc: does not work

I've reproduced this on the following barebox versions:
* phytec's 2013.06 fork
* 2019.07.0 (which I've been (successfully) using for omap4430)
* the latest 2020.03.0

Any clues what could be going wrong here?

Maybe the 8/16bit thing is a red herring, but it was the most obvious difference.
I've tried setting the nand device width to 16 (instead of 0 (auto)) in the board file, but that didn't change the above behaviour.

(I've also noticed the ubi tools keep assuming the subpage size is 512, when the nand has no subpages. Passing -s 2048 and -O 2048 works for the omap4430 though.)

Thanks

Tibault

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nand "BCH decoding failed" when using bch8_hw_romcode ecc mode
  2022-03-16 13:45 nand "BCH decoding failed" when using bch8_hw_romcode ecc mode Tibault Damman
@ 2022-03-17  7:46 ` Sascha Hauer
  2022-03-18  9:49   ` Tibault Damman
  2022-03-18 10:32   ` Tibault Damman
  0 siblings, 2 replies; 7+ messages in thread
From: Sascha Hauer @ 2022-03-17  7:46 UTC (permalink / raw)
  To: Tibault Damman; +Cc: barebox

Hi,

On Wed, Mar 16, 2022 at 01:45:31PM +0000, Tibault Damman wrote:
> Hi all
> 
> Due to component shortages, I'm trying to move an old board from a Phytec Phycore omap4430 with 8bit nand (Micron MT29F4G08ABBDAH4) to an omap4460 variant with 16bit nand (Micron MT29F8G16ADBDAH4).
> 
> To be compatible with Linux 5.4, the rootfs nand (ubi) partition needs to be in BCH8_HW_ROMCODE ecc mode instead of the default BCH8_HW.
> When I use ubiformat or ubiattach from barebox in this mode though, I get a bazillion "BCH decoding failed" prints (which I did not get on the omap4430)
> 
> > barebox@Phytec phyCORE-OMAP4460:/ ubiattach -O 2048 /dev/nand0.sys
> > ...
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > nand0.root: error -74 (ECC error) while reading 512 bytes from PEB 887:0
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > nand0.root: error -74 (ECC error) while reading 512 bytes from PEB 888:0
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > BCH decoding failed
> > ...
> 
> I tried these combinations:
> * omap4430 (8bit nand) + BCH8_HW ecc: works (but not compatible with Linux)
> * omap4430 (8bit nand) + BCH8_HW_ROMCODE ecc: works
> * omap4460 (16bit nand) + BCH8_HW ecc: works (but not compatible with Linux)
> * omap4460 (16bit nand) + BCH8_HW_ROMCODE ecc: does not work
> 
> I've reproduced this on the following barebox versions:
> * phytec's 2013.06 fork
> * 2019.07.0 (which I've been (successfully) using for omap4430)
> * the latest 2020.03.0
> 
> Any clues what could be going wrong here?

No clue, just some things you could test:

- in BCH8_HW_ROMCODE barebox can't read what it has written itself,
  right?
- Can barebox read what Linux has written in this mode?
- Use Linux to write known data to a page:
  seq 10000 > foo
  flash_erase /dev/mtdx 0 0
  nandwrite /dev/mtdx foo
- Read the same page in raw mode in barebox:
  md -s /dev/nand0.raw 0+2112
- Write the same data with barebox
- Read again:
  md -s /dev/nand0.raw 0+2112
- Compare the results

You could also just return successfully in chien() when the result would
fail and see what you read.

Use plain NAND accesses for now, i.e. no UBI.

Playing with these things should give us a starting point where to look
at.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nand "BCH decoding failed" when using bch8_hw_romcode ecc mode
  2022-03-17  7:46 ` Sascha Hauer
@ 2022-03-18  9:49   ` Tibault Damman
  2022-03-18 10:32   ` Tibault Damman
  1 sibling, 0 replies; 7+ messages in thread
From: Tibault Damman @ 2022-03-18  9:49 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 17/03/2022 08:46, Sascha Hauer wrote:

> No clue, just some things you could test:
>
> - in BCH8_HW_ROMCODE barebox can't read what it has written itself,
>    right?

so it would seem yeah

> - Can barebox read what Linux has written in this mode?
> - Use Linux to write known data to a page:
>    seq 10000 > foo
>    flash_erase /dev/mtdx 0 0
>    nandwrite /dev/mtdx foo
> - Read the same page in raw mode in barebox:
>    md -s /dev/nand0.raw 0+2112
> - Write the same data with barebox
> - Read again:
>    md -s /dev/nand0.raw 0+2112
> - Compare the results
>
> You could also just return successfully in chien() when the result would
> fail and see what you read.

(I had to edit chien as you suggested, else md didn't print the results)

Writing from linux and barebox seems to give the same result:

> barebox@Phytec phyCORE-OMAP4460:/ gpmc_nand0.eccmode=bch8_hw_romcode 
> barebox@Phytec phyCORE-OMAP4460:/ md -s /dev/nand0 0+2112 BCH decoding 
> failed BCH decoding failed BCH decoding failed BCH decoding failed BCH 
> decoding failed BCH decoding failed 00000000: 0a320a31 0a340a33 
> 0a360a35 0a380a37                1.2.3.4.5.6.7.8. 00000010: 30310a39 
> 0a31310a 310a3231 34310a33                9.10.11.12.13.14 00000020: 
> 0a35310a 310a3631 38310a37 0a39310a                .15.16.17.18.19. 
> 00000030: 320a3032 32320a31 0a33320a 320a3432                
> 20.21.22.23.24.2 00000040: 36320a35 0a37320a 320a3832 
> 30330a39                5.26.27.28.29.30 00000050: 0a31330a 330a3233 
> 34330a33 0a35330a                .31.32.33.34.35. 00000060: 330a3633 
> 38330a37 0a39330a 340a3034                36.37.38.39.40.4 00000070: 
> 32340a31 0a33340a 340a3434 36340a35                1.42.43.44.45.46 
> 00000080: 0a37340a 340a3834 30350a39 0a31350a                
> .47.48.49.50.51. 00000090: 350a3235 34350a33 0a35350a 
> 350a3635                52.53.54.55.56.5 000000a0: 38350a37 0a39350a 
> 360a3036 32360a31                7.58.59.60.61.62 000000b0: 0a33360a 
> 360a3436 36360a35 0a37360a                .63.64.65.66.67. 000000c0: 
> 360a3836 30370a39 0a31370a 370a3237                68.69.70.71.72.7 
> 000000d0: 34370a33 0a35370a 370a3637 38370a37                
> 3.74.75.76.77.78 000000e0: 0a39370a 380a3038 32380a31 
> 0a33380a                .79.80.81.82.83. 000000f0: 380a3438 36380a35 
> 0a37380a 380a3838                84.85.86.87.88.8 00000100: 30390a39 
> 0a31390a 390a3239 34390a33                9.90.91.92.93.94 00000110: 
> 0a35390a 390a3639 38390a37 0a39390a                .95.96.97.98.99. 
> 00000120: 0a303031 0a313031 0a323031 0a333031                
> 100.101.102.103. 00000130: 0a343031 0a353031 0a363031 
> 0a373031                104.105.106.107. 00000140: 0a383031 0a393031 
> 0a303131 0a313131                108.109.110.111. 00000150: 0a323131 
> 0a333131 0a343131 0a353131                112.113.114.115. 00000160: 
> 0a363131 0a373131 0a383131 0a393131                116.117.118.119. 
> 00000170: 0a303231 0a313231 0a323231 0a333231                
> 120.121.122.123. 00000180: 0a343231 0a353231 0a363231 
> 0a373231                124.125.126.127. 00000190: 0a383231 0a393231 
> 0a303331 0a313331                128.129.130.131. 000001a0: 0a323331 
> 0a333331 0a343331 0a353331                132.133.134.135. 000001b0: 
> 0a363331 0a373331 0a383331 0a393331                136.137.138.139. 
> 000001c0: 0a303431 0a313431 0a323431 0a333431                
> 140.141.142.143. 000001d0: 0a343431 0a353431 0a363431 
> 0a373431                144.145.146.147. 000001e0: 0a383431 0a393431 
> 0a303531 0a313531                148.149.150.151. 000001f0: 0a323531 
> 0a333531 0a343531 0a353531                152.153.154.155. 00000200: 
> 0a363531 0a373531 0a383531 0a393531                156.157.158.159. 
> 00000210: 0a303631 0a313631 0a323631 0a333631                
> 160.161.162.163. 00000220: 0a343631 0a353631 0a363631 
> 0a373631                164.165.166.167. 00000230: 0a383631 0a393631 
> 0a303731 0a313731                168.169.170.171. 00000240: 0a323731 
> 0a333731 0a343731 0a353731                172.173.174.175. 00000250: 
> 0a363731 0a373731 0a383731 0a393731                176.177.178.179. 
> 00000260: 0a303831 0a313831 0a323831 0a333831                
> 180.181.182.183. 00000270: 0a343831 0a353831 0a363831 
> 0a373831                184.185.186.187. 00000280: 0a383831 0a393831 
> 0a303931 0a313931                188.189.190.191. 00000290: 0a323931 
> 0a333931 0a343931 0a353931                192.193.194.195. 000002a0: 
> 0a363931 0a373931 0a383931 0a393931                196.197.198.199. 
> 000002b0: 0a303032 0a313032 0a323032 0a333032                
> 200.201.202.203. 000002c0: 0a343032 0a353032 0a363032 
> 0a373032                204.205.206.207. 000002d0: 0a383032 0a393032 
> 0a303132 0a313132                208.209.210.211. 000002e0: 0a323132 
> 0a333132 0a343132 0a353132                212.213.214.215. 000002f0: 
> 0a363132 0a373132 0a383132 0a393132                216.217.218.219. 
> 00000300: 0a303232 0a313232 0a323232 0a333232                
> 220.221.222.223. 00000310: 0a343232 0a353232 0a363232 
> 0a373232                224.225.226.227. 00000320: 0a383232 0a393232 
> 0a303332 0a313332                228.229.230.231. 00000330: 0a323332 
> 0a333332 0a343332 0a353332                232.233.234.235. 00000340: 
> 0a363332 0a373332 0a383332 0a393332                236.237.238.239. 
> 00000350: 0a303432 0a313432 0a323432 0a333432                
> 240.241.242.243. 00000360: 0a343432 0a353432 0a363432 
> 0a373432                244.245.246.247. 00000370: 0a383432 0a393432 
> 0a303532 0a313532                248.249.250.251. 00000380: 0a323532 
> 0a333532 0a343532 0a353532                252.253.254.255. 00000390: 
> 0a363532 0a373532 0a383532 0a393532                256.257.258.259. 
> 000003a0: 0a303632 0a313632 0a323632 0a333632                
> 260.261.262.263. 000003b0: 0a343632 0a353632 0a363632 
> 0a373632                264.265.266.267. 000003c0: 0a383632 0a393632 
> 0a303732 0a313732                268.269.270.271. 000003d0: 0a323732 
> 0a333732 0a343732 0a353732                272.273.274.275. 000003e0: 
> 0a363732 0a373732 0a383732 0a393732                276.277.278.279. 
> 000003f0: 0a303832 0a313832 0a323832 0a333832                
> 280.281.282.283. 00000400: 0a343832 0a353832 0a363832 
> 0a373832                284.285.286.287. 00000410: 0a383832 0a393832 
> 0a303932 0a313932                288.289.290.291. 00000420: 0a323932 
> 0a333932 0a343932 0a353932                292.293.294.295. 00000430: 
> 0a363932 0a373932 0a383932 0a393932                296.297.298.299. 
> 00000440: 0a303033 0a313033 0a323033 0a333033                
> 300.301.302.303. 00000450: 0a343033 0a353033 0a363033 
> 0a373033                304.305.306.307. 00000460: 0a383033 0a393033 
> 0a303133 0a313133                308.309.310.311. 00000470: 0a323133 
> 0a333133 0a343133 0a353133                312.313.314.315. 00000480: 
> 0a363133 0a373133 0a383133 0a393133                316.317.318.319. 
> 00000490: 0a303233 0a313233 0a323233 0a333233                
> 320.321.322.323. 000004a0: 0a343233 0a353233 0a363233 
> 0a373233                324.325.326.327. 000004b0: 0a383233 0a393233 
> 0a303333 0a313333                328.329.330.331. 000004c0: 0a323333 
> 0a333333 0a343333 0a353333                332.333.334.335. 000004d0: 
> 0a363333 0a373333 0a383333 0a393333                336.337.338.339. 
> 000004e0: 0a303433 0a313433 0a323433 0a333433                
> 340.341.342.343. 000004f0: 0a343433 0a353433 0a363433 
> 0a373433                344.345.346.347. 00000500: 0a383433 0a393433 
> 0a303533 0a313533                348.349.350.351. 00000510: 0a323533 
> 0a333533 0a343533 0a353533                352.353.354.355. 00000520: 
> 0a363533 0a373533 0a383533 0a393533                356.357.358.359. 
> 00000530: 0a303633 0a313633 0a323633 0a333633                
> 360.361.362.363. 00000540: 0a343633 0a353633 0a363633 
> 0a373633                364.365.366.367. 00000550: 0a383633 0a393633 
> 0a303733 0a313733                368.369.370.371. 00000560: 0a323733 
> 0a333733 0a343733 0a353733                372.373.374.375. 00000570: 
> 0a363733 0a373733 0a383733 0a393733                376.377.378.379. 
> 00000580: 0a303833 0a313833 0a323833 0a333833                
> 380.381.382.383. 00000590: 0a343833 0a353833 0a363833 
> 0a373833                384.385.386.387. 000005a0: 0a383833 0a393833 
> 0a303933 0a313933                388.389.390.391. 000005b0: 0a323933 
> 0a333933 0a343933 0a353933                392.393.394.395. 000005c0: 
> 0a363933 0a373933 0a383933 0a393933                396.397.398.399. 
> 000005d0: 0a303034 0a313034 0a323034 0a333034                
> 400.401.402.403. 000005e0: 0a343034 0a353034 0a363034 
> 0a373034                404.405.406.407. 000005f0: 0a383034 0a393034 
> 0a303134 0a313134                408.409.410.411. 00000600: 0a323134 
> 0a333134 0a343134 0a353134                412.413.414.415. 00000610: 
> 0a363134 0a373134 0a383134 0a393134                416.417.418.419. 
> 00000620: 0a303234 0a313234 0a323234 0a333234                
> 420.421.422.423. 00000630: 0a343234 0a353234 0a363234 
> 0a373234                424.425.426.427. 00000640: 0a383234 0a393234 
> 0a303334 0a313334                428.429.430.431. 00000650: 0a323334 
> 0a333334 0a343334 0a353334                432.433.434.435. 00000660: 
> 0a363334 0a373334 0a383334 0a393334                436.437.438.439. 
> 00000670: 0a303434 0a313434 0a323434 0a333434                
> 440.441.442.443. 00000680: 0a343434 0a353434 0a363434 
> 0a373434                444.445.446.447. 00000690: 0a383434 0a393434 
> 0a303534 0a313534                448.449.450.451. 000006a0: 0a323534 
> 0a333534 0a343534 0a353534                452.453.454.455. 000006b0: 
> 0a363534 0a373534 0a383534 0a393534                456.457.458.459. 
> 000006c0: 0a303634 0a313634 0a323634 0a333634                
> 460.461.462.463. 000006d0: 0a343634 0a353634 0a363634 
> 0a373634                464.465.466.467. 000006e0: 0a383634 0a393634 
> 0a303734 0a313734                468.469.470.471. 000006f0: 0a323734 
> 0a333734 0a343734 0a353734                472.473.474.475. 00000700: 
> 0a363734 0a373734 0a383734 0a393734                476.477.478.479. 
> 00000710: 0a303834 0a313834 0a323834 0a333834                
> 480.481.482.483. 00000720: 0a343834 0a353834 0a363834 
> 0a373834                484.485.486.487. 00000730: 0a383834 0a393834 
> 0a303934 0a313934                488.489.490.491. 00000740: 0a323934 
> 0a333934 0a343934 0a353934                492.493.494.495. 00000750: 
> 0a363934 0a373934 0a383934 0a393934                496.497.498.499. 
> 00000760: 0a303035 0a313035 0a323035 0a333035                
> 500.501.502.503. 00000770: 0a343035 0a353035 0a363035 
> 0a373035                504.505.506.507. 00000780: 0a383035 0a393035 
> 0a303135 0a313135                508.509.510.511. 00000790: 0a323135 
> 0a333135 0a343135 0a353135                512.513.514.515. 000007a0: 
> 0a363135 0a373135 0a383135 0a393135                516.517.518.519. 
> 000007b0: 0a303235 0a313235 0a323235 0a333235                
> 520.521.522.523. 000007c0: 0a343235 0a353235 0a363235 
> 0a373235                524.525.526.527. 000007d0: 0a383235 0a393235 
> 0a303335 0a313335                528.529.530.531. 000007e0: 0a323335 
> 0a333335 0a343335 0a353335                532.533.534.535. 000007f0: 
> 0a363335 0a373335 0a383335 0a393335                536.537.538.539. 
> 00000800: 0a303435 0a313435 0a323435 0a333435                
> 540.541.542.543. 00000810: 0a343435 0a353435 0a363435 
> 0a373435                544.545.546.547. 00000820: 0a383435 0a393435 
> 0a303535 0a313535                548.549.550.551. 00000830: 0a323535 
> 0a333535 0a343535 0a353535                552.553.554.555.
Because the data looks right(?), despite the error prints, I tried 
ubiformat again from barebox, then booted linux from SD, and attached 
the ubi nand partition in linux... which worked fine. All volumes and 
data were there. Very confused about what's going wrong here. Tibault


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nand "BCH decoding failed" when using bch8_hw_romcode ecc mode
  2022-03-17  7:46 ` Sascha Hauer
  2022-03-18  9:49   ` Tibault Damman
@ 2022-03-18 10:32   ` Tibault Damman
  2022-03-18 11:59     ` Sascha Hauer
  1 sibling, 1 reply; 7+ messages in thread
From: Tibault Damman @ 2022-03-18 10:32 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Gah, I just saw how that mail was sent, let me try that again:

On 17/03/2022 08:46, Sascha Hauer wrote:
> No clue, just some things you could test:
>
> - in BCH8_HW_ROMCODE barebox can't read what it has written itself,
>    right?

so it would seem yeah

> - Can barebox read what Linux has written in this mode?
> - Use Linux to write known data to a page:
>    seq 10000 > foo
>    flash_erase /dev/mtdx 0 0
>    nandwrite /dev/mtdx foo
> - Read the same page in raw mode in barebox:
>    md -s /dev/nand0.raw 0+2112
> - Write the same data with barebox
> - Read again:
>    md -s /dev/nand0.raw 0+2112
> - Compare the results
>
> You could also just return successfully in chien() when the result would
> fail and see what you read.

(I had to edit chien as you suggested, else md didn't print the results)

Writing from linux and barebox seems to give the same result:

> barebox@Phytec phyCORE-OMAP4460:/ gpmc_nand0.eccmode=bch8_hw_romcode
> barebox@Phytec phyCORE-OMAP4460:/ md -s /dev/nand0 0+2112    
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> BCH decoding failed
> 00000000: 0a320a31 0a340a33 0a360a35 0a380a37                1.2.3.4.5.6.7.8.
> 00000010: 30310a39 0a31310a 310a3231 34310a33                9.10.11.12.13.14
> 00000020: 0a35310a 310a3631 38310a37 0a39310a                .15.16.17.18.19.
> 00000030: 320a3032 32320a31 0a33320a 320a3432                20.21.22.23.24.2
> 00000040: 36320a35 0a37320a 320a3832 30330a39                5.26.27.28.29.30
> 00000050: 0a31330a 330a3233 34330a33 0a35330a                .31.32.33.34.35.
> 00000060: 330a3633 38330a37 0a39330a 340a3034                36.37.38.39.40.4
> 00000070: 32340a31 0a33340a 340a3434 36340a35                1.42.43.44.45.46
> 00000080: 0a37340a 340a3834 30350a39 0a31350a                .47.48.49.50.51.
> 00000090: 350a3235 34350a33 0a35350a 350a3635                52.53.54.55.56.5
> 000000a0: 38350a37 0a39350a 360a3036 32360a31                7.58.59.60.61.62
> 000000b0: 0a33360a 360a3436 36360a35 0a37360a                .63.64.65.66.67.
> 000000c0: 360a3836 30370a39 0a31370a 370a3237                68.69.70.71.72.7
> 000000d0: 34370a33 0a35370a 370a3637 38370a37                3.74.75.76.77.78
> 000000e0: 0a39370a 380a3038 32380a31 0a33380a                .79.80.81.82.83.
> 000000f0: 380a3438 36380a35 0a37380a 380a3838                84.85.86.87.88.8
> 00000100: 30390a39 0a31390a 390a3239 34390a33                9.90.91.92.93.94
> 00000110: 0a35390a 390a3639 38390a37 0a39390a                .95.96.97.98.99.
> 00000120: 0a303031 0a313031 0a323031 0a333031                100.101.102.103.
> 00000130: 0a343031 0a353031 0a363031 0a373031                104.105.106.107.
> 00000140: 0a383031 0a393031 0a303131 0a313131                108.109.110.111.
> 00000150: 0a323131 0a333131 0a343131 0a353131                112.113.114.115.
> 00000160: 0a363131 0a373131 0a383131 0a393131                116.117.118.119.
> 00000170: 0a303231 0a313231 0a323231 0a333231                120.121.122.123.
> 00000180: 0a343231 0a353231 0a363231 0a373231                124.125.126.127.
> 00000190: 0a383231 0a393231 0a303331 0a313331                128.129.130.131.
> 000001a0: 0a323331 0a333331 0a343331 0a353331                132.133.134.135.
> 000001b0: 0a363331 0a373331 0a383331 0a393331                136.137.138.139.
> 000001c0: 0a303431 0a313431 0a323431 0a333431                140.141.142.143.
> 000001d0: 0a343431 0a353431 0a363431 0a373431                144.145.146.147.
> 000001e0: 0a383431 0a393431 0a303531 0a313531                148.149.150.151.
> 000001f0: 0a323531 0a333531 0a343531 0a353531                152.153.154.155.
> 00000200: 0a363531 0a373531 0a383531 0a393531                156.157.158.159.
> 00000210: 0a303631 0a313631 0a323631 0a333631                160.161.162.163.
> 00000220: 0a343631 0a353631 0a363631 0a373631                164.165.166.167.
> 00000230: 0a383631 0a393631 0a303731 0a313731                168.169.170.171.
> 00000240: 0a323731 0a333731 0a343731 0a353731                172.173.174.175.
> 00000250: 0a363731 0a373731 0a383731 0a393731                176.177.178.179.
> 00000260: 0a303831 0a313831 0a323831 0a333831                180.181.182.183.
> 00000270: 0a343831 0a353831 0a363831 0a373831                184.185.186.187.
> 00000280: 0a383831 0a393831 0a303931 0a313931                188.189.190.191.
> 00000290: 0a323931 0a333931 0a343931 0a353931                192.193.194.195.
> 000002a0: 0a363931 0a373931 0a383931 0a393931                196.197.198.199.
> 000002b0: 0a303032 0a313032 0a323032 0a333032                200.201.202.203.
> 000002c0: 0a343032 0a353032 0a363032 0a373032                204.205.206.207.
> 000002d0: 0a383032 0a393032 0a303132 0a313132                208.209.210.211.
> 000002e0: 0a323132 0a333132 0a343132 0a353132                212.213.214.215.
> 000002f0: 0a363132 0a373132 0a383132 0a393132                216.217.218.219.
> 00000300: 0a303232 0a313232 0a323232 0a333232                220.221.222.223.
> 00000310: 0a343232 0a353232 0a363232 0a373232                224.225.226.227.
> 00000320: 0a383232 0a393232 0a303332 0a313332                228.229.230.231.
> 00000330: 0a323332 0a333332 0a343332 0a353332                232.233.234.235.
> 00000340: 0a363332 0a373332 0a383332 0a393332                236.237.238.239.
> 00000350: 0a303432 0a313432 0a323432 0a333432                240.241.242.243.
> 00000360: 0a343432 0a353432 0a363432 0a373432                244.245.246.247.
> 00000370: 0a383432 0a393432 0a303532 0a313532                248.249.250.251.
> 00000380: 0a323532 0a333532 0a343532 0a353532                252.253.254.255.
> 00000390: 0a363532 0a373532 0a383532 0a393532                256.257.258.259.
> 000003a0: 0a303632 0a313632 0a323632 0a333632                260.261.262.263.
> 000003b0: 0a343632 0a353632 0a363632 0a373632                264.265.266.267.
> 000003c0: 0a383632 0a393632 0a303732 0a313732                268.269.270.271.
> 000003d0: 0a323732 0a333732 0a343732 0a353732                272.273.274.275.
> 000003e0: 0a363732 0a373732 0a383732 0a393732                276.277.278.279.
> 000003f0: 0a303832 0a313832 0a323832 0a333832                280.281.282.283.
> 00000400: 0a343832 0a353832 0a363832 0a373832                284.285.286.287.
> 00000410: 0a383832 0a393832 0a303932 0a313932                288.289.290.291.
> 00000420: 0a323932 0a333932 0a343932 0a353932                292.293.294.295.
> 00000430: 0a363932 0a373932 0a383932 0a393932                296.297.298.299.
> 00000440: 0a303033 0a313033 0a323033 0a333033                300.301.302.303.
> 00000450: 0a343033 0a353033 0a363033 0a373033                304.305.306.307.
> 00000460: 0a383033 0a393033 0a303133 0a313133                308.309.310.311.
> 00000470: 0a323133 0a333133 0a343133 0a353133                312.313.314.315.
> 00000480: 0a363133 0a373133 0a383133 0a393133                316.317.318.319.
> 00000490: 0a303233 0a313233 0a323233 0a333233                320.321.322.323.
> 000004a0: 0a343233 0a353233 0a363233 0a373233                324.325.326.327.
> 000004b0: 0a383233 0a393233 0a303333 0a313333                328.329.330.331.
> 000004c0: 0a323333 0a333333 0a343333 0a353333                332.333.334.335.
> 000004d0: 0a363333 0a373333 0a383333 0a393333                336.337.338.339.
> 000004e0: 0a303433 0a313433 0a323433 0a333433                340.341.342.343.
> 000004f0: 0a343433 0a353433 0a363433 0a373433                344.345.346.347.
> 00000500: 0a383433 0a393433 0a303533 0a313533                348.349.350.351.
> 00000510: 0a323533 0a333533 0a343533 0a353533                352.353.354.355.
> 00000520: 0a363533 0a373533 0a383533 0a393533                356.357.358.359.
> 00000530: 0a303633 0a313633 0a323633 0a333633                360.361.362.363.
> 00000540: 0a343633 0a353633 0a363633 0a373633                364.365.366.367.
> 00000550: 0a383633 0a393633 0a303733 0a313733                368.369.370.371.
> 00000560: 0a323733 0a333733 0a343733 0a353733                372.373.374.375.
> 00000570: 0a363733 0a373733 0a383733 0a393733                376.377.378.379.
> 00000580: 0a303833 0a313833 0a323833 0a333833                380.381.382.383.
> 00000590: 0a343833 0a353833 0a363833 0a373833                384.385.386.387.
> 000005a0: 0a383833 0a393833 0a303933 0a313933                388.389.390.391.
> 000005b0: 0a323933 0a333933 0a343933 0a353933                392.393.394.395.
> 000005c0: 0a363933 0a373933 0a383933 0a393933                396.397.398.399.
> 000005d0: 0a303034 0a313034 0a323034 0a333034                400.401.402.403.
> 000005e0: 0a343034 0a353034 0a363034 0a373034                404.405.406.407.
> 000005f0: 0a383034 0a393034 0a303134 0a313134                408.409.410.411.
> 00000600: 0a323134 0a333134 0a343134 0a353134                412.413.414.415.
> 00000610: 0a363134 0a373134 0a383134 0a393134                416.417.418.419.
> 00000620: 0a303234 0a313234 0a323234 0a333234                420.421.422.423.
> 00000630: 0a343234 0a353234 0a363234 0a373234                424.425.426.427.
> 00000640: 0a383234 0a393234 0a303334 0a313334                428.429.430.431.
> 00000650: 0a323334 0a333334 0a343334 0a353334                432.433.434.435.
> 00000660: 0a363334 0a373334 0a383334 0a393334                436.437.438.439.
> 00000670: 0a303434 0a313434 0a323434 0a333434                440.441.442.443.
> 00000680: 0a343434 0a353434 0a363434 0a373434                444.445.446.447.
> 00000690: 0a383434 0a393434 0a303534 0a313534                448.449.450.451.
> 000006a0: 0a323534 0a333534 0a343534 0a353534                452.453.454.455.
> 000006b0: 0a363534 0a373534 0a383534 0a393534                456.457.458.459.
> 000006c0: 0a303634 0a313634 0a323634 0a333634                460.461.462.463.
> 000006d0: 0a343634 0a353634 0a363634 0a373634                464.465.466.467.
> 000006e0: 0a383634 0a393634 0a303734 0a313734                468.469.470.471.
> 000006f0: 0a323734 0a333734 0a343734 0a353734                472.473.474.475.
> 00000700: 0a363734 0a373734 0a383734 0a393734                476.477.478.479.
> 00000710: 0a303834 0a313834 0a323834 0a333834                480.481.482.483.
> 00000720: 0a343834 0a353834 0a363834 0a373834                484.485.486.487.
> 00000730: 0a383834 0a393834 0a303934 0a313934                488.489.490.491.
> 00000740: 0a323934 0a333934 0a343934 0a353934                492.493.494.495.
> 00000750: 0a363934 0a373934 0a383934 0a393934                496.497.498.499.
> 00000760: 0a303035 0a313035 0a323035 0a333035                500.501.502.503.
> 00000770: 0a343035 0a353035 0a363035 0a373035                504.505.506.507.
> 00000780: 0a383035 0a393035 0a303135 0a313135                508.509.510.511.
> 00000790: 0a323135 0a333135 0a343135 0a353135                512.513.514.515.
> 000007a0: 0a363135 0a373135 0a383135 0a393135                516.517.518.519.
> 000007b0: 0a303235 0a313235 0a323235 0a333235                520.521.522.523.
> 000007c0: 0a343235 0a353235 0a363235 0a373235                524.525.526.527.
> 000007d0: 0a383235 0a393235 0a303335 0a313335                528.529.530.531.
> 000007e0: 0a323335 0a333335 0a343335 0a353335                532.533.534.535.
> 000007f0: 0a363335 0a373335 0a383335 0a393335                536.537.538.539.
> 00000800: 0a303435 0a313435 0a323435 0a333435                540.541.542.543.
> 00000810: 0a343435 0a353435 0a363435 0a373435                544.545.546.547.
> 00000820: 0a383435 0a393435 0a303535 0a313535                548.549.550.551.
> 00000830: 0a323535 0a333535 0a343535 0a353535                552.553.554.555.


Because the data looks right(?), despite the error prints, I tried
ubiformat again from barebox, then booted linux from SD, and attached
the ubi nand partition in linux... which worked fine.
All volumes and data were there.

Very confused about what's going wrong here.

--

I have since also tried attaching from barebox again, ignoring all the
errors. It does (after several minutes) finally succeed in attaching,
and recognizes all volumes.

Tibault

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nand "BCH decoding failed" when using bch8_hw_romcode ecc mode
  2022-03-18 10:32   ` Tibault Damman
@ 2022-03-18 11:59     ` Sascha Hauer
  2022-03-18 21:41       ` Trent Piepho
  2022-03-21  8:04       ` Tibault Damman
  0 siblings, 2 replies; 7+ messages in thread
From: Sascha Hauer @ 2022-03-18 11:59 UTC (permalink / raw)
  To: Tibault Damman; +Cc: barebox

On Fri, Mar 18, 2022 at 11:32:36AM +0100, Tibault Damman wrote:
> Gah, I just saw how that mail was sent, let me try that again:
> 
> 
> Because the data looks right(?), despite the error prints, I tried
> ubiformat again from barebox, then booted linux from SD, and attached
> the ubi nand partition in linux... which worked fine.
> All volumes and data were there.
> 
> Very confused about what's going wrong here.

You can correctly write to the NAND and can even correctly read the
data, that's good news.

Reading is done in omap_gpmc_read_page_bch_rom_mode(). Here we have this
to read the OOB data:

> 	p = chip->oob_poi;
> 
> 	p += omap_gpmc_read_buf_manual(chip, p, 2, 5);
> 
> 	for (i = 0; i < 4; i++) {
> 		p += omap_gpmc_read_buf_manual(chip, p, 13, i + 1);
> 		p += omap_gpmc_read_buf_manual(chip, p, 1, 5);
> 	}

omap_gpmc_read_buf_manual() is called with uneven numbers of bytes. This
goes down to omap_read_buf_pref():

> 	/* take care of subpage reads */
> 	if (len % 4) {
> 		if (info->nand.options & NAND_BUSWIDTH_16)
> 			readsw(info->cs_base, buf, (len % 4) / 2);
> 		else
> 			readsb(info->cs_base, buf, len % 4);
> 		p = (u32 *) (buf + len % 4);
> 		len -= len % 4;
> 	}

This can't work properly for 16bit NANDs.

I don't know how to do this correctly though, you'll have to experiment
a bit here.

Have a look at "md -s /dev/nand0.raw 0+2112", then you can see how the
OOB data should look like and compare it with the data read in
omap_gpmc_read_page_bch_rom_mode(). The ".raw" is important, I saw you
printed 2112 bytes from a non raw device. I meant to print a single
page, on a non raw device that would be 2048. You might have to enable
CONFIG_MTD_RAW_DEVICE to get the raw device.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nand "BCH decoding failed" when using bch8_hw_romcode ecc mode
  2022-03-18 11:59     ` Sascha Hauer
@ 2022-03-18 21:41       ` Trent Piepho
  2022-03-21  8:04       ` Tibault Damman
  1 sibling, 0 replies; 7+ messages in thread
From: Trent Piepho @ 2022-03-18 21:41 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Tibault Damman, barebox

On Fri, Mar 18, 2022 at 5:00 AM Sascha Hauer <sha@pengutronix.de> wrote:
>
> On Fri, Mar 18, 2022 at 11:32:36AM +0100, Tibault Damman wrote:
> > Gah, I just saw how that mail was sent, let me try that again:
> >
> >
> > Because the data looks right(?), despite the error prints, I tried
> > ubiformat again from barebox, then booted linux from SD, and attached
> > the ubi nand partition in linux... which worked fine.
> > All volumes and data were there.
> >
> > Very confused about what's going wrong here.
>
> You can correctly write to the NAND and can even correctly read the
> data, that's good news.

Yes, NAND hardware likely works fine.  This looks like a BCH layout flaw to me.

Some background:  (for Tibault, I'm sure Sascha knows this!)

Normal read/writes to NAND use some kind of ECC.  The real data is
written, unmodified, to NAND, and then also some extra bytes of ECC
information.  The real data and the ECC data are probably interleaved
in various complicated ways that are a pain to deal with.

Suppose the ECC data isn't done correctly.  It's generated
incorrectly, *written to the wrong spot*, read from the wrong
location, etc.  It doesn't work.  But we still write the real data
somewhere too.  And can then read it back from that same place.  Maybe
we are writing the real data to the incorrect locations, but as long
as we read it back from the same incorrect locations, it appears to
work.

So what happens?  We can write data, then read it back, but get many
ECC errors, because ECC is broken.

This looks like your problem.

ECC needs to work, as modern MLC/TLC/QLC NAND is not reliable enough
to use without ECC.  You can test one page one time and it worked with
no errors, but test the entire chip many times and it will become
clear it just isn't good enough.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: nand "BCH decoding failed" when using bch8_hw_romcode ecc mode
  2022-03-18 11:59     ` Sascha Hauer
  2022-03-18 21:41       ` Trent Piepho
@ 2022-03-21  8:04       ` Tibault Damman
  1 sibling, 0 replies; 7+ messages in thread
From: Tibault Damman @ 2022-03-21  8:04 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 18/03/2022 12:59, Sascha Hauer wrote:
> Have a look at "md -s /dev/nand0.raw 0+2112", then you can see how the
> OOB data should look like and compare it with the data read in
> omap_gpmc_read_page_bch_rom_mode(). The ".raw" is important, I saw you
> printed 2112 bytes from a non raw device. I meant to print a single
> page, on a non raw device that would be 2048. 

Oh thank god, I'm not gonna lie, I was kinda worried when I saw no
non-data bytes.

> You might have to enable CONFIG_MTD_RAW_DEVICE to get the raw device.

Thanks, that's exactly why I couldn't find the raw device.

Linux writes:
> ...
> 000007f0: 0a363335 0a373335 0a383335 0a393335                536.537.538.539.
> 00000800: a060ffff 7286981b 604c42b1 002b5238                ..`....r.BL`8R+.
> 00000810: 9ed8f629 4709bc76 8b658d4d 606e000c                )...v..GM.e...n`
> 00000820: 0d54d92c 98ec3c7d 0048f800 4e9ee01e                ,.T.}<....H....N
> 00000830: 3b4d302e 72844fa4 ffff0099 ffffffff                .0M;.O.r........
                                  ^^
Barebox writes:
> ...
> 000007f0: 0a363335 0a373335 0a383335 0a393335                536.537.538.539.
> 00000800: a060ffff 7286981b 604c42b1 002b5238                ..`....r.BL`8R+.
> 00000810: 9ed8f629 4709bc76 8b658d4d 606e000c                )...v..GM.e...n`
> 00000820: 0d54d92c 98ec3c7d 0048f800 4e9ee01e                ,.T.}<....H....N
> 00000830: 3b4d302e 72844fa4 ffff6e99 ffffffff                .0M;.O.r.n......
                                  ^^

So, interestingly, there does appear to be a 1 byte difference as well...

I'll have a look at the code you mentioned.


Thanks again

Tibault

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-21  8:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 13:45 nand "BCH decoding failed" when using bch8_hw_romcode ecc mode Tibault Damman
2022-03-17  7:46 ` Sascha Hauer
2022-03-18  9:49   ` Tibault Damman
2022-03-18 10:32   ` Tibault Damman
2022-03-18 11:59     ` Sascha Hauer
2022-03-18 21:41       ` Trent Piepho
2022-03-21  8:04       ` Tibault Damman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox