/**************************************************************************** **************************************************************************** Program1020 : Program the flash in the P1020-RDB ****************************************************************************/ static const BDI_InitTypeT initList1020[] = { {BDI_INIT_PQ3_WSPR, 8002 , 500 }, // give reset time to complete {BDI_INIT_PQ3_WSPR, 8003 , 0x00000000}, // Use Startup Mode HALT // Move the L2SRAM to the initial MMU page {BDI_INIT_PQ3_WM32, 0xFF720E44, 0x0000001C}, // L2ERRDIS: disable parity error {BDI_INIT_PQ3_WM32, 0xFF720000, 0x50010000}, // L2CTL {BDI_INIT_PQ3_WM32, 0xFF720100, 0xFFFC0000}, // L2SRBAR0: map to 0x0_FFFC0000 {BDI_INIT_PQ3_WM32, 0xFF720104, 0x00000000}, // L2SRBAREA0 {BDI_INIT_PQ3_WM32, 0xFF720000, 0x90010000}, // L2CTL // load and execute some boot code (necessary for STARTUP HALT) {BDI_INIT_PQ3_WM32, 0xfffffffc, 0x48000000}, // loop {BDI_INIT_PQ3_EXEC, 0xfffffffc, 0x00000000}, // load TLB entries, helper code @ 0xfffff000 {BDI_INIT_PQ3_WM32, 0xfffff000, 0x7c0007a4}, // tlbwe {BDI_INIT_PQ3_WM32, 0xfffff004, 0x7c0004ac}, // msync {BDI_INIT_PQ3_WM32, 0xfffff008, 0x48000000}, // loop {BDI_INIT_PQ3_WSPR, 628 , 0x00000000}, // MAS4: {BDI_INIT_PQ3_WSPR, 630 , 0x00000000}, // MAS7: // 256 MB TLB1 #0 0xf0000000 - 0xffffffff {BDI_INIT_PQ3_WSPR, 624 , 0x10000000}, // MAS0: {BDI_INIT_PQ3_WSPR, 625 , 0x80000900}, // MAS1: {BDI_INIT_PQ3_WSPR, 626 , 0xf000000a}, // MAS2: {BDI_INIT_PQ3_WSPR, 627 , 0xf0000015}, // MAS3: {BDI_INIT_PQ3_EXEC, 0xfffff000, 0x00000000}, // 64 MB TLB1 #1 0xe0000000 - 0xe3ffffff {BDI_INIT_PQ3_WSPR, 624 , 0x10010000}, // MAS0: {BDI_INIT_PQ3_WSPR, 625 , 0x80000800}, // MAS1: {BDI_INIT_PQ3_WSPR, 626 , 0xe000000a}, // MAS2: {BDI_INIT_PQ3_WSPR, 627 , 0xe0000015}, // MAS3: {BDI_INIT_PQ3_EXEC, 0xfffff000, 0x00000000}, // Remove the L2SRAM from the initial MMU page {BDI_INIT_PQ3_WM32, 0xFF720000, 0x10010000}, // L2CTL {BDI_INIT_PQ3_WM32, 0xFF720000, 0x10000000}, // L2CTL // Move CCSRBAR to 0xe0000000 {BDI_INIT_PQ3_WM32, 0xff700000, 0x000e0000}, // CCSRBAR to 0xe0000000 // Initialize LAWBAR's {BDI_INIT_PQ3_WM32, 0xe0000C08, 0x00000000}, // LAWBAR0 : @0x00000000 {BDI_INIT_PQ3_WM32, 0xe0000C10, 0x80f0001e}, // LAWAR0 : DDR/SDRAM 2GB {BDI_INIT_PQ3_WM32, 0xe0000C28, 0x000c0000}, // LAWBAR1 : @0xc0000000 {BDI_INIT_PQ3_WM32, 0xe0000C30, 0x8040001d}, // LAWAR1 : Local Bus 1GB // Setup Flash chip select {BDI_INIT_PQ3_WM32, 0xe0005004, 0xff000ff7}, // OR0 : Flash (boot bank) {BDI_INIT_PQ3_WM32, 0xe0005000, 0xff001001}, // BR0 : 16MB at 0xff000000 // Setup flash programming workspace in L2SRAM {BDI_INIT_PQ3_WM32, 0xe0020e44, 0x0000001c}, // L2ERRDIS: disable parity error {BDI_INIT_PQ3_WM32, 0xe0020000, 0x50010000}, // L2CTL {BDI_INIT_PQ3_WM32, 0xe0020100, 0xf0000000}, // L2SRBAR0: map to 0x0_F0000000 {BDI_INIT_PQ3_WM32, 0xe0020104, 0x00000000}, // L2SRBAREA0 {BDI_INIT_PQ3_WM32, 0xe0020000, 0x90010000}, // L2CTL {BDI_INIT_PQ3_WSPR, 63 , 0xf0000000}, // IVPR to workspace {BDI_INIT_PQ3_WSPR, 415 , 0x00001500}, // IVOR15 : Debug exception {BDI_INIT_PQ3_WM32, 0xf0001500, 0x48000000}, // write valid instruction }; static int Program1020(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* Flash type: S29GL128P, Workspace in L2SRAM */ result = BDI_FlashSetType(BDI_FLASH_MIRRORX16, 0x1000000, 0, 16, 0xF0000000); /* reset and init target */ result = BDI_TargetStartup(0, 7L << 8 | 1, /* P1020, 16 MHz JTAG clock */ sizeof initList1020 / sizeof initList1020[0], initList1020); /* erase sectors */ addr = 0xFFC00000; for (sector = 0; sector <= 3; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x20000; } /* for */ /* programming */ printf("programming..."); result = BDI_FlashWriteBinary("E:/temp/dump256k.bin", 0xFFC00000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); /* verifying */ printf("verifying... "); result = BDI_VerifyBinary("E:/temp/dump256k.bin", 0xFFC00000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); return result; } /* Program1020 */