TI中文支持网
TI专业的中文技术问题搜集分享网站

AM3354移植MT29F8G08ABACAWP-T 驱动

Hi TI工程师

目前我们有需求要更换一下NandFlash, 从S34ML08G101TFI00更换为MT29F8G08ABACAWP

计划先移植Uboot的驱动。uboot版本号为u-boot-2015.10

本人新手,参照 https://www.deyisupport.com/question_answer/dsp_arm/sitara_arm/f/25/t/130812.aspx?pi239031348=1 ,我修改了如下项目,

uboot阶段读取所有page都报如下错误,请问是否还有哪里遗漏了呢?详细的串口log请参见附件

omap-elm: uncorrectable ECC errors

omap-elm: uncorrectable ECC errors

omap-elm: uncorrectable ECC errors

omap-elm: uncorrectable ECC errors

omap-elm: uncorrectable ECC errors

/////////////// changes 

#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x40000

#define CONFIG_SYS_NAND_PAGE_SIZE 4096
#define CONFIG_SYS_NAND_OOBSIZE 224
#define CONFIG_SYS_NAND_BLOCK_SIZE (64*4096)

#define CONFIG_SYS_NAND_ECCPOS { \
2, 3, 4, 5, 6, 7, 8, 9, \
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \
20, 21, 22, 23, 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, 64, 65, 66, 67, 68, 69, \
70, 71, 72, 73, 74, 75, 76, 77, 78, 79, \
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, \
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, \
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, \
110, 111, 112, 113, 114, 115, 116, 117, 118, 119, \
120, 121, 122, 123, 124, 125, 126, 127, 128, 129, \
130, 131, 132, 133, 134, 135, 136, 137, 138, 139, \
140, 141, 142, 143, 144, 145, 146, 147, 148, 149, \
150, 151, 152, 153, 154, 155, 156, 157, 158, 159, \
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, \
170, 171, 172, 173, 174, 175, 176, 177, 178, 179, \
180, 181, 182, 183, 184, 185, 186, 187, 188, 189, \
190, 191, 192, 193, 194, 195, 196, 197, 198, 199, \
200, 201, 202, 203, 204, 205, 206, 207, 208, 209, }
#define CONFIG_SYS_NAND_ECCSIZE 512
#define CONFIG_SYS_NAND_ECCBYTES 26
#define CONFIG_SYS_NAND_ECCSTEPS 8

期待回复 

Jian Zhou:

MT29F8G08ABACAWP这个是多大的page size,是SLC还是MLC的?

junqian li:

回复 Jian Zhou:

Hi ZhouJian

感谢回复。

MT29F8G08ABACA(8G×8)1 page = (4K + 224 bytes)1 block = (4K + 224) bytes x 64 pages = (256K + 14K) bytes1 plane = (256K + 14K) bytes x 2048 blocks = 4320Mb是SLC的。

上面的问题,本地做了如下修改后,已经可以成功读写nandflash了。

可以通过SD卡启动,且可以开进kernel并做download

但最新的问题是,从SD卡download后,根据log看所有的分区都以写完,且无fail,

之后拔掉SD卡,重启从flash启动,只能到SPL的log。

如果可以从SD卡启动,可以说明uboot image 没问题吧?

如果 uboot image OK的话,那我当前遇到的问题,可以说明是写到flash 中的uboot 有问题吗?这种问题如何debug呢?

(完整的download log 可参见附件download_without_fail.txt)

// 重启后定期重复打印如下标红的log,应该是SPL reset

U-Boot SPL 2015.10 (Dec 26 2017 – 08:47:59)[johnchain+++][debug CONFIG_SYS_NAND_BASE] here in board_nand_init[johnchain+++][debug MT nand flash] here in omap_select_ecc_scheme, CONFIG_NAND_PAGE_4K, ecc_scheme = 7[johnchain+++][debug CONFIG_SYS_NAND_BASE] here in omap_select_ecc_scheme, CONFIG_SYS_NAND_BASE = 0x8000000nand: using OMAP_ECC_BCH16_CODE_HW[johnchain+++][debug MT nand flash] in CONFIG_NAND_PAGE_4K build[johnchain+++] here in nand_init, CONFIG_SYS_NAND_BASE = 0x8000000

//正常启动的话,后面应该打印下面的logU-Boot 2015.10 (Dec 26 2017 – 08:47:59 +0000)

Watchdog enabledI2C: readyDRAM: 512 MiB

………..

// changes:

— a/u-boot-2015.10/drivers/mtd/nand/omap_gpmc.c+++ b/u-boot-2015.10/drivers/mtd/nand/omap_gpmc.c@@ -719,6 +719,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,

case OMAP_ECC_BCH16_CODE_HW:

