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.

NAND Problem u-boo

Other Parts Discussed in Thread: OMAP-L138, OMAPL138

Hi.

We are working on OMAP-L138 custom board. We have some problems with all the NAND commands from u-boot.

The nand seems to be correctly identified. but reads and dumps fails with error, write don't seem to be properly:

We are using latest mcsdk_1_01_00_02

Here is my memory contents after fatload command:

U-Boot > md 0xc0700000
c0700000: 56190527 5799701b 62516d56 9f732900    '..V.p.WVmQb.)s.
c0700010: 008000c0 008000c0 ff86a335 00020205    ........5.......
c0700020: 756e696c 2e332d78 332e3431 00354237    linux-3.14.37B5.
c0700030: 00000000 00000000 00000000 00000000    ................
c0700040: e1a00000 e1a00000 e1a00000 e1a00000    ................
c0700050: e1a00000 e1a00000 e1a00000 e1a00000    ................
c0700060: ea000002 016f2818 00000000 00295888    .....(o......X).
c0700070: e10f9000 e1a07001 e1a08002 e10f2000    .....p....... ..
c0700080: e3120003 1a000001 e3a00017 ef123456    ............V4..
c0700090: e321f0d3 e16ff009 00000000 00000000    ..!...o.........
c07000a0: e59f47d8 e1a0000f e1500004 359f0164    .G........P.d..5
c07000b0: 3080000f 31540000 33844001 2b000057    ...0..T1.@.3W..+
c07000c0: e28f0e13 e8901c4e e590d01c e0400001    ....N.........@.
c07000d0: e0866000 e08aa000 e5da9000 e5dae001    .`..............
c07000e0: e189940e e5dae002 e5daa003 e189980e    ................
c07000f0: e1899c0a e08dd000 e28da801 e3a05000    .............P..

When i issue 'nand erase 0x20000 0x80000' then 'nand write.trimffs 0xc0700000 0x20000 0x80000' i get '524288 bytes written OK'

Then when i issue 'nand dump 0x20000' i get:

nand dump 0x20000
Page 00020000 dump:
        27 ff 19 ff 1b ff 99 ff  56 ff 51 ff 00 ff 73 ff
        c0 ff 80 ff c0 ff 80 ff  35 ff 86 ff 05 ff 02 ff
        6c ff 6e ff 78 ff 33 ff  31 ff 2e ff 37 ff 35 ff
        00 ff 00 ff 00 ff 00 ff  00 ff 00 ff 00 ff 00 ff
        00 ff a0 ff 00 ff a0 ff  00 ff a0 ff 00 ff a0 ff
        00 ff a0 ff 00 ff a0 ff  00 ff a0 ff 00 ff a0 ff
        02 ff 00 ff 18 ff 6f ff  00 ff 00 ff 88 ff 29 ff
        00 ff 0f ff 01 ff a0 ff  02 ff a0 ff 00 ff 0f ff
        03 ff 12 ff 01 ff 00 ff  17 ff a0 ff 56 ff 12 ff
        d3 ff 21 ff 09 ff 6f ff  00 ff 00 ff 00 ff 00 ff
        d8 ff 9f ff 0f ff a0 ff  04 ff 50 ff 64 ff 9f ff
        0f ff 80 ff 00 ff 54 ff  01 ff 84 ff 57 ff 00 ff
        13 ff 8f ff 4e ff 90 ff  1c ff 90 ff 01 ff 40 ff
        00 ff 86 ff 00 ff 8a ff  00 ff da ff 01 ff da ff
        0e ff 89 ff 02 ff da ff  03 ff da ff 0e ff 89 ff
        0a ff 89 ff 00 ff 8d ff  01 ff 8d ff 00 ff a0 ff
        01 ff 8a ff 0a ff 54 ff  16 ff 00 ff 09 ff 84 ff
        50 ff 8f ff 09 ff 5a ff  12 ff 00 ff 02 ff 8a ff
        ff ff ca ff 6c ff 4f ff  1f ff c5 ff 05 ff 46 ff
        1f ff 89 ff 1f ff c9 ff  05 ff 89 ff 0a ff 89 ff
        0f ff 36 ff 05 ff 56 ff  0f ff 29 ff fb ff ff ff
        06 ff 49 ff 06 ff 8d ff  50 ff 00 ff a4 ff 4f ff
        06 ff 80 ff 00 ff a0 ff  05 ff 90 ff 0d ff 00 ff
        00 ff 8b ff 00 ff 8c ff  00 ff 82 ff 00 ff 83 ff
        00 ff 9b ff 00 ff 81 ff  02 ff 51 ff 01 ff 53 ff
        05 ff 81 ff 04 ff 8b ff  0c ff 5b ff f7 ff ff ff
        05 ff 82 ff 05 ff 83 ff  00 ff a0 ff 04 ff 82 ff
        04 ff 82 ff 04 ff 82 ff  04 ff 82 ff 03 ff 52 ff
        f9 ff ff ff 01 ff 14 ff  01 ff c4 ff 13 ff 00 ff
        04 ff a0 ff 0d ff a0 ff  01 ff 8d ff 07 ff a0 ff
        0b ff 00 ff 2d ff 00 ff  04 ff 00 ff 07 ff a0 ff
        08 ff a0 ff a4 ff 00 ff  b8 ff 00 ff 88 ff 29 ff
        a8 ff 29 ff 88 ff 29 ff  43 ff 29 ff 54 ff 29 ff
        80 ff 29 ff a8 ff 29 ff  28 ff 39 ff 00 ff 20 ff
        08 ff a0 ff 88 ff 00 ff  3f ff a0 ff 17 ff 06 ff
        37 ff 06 ff 80 ff a0 ff  10 ff 02 ff 30 ff 02 ff
        10 ff 03 ff 03 ff a0 ff  30 ff 05 ff 10 ff 05 ff
        00 ff a0 ff 9a ff 07 ff  15 ff 07 ff 16 ff 07 ff
        10 ff 11 ff 2d ff 80 ff  01 ff 80 ff 10 ff 01 ff
        00 ff a0 ff 15 ff 07 ff  16 ff 07 ff 0e ff a0 ff
        3f ff a0 ff 17 ff 06 ff  80 ff a0 ff 10 ff 02 ff
        10 ff 03 ff 03 ff a0 ff  10 ff 05 ff 00 ff a0 ff
        10 ff 07 ff 10 ff 11 ff  0d ff 80 ff 00 ff a0 ff
        10 ff 01 ff 10 ff 07 ff  0e ff a0 ff 01 ff 44 ff
        ff ff c3 ff 3f ff c3 ff  03 ff a0 ff 20 ff a0 ff
        09 ff a0 ff 01 ff 89 ff  12 ff a0 ff 03 ff 81 ff
        01 ff 83 ff 09 ff 51 ff  01 ff 5a ff 1c ff c1 ff
        10 ff 81 ff 06 ff 81 ff  04 ff 80 ff 01 ff 81 ff
        02 ff 30 ff f6 ff ff ff  04 ff 86 ff 03 ff 81 ff
        0f ff a0 ff 22 ff a0 ff  02 ff 81 ff 02 ff 83 ff
        04 ff 80 ff 01 ff 81 ff  00 ff 80 ff 0e ff a0 ff
        10 ff 11 ff 02 ff c0 ff  01 ff 80 ff 10 ff 01 ff
        01 ff 00 ff 04 ff a0 ff  10 ff ef ff 0e ff a0 ff
        1a ff a0 ff d8 ff ff ff  00 ff a0 ff 9a ff 07 ff
        17 ff 08 ff 10 ff 11 ff  05 ff 80 ff 30 ff 80 ff
        2c ff 00 ff 00 ff a0 ff  17 ff 08 ff 0c ff a0 ff
        0e ff a0 ff 91 ff 10 ff  0f ff 1b ff 0a ff a0 ff
        c9 ff ff ff 00 ff a0 ff  9a ff 07 ff 0f ff 1b ff
        17 ff 08 ff 10 ff 11 ff  01 ff c0 ff 05 ff 80 ff
        3c ff 80 ff 02 ff c0 ff  01 ff 80 ff 50 ff 12 ff
        01 ff 80 ff 02 ff e0 ff  02 ff c6 ff 03 ff c6 ff
        10 ff 02 ff 10 ff 03 ff  50 ff 02 ff 95 ff 07 ff
        10 ff 01 ff 10 ff 11 ff  00 ff a0 ff 95 ff 07 ff
        0c ff a0 ff 0e ff a0 ff  1a ff a0 ff ae ff ff ff
        00 ff a0 ff 17 ff 07 ff  9a ff 07 ff 17 ff 08 ff
        10 ff 11 ff 01 ff 80 ff  02 ff 00 ff 00 ff a0 ff
        17 ff 08 ff 0c ff a0 ff  0d ff 80 ff 00 ff e0 ff
        10 ff 02 ff 10 ff 03 ff  00 ff 00 ff 00 ff 20 ff
        10 ff 01 ff 10 ff 11 ff  20 ff 4e ff 1c ff 8f ff
        10 ff 10 ff 00 ff 9c ff  04 ff 9c ff 09 ff 21 ff
        02 ff 11 ff 03 ff 8c ff  14 ff 8c ff f8 ff ff ff
        00 ff 00 ff 00 ff 00 ff  0e ff a0 ff 0e ff a0 ff
        0e ff a0 ff 00 ff 00 ff  00 ff f8 ff 0e ff a0 ff
        0e ff a0 ff 0e ff a0 ff  00 ff 80 ff 00 ff ff ff
        a9 ff ff ff 65 ff 00 ff  0e ff a0 ff 00 ff 00 ff
        00 ff 00 ff 71 ff ff ff  5a ff 00 ff ea ff 00 ff
        00 ff 00 ff 00 ff 00 ff  56 ff ff ff 4d ff 00 ff
        74 ff 00 ff 60 ff 06 ff  f0 ff 0f ff 98 ff ff ff
        56 ff 00 ff be ff 00 ff  00 ff 00 ff 00 ff 00 ff
        0e ff a0 ff 0e ff a0 ff  0e ff a0 ff 00 ff 01 ff
        e0 ff ff ff 90 ff ff ff  4c ff 00 ff bb ff 00 ff
        10 ff 01 ff f0 ff ff ff  8b ff ff ff 47 ff 00 ff
        b6 ff 00 ff 00 ff 05 ff  00 ff ff ff 86 ff ff ff
        42 ff 00 ff b1 ff 00 ff  00 ff 15 ff 00 ff ff ff
        81 ff ff ff 3d ff 00 ff  a5 ff 00 ff 00 ff 05 ff
        00 ff 0f ff 7c ff ff ff  38 ff 00 ff a0 ff 00 ff
        61 ff 01 ff f1 ff 01 ff  a1 ff ff ff 33 ff 00 ff
        5c ff 00 ff 00 ff 02 ff  00 ff 0f ff 72 ff ff ff
        2e ff 00 ff 9d ff 00 ff  00 ff 05 ff 00 ff 0f ff
        6d ff ff ff 29 ff 00 ff  98 ff 00 ff 00 ff 06 ff
        00 ff 0f ff 68 ff ff ff  24 ff 00 ff 8c ff 00 ff
        00 ff 07 ff 00 ff 0f ff  5c ff ff ff 1f ff 00 ff
        4f ff 00 ff 00 ff 0f ff  00 ff 0f ff 6b ff ff ff
        21 ff 00 ff 51 ff 00 ff  00 ff 00 ff 00 ff 00 ff
        0e ff a0 ff 0e ff a0 ff  0e ff a0 ff 00 ff 20 ff
        00 ff 20 ff 00 ff 20 ff  00 ff 20 ff 00 ff 20 ff
        0c ff a0 ff 90 ff ff ff  10 ff 11 ff 0d ff c0 ff
        10 ff 01 ff 00 ff a0 ff  9a ff 07 ff 16 ff 07 ff
        15 ff 07 ff 0e ff a0 ff  10 ff 11 ff 0d ff c0 ff
        10 ff 01 ff 00 ff a0 ff  10 ff 07 ff 0e ff a0 ff
        10 ff 11 ff 0d ff c0 ff  10 ff 01 ff 00 ff a0 ff
        17 ff 07 ff 17 ff 08 ff  0e ff a0 ff 10 ff 11 ff
        0d ff c0 ff 10 ff 01 ff  0e ff a0 ff 2b ff 00 ff
        00 ff a0 ff 17 ff 08 ff  d5 ff 07 ff 9a ff 07 ff
        95 ff 07 ff 0c ff a0 ff  00 ff 20 ff 00 ff 20 ff
        00 ff 20 ff 00 ff 20 ff  00 ff 20 ff 00 ff 20 ff
        10 ff a0 ff 68 ff ff ff  01 ff 14 ff 0e ff a0 ff
        01 ff a0 ff 00 ff a0 ff  16 ff 07 ff e0 ff a0 ff
        3f ff 81 ff 5e ff 07 ff  01 ff 53 ff fc ff ff ff
        20 ff 51 ff f9 ff ff ff  00 ff 32 ff 15 ff 07 ff
        9a ff 07 ff 0e ff a0 ff  01 ff 14 ff 0e ff a0 ff
        00 ff a0 ff 1e ff 07 ff  15 ff 07 ff 9a ff 07 ff
        0e ff a0 ff 00 ff a0 ff  01 ff 14 ff 1e ff 07 ff
        15 ff 07 ff 1f ff 07 ff  9a ff 07 ff 0e ff a0 ff
        01 ff 14 ff 29 ff 00 ff  b1 ff 10 ff 0f ff 1a ff
        00 ff a0 ff 01 ff 00 ff  1e ff 07 ff 23 ff 00 ff
        ba ff 07 ff ff ff 2d ff  30 ff 30 ff 07 ff 10 ff
        a3 ff a0 ff 1a ff 00 ff  00 ff a0 ff aa ff 8a ff
        30 ff a0 ff 07 ff 01 ff  02 ff 51 ff 11 ff 00 ff
        10 ff 40 ff 95 ff 07 ff  10 ff 30 ff 07 ff 01 ff
        04 ff 82 ff f8 ff 9f ff  a1 ff 14 ff 14 ff 6f ff
        f0 ff 9f ff a1 ff 17 ff  04 ff a0 ff 19 ff 8a ff
        17 ff 8b ff 5e ff 07 ff  01 ff 59 ff fa ff ff ff
        01 ff 57 ff f7 ff ff ff  02 ff 8a ff 0a ff 53 ff
        e5 ff ff ff ff ff bd ff  00 ff a0 ff 10 ff 40 ff
        9a ff 07 ff 15 ff 07 ff  9a ff 07 ff 95 ff 07 ff
        0e ff a0 ff 01 ff 14 ff  0e ff a0 ff 7e ff 17 ff
        fd ff ff ff 15 ff 07 ff  9a ff 07 ff 0e ff a0 ff
OOB:
        ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff
        f3 ff f3 ff a6 ff 99 ff
        ab ff 5a ff aa ff 5b ff
        c0 ff 99 ff 67 ff 96 ff
Command failed, result=1

when i issue 'nand read 0xc0700000 0x20000 0x80000' i get:

NAND read: device 0 offset 0x20000, size 0x80000
NAND read from offset 20000 failed -74
 0 bytes read: ERROR

My UBOOT configuration for nand is:

#ifdef CONFIG_USE_NAND
#undef CONFIG_ENV_IS_IN_FLASH
#define CONFIG_NAND_DAVINCI
#define CONFIG_SYS_NO_FLASH
#undef CONFIG_ENV_IS_IN_NAND            /* U-Boot env in NAND Flash  */
#define CONFIG_ENV_IS_NOWHERE
#define CONFIG_ENV_OVERWRITE
//#define CFG_DAVINCI_STD_NAND_LAYOUT
#define CONFIG_CMD_NAND_TRIMFFS
#define CONFIG_MTD_DEVICE
#define CONFIG_MTD_PARTITIONS
#define CONFIG_CMD_MTDPARTS

#define CONFIG_MTDDEBUG 

#define CONFIG_ENV_OFFSET 0x0 /* Block 0--not used by bootcode */ #define CONFIG_ENV_SIZE (128 << 9) #define CONFIG_MTD_DEVICE #define CONFIG_SYS_NAND_USE_FLASH_BBT #define CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST #define CONFIG_SYS_NAND_PAGE_2K #undef CONFIG_SYS_NAND_BUSWIDTH_16_BIT #define CONFIG_SYS_NAND_CS 2 #define CONFIG_SYS_NAND_BASE DAVINCI_ASYNC_EMIF_DATA_CE3_BASE #define CONFIG_SYS_CLE_MASK 0x10 #define CONFIG_SYS_ALE_MASK 0x8 #undef CONFIG_SYS_NAND_HW_ECC #define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND devices */ #define NAND_MAX_CHIPS 1 #endif

What could be the cause for this fault? 

Kind Regards

  • Dear MoonDrop,
    Currently where u-boot resides ?
    On flash or SD card ?

    i.e Able to boot u-boot from NAND ?

    Do NFS boot and try to access the mtdpartitions...

    Please mention your NAND part no.
  • Hi. Thanks for reply.

    U-boot currently resided on MMC. I am not able to boot u-boot from nand because the nand write/read won't work ;p. nand write don't write the data correctly.

    I use fatload to get uImage into memory, i check memory with md, and see the uImage loaded correctly, and i can load the kernel then and file system.

    but look at the following sequence

    U-Boot > nand scrub 0x20000 0x500000
    
    NAND scrub: device 0 offset 0x20000, size 0x500000
    Warning: scrub option will erase all factory set bad blocks!
             There is no reliable way to recover them.
             Use this command only for testing purposes if you
             are sure of what you are doing!
    
    Really scrub this NAND flash? <y/N>
    Erasing at 0x500000 -- 100% complete.
    Bad block table not found for chip 0
    Bad block table not found for chip 0
    Bad block table written to 0x000007fe0000, version 0x01
    Bad block table written to 0x000007fc0000, version 0x01
    OK
    
    after fatload:
    2716639 bytes read
    U-Boot > md 0xc0700000
    c0700000: 56190527 5799701b 62516d56 9f732900    '..V.p.WVmQb.)s.
    c0700010: 008000c0 008000c0 ff86a335 00020205    ........5.......
    c0700020: 756e696c 2e332d78 332e3431 00354237    linux-3.14.37B5.
    c0700030: 00000000 00000000 00000000 00000000    ................
    c0700040: e1a00000 e1a00000 e1a00000 e1a00000    ................
    c0700050: e1a00000 e1a00000 e1a00000 e1a00000    ................
    c0700060: ea000002 016f2818 00000000 00295888    .....(o......X).
    c0700070: e10f9000 e1a07001 e1a08002 e10f2000    .....p....... ..
    c0700080: e3120003 1a000001 e3a00017 ef123456    ............V4..
    c0700090: e321f0d3 e16ff009 00000000 00000000    ..!...o.........
    c07000a0: e59f47d8 e1a0000f e1500004 359f0164    .G........P.d..5
    c07000b0: 3080000f 31540000 33844001 2b000057    ...0..T1.@.3W..+
    c07000c0: e28f0e13 e8901c4e e590d01c e0400001    ....N.........@.
    c07000d0: e0866000 e08aa000 e5da9000 e5dae001    .`..............
    c07000e0: e189940e e5dae002 e5daa003 e189980e    ................
    c07000f0: e1899c0a e08dd000 e28da801 e3a05000    .............P..
    

    then:

    U-Boot > nand write.e 0xc0700000 0x20000 0x2973DF
    
    NAND write: device 0 offset 0x20000, size 0x2973df
     2716639 bytes written: OK
    U-Boot > 
    

    then:

     nand read 0xc0700000 0x20000 0x2973df
    
    NAND read: device 0 offset 0x20000, size 0x2973df
    NAND read from offset 20000 failed -74
     0 bytes read: ERROR
    Command failed, result=1

    so both read and write not to seem working ok. Now something that bothers me is the message of: '

    Bad block table written to 0x000007fe0000, version 0x01

    Why the address is so long, it seems that there is some mistmach in sizes. it seems that every second byte is written as 0xFF, as if it is trying to write 2byte word where the second byte is always 0xFF, and the 0x000007fe0000 address make me think it's some kind sizes/length mismatch in the driver.

    It's 8 bit nand 1Gb Micron MT29F1G08ABB nand.

    Thanks :)

  • Dear MoonDrop,

    Apologize for the delayed response.

    Please make sure that you have used the proper NAND timings of your NAND.


    #define CONFIG_SYS_NAND_PAGE_2K
    #undef CONFIG_SYS_NAND_BUSWIDTH_16_BIT
    #define CONFIG_SYS_NAND_CS 2
    #define CONFIG_SYS_NAND_BASE DAVINCI_ASYNC_EMIF_DATA_CE3_BASE
    #define CONFIG_SYS_CLE_MASK 0x10
    #define CONFIG_SYS_ALE_MASK 0x8
    #undef CONFIG_SYS_NAND_HW_ECC
    #define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND devices */
    #define NAND_MAX_CHIPS 1
    #endif


    Your configurations seems to be CS2 but you mentioned CS3 address space.

    What is your CS for NAND flash ?

    CS3 is the recommended for NAND flash and CS2 for NOR flash, please refer to TRM of OMAPL138.

    If still you used CS2 then do the following.

    #define CONFIG_SYS_NAND_CS 2
    #define CONFIG_SYS_NAND_BASE DAVINCI_ASYNC_EMIF_DATA_CE2_BASE
  • Also please make sure that you have done necessary changes for your 8bit NAND flash.

    board/davinci/da8xxevm/omapl138_lcdk.c

    206 #ifdef CONFIG_NAND_DAVINCI
    207 /*
    208 * NAND CS setup - cycle counts based on da850evm NAND timings in the
    209 * Linux kernel @ 25MHz EMIFA
    210 */
    //Titus: Cross check NAND timings for your flash here
    211 writel((DAVINCI_ABCR_WSETUP(15) |
    212 DAVINCI_ABCR_WSTROBE(63) |
    213 DAVINCI_ABCR_WHOLD(7) |
    214 DAVINCI_ABCR_RSETUP(15) |
    215 DAVINCI_ABCR_RSTROBE(63) |
    216 DAVINCI_ABCR_RHOLD(7) |
    217 DAVINCI_ABCR_TA(3) |
    218 DAVINCI_ABCR_ASIZE_16BIT), //For 16bit NAND flash: Titus: You may have to change to 8bit
    219 &davinci_emif_regs->ab2cr); /* CS3 */
    220 #endif
  • Hi.

    That was Helpful :), it actually almost solved the problem. After changing timings and bus width, there were still some error while reading from specific offsets from the nand. it seems like it tries to read the oob from the wrong place. I had to remove the following in nand_base:

    if (!(busw & NAND_BUSWIDTH_16) &&*maf_id == NAND_MFR_STMICRO && mtd->writesize == 2048) {
        chip->options |= NAND_BBT_SCANBYTE1AND6;
        chip->badblockpos = 0;
    }

    And also change the nand layout in davinci_nand.c to :

    /*      .eccbytes = 40,
            .eccpos = {
                    24, 25, 26, 27, 28,
                    29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
                    39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
                    49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
                    59, 60, 61, 62, 63,
                    },
            .oobfree = {
                    {.offset = 2, .length = 22, },
            },*/
    // NOTE: old layout commented, new layout below
            .eccbytes = 10,
            .eccpos = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
                       22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
                       38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
                       54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
                    },
            .oobfree = {
                            {.offset = 0, .length = 6},
                            {.offset = 16, .length = 6},
                            {.offset = 32, .length = 6},
                            {.offset = 48, .length = 6},
                    }
    

    That seems to fix the issues (the visible issues at least ;)

    Kind regards 

    Titusrathinaraj Stalin thank you for your help :)

  • Dear MoonDrop,
    Glad to hear that you were able to solve the problem.
  • Hi.

    Well apparently, i only thought this was over :0

    Now there is problems with nand reading ubi file-system.... have a look:

    I create a ubi image using

    mkfs.ubifs -r . -o myrfs.ubi -m 2048 -e 126976 -c 380

    then put the image on fat partition on sd card. then loading from u-boot the following happens:

    U-Boot > mtdparts 
    
    device nand0 <davinci.nand>, # parts = 6
     #: name                size            offset          mask_flags
     0: ubl                0x00020000      0x00000000      0
     1: uboot               0x001e0000      0x00020000      0
     2: uimage1             0x00400000      0x00200000      0
     3: uimage2             0x00400000      0x00600000      0
     4: rfs1                0x03000000      0x00a00000      0
     5: rfs2                0x03000000      0x03a00000      0
    
    active partition: nand0,0 - (ubl) 0x00020000 @ 0x00000000
    
    defaults:
    mtdids  : none
    mtdparts: none
    
    

    U-Boot > nand erase 0xa00000 0x3000000

    NAND erase: device 0 offset 0xa00000, size 0x3000000
    Erasing at 0x39e0000 -- 100% complete.
    OK

    U-Boot > ubi part rfs1
    
    Creating 1 MTD partitions on "nand0":
    0x000000a00000-0x000003a00000 : "mtd=4"
    UBI: attaching mtd1 to ubi0
    UBI: physical eraseblock size:   131072 bytes (128 KiB)
    UBI: logical eraseblock size:    129024 bytes
    UBI: smallest flash I/O unit:    2048
    UBI: sub-page size:              512
    UBI: VID header offset:          512 (aligned 512)
    UBI: data offset:                2048
    UBI: empty MTD device detected
    UBI: create volume table (copy #1)
    UBI: create volume table (copy #2)
    UBI: attached mtd1 to ubi0
    UBI: MTD device name:            "mtd=4"
    UBI: MTD device size:            48 MiB
    UBI: number of good PEBs:        384
    UBI: number of bad PEBs:         0
    UBI: max. allowed volumes:       128
    UBI: wear-leveling threshold:    4096
    UBI: number of internal volumes: 1
    UBI: number of user volumes:     0
    UBI: available PEBs:             377
    UBI: total number of reserved PEBs: 7
    UBI: number of PEBs reserved for bad PEB handling: 3
    UBI: max/mean erase counter: 1/0
    

    U-Boot > ubi create cont
    No size specified -> Using max size (48642048)
    Creating dynamic volume cont of size 48642048
    

     

    U-Boot > fatload mmc 0:1 0xc0700000 myrfs.ubi
    reading myrfs.ubi
    
    42061824 bytes read
    

    U-Boot > ubi write 0xc0700000 cont 0x281D000
    42061824 bytes written to volume cont
    

    then:

    U-Boot > ubifsmount cont
    UBIFS: mounted UBI device 0, volume 0, name "cont"
    UBIFS: mounted read-only
    UBIFS: file system size:   47351808 bytes (46242 KiB, 45 MiB, 367 LEBs)
    UBIFS: journal size:       6451200 bytes (6300 KiB, 6 MiB, 50 LEBs)
    UBIFS: media format:       w4/r0 (latest is w4/r0)
    UBIFS: default compressor: LZO
    UBIFS: reserved for root:  0 bytes (0 KiB)

    U-Boot > ubifsls
    <DIR>        6784  Mon Nov 30 07:50:55 2015  bin
    <DIR>        4456  Mon Mar 30 15:28:53 2015  dev
    <DIR>        5000  Mon Dec 07 14:42:49 2015  etc
    <DIR>        6256  Tue Dec 01 13:22:22 2015  lib
    <DIR>         808  Sun Nov 22 14:12:48 2015  mnt
    <DIR>         224  Sun Mar 29 08:50:17 2015  opt
    <DIR>         224  Wed Nov 06 04:31:21 2013  srv
    <LNK>           8  Sun Mar 29 08:54:59 2015  tmp
    <DIR>         160  Wed Nov 06 02:57:30 2013  sys
    <DIR>         872  Sun Mar 29 08:53:47 2015  var
    <DIR>         736  Sun Mar 29 17:54:19 2015  usr
    <DIR>         160  Sun Mar 29 16:54:59 2015  boot
    <DIR>         224  Wed Nov 06 04:31:26 2013  home
    <DIR>         160  Wed Nov 06 02:57:30 2013  proc
    <DIR>       11672  Tue Dec 01 13:26:29 2015  sbin
    <LNK>          11  Mon Nov 30 07:50:55 2015  linuxrc
    <DIR>         752  Sun Mar 29 17:27:32 2015  media
    <DIR>         224  Tue Dec 01 13:26:29 2015  share
    

    So far so good... But then after the steps above, i perform hard reset, then again in uboot i issue:

    U-Boot > mtdparts 
    
    device nand0 <davinci.nand>, # parts = 6
     #: name                size            offset          mask_flags
     0: ubl                 0x00020000      0x00000000      0
     1: uboot               0x001e0000      0x00020000      0
     2: uimage1             0x00400000      0x00200000      0
     3: uimage2             0x00400000      0x00600000      0
     4: rfs1                0x03000000      0x00a00000      0
     5: rfs2                0x03000000      0x03a00000      0
    
    active partition: nand0,0 - (ubl) 0x00020000 @ 0x00000000
    
    defaults:
    mtdids  : none
    mtdparts: none
    U-Boot > ubi part rfs1
    

    and i get:

    U-Boot > ubi part rfs1
    Creating 1 MTD partitions on "nand0":
    0x000000a00000-0x000003a00000 : "mtd=4"
    UBI: attaching mtd1 to ubi0
    UBI: physical eraseblock size:   131072 bytes (128 KiB)
    UBI: logical eraseblock size:    129024 bytes
    UBI: smallest flash I/O unit:    2048
    UBI: sub-page size:              512
    UBI: VID header offset:          512 (aligned 512)
    UBI: data offset:                2048
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 0:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 0:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 1:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 1:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 33:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 33:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 34:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 34:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 35:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 35:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 36:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 36:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 37:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 37:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 38:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 38:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 39:0, read 64 bytes
    UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 39:512, read 512 bytes
    UBI error: ubi_io_read: error -74 while reading 64 bytes from PEB 40:0, read 64 bytes
    

    Why is that? a second ago it was showing me the ubifs correctly, i did not load the kernel or anything, just performed reset... what can be the cause??

    Also another problem is when i try to mount it as rootfs... (the following is immediatly after burning ubi to nand):

    my bootargs are :

    mem=64M noinitrd init=/sbin/init.sysvinit rootfstype=ubifs ubi.mtd=5,512 rw rootwait panic=5 root=ubi0:rootfs earlyprink ip=off psplash=false

    And it fails with:

        3.821748] NET: Registered protocol family 17
    [    3.850699] UBI: attaching mtd5 to ubi0
    [    3.858408] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
    [    3.870700] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
    [    3.882224] mmc0: new high speed SDHC card at address e624
    [    3.888428] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
    [    3.902295] mmcblk0: mmc0:e624 SU32G 29.7 GiB 
    [    3.911449] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read 64 bytes
    [    3.923143] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 0:512, read only 512 bytes, retry
    [    3.935018]  mmcblk0: p1 p2 p3
    [    3.939211] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 0:512, read only 512 bytes, retry
    [    3.959852] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 0:512, read only 512 bytes, retry
    [    3.971917] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 0:512, read 512 bytes
    [    3.984149] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1:0, read only 64 bytes, retry
    .....
    .....
    42.615000] UBI: scanning is finished
    [ 42.623839] UBI warning: ubi_io_read: error -74 (ECC error) while reading 22528 bytes from PEB 0:2048, read only 22528 bytes, retry
    [ 42.640339] UBI warning: ubi_io_read: error -74 (ECC error) while reading 22528 bytes from PEB 0:2048, read only 22528 bytes, retry
    [ 42.656897] UBI warning: ubi_io_read: error -74 (ECC error) while reading 22528 bytes from PEB 0:2048, read only 22528 bytes, retry
    [ 42.673351] UBI error: ubi_io_read: error -74 (ECC error) while reading 22528 bytes from PEB 0:2048, read 22528 bytes
    [ 42.689974] UBI warning: ubi_io_read: error -74 (ECC error) while reading 22528 bytes from PEB 1:2048, read only 22528 bytes, retry
    [ 42.706640] UBI warning: ubi_io_read: error -74 (ECC error) while reading 22528 bytes from PEB 1:2048, read only 22528 bytes, retry
    [ 42.723113] UBI warning: ubi_io_read: error -74 (ECC error) while reading 22528 bytes from PEB 1:2048, read only 22528 bytes, retry
    [ 42.739586] UBI error: ubi_io_read: error -74 (ECC error) while reading 22528 bytes from PEB 1:2048, read 22528 bytes
    [ 42.758477] UBI warning: print_rsvd_warning: cannot reserve enough PEBs for bad PEB handling, reserved 3, need 20
    [ 42.775948] UBI: attached mtd5 (name "FS1", size 48 MiB) to ubi0
    [ 42.781996] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
    [ 42.788960] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 512
    [ 42.795703] UBI: VID header offset: 512 (aligned 512), data offset: 2048
    [ 42.802424] UBI: good PEBs: 384, bad PEBs: 0, corrupted PEBs: 0
    [ 42.808449] UBI: user volume: 1, internal volumes: 1, max. volumes count: 128
    [ 42.815687] UBI: max/mean erase counter: 4/1, WL threshold: 4096, image sequence number: 0
    [ 42.824042] UBI: available PEBs: 0, total reserved PEBs: 384, PEBs reserved for bad PEB handling: 3
    [ 42.833155] UBI: background thread "ubi_bgt0d" started, PID 1058
    [ 42.839395] console [netcon0] enabled
    [ 42.843087] netconsole: network logging started
    [ 42.854359] davinci_emac davinci_emac.1: using random MAC addr: b2:d6:d2:36:7b:13
    [ 42.889574] UBIFS error (pid 1): ubifs_mount: cannot open "ubi0:rootfs", error -19
    [ 42.898344] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
    [ 42.906616] Rebooting in 5 seconds..
    [ 47.925665] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 33:512, read only 512 bytes, retry
    [ 47.937986] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 33:512, read only 512 bytes, retry
    [ 47.950083] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 33:512, read only 512 bytes, retry
    [ 47.962173] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 33:512, read 512 bytes
    

    Seems like some misconfiguration that always works on the first shot, but never on the second ;P

    What am doing wrong? It feels like a subpage write issue / ecc mistmatch, but i tried without subpage (disabled in uboot and kernel) and the results were the same. I disqualified the option of ecc mistmatch because i use same uboot for the tests above, and it fails already in uboot.

    Any advice?

    Kind Regards and merry Hanukchristmas to all 

  • Dear MoonDrop,


    Why is that? a second ago it was showing me the ubifs correctly, i did not load the kernel or anything, just performed reset... what can be the cause??


    1)
    Can you please do the same for two times at u-boot ?
    i.e flash ubifs, mount,list, unmount, mount, and list.

    mtdparts
    nand erase 0xa00000 0x3000000
    ubi part rfs1
    ubi create cont
    fatload mmc 0:1 0xc0700000 myrfs.ubi
    ubi write 0xc0700000 cont 0x281D000
    ubifsmount cont
    ubifsls

    ubifsumount
    ubifsmount cont
    ubifsls

    2) Can you please try to flash the ubifs from Linux ?
    Do NFS boot and flash the ubifs at Linux.
  • Hi.

    Doing mount/umount multiple times from u-boot works well without problems.

    Also flashing ubi from linux works well. Why then when flashing from u-boot, i get these -74 errors???

    I disabled sub-paging in kernel and then the flashing from nfs worked. i also disabled subpaging in the ubi driver in u-boot, as mentioned in this thread:

    https://e2e.ti.com/support/arm/sitara_arm/f/791/t/319145

    so i see that both uboot and kernel has same configuraion for ubi (min/max io - 2048, subpage - 2048, leb count - 380 ....) but still when i flash from uboot i get these -74 error.

    Please Help :)

  • Can you please do "nand scrub" for complete NAND flash and then flash one by one with sub-page disabled in u-boot ubi driver.