This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OMAP4460 : BCH 8-bit HW ECC layout for NAND

Hi,

I am working on a board based on OMAP4460.

I use a 2GB/16Gb nand flash for booting.

Information on NAND
Part : MT29F16G16ADBCA
Device width : 16-bit
Page size : 2048 Words (4096 bytes)
Spare/oob area per page  : 112 Words (224 bytes)
Page per block : 64
No of blocks : 8192

From the OMAP4460 TRM Revision V section "27.4.7.4.2 Read Sector Procedure", I have come
to know that the default ECC correction applied by ROM code is BCH 8b/sector(512 bytes)
using the GPMC and ELM hardware.

Hence i have planned to use the BCH 8-bit HW ECC throughout x-loader, u-boot and linux kernel.

And as per the ECC mapping in the spare/oob area described in same section its
2bytes reserved for block state(at start of oob) + (13 byte ecc + 1 byte padding) per sector.

could anybody tell me if the below ecc layout for my NAND is correct ?

.eccbytes = 104,

                                                /*1    2    3     4    5    6    7    8    9    10   11   12   13*/

                              .eccpos   = { 2,   3,   4,   5,   6,   7,   8,   9,  10,   11,  12,  13,  14,            /* sector 1 */    

                                                16,  17,  18,  19,  20,  21,  22,  23,  24,   25,  26,  27,  28,        /* sector 2 */

                                                 30,  31,  32,  33,  34,  35,  36,  37,  38,   39,  40,  41,  42,        /* sector 3 */

                                                 44,  45,  46,  47,  48,  49,  50,  51,  52,   53,  54,  55,  56,        /* sector 4 */

                                                 58,  59,  60,  61,  62,  63,  64,  65,  66,   67,  68,  69,  70,        /* sector 5 */

                                                 72,  73,  74,  75,  76,  77,  78,  79,  80,   81,  82,  83,  84,        /* sector 6 */

                                                 86,  87,  88,  89,  90,  91,  92,  93,  94,   95,  96,  97,  98,        /* sector 7 */

                                                100, 101, 102, 103, 104, 105, 106, 107, 108,  109, 110, 111, 112 }     /* sector 8 */

 

 Also please point me to any other things that i need to take care.

 Regards,

