阅读:1910回复:0
u-boot,flash 问题
各位大虾
本人正在做uboot移植,但发现一个奇怪的现象: 我的板子用amd 29lv642 flash memory, 根据资料要读到flash的厂商ID和设备ID 要用以下flash命令(4个周期) 周期1 写 | 周期2 写 | 周期3 写 | 周期4 读 地址 数据 | 地址 数据| 地址 数据 | 地址 数据 0x555, 0xaa | 0x2aa 0x55| 0x555 0x90 | [0] 0001 <--厂商ID: 0x555, 0xaa | 0x2aa 0x55| 0x555 0x90 | [1] 22D7 <--设备ID: 但是在U-boot的源程序中 却这样定义: #if 0 #define FLASH_CYCLE1 0x0555 #define FLASH_CYCLE2 0x02aa #else #define FLASH_CYCLE1 0x0554 #define FLASH_CYCLE2 0x02ab #endif 为什么要减一用0x554,0x02ab呢? 还有读回来的数据第一个应该是厂商ID,然后才是设备ID 但在u-boot里头第一个是设备ID 这是为是么? 源程序: ulong flash_get_size (FPWV *addr, flash_info_t *info) { /* Write auto select command: read Manufacturer ID */ /* Write auto select command sequence and test FLASH answer */ addr[FLASH_CYCLE1] = (FPW)0x00AA00AA; /* for AMD, Intel ignores this */ addr[FLASH_CYCLE2] = (FPW)0x00550055; /* for AMD, Intel ignores this */ addr[FLASH_CYCLE1] = (FPW)0x00900090; /* selects Intel or AMD */ /* The manufacturer codes are only 1 byte, so just use 1 byte.This works for any bus width and any FLASH device width. */ switch (addr[1] & 0xff) { case (uchar)AMD_MANUFACT: info->flash_id = FLASH_MAN_AMD; break; case (uchar)INTEL_MANUFACT: info->flash_id = FLASH_MAN_INTEL; break; default: info->flash_id = FLASH_UNKNOWN; info->sector_count = 0; info->size = 0; break; } /* Check 16 bits or 32 bits of ID so work on 32 or 16 bit bus. */ if (info->flash_id != FLASH_UNKNOWN) switch (addr[0]) { case (FPW)AMD_ID_LV640U: /* 29LV640 and 29LV641 have same ID */ info->flash_id += FLASH_AM640U; info->sector_count = 128; info->size = 0x00800000 * (sizeof(FPW)/2); break; /* => 8 or 16 MB */ case (FPW)INTEL_ID_28F800C3B: info->flash_id += FLASH_28F800C3B; info->sector_count = 23; info->size = 0x00100000 * (sizeof(FPW)/2); break; /* => 1 or 2 MB */ 。。。。。。。。 |
|