/**************************************************************************** **************************************************************************** Program5121 : Program the flash on the MPC5121E-MDS ****************************************************************************/ static const BDI_InitTypeT initList5121[] = { {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 , 0xc0000b00}, // override reset configuration word high // {BDI_INIT_PPC_WSPR, 8021 , 0x03040000}, // 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, 0xe00000c4, 0x00000000}, // SRAMBAR to 0x00000000 {BDI_INIT_PPC_WM32, 0xe0000f04, 0xffffffff}, // SCCR1: enable all clocks {BDI_INIT_PPC_WM32, 0xe0000f08, 0xffffffff}, // SCCR2: enable all clocks // Setup chip selects {BDI_INIT_PPC_WM32, 0xe000002C, 0xe200e200}, // LPCS2AW : Access Window 0xe2000000...0xe200ffff {BDI_INIT_PPC_WM32, 0xe0010008, 0x05059010}, // CS2_CONFIG: {BDI_INIT_PPC_WM32, 0xe0000024, 0xFC00FFFF}, // LPCS0AW : Access Window 0xfc000000...0xffffffff {BDI_INIT_PPC_WM32, 0xe0010000, 0x05059310}, // CS0_CONFIG: {BDI_INIT_PPC_WM32, 0xe0010020, 0x01000000}, // CS_CONTROL: BCSR // Enable flash programming {BDI_INIT_PPC_WM8, 0xe2000008, 0xD1 }, // enable write to Boot Flash (WP# high) }; static int Program5121(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* Flash type: S29GL256N */ result = BDI_FlashSetType(BDI_FLASH_MIRRORX16, 0x02000000, 0, 32, 0x00000000); /* reset and init target */ result = BDI_TargetStartup(0, 12L << 8 | 1, /* MPC83xx/51xx, 16 MHz JTAG clock */ sizeof initList5121 / sizeof initList5121[0], initList5121); /* erase sectors */ addr = 0xff000000; 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 += 0x40000; } /* for */ printf("programming..."); result = BDI_FlashWriteBinary("E:/temp/dump256k.bin", 0xff000000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("E:/temp/dump256k.bin", 0xff000000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); return result; } /* Program5121 */