#ifdef CONFIG_NAND_OMAP_ELM printf("nand: using OMAP_ECC_BCH16_CODE_HW\n");……. /* define ecc-layout */ ecclayout->eccbytes = nand->ecc.bytes * eccsteps;#ifdef CONFIG_NAND_PAGE_4K

printf("[johnchain+++][debug MT nand flash] in CONFIG_NAND_PAGE_4K build\n");for (i = 0; i < ecclayout->eccbytes; i++) {    if (nand->options & NAND_BUSWIDTH_16)        ecclayout->eccpos[i] = i + 200;}ecclayout->oobfree[0].offset = 2;ecclayout->oobfree[0].length = 38;

#else

for (i = 0; i < ecclayout->eccbytes; i++) ecclayout->eccpos[i] = i + BADBLOCK_MARKER_LENGTH; ecclayout->oobfree[0].offset = i + BADBLOCK_MARKER_LENGTH; ecclayout->oobfree[0].length = oobsize – nand->ecc.bytes – BADBLOCK_MARKER_LENGTH;

#endif

break;

junqian li:

回复 Jian Zhou:

Hi ZhouJian

感谢回复。

MT29F8G08ABACA(8G×8)1 page = (4K + 224 bytes)1 block = (4K + 224) bytes x 64 pages = (256K + 14K) bytes1 plane = (256K + 14K) bytes x 2048 blocks = 4320Mb

是SLC的。

上面的问题,本地做了如下修改后,已经可以成功读写nandflash了。由于是参考其他人修改,所以具体原因还不确定。

可以通过SD卡启动,且可以开进kernel并做download

但最新的问题是,从SD卡download后,根据log看所有的分区都以写完,且无fail,

之后拔掉SD卡,重启从flash启动,只能到SPL的log。

如果可以从SD卡启动,可以说明uboot image 没问题吧?

如果 uboot image OK的话,那我当前遇到的问题,可以说明是写到flash 中的uboot 有问题吗?这种问题如何debug呢?

(完整的download log 可参见附件download_without_fail.txt)

//串口 log: 重启后定期重复打印如下标红的log,应该是SPL reset

U-Boot SPL 2015.10 (Dec 26 2017 – 08:47:59)[johnchain+++][debug CONFIG_SYS_NAND_BASE] here in board_nand_init[johnchain+++][debug MT nand flash] here in omap_select_ecc_scheme, CONFIG_NAND_PAGE_4K, ecc_scheme = 7[johnchain+++][debug CONFIG_SYS_NAND_BASE] here in omap_select_ecc_scheme, CONFIG_SYS_NAND_BASE = 0x8000000nand: using OMAP_ECC_BCH16_CODE_HW[johnchain+++][debug MT nand flash] in CONFIG_NAND_PAGE_4K build[johnchain+++] here in nand_init, CONFIG_SYS_NAND_BASE = 0x8000000

//正常启动的话,后面应该接着打印下面的logU-Boot 2015.10 (Dec 26 2017 – 08:47:59 +0000)

Watchdog enabledI2C: readyDRAM: 512 MiB

………..

// changes:

— a/u-boot-2015.10/drivers/mtd/nand/omap_gpmc.c+++ b/u-boot-2015.10/drivers/mtd/nand/omap_gpmc.c@@ -719,6 +719,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,

case OMAP_ECC_BCH16_CODE_HW:

#ifdef CONFIG_NAND_OMAP_ELMprintf("nand: using OMAP_ECC_BCH16_CODE_HW\n");……./* define ecc-layout */ecclayout->eccbytes = nand->ecc.bytes * eccsteps;#ifdef CONFIG_NAND_PAGE_4K

printf("[johnchain+++][debug MT nand flash] in CONFIG_NAND_PAGE_4K build\n");for (i = 0; i < ecclayout->eccbytes; i++) { if (nand->options & NAND_BUSWIDTH_16) ecclayout->eccpos[i] = i + 200;}ecclayout->oobfree[0].offset = 2;ecclayout->oobfree[0].length = 38;

#else

for (i = 0; i < ecclayout->eccbytes; i++)    ecclayout->eccpos[i] = i + BADBLOCK_MARKER_LENGTH;ecclayout->oobfree[0].offset = i + BADBLOCK_MARKER_LENGTH;ecclayout->oobfree[0].length = oobsize – nand->ecc.bytes – BADBLOCK_MARKER_LENGTH;

#endif

break;

junqian li:

回复 junqian li:

附上MT29F8G08ABACA的datasheet 供您参考

Jian Zhou:

回复 junqian li:

这是个4K Page的NAND,你是想做成直接从ROMCODE启动么?

junqian li:

回复 Jian Zhou:

嗯是4K Page的NAND