Murali

  • Could anyone please reply to the above post ?

  • Murali,

    Are you able to boot the device from NAND? If so, then try the command "nand dump 0x0"? This will print the working layout. You can try matching the layout with the layout given above.

  • Hi Renjith,

    Thanks for your response.

    I cannot test it on the board, as it is currently in design stage and i am working
    on porting x-loader,u-boot to support NAND flash booting for OMAP4460.

    You have suggested to get the information from "working layout". I guess this ecc layout
    would be the layout which was used to flash/write the images to the NAND flash.

    In that case, i plan to use fastboot as the tool to flash the images to the NAND flash,
    and i would be fixing the ecc layout for that also.

    I can implement a common ecc scheme across x-loader, u-boot and linux kernel but my
    concern is that how would i come to know the ecc layout that the rom code expects the
    x-loader partition to have.

    The rom code would only read the x-loader image and check the ecc and would not do any
    write operation to the spare/oob area of the pages in that partition. Correct me if am wrong.

    Hence i would like to know that whether the layout which i mentioned in my question is
    the one used by the ROM code of OMAP4460.


    Regards,
    Murali.M

  • Murali,

    I feel the layout that you've depicted is correct even though there is no much information given about 4K page and BCH8 layout. 

    Also have you checked this point? 

    "For device ID codes D3h, C3h, D5h, C5h, D7h, C7h, DEh, CEh when the manufacturer code (first ID byte) is 98h, the cell type information is checked in the 4th byte of ID data. If it is equal to 10b, the ECC correction applied is BCH 16b/sector."

  • Hi murali  

                                     go through  link  http://www.linux-mtd.infradead.org/tech/mtdnand/x111.html

  • Hi Renjith,

    The device ID code for my NAND part is 0xB5 and hence the 16b/sector layout does not apply to it.

    I have seen in one of the posts in e2e.ti.com where it was mentioned that if ROM code find sufficient

    space in the spare area of the NAND page to support BCH 16b, it would prefer the BCH 16b/sector

    ECC algorithm. I have not bookmarked that page and am unable to find it now. I will try to confirm that point.

     

    Thanks for your response.

    Regards,

    Murali.M

  • Hi Prashant,

    I had gone through the link some time ago while refering the linux mtd framework. From that link

    i  understood the way of adding custom HW Ecc layout.

    Anyway thanks for your suggestion :).

     

    Regards,

    Murali.M

  • Murali,

    Just go ahead and try with BCH8 and see what happens. 

  • Murali,

    Is this working for you now?

    Regards,
    Gina 

  • Hi Gina,

    As i have mentioned earlier in this post that the board is still in design stage,

    i cannot test it now. I will update my results/observations once i get a chance

    to test it.

    Thanks & Best Regards,

    Murali.M

  • Hi Murali.M n All,

    I am now working on PandaBoard OMAP4460.

    Before, I used SD card for booting. But now I plan to use NAND flash.

    I started off it by investigating how to flash u-boot and x-loader to NAND from SD card: http://www.sakoman.com/OMAP/how-to-write-x-loader-to-nand.html

    There is a command in u-boot: "nand write ${loadaddr}  ${offset} ${filesize}" but I don't know how I can find these three arguments? It may be the memory partitioning for each file as used on PandaBoard. Anyone help?

    Since it is the first time working with NAND, I don't know where to start. Could you please show me some references? Which do I need to modify in u-boot and file system?

    Thanks,

    Jack

  • Jack, There is no nand flash available on pandaboard.
  • Hi Renjith Thomas,

    Yes, PandaBoard is the reference board. My board is on design state, and I decide to use NAND instead of SD card.

    Any help is really useful for me to start with!

    Thanks for your reply,

    Jack

  • Jack,

    The variables are explained below.

     ${loadaddr} -> This is the DDR address where the X-loader binary image is loaded from the SD card. It will be DDR-SDRAM memory address. You can give something like 0x8050_0000 as an example.

    ${offset} -> Offset inside NAND. This can be 0x0 for x-loader.

    ${filesize} -> Size of the x-loader image to be flashed to NAND.

  • Hi Renjith, and All,

    Thanks for your clear explaination!

    As I investigated so far, I have some unclear points as the following, please support me:

    1. Where I can fine NAND partition to define {offset} of u-boot, kernel, file system? Because as I see in my "kernel/arch/arm/mach-omap2/" directory: file "board-omap3beagle.c" defined omap3beagle_nand_partitions, but in file "board-omap4panda.c", nand_partion is not defined?

    2. Since NAND flash not available in current PandaBoard OMAP4. So If I use NAND, do I need to add/modify anything in u-boot or kernel to adapt with my NAND? If yes, which file should be modified? or Do I need to write own driver for NAND?

    3. As I know, there are 2 ways to file system to NAND, and it is recommend to use the 2nd way (using kernel). But with this way, I have to choose the format of file system support NAND (JFFS2 or UBIFS) and need the corresponding util (MTD..).

    I checked in "kernel/fs" directory, there are UBIFS, JFFS2 both. Could you please tell me which one should I use for NAND flash? And if i use it, I need to modify or configure something. Is it right?


    Please help me with any above. Any help will be greatly appreciated!

    Thanks and best regards,

    Jack

  • Jack,

    1. You can define your own offsets and change the code accordingly, except for MLO(x-loader). Make sure that you read from the same location from where you are writing.

    2. Yes, you've to add support for NAND in "board-omap4panda.c" as well as you've to declare the partitions. These partitions doesn't do anything with the NAND except for Filesystem partitions. 

    3. You can use any one of  JFFS2, UBIFS. UBIFS will be faster for mounting and better performing. 

  • Hi Renjith, and All,

    Thanks for your help!

    Since OMAP4460 support booting from MMC interface2 (eMMC), I planed moving to use eMMC instead bare NAND as mentioned before.

    May I ask you some questions:

    1. With using eMMC (slot2), OMAP4460 supports only RAW boot method, we don't need to care about format partition (for all images)? Am I right?

    2. As an embedded device, to flash eMMC, we need to boot-up the system from a SD card (which contains all the necessary files), then flash (copy) x-loader & u-boot image to eMMC using u-boot commands (mmc read/write...). With above, we need a boot-able SD card. But now I am finding another way to run u-boot without booting-up from SD card. That would be from UART or USB. Could you guys provide me any methods/utils to boot from these peripherals for my Panda?

    Any help?

    Thanks,

    Jack

  • Jack,

    Regarding the points that you've mentioned.

    1. You are right. Only raw boot is supported in eMMC2.

    2. You can use any of the tools 

    OMAP Flash tool given in the first post -> http://forum.xda-developers.com/showthread.php?t=1242330

    http://omappedia.org/wiki/Zoom_Flashing