//修改定义部分如下:
//#define MAIN_SECT_SIZE 0x10000 #define MAIN_SECT_SIZE 0x1000 //定义为4k,刚好是一个扇区的大小
//#define MEM_FLASH_ADDR1 (*(volatile u16 *)(CONFIG_SYS_FLASH_BASE + (0x00000555 << 1))) //#define MEM_FLASH_ADDR2 (*(volatile u16 *)(CONFIG_SYS_FLASH_BASE + (0x000002AA << 1))) #define MEM_FLASH_ADDR1 (*(volatile u16 *)(CONFIG_SYS_FLASH_BASE +(0x00005555 << 1))) //这两个参数看SST39VF1601手册 #define MEM_FLASH_ADDR2 (*(volatile u16 *)(CONFIG_SYS_FLASH_BASE +(0x00002AAA << 1)))
//修改flash_init函数如下: #elif defined(CONFIG_AMD_LV800) (AMD_MANUFACT & FLASH_VENDMASK) | (AMD_ID_LV800B & FLASH_TYPEMASK); #elif defined(CONFIG_SST_39VF1601) //在CONFIG_AMD_LV800后面添加CONFIG_SST_39VF1601 (SST_MANUFACT & FLASH_VENDMASK) | (SST_ID_xF1601 & FLASH_TYPEMASK);
for (j = 0; j < flash_info[i].sector_count; j++) { //if (j <= 3) { // /* 1st one is 16 KB */ // if (j == 0) { // flash_info[i].start[j] = flashbase + 0; // }
// /* 2nd and 3rd are both 8 KB */ // if ((j == 1) || (j == 2)) { // flash_info[i].start[j] = flashbase + 0x4000 + (j - 1) * 0x2000; // }
// /* 4th 32 KB */ // if (j == 3) { // flash_info[i].start[j] = flashbase + 0x8000; // } //} else { // flash_info[i].start[j] = flashbase + (j - 3) * MAIN_SECT_SIZE; //}
flash_info[i].start[j] = flashbase + j * MAIN_SECT_SIZE; }
//修改flash_print_info函数如下:
case (AMD_MANUFACT & FLASH_VENDMASK): printf ("AMD: "); break; case (SST_MANUFACT & FLASH_VENDMASK): //添加SST39VF1601的 printf ("SST: "); break;
case (AMD_ID_LV800B & FLASH_TYPEMASK): printf ("1x Amd29LV800BB (8Mbit)\n"); break; case (SST_ID_xF1601 & FLASH_TYPEMASK): //添加SST39VF1601的 printf ("1x SST39VF1610 (16Mbit)\n"); break;
//修改flash_erase函数如下: //if ((info->flash_id & FLASH_VENDMASK) != // (AMD_MANUFACT & FLASH_VENDMASK)) { // return ERR_UNKNOWN_FLASH_VENDOR; //} if ((info->flash_id & FLASH_VENDMASK) != (SST_MANUFACT & FLASH_VENDMASK)) { return ERR_UNKNOWN_FLASH_VENDOR; }
///* wait until flash is ready */ //chip = 0; //do { // result = *addr; // /* check timeout */ // if (get_timer_masked () > // CONFIG_SYS_FLASH_ERASE_TOUT) { // MEM_FLASH_ADDR1 = CMD_READ_ARRAY; // chip = TMO; // break; // }
// if (!chip // && (result & 0xFFFF) & BIT_ERASE_DONE) // chip = READY;
// if (!chip // && (result & 0xFFFF) & BIT_PROGRAM_ERROR) // chip = ERR; //} while (!chip);
//MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
//if (chip == ERR) { // rc = ERR_PROG_ERROR; // goto outahere; //}
//if (chip == TMO) { // rc = ERR_TIMOUT; // goto outahere; //} while (1) { if ((*addr & 0x40) != (*addr & 0x40)) continue;
if (*addr & 0x80) { rc = ERR_OK; break; } }
//修改write_hword函数如下: MEM_FLASH_ADDR1 = CMD_UNLOCK1; MEM_FLASH_ADDR2 = CMD_UNLOCK2; //MEM_FLASH_ADDR1 = CMD_UNLOCK_BYPASS; MEM_FLASH_ADDR1 = CMD_PROGRAM; //*addr = CMD_PROGRAM; *addr = data;
///* wait until flash is ready */ //chip = 0; //do { // result = *addr; // /* check timeout */ // if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { // chip = ERR | TMO; // break; // }
// if (!chip && ((result & 0x80) == (data & 0x80))) // chip = READY;
// if (!chip && ((result & 0xFFFF) & BIT_PROGRAM_ERROR)) { // result = *addr;
// if ((result & 0x80) == (data & 0x80)) // chip = READY; // else // chip = ERR; // } //} while (!chip);
//*addr = CMD_READ_ARRAY;
//if (chip == ERR || *addr != data) // rc = ERR_PROG_ERROR; while (1) { if ((*addr & 0x40) != (*addr & 0x40)) continue;
if ((*addr & 0x80) == (data & 0x80)) { rc = ERR_OK; break; } }
|