uBoot MXS NAND Driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

uBoot MXS NAND Driver

1,098 Views
mus
Contributor III

We are working with the mxs nand driver in uBoot on iMX6SX. uBoot loads the kernel from NAND fine and the kernel boots successfully. However, when we use mxs_nand_ecc_read_page() declared in mxs_nand.c to read a page, the buffer returned doesn't contain all the bytes from the kernel but also includes some ecc sections.

In a separate discussion in the community and research online, we found that there may be 2 ways of raw NAND layout for ECC. The two ways to store the redundant data are:

  1. After every 512 bytes of data. This will cause some original data to be stored in the spare area. In RBL terminology, this is called "compatible mode".
  2. Completely within the spare memory area. Here, the original data is stored in the page followed by all of the redundant data for that page together. This is called "non-compatible mode".

Since the mxs_nand_ecc_read_page() is returning ecc data after the 512 bytes in the buffer, we probably have the first layout described above. 

As far as we can tell from reading the code in this function, the parameters configured suggests that BCH should strip out this extra data and just return the standalone data in the buffer returned. Although it strips the header, it still leaves the extra ecc data in the buffer causing the data to be truncated. But again, uBoot itself can read this area from NAND and put it in DRAM correctly. When we use the mxs_nand_ecc_read_page() from SPL, it fails as described above.

For reference, the NAND ecc layout picture is at iMX28 NAND Flash ECC Layout BBI Swap 

As far as we can tell, there is a 10byte header, 512byte data + 13byte ecc repeated.

How do we resolve this?

  1. Is there a way to configure the NAND ecc implementation for iMX6SX? Can the BCH be configured for "non-compatible mode" vs "compatible mode", either in DCD or in board init?
  2. How do we fix mxs_nand_ecc_read_page() so it returns only the raw data?
Labels (2)
Tags (3)
0 Kudos
2 Replies

893 Views
mus
Contributor III

If anyone is wondering, after patching the bug in NXP's mxs_nand driver in uBoot, SPL is working correctly for i.MX6SoloX.

0 Kudos

893 Views
mus
Contributor III

I think the answer to #1 is no. iMX6 stores the data in compatible mode.

0 Kudos