/**************************************************************************** **************************************************************************** Erase/Program LPC2106 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListLPC2106[] = { {BDI_INIT_ARM_WGPR, 8006, 100 }, // Wake-up delay after releasing reset {BDI_INIT_ARM_WM32, 0xE01FC040, 0x00000001}, // MEMMAP: User flash mode }; static int ProgramLPC2106(void) { int result; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (0L << 8) | 4, // little endian, ARM7TDMI, 1 MHz JTAG sizeof initListLPC2106 / sizeof initListLPC2106[0], initListLPC2106); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetupLPC2000(0x20000, // 128k flash device 14745, // fsys = 14.745MHz 0x40001000); // internal SRAM for buffer, code and stack if (result != BDI_OKAY) return result; /* erase flash */ printf("erasing ... "); result = BDI_FlashEraseSector(0x000000F0); // erase sectors 4 - 7 // result = BDI_FlashEraseSector(0x00007FFF); // erase sectors 0 - 14 if (result != BDI_OKAY) return result; printf("passed\n"); /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("e:/temp/dump16k.bin", 0x08000, &errorAddr); //result = BDI_FlashWriteBinary("E:/cygwin/home/bdidemo/arm/lpc2100.bin", 0x00000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("e:/temp/dump16k.bin", 0x08000, &errorAddr); // result = BDI_VerifyBinary("E:/cygwin/home/bdidemo/arm/lpc2100.bin", 0x00000, &errorAddr); printf("passed\n"); return result; } /* ProgramLPC2106 */ /**************************************************************************** **************************************************************************** Erase/Program LPC2129 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListLPC2129[] = { {BDI_INIT_ARM_WGPR, 8006, 100 }, // Wake-up delay after releasing reset {BDI_INIT_ARM_WM32, 0xE01FC040, 0x00000001}, // MEMMAP: User flash mode // Disable PLL for flash programming {BDI_INIT_ARM_WM32, 0xE01FC080, 0x00000000}, // PLLCON {BDI_INIT_ARM_WM32, 0xE01FC084, 0x00000000}, // PLLCFG {BDI_INIT_ARM_WM32, 0xE01FC08C, 0x000000AA}, // PLLFEED {BDI_INIT_ARM_WM32, 0xE01FC08C, 0x00000055}, // PLLFEED }; static int ProgramLPC2129(void) { int result; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (0L << 8) | 4, // little endian, ARM7TDMI, 1 MHz JTAG sizeof initListLPC2129 / sizeof initListLPC2129[0], initListLPC2129); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetupLPC2000(0x40000, // 256k flash device 12000, // fsys = 12.000MHz 0x40001000); // internal SRAM for buffer, code and stack if (result != BDI_OKAY) return result; /* erase flash */ printf("erasing ... "); result = BDI_FlashEraseSector(0x0001FFFF); // erase sectors 0 - 16 if (result != BDI_OKAY) return result; printf("passed\n"); /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteFile("D:/abatron/bdi360/arm/pro/lpc248k.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyFile("D:/abatron/bdi360/arm/pro/lpc248k.sss", &errorAddr); printf("passed\n"); return result; } /* ProgramLPC2129 */