/**************************************************************************** **************************************************************************** Program8323 : Program the flash in the MPC8323-MDS ****************************************************************************/ static const BDI_InitTypeT initList8323[] = { {BDI_INIT_PPC_WSPR, 8009 , 500 }, // give reset time to complete {BDI_INIT_PPC_WSPR, 8002 , 0xFFF00100}, // boot address used for start-up break {BDI_INIT_PPC_WSPR, 8020 , 0x84600000}, // override reset configuration word high {BDI_INIT_PPC_WSPR, 8021 , 0x42040083}, // override reset configuration word low {BDI_INIT_PPC_WMSR, 0x00000000, 0x00001002}, // MSR: ME,RI {BDI_INIT_PPC_WM32, 0xff400000, 0xe0000000}, // MABR to 0xe0000000 {BDI_INIT_PPC_WM32, 0xe0000204, 0xffff0000}, // SWCRR: disable watchdog {BDI_INIT_PPC_WM32, 0xe0000110, 0x00400000}, // SPCR : enable timebase unit {BDI_INIT_PPC_WM32, 0xe00050d4, 0x80000004}, // LCRR : CLKDIV = 4 // Initialize LAWBAR's {BDI_INIT_PPC_WM32, 0xe0000020, 0xfe000000}, // LBLAWBAR0 : Flash {BDI_INIT_PPC_WM32, 0xe0000024, 0x80000017}, // LBLAWAR0 {BDI_INIT_PPC_WM32, 0xe0000028, 0xf8000000}, // LBLAWBAR1 : BCSR {BDI_INIT_PPC_WM32, 0xe000002C, 0x8000000e}, // LBLAWAR1 {BDI_INIT_PPC_WM32, 0xe0000030, 0x00000000}, // LBLAWBAR2 {BDI_INIT_PPC_WM32, 0xe0000034, 0x00000000}, // LBLAWAR2 {BDI_INIT_PPC_WM32, 0xe0000038, 0x00000000}, // LBLAWBAR3 {BDI_INIT_PPC_WM32, 0xe000003c, 0x00000000}, // LBLAWAR3 // Setup chip selects {BDI_INIT_PPC_WM32, 0xe0005004, 0xff006ff7}, // OR0 : Flash {BDI_INIT_PPC_WM32, 0xe0005000, 0xfe001001}, // BR0 : Flash {BDI_INIT_PPC_WM32, 0xe000500C, 0xffffe9f7}, // OR1 : BCSR {BDI_INIT_PPC_WM32, 0xe0005008, 0xf8000801}, // BR1 : BCSR // Enable flash programming {BDI_INIT_PPC_WM8, 0xf8000009, 0x81 }, // Disable flash protection in BCSR9 }; static int Program8323(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(0, 12L << 8 | 1, /* MPC8300, 16 MHz JTAG clock */ sizeof initList8323 / sizeof initList8323[0], initList8323); /* Flash type: Micron Q-Flash MT28F128J3 */ /* workspace in QE Lite MultiUser RAM */ result = BDI_FlashSetType(BDI_FLASH_STRATAX16, 0x1000000, 0, 16, 0xe0110000); /* clear block lock-bits */ result = BDI_SetWord(0xfe000000, 0x0060); result = BDI_SetWord(0xfe000000, 0x00d0); Sleep(1000); result = BDI_SetWord(0xfe000000, 0xffff); /* erase sectors */ addr = 0xfe100000; 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 */ printf("programming..."); result = BDI_FlashWriteBinary("E:/temp/dump256k.bin", 0xfe100000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("E:/temp/dump256k.bin", 0xfe100000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); return result; } /* Program8323 */