赞
踩
无论系统从NOR启动还是从NAND启动,都会打印相同的错误信息
Flash:*** failed ***
### ERROR ### Please RESET the board
正常的打印信息应该是
Flash: 2M
2M表示Flash大小
显然这里Flash识别出错
通过下面命令定位错误在arch/arm/lib/board.c:506:
grep "Flash: " * -nR
分析arch/arm/lib/board.c:506行后的代码可以知道,打印错误信息的原因可能是nor flash初始化不成功
flash_size = flash_init();
分析flash_init,这个函数会调用子函数检测nor flash信息
- if (!flash_detect_legacy(cfi_flash_bank_addr(i), i))
- flash_get_size(cfi_flash_bank_addr(i), i);
在检测函数中有debug信息,在drivers/mtd/cfi_flash.c中定义宏DEBUG为1,开启调试信息
重新编译烧写u-boot,从nor flash启动后可以看到调试信息
JEDEC PROBE: ID c2 2249 0
对比nor flash芯片手册,打印的id正确
搜索JEDEC PROBE,定位到drivers/mtd/cfi_flash.c:1697
grep “JEDEC PROBE” * -nR
定位位置其后的代码会去jedec_table数组中寻找匹配的nor flash
- if (jedec_flash_match(info, info->start[0]))
- break;
检查jedec_table数组,没有一项描述我们所使用的nor flash,故自行添加一项
- {
- .mfr_id = (u16)MX_MANUFACT,
- .dev_id = 0x2249,
- .name = "MXIC MT29LV160DB",
- .uaddr = {
- [1] = MTD_UADDR_0x0555_0x02AA /* x16 */
- },
- .DevSize = SIZE_2MiB,
- .CmdSet = P_ID_AMD_STD,
- .NumEraseRegions= 4,
- .regions = {
- ERASEINFO(16*1024, 1),
- ERASEINFO(8*1024, 2),
- ERASEINFO(32*1024, 1),
- ERASEINFO(64*1024, 31),
- }
- },
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
mfr_id和dev_id是厂家id等信息
uaddr:[1]表示16位位宽,其值表示解锁方法
DevSize:nor flash大小
CmdSet:命令标准
NumEraseRegions:擦除分区数
regions:分区结构
重新编译烧写试验发现,打印错误
ERROR: too many flash sectors
搜索定位到drivers/mtd/cfi_flash.c:2018
grep “ERROR: too many flash sectors” * -nR
修改include/configs/smdk2440.h
- //#define CONFIG_SYS_MAX_FLASH_SECT 19
- #define CONFIG_SYS_MAX_FLASH_SECT (1+2+1+31)
重新编译烧写,至此uboot已经可以支持nor flash,把前面定义的宏DEBUG删除,重新编译
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。