串口数据被覆盖了,简单记录下收获。
一开始,串口显示“Flash: 0 Bytes”,没有读到norflash的空间,在源码搜索“Flash:” 定位在 Board_r.c (u-boot-2016.05\common)的initr_flash()
puts("Flash: "); //打印“Flash:”
if (board_flash_wp_on())
printf("Uninitialized - Write Protect On\n");
else
flash_size = flash_init();
print_size(flash_size, ""); //打印“0 Bytes”
可见问题出现在 flash_init(); flash初始化失败,在初始化时flash_detect_legacy(cfi_flash_bank_addr(i), i)探测cfi_flash_bank_addr--nGCS0地址上norflash,探测方式jedec_flash_match遍历jedec_table里面所有的mfr_id和mfr_id。问题来了板子上的mfr_id和mfr_id是多少呢?在flash_detect_legacy函数可知道
debug("JEDEC PROBE: ID %x %x %x\n",
info->manufacturer_id,
info->device_id,
定义宏#define DEBUG 串口输出“JEDEC PROBE: ID 1c 2249 0”可查出mfr_id=0x1c 和mfr_id=0x2249 。在Jedec_flash.c (u-boot-2016.05\drivers\mtd)的jedec_table表中定义结构体
#ifdef CONFIG_SYS_FLASH_LEGACY_1024Kx16
{
.mfr_id= 0x1c,
.dev_id= 0x2249,
.name= "EON EN29LV160AB",
.uaddr= {
[1] = MTD_UADDR_0x0555_0x02AA /* x16 */
},
.DevSize= SIZE_2MiB,
.CmdSet= P_ID_AMD_STD,
.NumEraseRegions= 4,
.regions= {
ERASEINFO(0x04000, 1),
ERASEINFO(0x02000, 2),
ERASEINFO(0x08000, 1),
ERASEINFO(0x10000, 31),
}
},
#endif
注释#define DEBUG,编译烧录
U-Boot 2016.05 (Jul 21 2017 - 22:11:28 +0800)
CPUID: 32440001
FCLK: 405.600 MHz
HCLK: 101.400 MHz
PCLK: 50.700 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND: 0 MiB
*** Warning - bad CRC, using default environment
Net: dm9000
SMDK2440 # flinfo
Bank # 1: EON EN29LV160AB flash (16 x 16) Size: 2 MB in 35 Sectors
AMD Legacy command set, Manufacturer ID: 0x1C, Device ID: 0x2249
Erase timeout: 30000 ms, write timeout: 100 ms
Sector Start Addresses:
00000000 RO 00004000 RO 00006000 RO 00008000 RO 00010000 RO
00020000 RO 00030000 RO 00040000 RO 00050000 RO 00060000 RO
00070000 RO 00080000 RO 00090000 000A0000 000B0000
000C0000 000D0000 000E0000 000F0000 00100000
00110000 00120000 00130000 00140000 00150000
00160000 00170000 00180000 00190000 001A0000
001B0000 001C0000 001D0000 001E0000 001F0000
SMDK2440 # protect off all
Un-Protect Flash Bank # 1
SMDK2440 # cp.b 32000000 0 10
Copy to Flash... Flash not Erased
SMDK2440 # flinfo
Bank # 1: EON EN29LV160AB flash (16 x 16) Size: 2 MB in 35 Sectors
AMD Legacy command set, Manufacturer ID: 0x1C, Device ID: 0x2249
Erase timeout: 30000 ms, write timeout: 100 ms
Sector Start Addresses:
00000000 00004000 00006000 00008000 00010000
00020000 00030000 00040000 00050000 00060000
00070000 00080000 00090000 000A0000 000B0000
000C0000 000D0000 000E0000 000F0000 00100000
00110000 00120000 00130000 00140000 00150000
00160000 00170000 00180000 00190000 001A0000
001B0000 001C0000 001D0000 001E0000 001F0000
SMDK2440 # protect off all
Un-Protect Flash Bank # 1
SMDK2440 # cp.b 32000000 0 10
Copy to Flash... Flash not Erased
SMDK2440 # cmp.b 0 32000000 10
byte at 0x00000000 (0x16) != byte at 0x32000000 (0xbe)
Total of 0 byte(s) were the same
SMDK2440 # md.b 32000000 10
32000000: be 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 ................
SMDK2440 # md.b 0 10
00000000: 16 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 ................
SMDK2440 #