您说的“直接从ROMCODE启动” 不是很清楚,不过我没有特殊的启动需求,还是按照默认的启动流程即可,只是解决移植支援镁光的这款flash的问题。

目前本地还没解决。。。继续网搜资料,并进一步检查uboot 和kernel两边的配置一致性,目前我的怀疑点还是在uboot和kernel端的ECC处理上可能有差别

还请帮忙一起debug一下,万分感谢!(不知是否合规,方便的话可以直接打我电话:18556732048,如不合规还请再告知我删除)

我把本地的目前kernel和uboot里的修改上传一份给您。

补充细节:

1. download完重启后只停留在SPL的log,但如果重启再从SD卡烧写盘启动,在uboot里使用nand read命令读取所有分区都报错,

2. 今天又尝试了下,如果参照uboot内做如下修改,download时,烧完rootfs时会有ubifs 的fail,其他分区都可以烧录成功,重启后从NAND启动串口直接只打“CCCC”,但如果再重启从SD卡烧写盘启动,在uboot里使用nand read命令读取所有分区都是可以成功,且数据正确。

//flash rootfs  error log 

Flashing rootfs partition………Erasin[ 24.736447] ubi0: attaching mtd11lete Erasing 256 Kibyte @ 3ecc0000 — 100 % complete[ 26.847014] ubi0: scanning is finished[ 26.850946] ubi0: empty MTD device detected[ 26.889515] ubi0: attached mtd11 (name "NAND.file-system", size 1005 MiB)[ 26.896741] ubi0: PEB size: 262144 bytes (256 KiB), LEB size: 258048 bytes[ 26.903947] ubi0: min./max. I/O unit sizes: 4096/4096, sub-page size 1024[ 26.911035] ubi0: VID header offset: 1024 (aligned 1024), data offset: 4096[ 26.918324] ubi0: good PEBs: 4020, bad PEBs: 0, corrupted PEBs: 0[ 26.924707] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128[ 26.932249] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 211410545[ 26.941715] ubi0: available PEBs: 3936, total reserved PEBs: 84, PEBs reserved for bad PEB handling: 80[ 26.952394] ubi0: background thread "ubi_bgt0d" started, PID 89[ 27.077108] UBIFS (ubi0:0): default file-system created[ 27.084524] omap2-nand omap2-nand.0: uncorrectable bit-flips found[ 27.090997] omap2-nand omap2-nand.0: uncorrectable bit-flips found……

[ 27.130311] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 4096 bytes from PEB 12:4096, read only 4096 bytes, retry[ 27.175820] omap2-nand omap2-nand.0: uncorrectable bit-flips found[ 27.182282] omap2-nand omap2-nand.0: uncorrectable bit-flips found

……[ 27.381664] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 4096 bytes from PEB 12:4096, read 4096 bytes[ 27.392773] CPU: 0 PID: 92 Comm: mount Not tainted 4.1.13 #13[ 27.398795] Hardware name: Generic AM33XX (Flattened Device Tree)[ 27.405207] [<c0016b04>] (unwind_backtrace) from [<c001304c>] (show_stack+0x10/0x14)[ 27.413309] [<c001304c>] (show_stack) from [<c07e9b64>] (dump_stack+0x84/0x9c)[ 27.420888] [<c07e9b64>] (dump_stack) from [<c046ca38>] (ubi_io_read+0x11c/0x2f8)[ 27.428732] [<c046ca38>] (ubi_io_read) from [<c0469d44>] (ubi_eba_read_leb+0x174/0x478)[ 27.437116] [<c0469d44>] (ubi_eba_read_leb) from [<c0468dc0>] (ubi_leb_read+0x70/0xc8)[ 27.445413] [<c0468dc0>] (ubi_leb_read) from [<c02d5040>] (ubifs_leb_read+0x28/0x94)[ 27.453503] [<c02d5040>] (ubifs_leb_read) from [<c02d6d78>] (ubifs_read_node+0x9c/0x314)[ 27.461978] [<c02d6d78>] (ubifs_read_node) from [<c02d342c>] (ubifs_read_sb_node+0x54/0x78)[ 27.470724] [<c02d342c>] (ubifs_read_sb_node) from [<c02d402c>] (ubifs_read_superblock+0xb9c/0x1594)[ 27.480287] [<c02d402c>] (ubifs_read_superblock) from [<c02d233c>] (ubifs_mount+0x964/0x1830)[ 27.489218] [<c02d233c>] (ubifs_mount) from [<c01689c4>] (mount_fs+0x44/0x164)[ 27.496791] [<c01689c4>] (mount_fs) from [<c0184324>] (vfs_kern_mount+0x54/0x134)[ 27.504635] [<c0184324>] (vfs_kern_mount) from [<c0187af8>] (do_mount+0x1c0/0xce0)[ 27.512543] [<c0187af8>] (do_mount) from [<c0188984>] (SyS_mount+0x74/0xa0)[ 27.519847] [<c0188984>] (SyS_mount) from [<c000f4a0>] (ret_fast_syscall+0x0/0x54)[ 27.683896] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 93

