/**************************************************************************** **************************************************************************** Erase/Program IXPD465 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListIXPD465[] = { {BDI_INIT_XSC_WGPR, 8005, 0xFFFF0800}, // Address of debug handler {BDI_INIT_XSC_WGPR, 8006, 0xFFFFFFFF}, // Do not update vector table {BDI_INIT_XSC_WGPR, 8007, 0xFFFFFFFF}, // Do not update relocated vector table {BDI_INIT_XSC_WGPR, 8008, 250 }, // Wakeup delay after reset. {BDI_INIT_XSC_CP15, 0x0001, 0x000000f8}, // CTR: set big endian mode {BDI_INIT_XSC_CP15, 0x2001, 0x00000001}, // AUX: Disable Write Buffer Coalescing {BDI_INIT_XSC_CP15, 0x010F, 0x00000001}, // CPA: Enable CP0 access {BDI_INIT_XSC_WM32, 0xc4000000, 0xbfff0242}, // EXP_CS0 32MB {BDI_INIT_XSC_WM32, 0xCC00e50c, 0x00000000}, // SDBR {BDI_INIT_XSC_WM32, 0xCC00e510, 0x80000002}, // SBR0 {BDI_INIT_XSC_WM32, 0xCC00e514, 0x80000004}, // SBR1 {BDI_INIT_XSC_WM32, 0xCC00e504, 0x52220106}, // SDCR0 {BDI_INIT_XSC_WM32, 0xCC00e508, 0x2560f084}, // SDCR1 {BDI_INIT_XSC_WM32, 0xCC00e51c, 0x0000000c}, // ECCR {BDI_INIT_XSC_WM32, 0xCC00e53c, 0x00000011}, // MPTCR {BDI_INIT_XSC_WM32, 0xCC00e548, 0x00000000}, // Set RFR-Refresh Rate to zero {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000003}, // Send NOP to Mem Controller {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000002}, // Send Precharge-All Command to Mem Controller {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000004}, // Send Extended Mode Reg Set (enable DLL) to Mem Controller {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000001}, // Send Mode Reg Set (DLL reset) to Mem Controller {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000002}, // Send Precharge-All Command to Mem Controller {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000006}, // Send Auto-Refresh Command to Mem Controller {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000006}, // Send Auto-Refresh Command to Mem Controller {BDI_INIT_XSC_DELAY, 0, 10 }, // Insert delay here {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000000}, // Send Mode Reg Set (no DLL reset) to Mem Controller {BDI_INIT_XSC_WM32, 0xCC00e500, 0x00000008}, // Send "Normal Operation" to Mem Controller {BDI_INIT_XSC_WM32, 0xCC00e548, 0x00000082}, // RFR - Refresh Counter {BDI_INIT_XSC_DELAY, 0, 100 }, // Insert delay here {BDI_INIT_XSC_WM32, 0xc4000000, 0xbcd20242}, // CS0 : Write enabled @0x50000000 {BDI_INIT_XSC_WM32, 0xc4000004, 0x00000000}, // CS1 : {BDI_INIT_XSC_WM32, 0xc4000008, 0xbfff3c03}, // CS2 : {BDI_INIT_XSC_WM32, 0xc4000020, 0x00ffff5e}, // CFG0 : Map SDRAM to 0x00000000 }; static int ProgramIXPD465(void) { int result; int i; DWORD blockAddr; DWORD errorAddr; /* install callback procedure */ BDI_InstallCallback(DisplayProgress); /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (1L << 16) | (3L << 8) | 0, // big endian, IXP400, 16MHz JTAG sizeof initListIXPD465 / sizeof initListIXPD465[0], initListIXPD465); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_STRATAX16, // used flash is 28F128J3 0x2000000, // flash size is 16MB 0, 16, // 16-bit flash system 0x00001000); // workspace in SDRAM if (result != BDI_OKAY) return result; /* erase t8 blocks */ printf("erasing ... "); blockAddr = 0x51000000; for (i = 0; i < 8; i++) { result = BDI_FlashEraseSector(blockAddr); if (result != BDI_OKAY) return result; blockAddr += 0x20000; } /* for */ printf("passed\n"); /* program/verify from a file */ printf("programming...\n"); result = BDI_FlashWriteBinary("E:/temp/dump512k.bin", 0x51000000, &errorAddr); if (result != BDI_OKAY) return result; printf("\npassed\n"); printf("verifing...\n"); result = BDI_VerifyBinary("E:/temp/dump512k.bin", 0x51000000, &errorAddr); printf("\npassed\n"); return result; } /* ProgramIXPD465 */