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@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox