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.

8bit nand bugs

Other Parts Discussed in Thread: AM3352


I am using evm board and follow this steps:

1: I use the 8bit nand and ubifs, flashed uboot and kernel and ramdisk, run into kernel.
2: In kernel, I mounted the ubi partion, and put a tar file in this ubi partion.
    ubiformat /dev/mtd/mtd6 -s 512 -O 2048
    ubiattach /dev/ubi_ctrl -m 6 -O 2048
    ubimkvol /dev/ubi0 -N rootfs -s 80MiB
    mount -t ubifs ubi0_0 /mnt
   
3: I put a file(*.tar.gz) in ubi partion and tar it.
    cd /mnt/
    tftp -r u-boot-2010.06-psp04.04.00.01.tar.gz -g 192.168.1.2
    tar jxvf u-boot-2010.06-psp04.04.00.01.tar.gz
   
4: It comes error, this is some error log:

    UBI error: ubi_io_write: error -5 while writing 131072 bytes to PEB 88:0, written 81920 bytes
    UBI error: erase_worker: failed to erase PEB 88, error -5
    UBI: mark PEB 88 as bad
    UBI: 7 PEBs left in the reserve
    UBI error: ubi_io_write: error -5 while writing 2048 bytes to PEB 397:55296, written 0 bytes
    UBI warning: ubi_eba_write_leb: failed to write data to PEB 397
    UBI: recover PEB 397, move data to PEB 398
    UBI: data was successfully recovered
    UBI: run torture test for PEB 397
    UBI error: ubi_io_write: error -5 while writing 2048 bytes to PEB 398:94208, written 0 bytes
    UBI warning: ubi_eba_write_leb: failed to write data to PEB 398
    UBI: recover PEB 398, move data to PEB 399
    UBI error: ubi_io_write: error -5 while writing 131072 bytes to PEB 397:0, written 0 bytes
    UBI error: erase_worker: failed to erase PEB 397, error -5
    UBI: reserve more 1 PEBs
    UBI: mark PEB 397 as bad
    UBI: 7 PEBs left in the reserve
    UBI error: ubi_io_write: error -5 while writing 92160 bytes to PEB 399:4096, written 0 bytes
    UBI warning: recover_peb: failed to write to PEB 399
    UBI: try again
    UBI: recover PEB 398, move data to PEB 400
    UBI: run torture test for PEB 399
   

  when i copy a large file from usb disk to the ubi partion, it looks working well. and i did some mtdtest, it works well also!
  So, i guess the 8bit nand flash is not stable. The tar operation is more complex(it will read file and wirte lots of file at same time)
  
PS:

  The nand flas is K9K8G08U0A, and it's device id is not in the Supported NAND Devices list!


