最近在看AM3358的nand flash,我发现在读nand读时候,设备进行ecc校验时,计算出的ecc全为0
sdk版本是ti-sdk-am335x-evm-08.00.00.00-Linux-x86-Install.bin
uboot版本是u-boot-2014.07-g7e537bf
我在omap_gpmc.c文件中的omap_correct_data_bch函数中,加了一些打印信息
356 /*
357 * omap_correct_data_bch – Compares the ecc read from nand spare area
358 * with ECC registers values and corrects one bit error if it has occured
359 *
360 * @mtd: MTD device structure
361 * @dat: page data
362 * @read_ecc: ecc read from nand flash (ignored)
363 * @calc_ecc: ecc read from ECC registers
364 *
365 * @return 0 if data is OK or corrected, else returns -1
366 */
367 static int omap_correct_data_bch(struct mtd_info *mtd, uint8_t *dat,
368 uint8_t *read_ecc, uint8_t *calc_ecc)
369 {
370 struct nand_chip *chip = mtd->priv;
371 struct omap_nand_info *info = chip->priv;
372 struct nand_ecc_ctrl *ecc = &chip->ecc;
373 uint32_t error_count = 0, error_max;
374 uint32_t error_loc[ELM_MAX_ERROR_COUNT];
375 enum bch_level bch_type;
376 uint32_t i, ecc_flag = 0;
377 uint8_t count, err = 0;
378 uint32_t byte_pos, bit_pos;
379380 printf("\nread ecc: \n");
381 for (i = 0; i < 13; i++)
382 printf("%02x ", read_ecc[i]);
383384 printf("\ncalc ecc :\n");
385 for (i = 0; i < 13; i++)
386 printf("%02x ", calc_ecc[i]);
387 printf("\n");
388
然后江编译好的MLO和uboot放在SD卡中,从SD卡启动后,进入uboot的命令行,使用nand read命令去读flash中的数据,发现calc ecc全为0,而且最终没有打印ecc有问题,显示正常读完2048字节的数据
U-Boot# nand read 0x80009000 0x80000 0x800
NAND read: device 0 offset 0x80000, size 0x800
read ecc:a8 e5 53 f6 b7 4d b8 3b e5 19 07 ba 6ecalc ecc :
00 00 00 00 00 00 00 00 00 00 00 00 00
read ecc:26 82 b7 42 ea 85 f7 a9 1e 06 9e ca 44calc ecc :
00 00 00 00 00 00 00 00 00 00 00 00 00
read ecc:c8 35 ef 86 2f a5 cb 88 b2 0e 57 af 5dcalc ecc :
00 00 00 00 00 00 00 00 00 00 00 00 00
read ecc:77 94 c7 c7 b4 44 42 90 ef d6 7d 98 4acalc ecc :
00 00 00 00 00 00 00 00 00 00 00 00 00 2048 bytes read: OK
U-Boot#
我看代码中,每次去读nand读时候,应该是都有调用calculate回调函数去计算ecc的,但是为什么计算出来全为0,
还有就是omap_correct_data_bch代码中elm模式检查错误是个什么模式,是不是就不需要读取的时候计算的calc_ecc了
Jian Zhou:
首先和您确认下,这个NAND在U-boot下可以被识别么?
Guoquan Zhang:
回复 Jian Zhou:
可以的,从u-boot命令行用nand命令读取的数据也是对的,现在就是这个calc_ecc为0是为什么,并且在MLO阶段,ecc校验和纠正位翻转是不是起作用了
yongqing wang:
回复 Guoquan Zhang:
你使用的是官方的板子吗