U-Boot 2008.10 No NAND device found!!! 0 MiB 问题的处理!
发布时间:2021-11-25 20:12:07 所属栏目:教程 来源:互联网
导读:这个问题断断续续花费了几天时间才算彻底解决。用这么长时间解决这么个小问题,什么原因?分析一下,归咎与我代码阅读能力及调试能力太差。以前裁的UBOOT都是运行在nor的,而且裁了几次uboot都是照抄别人的手册,实在收获甚微。过去的惯性驱使我再次参照别人
这个问题断断续续花费了几天时间才算彻底解决。用这么长时间解决这么个小问题,什么原因?分析一下,归咎与我代码阅读能力及调试能力太差。以前裁的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 = %dn",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}, {"NAND 32MiB 1,8V 8-bit", 0x35, 512, 32, 0x4000, 0}, {"NAND 32MiB 3,3V 8-bit", 0x75, 512, 32, 0x4000, 0}, {"NAND 32MiB 1,8V 16-bit", 0x45, 512, 32, 0x4000, NAND_BUSWIDTH_16}, {"NAND 32MiB 3,3V 16-bit", 0x55, 512, 32, 0x4000, NAND_BUSWIDTH_16}, {"NAND 64MiB 1,8V 8-bit", 0x36, 512, 64, 0x4000, 0}, {"NAND 64MiB 3,3V 8-bit", 0x76, 512, 64, 0x4000, 0}, {"NAND 64MiB 1,8V 16-bit", 0x46, 512, 64, 0x4000, NAND_BUSWIDTH_16}, {"NAND 64MiB 3,3V 16-bit", 0x56, 512, 64, 0x4000, NAND_BUSWIDTH_16}, {"NAND 128MiB 1,8V 8-bit", 0x78, 512, 128, 0x4000, 0}, {"NAND 128MiB 1,8V 8-bit", 0x39, 512, 128, 0x4000, 0}, {"NAND 128MiB 3,3V 8-bit", 0x79, 512, 128, 0x4000, 0}, {"NAND 128MiB 1,8V 16-bit", 0x72, 512, 128, 0x4000, NAND_BUSWIDTH_16}, {"NAND 128MiB 1,8V 16-bit", 0x49, 512, 128, 0x4000, NAND_BUSWIDTH_16}, {"NAND 128MiB 3,3V 16-bit", 0x74, 512, 128, 0x4000, NAND_BUSWIDTH_16}, {"NAND 128MiB 3,3V 16-bit", 0x59, 512, 128, 0x4000, NAND_BUSWIDTH_16}, {"NAND 256MiB 3,3V 8-bit", 0x71, 512, 256, 0x4000, 0}, /* * These are the new chips with large page size. The pagesize and the * erasesize is determined from the extended id bytes */ #define LP_OPTIONS (NAND_SAMSUNG_LP_OPTIONS | NAND_NO_READRDY | NAND_NO_AUTOINCR) #define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16) /*512 Megabit */ {"NAND 64MiB 1,8V 8-bit", 0xA2, 0, 64, 0, LP_OPTIONS}, {"NAND 64MiB 3,3V 8-bit", 0xF2, 0, 64, 0, LP_OPTIONS}, {"NAND 64MiB 1,8V 16-bit", 0xB2, 0, 64, 0, LP_OPTIONS16}, {"NAND 64MiB 3,3V 16-bit", 0xC2, 0, 64, 0, LP_OPTIONS16}, /* 1 Gigabit */ {"NAND 128MiB 1,8V 8-bit", 0xA1, 0, 128, 0, LP_OPTIONS}, {"NAND 128MiB 3,3V 8-bit", 0xF1, 0, 128, 0, LP_OPTIONS}, {"NAND 128MiB 1,8V 16-bit", 0xB1, 0, 128, 0, LP_OPTIONS16}, {"NAND 128MiB 3,3V 16-bit", 0xC1, 0, 128, 0, LP_OPTIONS16}, /* 2 Gigabit */ {"NAND 256MiB 1,8V 8-bit", 0xAA, 0, 256, 0, LP_OPTIONS}, {"NAND 256MiB 3,3V 8-bit", 0xDA, 0, 256, 0, LP_OPTIONS}, {"NAND 256MiB 1,8V 16-bit", 0xBA, 0, 256, 0, LP_OPTIONS16}, {"NAND 256MiB 3,3V 16-bit", 0xCA, 0, 256, 0, LP_OPTIONS16}, /* 4 Gigabit */ {"NAND 512MiB 1,8V 8-bit", 0xAC, 0, 512, 0, LP_OPTIONS}, {"NAND 512MiB 3,3V 8-bit", 0xDC, 0, 512, 0, LP_OPTIONS}, {"NAND 512MiB 1,8V 16-bit", 0xBC, 0, 512, 0, LP_OPTIONS16}, {"NAND 512MiB 3,3V 16-bit", 0xCC, 0, 512, 0, LP_OPTIONS16}, /* 8 Gigabit */ {"NAND 1GiB 1,8V 8-bit", 0xA3, 0, 1024, 0, LP_OPTIONS}, {"NAND 1GiB 3,3V 8-bit", 0xD3, 0, 1024, 0, LP_OPTIONS}, {"NAND 1GiB 1,8V 16-bit", 0xB3, 0, 1024, 0, LP_OPTIONS16}, {"NAND 1GiB 3,3V 16-bit", 0xC3, 0, 1024, 0, LP_OPTIONS16}, /* 16 Gigabit */ {"NAND 2GiB 1,8V 8-bit", 0xA5, 0, 2048, 0, LP_OPTIONS}, {"NAND 2GiB 3,3V 8-bit", 0xD5, 0, 2048, 0, LP_OPTIONS}, {"NAND 2GiB 1,8V 16-bit", 0xB5, 0, 2048, 0, LP_OPTIONS16}, {"NAND 2GiB 3,3V 16-bit", 0xC5, 0, 2048, 0, LP_OPTIONS16}, /* * Renesas AND 1 Gigabit. Those chips do not support extended id and * have a strange page/block layout ! The chosen minimum erasesize is * 4 * 2 * 2048 = 16384 Byte, as those chips have an array of 4 page * planes 1 block = 2 pages, but due to plane arrangement the blocks * 0-3 consists of page 0 + 4,1 + 5, 2 + 6, 3 + 7 Anyway JFFS2 would * increase the eraseblock size so we chose a combined one which can be * erased in one go There are more speed improvements for reads and * writes possible, but not implemented now */ {"AND 128MiB 3,3V 8-bit", 0x01, 2048, 128, 0x4000, NAND_IS_AND | NAND_NO_AUTOINCR |NAND_NO_READRDY | NAND_4PAGE_ARRAY | BBT_AUTO_REFRESH }, {NULL,} }; 每行的16进制数就是相应nandflash的ID号 确实没16,这里说明一下在uboot 2008.10版本有两个关于struct nand_flash_dev nand_flash_ids[] = {的定义 而如何知道 if (dev_id == nand_flash_ids[i].id)语句中的nand_flash_ids的定义就是drivers/mtd/nand/nand_ids.c文件里的呢,我们可以在 for (i = 0; nand_flash_ids[i].name != NULL; i++) { if (dev_id == nand_flash_ids[i].id) { printf("%s",nand_flash_ids[i].name );//打印nand_flash_ids结构体name成员, type = &nand_flash_ids[i]; break; 另一个nand_flash_ids的定义为 static struct nand_flash_dev nand_flash_ids[] = { {"Toshiba TC5816BDC", NAND_MFR_TOSHIBA, 0x64, 21, 1, 2, 0x1000, 0}, {"Toshiba TC5832DC", NAND_MFR_TOSHIBA, 0x6b, 22, 0, 2, 0x2000, 0}, {"Toshiba TH58V128DC", NAND_MFR_TOSHIBA, 0x73, 24, 0, 2, 0x4000, 0}, {"Toshiba TC58256FT/DC", NAND_MFR_TOSHIBA, 0x75, 25, 0, 2, 0x4000, 0}, {"Toshiba TH58512FT", NAND_MFR_TOSHIBA, 0x76, 26, 0, 3, 0x4000, 0}, {"Toshiba TC58V32DC", NAND_MFR_TOSHIBA, 0xe5, 22, 0, 2, 0x2000, 0}, {"Toshiba TC58V64AFT/DC", NAND_MFR_TOSHIBA, 0xe6, 23, 0, 2, 0x2000, 0}, {"Toshiba TC58V16BDC", NAND_MFR_TOSHIBA, 0xea, 21, 1, 2, 0x1000, 0}, {"Toshiba TH58100FT", NAND_MFR_TOSHIBA, 0x79, 27, 0, 3, 0x4000, 0}, {"Samsung KM29N16000", NAND_MFR_SAMSUNG, 0x64, 21, 1, 2, 0x1000, 0}, {"Samsung unknown 4Mb", NAND_MFR_SAMSUNG, 0x6b, 22, 0, 2, 0x2000, 0}, {"Samsung KM29U128T", NAND_MFR_SAMSUNG, 0x73, 24, 0, 2, 0x4000, 0}, {"Samsung KM29U256T", NAND_MFR_SAMSUNG, 0x75, 25, 0, 2, 0x4000, 0}, {"Samsung unknown 64Mb", NAND_MFR_SAMSUNG, 0x76, 26, 0, 3, 0x4000, 0}, {"Samsung KM29W32000", NAND_MFR_SAMSUNG, 0xe3, 22, 0, 2, 0x2000, 0}, {"Samsung unknown 4Mb", NAND_MFR_SAMSUNG, 0xe5, 22, 0, 2, 0x2000, 0}, {"Samsung KM29U64000", NAND_MFR_SAMSUNG, 0xe6, 23, 0, 2, 0x2000, 0}, {"Samsung KM29W16000", NAND_MFR_SAMSUNG, 0xea, 21, 1, 2, 0x1000, 0}, {"Samsung K9F5616Q0C", NAND_MFR_SAMSUNG, 0x45, 25, 0, 2, 0x4000, 1}, {"Samsung K9K1216Q0C", NAND_MFR_SAMSUNG, 0x46, 26, 0, 3, 0x4000, 1}, {"Samsung K9F1G08U0M", NAND_MFR_SAMSUNG, 0xf1, 27, 0, 2, 0, 0}, {NULL,} }; 而打印结果为 NAND: In drivers/mtd/nand/nand.c dev_id = 16 NAND 16MiB 1,8V 8-bit NAND 16MiB 3,3V 8-bit NAND 16MiB 1,8V 16-bit NAND 16MiB 3,3V 16-bit NAND 32MiB 1,8V 8-bit NAND 32MiB 3,3V 8-bit NAND 32MiB 1,8V 16-bit NAND 32MiB 3,3V 16-bit NAND 64MiB 1,8V 8-bit NAND 64MiB 3,3V 8-bit NAND 64MiB 1,8V 16-bit NAND 64MiB 3,3V 16-bit NAND 128MiB 1,8V 8-bit NAND 128MiB 1,8V 8-bit NAND 128MiB 3,3V 8-bit NAND 128MiB 1,8V 16-bit NAND 128MiB 1,8V 16-bit NAND 128MiB 3,3V 16-bit NAND 128MiB 3,3V 16-bit NAND 256MiB 3,3V 8-bit NAND 64MiB 1,8V 8-bit NAND 64MiB 3,3V 8-bit NAND 64MiB 1,8V 16-bit NAND 64MiB 3,3V 16-bit NAND 128MiB 1,8V 8-bit NAND 128MiB 3,3V 8-bit NAND 128MiB 1,8V 16-bit NAND 128MiB 3,3V 16-bit NAND 256MiB 1,8V 8-bit NAND 256MiB 3,3V 8-bit NAND 256MiB 1,8V 16-bit NAND 256MiB 3,3V 16-bit NAND 512MiB 1,8V 8-bit NAND 512MiB 3,3V 8-bit NAND 512MiB 1,8V 16-bit NAND 512MiB 3,3V 16-bit NAND 1GiB 1,8V 8-bit NAND 1GiB 3,3V 8-bit NAND 1GiB 1,8V 16-bit NAND 1GiB 3,3V 16-bit NAND 2GiB 1,8V 8-bit NAND 2GiB 3,3V 8-bit NAND 2GiB 1,8V 16-bit NAND 2GiB 3,3V 16-bit AND 128MiB 3,3V 8-bit No NAND device found!!! 0 MiB 可见nand_flash_ids的定义位置 针对16这ID号 我直接编译了tekkamanninja 的uboot 同样加上打印语句发现ID号为218,而同一块开发板ID号是不可能不通的。 可见是nandflash的初始化出问题了ID都读错了。好了找到问题出在哪就好解决了,还是那个文件开始提到的cpu/arm920t/s3c24X0/nand.c 文件,问题就出在他身上。重新修正,果然NFCONT 被我误写成了NFCONF 修改 编译 NAND: 256M 哈 成了! 现写下此文,已记录问题的解决过程。。。 (编辑:济南站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |