Boot 2008.10 No NAND device found!!! 0 MiB 问题的解决!

这个问题断断续续花费了几天时间才算彻底解决。用这么长时间解决这么个小问题,什么原因?分析一下,归咎与我代码阅读能力及调试能力太差。以前裁的UBOOT都是运行在nor的,而且裁了几次uboot都是照抄别人的手册,实在收获甚微。过去的惯性驱使我再次参照别人的手册修改代码,这次可没那么顺利。

在此要感谢tekkamanninja ,我是参照这个superman的手册修改的uboot 2008.10, tekkamanninja的文档没有这个版本的uboot,而uboot 2008.10版本较老,个别文件和新版uboot无法对应。抄起来还是有点难度的。

其中在tekkamanninja 文档中提到的s3c2410_nand.c文件,在uboot 2008.10版本里没有的,只好搜寻相关函数的踪迹,没s3c2410_nand.c至少也得找到到里面的函数吧,最后发现uboot 2008.10版本cpu/arm920t/s3c24X0/nand.c 文件里有相关函数的定义。。。

抄完手册,启动No NAND device found!!! 0 MiB god!失败

又重新对照手册,correct 启动仍旧打印

No NAND device found!!! 0 MiB

开始找这个问题原因很是茫然,百度,谷歌也没找到相关有效解决问题,哪里出问题了呢?最先想到的是

include/configs/micro2440.h 这个配置文件出了问题,于是仔细修改了一下,如下

#define CONFIG_CMD_NAND

#define CONFIG_ENV_IS_IN_NAND 1
//#define CONFIG_ENV_IS_IN_FLASH 1
#define CONFIG_ENV_OFFSET 0X60000
#define CONFIG_ENV_SIZE 0x20000

#if defined(CONFIG_CMD_NAND)
#define CMD_SAVEENV
#define CONFIG_NAND_S3C2410
#define CFG_NAND_BASE 0x4E000000
#define CFG_MAX_NAND_DEVICE 1 /* Max number of NAND devices */
#define SECTORSIZE 512
#define SECTORSIZE_2K 2048
#define NAND_SECTOR_SIZE SECTORSIZE
#define NAND_SECTOR_SIZE_2K SECTORSIZE_2K
#define NAND_BLOCK_MASK 511
#define NAND_BLOCK_MASK_2K 2047
#define NAND_MAX_CHIPS 1
#define CONFIG_MTD_NAND_VERIFY_WRITE
#define CONFIG_SYS_64BIT_VSPRINTF /* needed for nand_util.c */
#endif /* CONFIG_CMD_NAND */

 编译,启动

No NAND device found!!! 0 MiB

还是不行

然后在打印语句上下功夫,代码中搜No NAND device found!!!

找到了drivers/mtd/nand/nand_base.c 这个文件

int nand_scan_ident(struct mtd_info *mtd, int maxchips)
{
 int i, busw, nand_maf_id;
 struct nand_chip *chip = mtd->priv;
 struct nand_flash_dev *type;

/* Get buswidth to select the correct functions */
 busw = chip->options & NAND_BUSWIDTH_16;
 /* Set the default functions */
 nand_set_defaults(chip, busw);

/* Read the flash type */
 type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id);

if (IS_ERR(type)) {
  printk(KERN_WARNING "No NAND device found!!!\n");
  chip->select_chip(mtd, -1);
  return PTR_ERR(type);
 }

。。。

}

打印语句是从这里出来的,看看前后代码,nand_get_flash_type()这个函数出了问题,在追踪这个函数

发现有这么一段

chip->select_chip(mtd, 0);

/* Send the command for reading device ID */
 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);

/* Read manufacturer and device IDs */
 *maf_id = chip->read_byte(mtd);
 dev_id = chip->read_byte(mtd);
 printf("dev_id = %d\n",dev_id);//这是我后来加上的,目的确认板子上读出的nandflash ID号
 /* Lookup the flash id */
 for (i = 0; nand_flash_ids[i].name != NULL; i++) {
  if (dev_id == nand_flash_ids[i].id) {
   type =  &nand_flash_ids[i];
   break;

编译打印,

No NAND device found!!!

dev_id = 16

0 MiB

16?找找定义ID为16的flash没  drivers/mtd/nand/nand_ids.c

struct nand_flash_dev nand_flash_ids[] = {

#ifdef CONFIG_MTD_NAND_MUSEUM_IDS
 {"NAND 1MiB 5V 8-bit",  0x6e, 256, 1, 0x1000, 0},
 {"NAND 2MiB 5V 8-bit",  0x64, 256, 2, 0x1000, 0},
 {"NAND 4MiB 5V 8-bit",  0x6b, 512, 4, 0x2000, 0},
 {"NAND 1MiB 3,3V 8-bit", 0xe8, 256, 1, 0x1000, 0},
 {"NAND 1MiB 3,3V 8-bit", 0xec, 256, 1, 0x1000, 0},
 {"NAND 2MiB 3,3V 8-bit", 0xea, 256, 2, 0x1000, 0},
 {"NAND 4MiB 3,3V 8-bit",  0xd5, 512, 4, 0x2000, 0},
 {"NAND 4MiB 3,3V 8-bit", 0xe3, 512, 4, 0x2000, 0},
 {"NAND 4MiB 3,3V 8-bit", 0xe5, 512, 4, 0x2000, 0},
 {"NAND 8MiB 3,3V 8-bit", 0xd6, 512, 8, 0x2000, 0},

{"NAND 8MiB 1,8V 8-bit", 0x39, 512, 8, 0x2000, 0},
 {"NAND 8MiB 3,3V 8-bit", 0xe6, 512, 8, 0x2000, 0},
 {"NAND 8MiB 1,8V 16-bit", 0x49, 512, 8, 0x2000, NAND_BUSWIDTH_16},
 {"NAND 8MiB 3,3V 16-bit", 0x59, 512, 8, 0x2000, NAND_BUSWIDTH_16},
#endif

{"NAND 16MiB 1,8V 8-bit", 0x33, 512, 16, 0x4000, 0},
 {"NAND 16MiB 3,3V 8-bit", 0x73, 512, 16, 0x4000, 0},
 {"NAND 16MiB 1,8V 16-bit", 0x43, 512, 16, 0x4000, NAND_BUSWIDTH_16},
 {"NAND 16MiB 3,3V 16-bit", 0x53, 512, 16, 0x4000, NAND_BUSWIDTH_16},

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwjzpw.html