So, can you give me some suggest to fix the bug in nand driver?

   

  • Jiangao,

    Can you try the following?

    1. Try creating/copying thousands of small files(less than 512bytes) into the partition? 

    2. Change the sub-page size from 512 to 2048(page size) and try?

  • I have done this test:

    # mount -t tmpfs -o size=600m tmpfs /var/

    # cd var/
    # tftp -r u-boot-2010.06-psp04.04.00.01.tar.gz -g 192.168.1.2
    # tar jxvf u-boot-2010.06-psp04.04.00.01.tar.gz
    # mount -t ubifs ubi0_0 /mnt
    # cd /mnt/
    # cp /var/u-boot-2010.06-psp04.04.00.01/* ./
    # sync

    It works well!

    I also write a simple nand test application:

      1 #include "stdio.h"
      2 #include "unistd.h"
      3 #include "sys/types.h"
      4 #include "sys/stat.h"
      5 #include "fcntl.h"
      6
      7 #define MAX_SIZE 280
      8
      9 int main()
     10 {
     11     int fd_write, fd_read;
     12     int i = 0,j = 0;
     13     char name[100];
     14     unsigned char buffer[MAX_SIZE];
     15     int size;
     16
     17     for (i=0; i < 10000; i++)
     18     {
     19         for (j=0; j < MAX_SIZE; j++)
     20         {
     21             buffer[j] = rand();
     22         }
     23
     24         sprintf(name, "file%d", i);
     25         fd_write = open(name, O_CREAT|O_RDWR);
     26         write(fd_write, buffer, MAX_SIZE);
     27         close(fd_write);
     28
     29
     30         fd_read = open(name, O_RDWR);
     31         if (read(fd_read, buffer, MAX_SIZE) != MAX_SIZE)
     32             printf("read fail\n");
     33         close(fd_read);
     34
     35         sprintf(name, "newfile%d", i);
     36         fd_write = open(name, O_CREAT|O_RDWR);
     37         write(fd_write, buffer, MAX_SIZE);
     38         close(fd_write);
     39     }
     40
     41     return 0;
     42 }

    I run the application on my ubi partion, it works well also.

    So, it looks that when i copy lots of files(source code of uboot and linux) to the ubi partion, it remain works well.

    But why i tar the u-boot-2010.06-psp04.04.00.01.tar.gz in this partion, it fails ?


    By the way, How to change the sub-page size from 512 to 2048(page size) ? I am using BCH8 ecc mode.

    Many thanks !

     

     

     

  • Jiangao,

    Can you try switch the IO scheduler in kernel from CFQ to noop or deadline?

    To change the sub-page size, when you create the UBI image you can specify, and also you can pass it as part of bootargs also. I can give a sample one. 

    ubi.mtd=3,2048 rootfstype=ubifs root=ubi0:rootfs

  • I have changed IO scheduler to noop or deadline, but it's useless.

    I use follows to force subpage as 2048:

    # ubiformat /dev/mtd/mtd6 -s 2048 -O 2048
    ubiformat: mtd6 (nand), size 268435456 bytes (256.0 MiB), 2048 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
    libscan: scanning eraseblock 2047 -- 100 % complete
    ubiformat: 2047 eraseblocks are supposedly empty
    ubiformat: 1 bad eraseblocks found, numbers: 2027
    ubiformat: formatting eraseblock 2047 -- 100 % complete
    # ubiattach /dev/ubi_ctrl -m 6 -O 2048
    UBI: attaching mtd6 to ubi0
    UBI: physical eraseblock size:   131072 bytes (128 KiB)
    UBI: logical eraseblock size:    126976 bytes
    UBI: smallest flash I/O unit:    2048
    UBI: sub-page size:              512
    UBI: VID header offset:          2048 (aligned 2048)
    UBI: data offset:                4096
    UBI: max. sequence number:       0
    UBI: attached mtd6 to ubi0
    UBI: MTD device name:            "File System"
    UBI: MTD device size:            256 MiB
    UBI: number of good PEBs:        2047
    UBI: number of bad PEBs:         1
    UBI: number of corrupted 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:             2023
    UBI: total number of reserved PEBs: 24
    UBI: number of PEBs reserved for bad PEB handling: 20
    UBI: max/mean erase counter: 0/0
    UBI: image sequence number:  265378814
    UBI: background thread "ubi_bgt0d" started, PID 95
    UBI device number 0, total 2047 LEBs (259919872 bytes, 247.9 MiB), available 2023 LEBs (256872448 bytes, 245.0 MiB), LEB size 126976 bytes (124.0 KiB)
    # ubimkvol /dev/ubi0 -N rootfs -s 80MiB

    but it's useless also.


    In my options, there is some bugs in nand driver, not ubi. Because when i used another 512MB flash (2K/Page,SLC,Toshiba),it works very well!

    so, it's some difference between K9K8G08U0B and TC58NVG2S3ETA00 ? both of them are SLC and 2KB/Page.

    Thanks .

  • The subpage is not set to 2K properly. You can see from the logs.

    jiangao peng101018 said:
    UBI: sub-page size:              512

  • Because of the nand driver, the UBI can find subpages always.

    I modify the nand driver, and there is no subpages now.

    # ubiformat /dev/mtd/mtd6 -s 2048 -O 2048
    ubiformat: mtd6 (nand), size 268435456 bytes (256.0 MiB), 2048 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
    libscan: scanning eraseblock 95usb 1-1: device descriptor read/64, error -110
    libscausb 1-1: new high speed USB device using musb-hdrc and address 3
    libscan: scanning eraseblock 2047 -- 100 % complete
    ubiformat: 2047 eraseblocks are supposedly empty
    ubiformat: 1 bad eraseblocks found, numbers: 2027
    ubiformat: formatting eraseblock 2047 -- 100 % complete
    # usb 1-1: device descriptor read/64, error -110
    ubiattach /dev/ubi_ctrl -m 6 -O 2048
    UBI: attaching mtd6 to ubi0
    UBI: physical eraseblock size:   131072 bytes (128 KiB)
    UBI: logical eraseblock size:    126976 bytes
    UBI: smallest flash I/O unit:    2048
    UBI: VID header offset:          2048 (aligned 2048)
    UBI: data offset:                4096
    UBI: max. sequence number:       0
    UBI: attached mtd6 to ubi0
    UBI: MTD device name:            "File System"
    UBI: MTD device size:            256 MiB
    UBI: number of good PEBs:        2047
    UBI: number of bad PEBs:         1
    UBI: number of corrupted 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:             2023
    UBI: total number of reserved PEBs: 24
    UBI: number of PEBs reserved for bad PEB handling: 20
    UBI: max/mean erase counter: 0/0
    UBI: image sequence number:  1474856324
    UBI: background thread "ubi_bgt0d" started, PID 96
    UBI device number 0, total 2047 LEBs (259919872 bytes, 247.9 MiB), available 2023 LEBs (256872448 bytes, 245.0 MiB), LEB size 126976 bytes (124.0 KiB)
    # ubimkvol /dev/ubi0 -N rootfs -s 200MiB

    But is comes error remain:

    # tar jxvf u-boot-2010.06-psp04.04.00.01.tar.gz
    ......
    u-boot-2010.06-psp04.04.00.01/arch/blackfin/include/asm/mach-bf548/BF549_cdef.h
    u-boot-2010.06-psp04.04.00.01/arch/blackfin/include/asm/mach-bf548/ADSP-EDN-BF544-extended_cdef.h
    UBI error: ubi_io_write: error -5 while writing 2048 bytes to PEB 103:20480, written 0 bytes
    UBI warning: ubi_eba_write_leb: failed to write data to PEB 103
    UBI: recover PEB 103, move data to PEB 1038
    u-boot-2010.06-psp04.04.00.01/arUBI error: ubi_io_write: error -5 while writing 2048 bytes to PEB 1038:2048, written 0 bytes
    ch/blackfin/inclUBI warning: recover_peb: failed to write to PEB 1038
    ude/asm/mach-bf5UBI: try again
    48/ADSP-EDN-BF54UBI: recover PEB 103, move data to PEB 1039
    9-extended_cdef.h
    UBI: run torture test for PEB 1038
    UBI: PEB 1038 passed torture test, do not mark it as bad
    UBI: data was successfully recovered
    UBI: run torture test for PEB 103

  • Could you please put a print inside the functions nand_do_write_ops() and nand_do_read_ops() inside the file drivers/mtd/nand/nand_base.c? Print the parameters from and to also. After that could you please send me the logs?

  • I have added some debug message, and i found "chip->errstat" fails :

    nand_do_write_ops -> chip->write_page -> chip->errstat 

    if (!cached || !(chip->options & NAND_CACHEPRG)) {

      chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
      status = chip->waitfunc(mtd, chip);
      /*
       * See if operation failed and additional status checks are
       * available
       */
      if ((status & NAND_STATUS_FAIL) && (chip->errstat))
       status = chip->errstat(mtd, chip, FL_WRITING, status,
                page);

      if (status & NAND_STATUS_FAIL)
      {
       printk("chip->errstat fail %x\n", status);  
       return -EIO;
      }
      
     } else {
      chip->cmdfunc(mtd, NAND_CMD_CACHEDPROG, -1, -1);
      status = chip->waitfunc(mtd, chip);
     }

    So , it looks like NAND_CMD_PAGEPROG failed, and chip->errstat failed also.

    Can you give me some ideas ? Thank you .

     

  • Hi Renjith:

    I come into omap_wait function:

    static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) {}

    I modify it like this :

    if (state == FL_ERASING)
      timeo += (HZ * 400) / 1000;
     else
      timeo += (HZ * 20) / 1000;

    to

    if (state == FL_ERASING)
      timeo += (HZ * 800) / 1000;
     else
      timeo += (HZ * 200) / 1000;

    Now, when i tar the u-boot-2010.06-psp04.01.00.06.patch1.tar.gz in my UBI partion, it works well !

    I will do some further testing .

    Thanks any way !

  • Good to know that its solved.

  • hi TI

    I am using am3352 u-boot-2013.01.01-psp05.07.00.00 and linux-3.2.0-psp04.06.00.10

    i found nand ubifs error and changed the nand delay as explained before

    but still i am facing this issue.. can you suggest any additions ?

    log  for reference:

    <11>Jan 10 21:28:48 kernel: [ 127.459064] UBI error: ubi_io_write: error -5 while writing 2048 bytes to PEB 263:38912, written 0 bytes
    192.168.10.13 15/01 18:05:35.645
    <12>Jan 10 21:28:48 kernel: [ 127.469106] UBI warning: ubi_eba_write_leb: failed to write data to PEB 263
    192.168.10.13 15/01 18:05:35.646
    <13>Jan 10 21:28:48 kernel: [ 127.476464] UBI: recover PEB 263, move data to PEB 264
    192.168.10.13 15/01 18:05:35.646
    <13>Jan 10 21:28:48 kernel: [ 127.500197] UBI: data was successfully recovered
    192.168.10.13 15/01 18:05:35.647
    <13>Jan 10 21:28:48 kernel: [ 127.505097] UBI: run torture test for PEB 263
    192.168.10.13 15/01 18:05:35.647
    <11>Jan 10 21:28:48 kernel: [ 127.511148] UBI error: do_sync_erase: cannot erase PEB 263, error -5
    192.168.10.13 15/01 18:05:35.691
    <11>Jan 10 21:28:48 kernel: [ 127.517860] UBI error: erase_worker: failed to erase PEB 263, error -5
    192.168.10.13 15/01 18:05:35.692
    <13>Jan 10 21:28:48 kernel: [ 127.524786] UBI: mark PEB 263 as bad
    192.168.10.13 15/01 18:05:35.692
    <11>Jan 10 21:28:48 kernel: [ 127.528686] UBI error: ubi_io_mark_bad: cannot mark PEB 263 bad, error -30
    192.168.10.13 15/01 18:05:35.692
    <12>Jan 10 21:28:48 kernel: [ 127.535933] UBI warning: ubi_ro_mode: switch to read-only mode
    192.168.10.13 15/01 18:05:35.692
    <11>Jan 10 21:28:48 kernel: [ 127.542094] UBI error: do_work: work failed with error code -30
    192.168.10.13 15/01 18:05:35.693
    <11>Jan 10 21:28:48 kernel: [ 127.548338] UBI error: ubi_thread: ubi_bgt11d: work failed with error code -30
    192.168.10.13 15/01 18:05:35.693
    <11>Jan 10 21:29:18 kernel: [ 157.868743] UBIFS error (pid 1299): ubifs_leb_write: writing 2048 bytes to LEB 11:18432 failed, error -30
    192.168.10.13 15/01 18:06:06.141
    <12>Jan 10 21:29:18 kernel: [ 157.878878] UBIFS warning (pid 1299): ubifs_ro_mode: switched to read-only mode, error -30
    192.168.10.13 15/01 18:06:06.142
    <12>Jan 10 21:29:18 kernel: [ 157.887588] Backtrace:
    192.168.10.13 15/01 18:06:06.142

    changes made to nand driver 

    ------------------------------------------

    --- nand_base.c (revision 4)
    +++ nand_base.c (revision 457)
    @@ -844,11 +844,11 @@

    unsigned long timeo = jiffies;
    int status, state = chip->state;
    -
    + /* FOR WAP, DELAY INCREASED 400 to 800, 20 to 200 */
    if (state == FL_ERASING)
    - timeo += (HZ * 400) / 1000;
    + timeo += (HZ * 800) / 1000;
    else
    - timeo += (HZ * 20) / 1000;
    + timeo += (HZ * 200) / 1000;

    led_trigger_event(nand_led_trigger, LED_FULL);

    regards

    Nagendra 

  • hi  Ti,

    i found that the nand ready/busy is not implemented in the kernel linux-3.2.0-psp04.06.00.10 for am335x

    is it true ? did i miss something ? 

    if not implemented, how to added it ? did we have any patches ?

    if rdy/busy is implemented i think the delay implementation is not required. is it ?

    for ref:

    --------

    drivers/mtd/nand/omap2.c

    /*
    * If RDY/BSY line is connected to OMAP then use the omap ready
    * funcrtion and the generic nand_wait function which reads the status
    * register after monitoring the RDY/BSY line.Otherwise use a standard
    * chip delay which is slightly more than tR (AC Timing) of the NAND
    * device and read status register until you get a failure or success
    */
    if (pdata->dev_ready) {
    info->nand.dev_ready = omap_dev_ready;
    info->nand.chip_delay = 0;
    } else {  /* controle comes here */
    info->nand.waitfunc = omap_wait;
    info->nand.chip_delay = 50;
    }

    can u please calrify this ?

    regards,

    Nagendra

  • Nagendra,

    nagendra bankupalli said:
    i found that the nand ready/busy is not implemented in the kernel linux-3.2.0-psp04.06.00.10 for am335x

    This is the DM814x/AM387x forum. For AM335x questions, I would recommend you to ask in the Sitara AM335x forum:

    http://e2e.ti.com/support/arm/sitara_arm/f/791.aspx

    Regards,
    Pavel