当使用nand flash的时候,为保证安全,会对flash上的数据做一次ecc校验。
但是烧写的时候发现uboot对自身的ecc 校验和对其他程序的ecc校验不一样。
所以当其他程序验证uboot的ecc会出现问题。具体代码:cpu/sh/stm-nand.c:441
static int set_ecc_mode (
struct mtd_info * const mtd,
const loff_t addr,
const size_t len)
{
struct nand_chip * const this = (struct nand_chip *)(mtd->priv);
if (!done_ecc_info) /* first time ? */
{
initialize_ecc_diffs (mtd);
done_ecc_info = 1; /* do not do this again */
}
/* do we need to switch ECC mode ? */
if ( addr >= CFG_NAND_STM_BOOT_MODE_BOUNDARY )
{ /* entire range is *not* in "boot-mode" (i.e. default ECC) */
if (this->eccmode == NAND_ECC_HW3_128)
{ /* we are in the wrong ECC mode, so change */
set_ecc_diffs (mtd, &default_ecc);
}
}
else if ( addr + len <= CFG_NAND_STM_BOOT_MODE_BOUNDARY )
{ /* entire range is in "boot-mode" (i.e. 3 bytes of ECC per 128 record */
if (this->eccmode != NAND_ECC_HW3_128)
{ /* we are in the wrong ECC mode, so change */
set_ecc_diffs (mtd, &special_ecc);
}
}
else
{ /* the range is split over *both* "boot" and "non-boot" modes! */
printf("ERROR: NAND range crosses \"boot-mode\" boundary (0x%08x)\n",
CFG_NAND_STM_BOOT_MODE_BOUNDARY);
return -EINVAL;
}
return 0; /* success */
}
其中
CFG_NAND_STM_BOOT_MODE_BOUNDARY 是uboot 自身代码大小
NAND_ECC_HW3_128 则是校验方式。
如果将uboot的ecc和其他程序的ecc写成一致的。那么uboot启动就会出现问题,无法启动。
看来uboot 自身的ecc必须是NAND_ECC_HW3_128 不能是其他的。
所以这里只修改了CFG_NAND_STM_BOOT_MODE_BOUNDARY 的大小。改成128K 正好是uboot的大小就没有问题了
阅读(2987) | 评论(0) | 转发(0) |