Chinaunix首页 | 论坛 | 博客
  • 博客访问: 117140
  • 博文数量: 22
  • 博客积分: 488
  • 博客等级: 下士
  • 技术积分: 265
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-09 09:31
文章分类

全部博文(22)

文章存档

2013年(1)

2011年(20)

2009年(1)

分类:

2011-04-28 14:31:07

当使用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的大小就没有问题了
阅读(2926) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~