/**************************************************************************** **************************************************************************** Program5272 : Program MCF5272 external flash. INPUT : - OUTPUT : RETURN error code ****************************************************************************/ #define MCF5272_CLOCK 48000000 #define MCF5272_WORKSPACE 0x20000000 static BDI_InitTypeT mcf5272InitList[] = { {BDI_INIT_MCF_WCREG, 0xC0F, 0x10000001}, // MBAR: SIM registers at 0x10000000 {BDI_INIT_MCF_WCREG, 0xC05, 0x20000001}, // RAMBAR: Internal SRAM at 0x20000000 {BDI_INIT_MCF_WM32, 0x10000040, 0xFFE00201}, // CSBR0: Flash {BDI_INIT_MCF_WM32, 0x10000044, 0xFFE00014}, // CSOR0: Flash }; static int Program5272(void) { int result; DWORD errorAddr; result = BDI_TargetStartup(0, MCF5272_CLOCK, sizeof mcf5272InitList / sizeof mcf5272InitList[0], mcf5272InitList); result = BDI_FlashSetType(BDI_FLASH_AM29FX00W, 0x200000, 0, 16, MCF5272_WORKSPACE); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFE00000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFE04000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFE06000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFE08000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFE40000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFE80000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFEC0000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFF00000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFF40000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFF80000); result = BDI_FlashErase(BDI_ERASE_SECTOR, 0xFFFC0000); /* oder result = BDI_FlashErase(BDI_ERASE_CHIP, 0xFFE00000); */ result = BDI_FlashWriteFile("D:\\abatron\\m5272.sss", &errorAddr); return result; } /* Program5272 */ /**************************************************************************** **************************************************************************** Program5282 : Program internal flash of MCF5282. INPUT : - OUTPUT : RETURN error code ****************************************************************************/ #define MCF5282_CLOCK 64000000 #define MCF5282_WORKSPACE 0x20000000 static BDI_InitTypeT mcf5282InitList[] = { {BDI_INIT_MCF_WCREG, 0xC05, 0x20000001}, // RAMBAR: Internal SRAM at 0x20000000 {BDI_INIT_MCF_WM16, 0x40140000, 0x000E }, // WCR : Disable watchdog {BDI_INIT_MCF_WM16, 0x40120000, 0x2000 }, // SYNCR : Speed-up PLL to 64MHz {BDI_INIT_MCF_DELAY, 0, 10 }, // Delay after changing the PLL {BDI_INIT_MCF_WCREG, 0xC04, 0xF0000121}, // FLASHBAR: Internal Flash at 0xf0000000 {BDI_INIT_MCF_WM8, 0x401D0002, 0x54 }, // CFMCLKD : Flash clock divider for 64MHz {BDI_INIT_MCF_WM32, 0x401D0010, 0x00000000}, // CFMPROT : disable flash protection }; static int Program5282(void) { int result; DWORD errorAddr; result = BDI_TargetStartup(0, MCF5282_CLOCK, sizeof mcf5282InitList / sizeof mcf5282InitList[0], mcf5282InitList); result = BDI_FlashSetType(BDI_FLASH_CFM, 0x40000, 0, 32, MCF5282_WORKSPACE); /* result = BDI_FlashErase(BDI_ERASE_SECTOR, 0x44040800); */ result = BDI_FlashErase(BDI_ERASE_BLOCK, 0x44000000); result = BDI_FlashErase(BDI_ERASE_BLOCK, 0x44040000); result = BDI_FlashWriteFile("D:\\abatron\\bdi360\\ColdFire\\pro\\m5282cfm.sss", &errorAddr); return result; } /* Program5282 */ /**************************************************************************** **************************************************************************** Program5213 : Program internal flash of MCF5213. INPUT : - OUTPUT : RETURN error code ****************************************************************************/ #define MCF5213_CLOCK 48000000 #define MCF5213_WORKSPACE 0x20000000 static BDI_InitTypeT mcf5213InitList[] = { {BDI_INIT_MCF_WCREG, 0xC05, 0x20000021}, // RAMBAR: Internal SRAM at 0x20000000 {BDI_INIT_MCF_WCREG, 0xC04, 0x00000121}, // FLASHBAR: Internal Flash at 0x00000000 {BDI_INIT_MCF_WM8, 0x401D0002, 0x4E }, // CFMCLKD : Flash clock divider for 48MHz (24MHz) {BDI_INIT_MCF_WM32, 0x401D0010, 0x00000000}, // CFMPROT : disable flash protection }; static int Program5213(void) { int result; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(0, MCF5213_CLOCK, sizeof mcf5213InitList / sizeof mcf5213InitList[0], mcf5213InitList); /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_CFM, 0x40000, 0, 32, MCF5213_WORKSPACE); /* erase all */ printf("erasing all ... "); result = BDI_FlashErase(BDI_ERASE_BLOCK, 0x44000000); if (result != BDI_OKAY) return result; printf("passed\n"); /* program/verify from a file */ printf("programming ... "); result = BDI_FlashWriteFile("D:\\abatron\\bdi360\\ColdFire\\pro\\m5213cfm.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifying ... "); result = BDI_VerifyFile("D:\\abatron\\bdi360\\ColdFire\\pro\\m5213cfm.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); return result; } /* Program5213 */ /**************************************************************************** **************************************************************************** Program5223 : Program internal flash of MCF5223. INPUT : - OUTPUT : RETURN error code ****************************************************************************/ #define MCF5223_CLOCK 60000000 #define MCF5223_WORKSPACE 0x20000000 static BDI_InitTypeT mcf5223InitList[] = { {BDI_INIT_MCF_WCREG, 0xC05, 0x20000021}, // RAMBAR: Internal SRAM at 0x20000000 {BDI_INIT_MCF_WCREG, 0xC04, 0x00000121}, // FLASHBAR: Internal Flash at 0x00000000 {BDI_INIT_MCF_WM8, 0x401D0002, 0x52 }, // CFMCLKD : Flash clock divider for fsys=60MHz {BDI_INIT_MCF_WM32, 0x401D0010, 0x00000000}, // CFMPROT : disable flash protection {BDI_INIT_MCF_WM8, 0x40120008, 0x04 }, // CCHR : PLL input = 1/5 ext. Clock {BDI_INIT_MCF_WM16, 0x40120000, 0x4003 }, // SYNCR : change PLL to 60MHz {BDI_INIT_MCF_DELAY, 0, 100 }, // let PLL lock {BDI_INIT_MCF_WM16, 0x40120000, 0x4007 }, // SYNCR : set fsys to 60MHz }; static int Program5223(void) { int result; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(0, MCF5223_CLOCK, sizeof mcf5223InitList / sizeof mcf5223InitList[0], mcf5223InitList); /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_CFM, 0x40000, 0, 32, MCF5223_WORKSPACE); /* erase all */ printf("erasing all ... "); result = BDI_FlashErase(BDI_ERASE_CHIP, 0x44000000); if (result != BDI_OKAY) return result; printf("passed\n"); /* program/verify from a file */ printf("programming ... "); result = BDI_FlashWriteFile("D:/abatron/bdi360/ColdFire/pro/m5223cfm.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifying ... "); result = BDI_VerifyFile("D:/abatron/bdi360/ColdFire/pro/m5223cfm.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); return result; } /* Program5223 */ static int Startup5223(void) { int result; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(0, MCF5223_CLOCK, sizeof mcf5223InitList / sizeof mcf5223InitList[0], mcf5223InitList); /* load from a file */ printf("loading ... "); result = BDI_LoadBinary("e:/temp/dump16k.bin", 0x20000000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifying... "); result = BDI_VerifyBinary("e:/temp/dump16k.bin", 0x20000000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); return result; } /* Startup5223 */