/**************************************************************************** **************************************************************************** Program4080 : Program the flash in the P4080-DS ****************************************************************************/ static const BDI_InitTypeT initList4080[] = { {BDI_INIT_QP4_WSPR, 8002 , 1000 }, // give reset time to complete {BDI_INIT_QP4_WSPR, 8004 , 1 }, // memory access via SAP // {BDI_INIT_QP4_WSPR, 8005 , 100 }, // 100us memroy access delay // {BDI_INIT_QP4_WSPR, 8020 , 0x18 }, // override RCW Soure, select Hard-coded 11000 // {BDI_INIT_QP4_WSPR, 8111 , 0x00830000}, // override RCW[11], RCW bits 352 - 383 // Setup TLB1 {BDI_INIT_QP4_STLB, 0x80000700, 0xfe00000a}, // 1/1: fe000000->0_fe000000 16MB -I-G- RWXRWX {BDI_INIT_QP4_WTLB, 0x10010000, 0xfe00003f}, {BDI_INIT_QP4_STLB, 0x80000900, 0xe000000a}, // 1/2: e0000000->0_e0000000 256MB -I-G- RWXRWX {BDI_INIT_QP4_WTLB, 0x10020000, 0xe000003f}, {BDI_INIT_QP4_STLB, 0x80000a00, 0x00000000}, // 1/3: 00000000->0_00000000 1GB ----- RWXRWX {BDI_INIT_QP4_WTLB, 0x10030000, 0x0000003f}, {BDI_INIT_QP4_STLB, 0x80000a00, 0x40000000}, // 1/4: 40000000->0_40000000 1GB ----- RWXRWX {BDI_INIT_QP4_WTLB, 0x10040000, 0x4000003f}, {BDI_INIT_QP4_STLB, 0x80000500, 0x80000000}, // 1/5: 80000000->0_80000000 1MB ----- RWXRWX {BDI_INIT_QP4_WTLB, 0x10050000, 0x8000003f}, // Initialize LAWBAR's {BDI_INIT_QP4_WM32, 0xfe000c00, 0x00000000}, // LAWBAR0 : Flash @0_e0000000 {BDI_INIT_QP4_WM32, 0xfe000c04, 0xe0000000}, {BDI_INIT_QP4_WM32, 0xfe000c08, 0x81f0001b}, // LAWAR0 : eLBC 256MB {BDI_INIT_QP4_WM32, 0xfe000c10, 0x00000000}, // LAWBAR1 : CPC1/SRAM @0_80000000 {BDI_INIT_QP4_WM32, 0xfe000c14, 0x80000000}, {BDI_INIT_QP4_WM32, 0xfe000c18, 0x81000013}, // LAWAR1 : DDR1/CPC1 1MB {BDI_INIT_QP4_WM32, 0xfe000df0, 0x00000000}, // LAWBAR31: SDRAM @0_00000000 {BDI_INIT_QP4_WM32, 0xfe000df4, 0x00000000}, {BDI_INIT_QP4_WM32, 0xfe000df8, 0x8100001e}, // LAWAR31 : DDR1/CPC1 2GB // Use L3 cache (CPC1) as SRAM at 0x80000000 {BDI_INIT_QP4_WM32, 0xfe010104, 0x8000000b}, // CPC1_SRCR0: all 32 ways as SRAM {BDI_INIT_QP4_WM32, 0xfe010000, 0x80000000}, // CPC1_CSR0 : CPC enable {BDI_INIT_QP4_WM32, 0xfe010f00, 0x08000000}, // CPC 4 Errata // Local Bus Controller {BDI_INIT_QP4_WM32, 0xfe124004, 0xf8000ff7}, // OR0: {BDI_INIT_QP4_WM32, 0xfe124000, 0xe8001001}, // BR0: {BDI_INIT_QP4_WM32, 0xfe12400c, 0xf8000ff7}, // OR1: {BDI_INIT_QP4_WM32, 0xfe124008, 0xe0001001}, // BR1: }; static int Startup4080(void) { int result; /* reset and init target */ result = BDI_TargetStartup(0, 0L << 8 | 1, /* P4080, 16 MHz JTAG clock */ sizeof initList4080 / sizeof initList4080[0], initList4080); return result; } /* Startup4080 */ static int Program4080(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* Flash type: S29GL01GP */ /* Workspace in CPC1/SRAM */ result = BDI_FlashSetType(BDI_FLASH_MIRRORX16, 0x08000000, 0, 16, 0x80001000); /* reset and init target */ result = BDI_TargetStartup(0, 0L << 8 | 1, /* P4080, 16 MHz JTAG clock */ sizeof initList4080 / sizeof initList4080[0], initList4080); /* erase sectors */ addr = 0xed800000; for (sector = 0; sector < 4; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x20000; } /* for */ printf("programming..."); result = BDI_FlashWriteBinary("E:/temp/dump256k.bin", 0xed800000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("E:/temp/dump256k.bin", 0xed800000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); return result; } /* Program4080 */