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.

AM3352 镁光NAND FLASH问题

Other Parts Discussed in Thread: AM3352

各位好:

      我司单板在linux内核下,有两个问题:

     1、flash芯片为32Gb的,即容量为4GB字节,如果只分成一个分区,该如何支持4GB?(dts不支持大于32位的长度,目前只能分成两个2G的分区)

     2、使用文件系统自带的测试程序(/usr/sbin/nandtest 、/usr/sbin/nandwirte)),测试很多坏块,但是在u-boot下使用nand命令测试只有几个坏块。这种情况可能是什么原因?

     环境如下:

     SDK:ti-processor-sdk-linux-am335x-evm-01.00.00.03-Linux-x86-Install.bin

     CPU:AM3352

      NAND FLASH:MICRON MT29F32G08CBADA

     备注:u-boot和内核放在NOR FLASH中了,NAND FLASH只存放文件系统

     dts配置如下:

       nandflash_pins_default: nandflash_pins_default {
  pinctrl-single,pins = <
   0x0 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad0.gpmc_ad0 */
   0x4 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad1.gpmc_ad1 */
   0x8 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad2.gpmc_ad2 */
   0xc (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad3.gpmc_ad3 */
   0x10 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad4.gpmc_ad4 */
   0x14 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad5.gpmc_ad5 */
   0x18 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad6.gpmc_ad6 */
   0x1c (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_ad7.gpmc_ad7 */
   0x70 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_wait0.gpmc_wait0 */
   0x74 (PIN_INPUT_PULLUP | MUX_MODE0) /* gpmc_wpn.gpio0_30 */
   0x7c (PIN_OUTPUT | MUX_MODE0)  /* gpmc_csn0.gpmc_csn0  */
   0x90 (PIN_OUTPUT | MUX_MODE0)  /* gpmc_advn_ale.gpmc_advn_ale */
   0x94 (PIN_OUTPUT | MUX_MODE0)  /* gpmc_oen_ren.gpmc_oen_ren */
   0x98 (PIN_OUTPUT | MUX_MODE0)  /* gpmc_wen.gpmc_wen */
   0x9c (PIN_OUTPUT | MUX_MODE0)  /* gpmc_be0n_cle.gpmc_be0n_cle */
  >;
 };

&gpmc {
 status = "okay";
 pinctrl-names = "default";
 pinctrl-0 = <&nandflash_pins_default>;
 ranges = <0 0 0x01000000 0x10000000>; /* CS0: NAND */
 nand@0,0 {
  reg = <0 0 0>; /* CS0, offset 0 */
  ti,nand-ecc-opt = "bch8";
  ti,elm-id = <&elm>;
  nand-bus-width = <8>;
  gpmc,device-width = <1>;
  gpmc,sync-clk-ps = <0>;
  gpmc,cs-on-ns = <0>;
  gpmc,cs-rd-off-ns = <44>;
  gpmc,cs-wr-off-ns = <44>;
  gpmc,adv-on-ns = <6>;
  gpmc,adv-rd-off-ns = <34>;
  gpmc,adv-wr-off-ns = <44>;
  gpmc,we-on-ns = <0>;
  gpmc,we-off-ns = <40>;
  gpmc,oe-on-ns = <0>;
  gpmc,oe-off-ns = <54>;
  gpmc,access-ns = <64>;
  gpmc,rd-cycle-ns = <82>;
  gpmc,wr-cycle-ns = <82>;
  gpmc,wait-on-read = "true";
  gpmc,wait-on-write = "true";
  gpmc,bus-turnaround-ns = <0>;
  gpmc,cycle2cycle-delay-ns = <0>;
  gpmc,clk-activation-ns = <0>;
  gpmc,wait-monitoring-ns = <0>;
  gpmc,wr-access-ns = <40>;
  gpmc,wr-data-mux-bus-ns = <0>;
  /* MTD partition table */
  /* All SPL-* partitions are sized to minimal length
   * which can be independently programmable. For
   * NAND flash this is equal to size of erase-block */
  #address-cells = <1>;
  #size-cells = <1>;
  partition@0 {
   label = "NAND.rootfs1";
   reg = <0x00000000 0x80000000>;
  };
  partition@1 {
   label = "NAND.rootfs2";
   reg = <0x00000000 0x80000000>;
  };
 };
};

系统运行后:

root@am335x-evm:/usr/sbin# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00010000 "spi1.0"
mtd1: 80000000 00200000 "NAND.rootfs1"
mtd2: 80000000 00200000 "NAND.rootfs2"

测试了256M的空间:

root@am335x-evm:/usr/sbin# ./nandtest -o 0 -l 0x10000000 /dev/mtd1
ECC corrections: 0
ECC failures   : 0
Bad blocks     : 515
BBT blocks     : 0
Bad block at 0x00000000
Bad block at 0x00200000
Bad block at 0x00400000
Bad block at 0x00600000
Bad block at 0x00800000
Bad block at 0x00a00000
Bad block at 0x00c00000
Bad block at 0x00e00000
Bad block at 0x01000000
Bad block at 0x01200000
Bad block at 0x01400000
Bad block at 0x01600000
Bad block at 0x01800000
Bad block at 0x01a00000
Bad block at 0x01c00000
Bad block at 0x01e00000
Bad block at 0x02000000
Bad block at 0x02200000
Bad block at 0x02400000
Bad block at 0x02600000
Bad block at 0x02800000
Bad block at 0x02a00000
Bad block at 0x02c00000
Bad block at 0x02e00000
Bad block at 0x03000000
Bad block at 0x03200000
Bad block at 0x03400000
Bad block at 0x03600000
Bad block at 0x03800000
Bad block at 0x03a00000
Bad block at 0x03c00000
Bad block at 0x03e00000
Bad block at 0x04000000
Bad block at 0x04200000
Bad block at 0x04400000
Bad block at 0x04600000
Bad block at 0x04800000
Bad block at 0x04a00000
Bad block at 0x04c00000
Bad block at 0x04e00000
05000000: erasing... [ 1390.993819] nand: nand_erase_nand: attempt to erase a bad block at page 0x00002800
MEMERASE: Input/output error
Bad block at 0x05200000
Bad block at 0x05400000
Bad block at 0x05600000
Bad block at 0x05800000
Bad block at 0x05a00000
Bad block at 0x05c00000
Bad block at 0x05e00000
Bad block at 0x06000000
Bad block at 0x06200000
Bad block at 0x06400000
Bad block at 0x06600000
Bad block at 0x06800000
Bad block at 0x06a00000
Bad block at 0x06c00000
Bad block at 0x06e00000
Bad block at 0x07000000
Bad block at 0x07200000
Bad block at 0x07400000
Bad block at 0x07600000
Bad block at 0x07800000
Bad block at 0x07a00000
Bad block at 0x07c00000
Bad block at 0x07e00000
Bad block at 0x08000000
Bad block at 0x08200000
Bad block at 0x08400000
Bad block at 0x08600000
08800000: erasing... [ 1391.651349] nand: nand_erase_nand: attempt to erase a bad block at page 0x00004400
MEMERASE: Input/output error
Bad block at 0x08a00000
Bad block at 0x08c00000
Bad block at 0x08e00000
Bad block at 0x09000000
Bad block at 0x09200000
Bad block at 0x09400000
Bad block at 0x09600000
Bad block at 0x09800000
Bad block at 0x09a00000
Bad block at 0x09c00000
Bad block at 0x09e00000
Bad block at 0x0a000000
Bad block at 0x0a200000
Bad block at 0x0a400000
Bad block at 0x0a600000
Bad block at 0x0a800000
Bad block at 0x0aa00000
Bad block at 0x0ac00000
Bad block at 0x0ae00000
Bad block at 0x0b000000
Bad block at 0x0b200000
Bad block at 0x0b400000
Bad block at 0x0b600000
Bad block at 0x0b800000
Bad block at 0x0ba00000
Bad block at 0x0bc00000
Bad block at 0x0be00000
Bad block at 0x0c000000
Bad block at 0x0c200000
Bad block at 0x0c400000
Bad block at 0x0c600000
Bad block at 0x0c800000
Bad block at 0x0ca00000
Bad block at 0x0cc00000
Bad block at 0x0ce00000
Bad block at 0x0d000000
Bad block at 0x0d200000
Bad block at 0x0d400000
Bad block at 0x0d600000
Bad block at 0x0d800000
Bad block at 0x0da00000
Bad block at 0x0dc00000
Bad block at 0x0de00000
Bad block at 0x0e000000
Bad block at 0x0e200000
Bad block at 0x0e400000
Bad block at 0x0e600000
Bad block at 0x0e800000
Bad block at 0x0ea00000
Bad block at 0x0ec00000
Bad block at 0x0ee00000
Bad block at 0x0f000000
Bad block at 0x0f200000
Bad block at 0x0f400000
Bad block at 0x0f600000
Bad block at 0x0f800000
Bad block at 0x0fa00000
Bad block at 0x0fc00000
Bad block at 0x0fe00000

Finished pass 1 successfully

 

  • 请问您选的这个nand是slc还是mlc,spec中规定的ecc要几位?

  • 谢谢热情的解答,nand是MLC的,ecc在资料中没有找到,但是在u-boot下是8位的,测试只有几个坏块。

    我把ubi文件系统在u-boot下烧写到nand flash,bootcmd修改为:“console=ttyO0,115200n8 root=ubi0:rootfs rw ubi.mtd=NAND.rootfs1,8192 rootfstype=ubifs rootwait=1”

    内核在启动后出现错误,卡在读nand的时候,说是“ecc错误”,详细日志如下:

    [ 4.117535] pinctrl-single 44e10800.pinmux: found group selector 6 for nandflash_pins_default
    [ 4.126100] pinctrl core: pinmux_enable_setting devname=50000000.gpmc
    [ 4.132599] pinmux core: >>> pinmux_enable_setting devname=44e10800.0 >>>
    [ 4.139427] pinmux core: >>> pinmux_enable_setting devname=44e10804.0 >>>
    [ 4.146242] pinmux core: >>> pinmux_enable_setting devname=44e10808.0 >>>
    [ 4.153068] pinmux core: >>> pinmux_enable_setting devname=44e1080c.0 >>>
    [ 4.159896] pinmux core: >>> pinmux_enable_setting devname=44e10810.0 >>>
    [ 4.166721] pinmux core: >>> pinmux_enable_setting devname=44e10814.0 >>>
    [ 4.173536] pinmux core: >>> pinmux_enable_setting devname=44e10818.0 >>>
    [ 4.180362] pinmux core: >>> pinmux_enable_setting devname=44e1081c.0 >>>
    [ 4.187189] pinmux core: >>> pinmux_enable_setting devname=44e10870.0 >>>
    [ 4.194003] pinmux core: >>> pinmux_enable_setting devname=44e10874.0 >>>
    [ 4.200829] pinmux core: >>> pinmux_enable_setting devname=44e1087c.0 >>>
    [ 4.207655] pinmux core: >>> pinmux_enable_setting devname=44e10890.0 >>>
    [ 4.214471] pinmux core: >>> pinmux_enable_setting devname=44e10894.0 >>>
    [ 4.221297] pinmux core: >>> pinmux_enable_setting devname=44e10898.0 >>>
    [ 4.228123] pinmux core: >>> pinmux_enable_setting devname=44e1089c.0 >>>
    [ 4.234945] pinctrl-single 44e10800.pinmux: enabling nandflash_pins_default function6
    [ 4.242956] omap-gpmc 50000000.gpmc: GPMC revision 6.0
    [ 4.248146] gpmc_mem_init: disabling cs 0 mapped at 0x0-0x1000000
    [ 4.255437] omap2-nand omap2-nand.0: no of_node; not parsing pinctrl DT
    [ 4.262726] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0x44
    [ 4.269131] nand: Micron MT29F32G08CBADAWP
    [ 4.273248] nand: 4096MiB, MLC, page size: 8192, OOB size: 744
    [ 4.279119] nand: using OMAP_ECC_BCH8_CODE_HW ECC scheme
    [ 4.284453]
    [ 4.284453] ############### writesize=8192,ecc.size=512 ###############
    [ 4.292760] 2 ofpart partitions found on MTD device omap2-nand.0
    [ 4.298811] Creating 2 MTD partitions on "omap2-nand.0":
    [ 4.304166] 0x000000000000-0x000080000000 : "NAND.rootfs1"
    [ 4.364764] 0x000000000000-0x000080000000 : "NAND.rootfs2"
    [ 4.425262] pinctrl core: add 1 pinmux maps
    [ 4.429570] pinctrl-single 44e10800.pinmux: found group selector 7 for pinmux_i2c0_pins
    [ 4.437633] pinctrl core: pinmux_enable_setting devname=44e0b000.i2c
    [ 4.444019] pinmux core: >>> pinmux_enable_setting devname=44e10988.0 >>>
    [ 4.450848] pinmux core: >>> pinmux_enable_setting devname=44e1098c.0 >>>
    [ 4.457683] pinctrl-single 44e10800.pinmux: enabling pinmux_i2c0_pins function7
    [ 4.479443] input_polldev: disagrees about version of symbol module_layout
    [ 4.493991] snd_soc_tlv320aic3x: disagrees about version of symbol module_layout
    [ 4.503148] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
    [ 4.509229] platform 44d00000.wkup_m3: Driver wkup_m3 requests probe deferral
    [ 4.517378] UBI: attaching mtd1 to ubi0
    [ 4.538674] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 4:0, read only 64 bytes, retry
    [ 4.565922] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 4:0, read only 64 bytes, retry

  • 使用ubiformat格式化mtd1的时候,也检测到只有一个好的块,其它的1023个都是坏块。有童鞋碰到类似问题吗?是否是ECC配置错了

  • Hi,

    1. Nand Datasheet一定有他基本要求的ecc規格, 看是否有超過8 bit.

    2. 如果是4K page size, 要改code. 就算依然是BCH8, 原先對應2K page size ecc bytes數量一定不足以應付4K page size.

    3. 可以參考下面連結修改4K pages size, BCH16的ECC:

    http://e2e.ti.com/support/arm/sitara_arm/f/791/t/214942.aspx?pi301021=1

  • Hi MR.Chang :

    我司核心板的nand flash的page size为8192,MTD信息如下:

    Count of MTD devices: 3
    Present MTD devices: mtd0, mtd1, mtd2
    Sysfs interface supported: yes

    mtd0
    Name: spi1.0
    Type: nor
    Eraseblock size: 65536 bytes, 64.0 KiB
    Amount of eraseblocks: 256 (16777216 bytes, 16.0 MiB)
    Minimum input/output unit size: 1 byte
    Sub-page size: 1 byte
    Character device major/minor: 90:0
    Bad blocks are allowed: false
    Device is writable: true

    mtd1
    Name: NAND.rootfs1
    Type: mlc-nand
    Eraseblock size: 2097152 bytes, 2.0 MiB
    Amount of eraseblocks: 1024 (2147483648 bytes, 2.0 GiB)
    Minimum input/output unit size: 8192 bytes
    Sub-page size: 8192 bytes
    OOB size: 744 bytes
    Character device major/minor: 90:2
    Bad blocks are allowed: true
    Device is writable: true

    mtd2
    Name: NAND.rootfs1
    Type: mlc-nand
    Eraseblock size: 2097152 bytes, 2.0 MiB
    Amount of eraseblocks: 1024 (2147483648 bytes, 2.0 GiB)
    Minimum input/output unit size: 8192 bytes
    Sub-page size: 8192 bytes
    OOB size: 744 bytes
    Character device major/minor: 90:4
    Bad blocks are allowed: true
    Device is writable: true

  • 我们使用的镁光MT29F32G08CBADAWP的NAND FLASH芯片,芯片datasheet如下:

    Description                                                                Requirement

    Minimum number of valid blocks (NVB) per LUN            2054
    Total available blocks per LUN                                     2128
    First spare area location                                             Byte 8192
    Bad-block mark                                                         00h
    Minimum required ECC                                             40-bit ECC per 1117 bytes of data

    这里面的ECC要求和BCH8/BCH16是如何对应的呢?

  • BCH8/16 是说可以支持8bit或者16bit的ecc校验,而您选的nand flash需要40bit的ecc校验,那么一个page上会出现的bit位反转超过了AM335x能够校验的位数,所以不适合这里用。

  • Qin,你好,你的意思是kernel不支持这款NAND FLASH?在ti-processor-sdk-linux-am335x-evm-01.00.00.03-Linux-x86-Install.bin的u-boot下没有修改ECC参数,在u-boot下可进行读写及擦除操作,u-boot是用的是缺省的bch8

    u-boot的am335x_evm.h中定义的是8bit

    #define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW

  • 是的,目前默认是BCH16,不支持40bit