mount: mounting ubi0:rootfs on /tmp/rootfs failed: Bad message    // rootfs mount 失败

// changeslinux-4.1.13/drivers/mtd/nand/omap2.cstatic int omap_nand_probe(struct platform_device *pdev){    ……    /* populate MTD interface based on ECC scheme */    ecclayout = &info->oobinfo;    switch (info->ecc_opt) {         ……         case OMAP_ECC_BCH16_CODE_HW:               ……

             /* define ECC layout */             ecclayout->eccbytes = nand_chip->ecc.bytes * (mtd->writesize / nand_chip->ecc.size);              //++++参照uboot 修改参数              for (i = 0; i < ecclayout->eccbytes; i++) {                     if (nand_chip->options & NAND_BUSWIDTH_16)                            ecclayout->eccpos[i] = i + 200;                     else

                           ecclayout->eccpos[i] = i + 200;              }              ecclayout->oobfree[0].offset = 2;              ecclayout->oobfree[0].length = 38;              //——参照uboot 修改参数

             // 原生code              // oob_index = BADBLOCK_MARKER_LENGTH;              // for (i = 0; i < ecclayout->eccbytes; i++, oob_index++)              //         ecclayout->eccpos[i] = oob_index;              /* reserved marker already included in ecclayout->eccbytes */              // ecclayout->oobfree->offset = ecclayout->eccpos[ecclayout->eccbytes – 1] + 1;        break;             ……}

Jian Zhou:

回复 junqian li:

就是实现AM335x上电后直接从4K page NAND Flash上启动,

我在E2E上搜到一些帖子,有些人加了BCH16 的ECC patch之后,AM3352可以boot 4K page NAND:

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

http://patchwork.ozlabs.org/patch/216188/

 

这些资源源于这个帖子:

https://e2e.ti.com/support/arm/sitara_arm/f/791/p/214942/846899

junqian li:

回复 Jian Zhou:

Hi Zhou Jian

感谢回复。

http://e2e.ti.com/support/arm/sitara_arm/f/791/t/241321  这个帖子里的里的Flash和我的型号一致,

不过他的是基于StarterWare平台的吧,之前没接触过StarterWare,而且看他的patch里的文件路径(AM335X_StarterWare/nandlib/xxx)和函数,

与我使用的kernel & uboot的都不一样,不知道如何导入到本地的uboot & kernel内,您这边可以提供帮助吗?

—————-

此外,我看了这个帖子里的uboot patch (http://patchwork.ozlabs.org/patch/216188/),不过都是基于比较旧版本的uboot,

目前看和我本地使用的版本差异很大,部分源文件(omap_gpmc.h 和 mtd-abi.h) 和函数都找不到,本地只能尝试修改下。。。

不过kernel端又如何修改呢?

可以先忽略kernel端,而仅仅先检测Uboot端的nand 功能吗?还是通过nand read/write 检验读写功能就够了吗? 

junqian li:

回复 junqian li:

Hi   Zhou Jian

我发现Uboot端还是有问题的。(尚未导入昨天您帮忙找的帖子里的patch)

目前我使用SD卡烧录盘启动,在uboot里使用 nand  烧录如下四个标红分区(log 显示write OK),其余分区全部擦除,重启使用NAND 启动,串口只打印“CCC”,

device nand0 <nand.0>, # parts = 12 #: name size offset mask_flags 0: NAND.SPL 0x00040000 0x00000000 0 1: NAND.SPL.backup1 0x00040000 0x00040000 0 2: NAND.SPL.backup2 0x00040000 0x00080000 0 3: NAND.SPL.backup3 0x00040000 0x000c0000 0 4: NAND.u-boot-spl-os 0x00040000 0x00100000 0 5: NAND.u-boot 0x00100000 0x00140000 0 6: NAND.u-boot-env 0x00040000 0x00240000 0 7: NAND.u-boot-env.backup10x00040000 0x00280000 0 8: NAND.kernel 0x00800000 0x002c0000 0 9: NAND.kernel.other 0x00800000 0x00ac0000 010: NAND.update 0x00040000 0x012c0000 011: NAND.file-system 0x3ed00000 0x01300000 0

Jian Zhou:

回复 junqian li:

4K page NAND的ECC机制和2K page的是不一样的,需要在Uboot里加入对4K page ECC的支持,因此我建议你加上那个patch试试。

赞(0)
未经允许不得转载:TI中文支持网 » AM3354移植MT29F8G08ABACAWP-T 驱动
分享到: 更多 (0)