/**************************************************************************** **************************************************************************** Erase/Program EB40A flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListEB40A[] = { {BDI_INIT_ARM_WGPR, 8003, 0 }, // Successor count {BDI_INIT_ARM_WGPR, 8004, 0 }, // Successor size {BDI_INIT_ARM_WM32, 0xFFE00020, 0x00000001}, // Cancel reset remapping {BDI_INIT_ARM_WM32, 0xFFE00024, 0x00000006}, // enable A0..A20 {BDI_INIT_ARM_WM32, 0xFFE00000, 0x01002539}, // Flash at 0x01000000 {BDI_INIT_ARM_WM32, 0xFFFFF124, 0xFFFFFFFF}, // disable all interrupts }; static int ProgramEB40A(void) { int result; DWORD errorAddr; result = BDI_FlashSetType(BDI_FLASH_AT49X16, 0x200000, 0, 16, 0x00000000); result = BDI_TargetStartup(100, // 100ms reset time 1, // ARM7TDMI, 16MHz JTAG Clock sizeof initListEB40A / sizeof initListEB40A[0], initListEB40A); result = BDI_FlashEraseSector(0x01140000); result = BDI_FlashEraseSector(0x01150000); result = BDI_FlashEraseSector(0x01160000); result = BDI_FlashEraseSector(0x01170000); result = BDI_FlashEraseSector(0x01180000); result = BDI_FlashWriteFile("e:\\temp\\eb40a.sss", &errorAddr); return result; } /* ProgramEB40A */ /**************************************************************************** **************************************************************************** Erase/Program SMDK40100 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListSMDK40100[] = { {BDI_INIT_ARM_WGPR, 8006, 1000 }, // Wake-up delay after releasing reset {BDI_INIT_ARM_WCPSR, 0, 0x000000D3}, // CPSR {BDI_INIT_ARM_WM16, 0x07FFA002, 0xA500 }, // BTCON {BDI_INIT_ARM_WM32, 0x07FF1000, 0x00017FF0}, // SYSCFG {BDI_INIT_ARM_WM8, 0x07FFD003, 0x18 }, // SYSCON {BDI_INIT_ARM_WM16, 0x07FFB012, 0x0707 }, // PCON1: Enable A16-A18 {BDI_INIT_ARM_WM16, 0x07FFB016, 0x2AAA }, // PCON3: enable WE0 {BDI_INIT_ARM_WM16, 0x07FFB018, 0xFFFF }, // PCON4: enable D8-D15 {BDI_INIT_ARM_WM32, 0x07FF2000, 0x02000071}, // BANKCON0 {BDI_INIT_ARM_WM32, 0x07FF2004, 0x00000000}, // BANKCON1 {BDI_INIT_ARM_WM32, 0x07FF2008, 0x00000000}, // BANKCON2 {BDI_INIT_ARM_WM32, 0x07FF200C, 0x00000000}, // BANKCON3 {BDI_INIT_ARM_WM32, 0x07FF2010, 0x00000000}, // BANKCON4 {BDI_INIT_ARM_WM32, 0x07FF2014, 0x00000000}, // BANKCON5 {BDI_INIT_ARM_WM32, 0x07FF2018, 0x00000000}, // BANKCON6 {BDI_INIT_ARM_WM32, 0x07FF201C, 0x00000000}, // BANKCON7 {BDI_INIT_ARM_WM32, 0x07FF2020, 0x00000001}, // REFCON }; static BYTE flashData[] = {1,2,3,4,5,6,7,8}; static int ProgramSMDK40100(void) { int result; DWORD errorAddr; result = BDI_FlashSetType(BDI_FLASH_AM29FX00W, 0x100000, 0, 16, 0x07FF0000); result = BDI_TargetStartup(100, // 100ms reset time (1L << 16) | (0L << 8) | 1, // big endian, ARM7TDMI, 16MHz JTAG sizeof initListSMDK40100 / sizeof initListSMDK40100[0], initListSMDK40100); result = BDI_FlashEraseSector(0x10000); /* result = BDI_FlashWriteBlock(0x10000, sizeof flashData, flashData, &errorAddr); */ result = BDI_FlashWriteBinary("e:/temp/testdc.bin", 0x10000, &errorAddr); result = BDI_VerifyBinary("e:/temp/testdc.bin", 0x10000, &errorAddr); return result; } /* ProgramSMDK40100 */ /**************************************************************************** **************************************************************************** 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 */ /**************************************************************************** **************************************************************************** Erase/Program ADuC7000 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListADuC7020[] = { {BDI_INIT_ARM_WGPR, 8006, 300 }, // Wake-up delay after releasing reset {BDI_INIT_ARM_WGPR, 8008, 0x00010000}, // Set save debug PC to internal SRAM {BDI_INIT_ARM_WCPSR, 0, 0x000000D3}, // CPSR: set superviser mode }; static int ProgramADuC7020(void) { int result; DWORD errorAddr; // DWORD sector; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (0L << 8) | 1, // little endian, ARM7TDMI, 16 MHz JTAG sizeof initListADuC7020 / sizeof initListADuC7020[0], initListADuC7020); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_ADUC7000, 0x10000, 0, 16, 0x00010020); if (result != BDI_OKAY) return result; /* erase flash */ /* for (sector = 0x80000; sector <= 0x8F600; sector += 0x200) { printf("erasing sector 0x%08lx ... ", sector); result = BDI_FlashEraseSector(sector); if (result != BDI_OKAY) return result; printf("passed\n"); } */ printf("erasing all sectors ... "); result = BDI_FlashErase(BDI_ERASE_CHIP, 0x80000); if (result != BDI_OKAY) return result; printf("passed\n"); /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteFile("D:/abatron/bdi360/arm/pro/aduc7020.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyFile("D:/abatron/bdi360/arm/pro/aduc7020.sss", &errorAddr); printf("passed\n"); return result; } /* ProgramADuC7020 */ /**************************************************************************** **************************************************************************** Erase/Program STA2051 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListSTA2051[] = { {BDI_INIT_ARM_WGPR, 8006, 300 }, // Wake-up delay after releasing reset {BDI_INIT_ARM_WGPR, 8008, 0x20000000}, // Set save debug PC to internal SRAM {BDI_INIT_ARM_WGPR, 15, 0x00000000}, // Set PC to 0x00000000 {BDI_INIT_ARM_WCPSR, 0, 0x000000D3}, // CPSR: set superviser mode }; static int ProgramSTA2051(void) { int result; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (0L << 8) | 2, // little endian, ARM7TDMI, 8 MHz JTAG sizeof initListSTA2051 / sizeof initListSTA2051[0], initListSTA2051); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_STA2051, 0x40000, 0, 32, 0x20000000); if (result != BDI_OKAY) return result; /* erase flash */ /* printf("erasing Bank 0 : Sector 0 - 4 ... "); result = BDI_FlashEraseSector(0x0000001f); if (result != BDI_OKAY) return result; printf("passed\n"); printf("erasing Bank 0 : Sector 5 ... "); result = BDI_FlashEraseSector(0x00000020); if (result != BDI_OKAY) return result; printf("passed\n"); printf("erasing Bank 0 : Sector 6 ... "); result = BDI_FlashEraseSector(0x00000040); if (result != BDI_OKAY) return result; printf("passed\n"); printf("erasing Bank 0 : Sector 7 ... "); result = BDI_FlashEraseSector(0x00000080); if (result != BDI_OKAY) return result; printf("passed\n"); printf("erasing Bank 1 : Sector 0 - 1 ... "); result = BDI_FlashEraseSector(0x00030000); if (result != BDI_OKAY) return result; printf("passed\n"); */ printf("erasing Bank 0 : Sector 0 - 7 ... "); result = BDI_FlashEraseSector(0x000000ff); if (result != BDI_OKAY) return result; printf("passed\n"); printf("erasing Bank 1 : Sector 0 - 1 ... "); result = BDI_FlashEraseSector(0x00030000); if (result != BDI_OKAY) return result; printf("passed\n"); /* reset and init target again becuase old flash code cuase programming error */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (0L << 8) | 2, // little endian, ARM7TDMI, 8 MHz JTAG sizeof initListSTA2051 / sizeof initListSTA2051[0], initListSTA2051); if (result != BDI_OKAY) return result; /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteFile("D:/abatron/bdi360/arm/pro/sta2051_256k.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyFile("D:/abatron/bdi360/arm/pro/sta2051_256k.sss", &errorAddr); printf("passed\n"); return result; } /* ProgramSTA2051 */ /**************************************************************************** **************************************************************************** Erase/Program ST30F774 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListST30F774[] = { {BDI_INIT_ARM_WGPR, 8009, 1 }, // TRST driver type is push-pull {BDI_INIT_ARM_WGPR, 8007, 2 }, // Use special ST30 reset sequence {BDI_INIT_ARM_WGPR, 8006, 1000 }, // Delay for 1000 us after TRST/RST released {BDI_INIT_ARM_WGPR, 8008, 0xA0000000}, // Set save debug PC to internal SRAM {BDI_INIT_ARM_WGPR, 15, 0x00000000}, // Set PC to 0x00000000 {BDI_INIT_ARM_WCPSR, 0, 0x000000D3}, // CPSR: set superviser mode }; static int ProgramST30F774(void) { int result; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (0L << 8) | 1, // little endian, ARM7TDMI, 16 MHz JTAG sizeof initListST30F774 / sizeof initListST30F774[0], initListST30F774); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_ST30F, // ST30F774 0x80000, // 512K 0, 32, 0xA0000000); // workspace in internal SRAM if (result != BDI_OKAY) return result; /* erase flash */ printf("erasing Bank 0 : Sector 0 - 11 ... "); result = BDI_FlashEraseSector(0x00000fff); if (result != BDI_OKAY) return result; printf("passed\n"); /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteFile("D:/abatron/bdi360/arm/pro/st30f_512k.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyFile("D:/abatron/bdi360/arm/pro/st30f_512k.sss", &errorAddr); printf("passed\n"); return result; } /* ProgramST30F774 */ /**************************************************************************** **************************************************************************** Erase/Program AT91SAM7S flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListAT91SAM7S[] = { {BDI_INIT_ARM_WM32, 0xFFFFFD44, 0x00008000}, // Disable watchdog {BDI_INIT_ARM_WM32, 0xFFFFFD08, 0xA5000001}, // Enable user reset {BDI_INIT_ARM_WM32, 0xFFFFFC20, 0x00000601}, // CKGR_MOR : Enabling the Main Oscillator {BDI_INIT_ARM_DELAY, 0, 20 }, {BDI_INIT_ARM_WM32, 0xFFFFFC2C, 0x10480A0E}, // CKGR_PLLR: 96.1MHz (DIV=14,MUL=72+1) {BDI_INIT_ARM_DELAY, 0, 20 }, {BDI_INIT_ARM_WM32, 0xFFFFFC30, 0x00000007}, // PMC_MCKR : MCK = PLL / 2 = 48MHz {BDI_INIT_ARM_DELAY, 0, 20 }, {BDI_INIT_ARM_WGPR, 8005, 0x00000001}, // Set new JTAG clock to 16 MHz {BDI_INIT_ARM_WM32, 0xFFFFFF60, 0x00300100}, // MC_FMR: Flash mode (FWS=1,FMCN=48) }; static int CALLBACK DisplayProgress(DWORD count) { printf("Done %li\r", count); return 0; } /* DisplayProgress */ static int ProgramAT91SAM7S(void) { int result; DWORD errorAddr; /* install callback procedure */ BDI_InstallCallback(DisplayProgress); /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (0L << 8) | 10, // little endian, ARM7TDMI, 10kHz JTAG sizeof initListAT91SAM7S / sizeof initListAT91SAM7S[0], initListAT91SAM7S); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_AT91SAM7S, // AT91SAM7S64K 0x10000, // 64K 0, 32, 0xFFFFFFFF); if (result != BDI_OKAY) return result; /* erase all */ printf("erasing all ... "); result = BDI_FlashErase(BDI_ERASE_CHIP, 0x00100000); if (result != BDI_OKAY) return result; printf("passed\n"); /* program/verify from a file */ printf("programming...\n"); result = BDI_FlashWriteFile("D:/abatron/bdi360/arm/pro/sam7s_64k.sss", &errorAddr); if (result != BDI_OKAY) return result; printf("\npassed\n"); printf("verifing... \n"); result = BDI_VerifyFile("D:/abatron/bdi360/arm/pro/sam7s_64k.sss", &errorAddr); printf("\npassed\n"); return result; } /* ProgramAT91SAM7S */ /**************************************************************************** **************************************************************************** Erase/Program STR912F flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListSTR912[] = { {BDI_INIT_ARM_WGPR, 8006, 250 }, // Wakeup time after reset released {BDI_INIT_ARM_WGPR, 8008, 0x40000000}, // Set save debug PC to internal SRAM {BDI_INIT_ARM_WGPR, 8001, 1 }, // Number of JTAG devices before the ARM core {BDI_INIT_ARM_WGPR, 8002, 5 }, // Total IR length before the ARM core {BDI_INIT_ARM_WGPR, 8003, 1 }, // Number of JTAG devices after the ARM core {BDI_INIT_ARM_WGPR, 8004, 8 }, // Total IR length after the ARM core // Set clock to 48MHz via PLL {BDI_INIT_ARM_WM32, 0x5C002004, 0x000BC019}, // SCU_PLLCONF: PLL=ENA,P=3,N=C0,M=19 {BDI_INIT_ARM_DELAY, 0, 100 }, // let PLL lock {BDI_INIT_ARM_WM32, 0x5C002000, 0x00020000}, // SCU_CLKCNTR: MCLK=PLL // Setup flash memory interface (FMI) {BDI_INIT_ARM_WM32, 0x54000000, 0x00000004}, // FMI_BBSR : boot bank size = 512k {BDI_INIT_ARM_WM32, 0x5400000C, 0x00000000}, // FMI_BBADR : boot bank addr = 0x00000000 {BDI_INIT_ARM_WM32, 0x54000004, 0x00000002}, // FMI_NBBSR : boot bank size = 32k {BDI_INIT_ARM_WM32, 0x54000010, 0x00020000}, // FMI_NBBADR: boot bank addr = 0x00080000 {BDI_INIT_ARM_WM32, 0x54000018, 0x00000018}, // FMI_CR : enable both flash banks // load an execute code to set Configuration Control Register bit 18 {BDI_INIT_ARM_WM32, 0x40000000, 0xEE3F0F11}, // mrc 15, 1, r0, cr15, cr1, {0} {BDI_INIT_ARM_WM32, 0x40000004, 0xE3800701}, // orr r0, r0, #262144 {BDI_INIT_ARM_WM32, 0x40000008, 0xEE2F0F11}, // mcr 15, 1, r0, cr15, cr1, {0} {BDI_INIT_ARM_WM32, 0x4000000C, 0xEAFFFFFE}, // b $pc {BDI_INIT_ARM_EXEC, 0x40000000, 0x00000000}, // execute code }; static int ProgramSTR912(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (11L << 8) | 4, // little endian, ARM966, 1 MHz JTAG sizeof initListSTR912 / sizeof initListSTR912[0], initListSTR912); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_STR910F, 0x80000, // 512K 0, 16, 0x40000000); // workspace in internal SRAM if (result != BDI_OKAY) return result; /* unlock and erase sectors */ addr = 0; for (sector = 0; sector < 8; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_SetWord(addr, 0x0060); result = BDI_SetWord(addr, 0x00D0); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x10000; } /* for */ /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("e:/temp/dump512k.bin", 0x00000000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("e:/temp/dump512k.bin", 0x00000000, &errorAddr); printf("passed\n"); return result; } /* ProgramSTR912 */ /**************************************************************************** **************************************************************************** Erase/Program DaVinci : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListDaVinci[] = { {BDI_INIT_ARM_WGPR, 8009, 1 }, // TRST driver type is push-pull {BDI_INIT_ARM_WGPR, 8006, 100 }, // Wakeup time after reset released {BDI_INIT_ARM_WGPR, 8001, 1 }, // Number of JTAG devices before the ARM core {BDI_INIT_ARM_WGPR, 8002, 6 }, // Total IR length before the ARM core {BDI_INIT_ARM_WGPR, 8003, 0 }, // Number of JTAG devices after the ARM core {BDI_INIT_ARM_WGPR, 8004, 0 }, // Total IR length after the ARM core {BDI_INIT_ARM_WGPR, 8015, 0x1F }, // set vector catch mask during reset }; // Configure ICEPick module to make ARM926 TAP visible static const char* scanInit = "r0:w10000:" "r1:t1:w1000:t0:w1000:" // assert reset and toggle TRST "i6=07:d8=89:i6=02:" // connect and select router "d32=81000082:" // set IP control "d32=a018206f:" // configure TAP0 "d32=a018216f:cl5:" // enable TAP0, clock 5 times in RTI "i10=ffff"; // scan bypass static int ProgramDaVinci(void) { int result; /* download Scan Init string */ result = BDI_SetOption(BDI_OPT_ARM_SCANINIT, scanInit); /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (14L << 8) | 4, // little endian, ARM926E, 1 MHz JTAG sizeof initListDaVinci / sizeof initListDaVinci[0], initListDaVinci); if (result != BDI_OKAY) return result; return result; } /* ProgramDaVinci */ /**************************************************************************** **************************************************************************** Startup/Program iMX31 : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListIMX31[] = { {BDI_INIT_ARM11_WGPR, 8006, 250 }, // Wakeup time after reset released {BDI_INIT_ARM11_WGPR, 8001, 2 }, // Number of JTAG devices before the ARM core {BDI_INIT_ARM11_WGPR, 8002, 9 }, // Total IR length before the ARM core {BDI_INIT_ARM11_WGPR, 8003, 1 }, // Number of JTAG devices after the ARM core {BDI_INIT_ARM11_WGPR, 8004, 4 }, // Total IR length after the ARM core {BDI_INIT_ARM11_CP15, 0x0001, 0x00050078}, // CP15 control register {BDI_INIT_ARM11_CP15, 0x0707, 0x00000000}, // CP15 invalidate I&D {BDI_INIT_ARM11_CP15, 0x0708, 0x00000000}, // CP15 invalidate TLB {BDI_INIT_ARM11_CP15, 0x4A07, 0x00000000}, // CP15 clean write buf }; static int StartupIMX31(void) { int result; /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (0L << 8) | 1, // little endian, ARM1136, 16 MHz JTAG sizeof initListIMX31 / sizeof initListIMX31[0], initListIMX31); if (result != BDI_OKAY) return result; return result; } /* StartupIMX31 */ static int ProgramIMX31(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (0L << 8) | 2, // little endian, ARM1136, 16 MHz JTAG sizeof initListIMX31 / sizeof initListIMX31[0], initListIMX31); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_I28BX16, 0x200000, // 2MB 0, 16, 0x1fffc000); // workspace in internal SRAM if (result != BDI_OKAY) return result; /* unlock and erase sectors */ addr = 0xa0140000; for (sector = 0; sector < 4; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_SetWord(addr, 0x0060); result = BDI_SetWord(addr, 0x00D0); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x10000; } /* for */ /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("e:/temp/dump256k.bin", 0xa0140000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifying... "); result = BDI_VerifyBinary("e:/temp/dump256k.bin", 0xa0140000, &errorAddr); printf("passed\n"); return result; } /* ProgramIMX31 */ /**************************************************************************** **************************************************************************** Startup OMAP3500 : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initList3500[] = { {BDI_INIT_ARM11_WGPR, 8001, 1 }, // Number of JTAG devices before the ARM core {BDI_INIT_ARM11_WGPR, 8002, 6 }, // Total IR length before the ARM core {BDI_INIT_ARM11_WGPR, 8003, 0 }, // Number of JTAG devices after the ARM core {BDI_INIT_ARM11_WGPR, 8004, 0 }, // Total IR length after the ARM core {BDI_INIT_ARM_WGPR, 8009, 1 }, // TRST as push-pull {BDI_INIT_ARM_WGPR, 8007, 0 }, // Select Reset Type NONE {BDI_INIT_ARM_WGPR, 8012, 0 }, // Memory Access via Core {BDI_INIT_ARM_WGPR, 8013, 10 }, // 80 TCK's access delay }; // Configure ICEPick module to make Cortex-A8 TAP visible static const char* scanInit3500 = "t1:w1000:t0:w1000:" // toggle TRST, "ch10:w1000:" // clock TCK with TMS high and wait "i6=07:d8=89:i6=02:" // connect and select router "d32=81000080:" // IP control: KeepPowered "d32=a3002048:" // TAP3: DebugConnect, ForcePower, ForceActive "d32=81000081:" // IP control: KeepPowered, SysReset "d32=a3002148:" // enable TAP3 "cl10:i10=ffff"; // clock 10 times in RTI, scan bypass static int StartupOMAP3500(void) { int result; /* download Scan Init string */ result = BDI_SetOption(BDI_OPT_ARM_SCANINIT, scanInit3500); /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (0L << 16) | (2L << 8) | 2, // little endian, OMAP3xxx, 16 MHz JTAG sizeof initList3500 / sizeof initList3500[0], initList3500); if (result != BDI_OKAY) return result; return result; } /* StartupOMAP3500 */ /**************************************************************************** **************************************************************************** Startup/Program STM32 : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListSTM32[] = { {BDI_INIT_ARM11_WGPR, 8006, 100 }, // Wakeup time after reset released {BDI_INIT_ARM11_WGPR, 8001, 1 }, // Number of JTAG devices before the ARM core {BDI_INIT_ARM11_WGPR, 8002, 5 }, // Total IR length before the ARM core {BDI_INIT_ARM11_WGPR, 8003, 0 }, // Number of JTAG devices after the ARM core {BDI_INIT_ARM11_WGPR, 8004, 0 }, // Total IR length after the ARM core {BDI_INIT_ARM_WGPR, 8013, 4 }, // 32 TCK's access delay {BDI_INIT_ARM11_WGPR, 13, 0x20004ffc }, // set SP to top of internal SRAM }; static int StartupSTM32(void) { int result; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (6L << 8) | 4, // little endian, Cortex-M3, 8 MHz JTAG sizeof initListSTM32 / sizeof initListSTM32[0], initListSTM32); if (result != BDI_OKAY) return result; return result; } /* StartupSTM32 */ static int ProgramSTM32(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (6L << 8) | 4, // little endian, Cortex-M3, 8 MHz JTAG sizeof initListSTM32 / sizeof initListSTM32[0], initListSTM32); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_STM32F10, 0x20000, 0, 16, 0x20000000); // workspace in internal SRAM if (result != BDI_OKAY) return result; /* erase sectors */ addr = 0x08010000; for (sector = 0; sector < 16; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x400; } /* for */ /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("e:/temp/dump16k.bin", 0x08010000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifying... "); result = BDI_VerifyBinary("e:/temp/dump16k.bin", 0x08010000, &errorAddr); printf("passed\n"); return result; } /* ProgramSTM32 */ static int EraseSTM32(void) { int result; int sector; DWORD addr; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (6L << 8) | 4, // little endian, Cortex-M3, 8 MHz JTAG sizeof initListSTM32 / sizeof initListSTM32[0], initListSTM32); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_STM32F10, 0x20000, 0, 16, 0x20000000); // workspace in internal SRAM if (result != BDI_OKAY) return result; /* erase sectors */ addr = 0x08010000; for (sector = 0; sector < 16; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x400; } /* for */ return result; } /* EraseSTM32 */ /**************************************************************************** **************************************************************************** Erase/Program ProgramSTM32L15 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListSTM32L15[] = { {BDI_INIT_ARM_WGPR, 8006, 100 }, // Wakeup time after reset released {BDI_INIT_ARM_WGPR, 8001, 1 }, // Number of JTAG devices before the core {BDI_INIT_ARM_WGPR, 8002, 5 }, // Total IR length before the core {BDI_INIT_ARM_WGPR, 8003, 0 }, // Number of JTAG devices after the core {BDI_INIT_ARM_WGPR, 8004, 0 }, // Total IR length after the core {BDI_INIT_ARM_WGPR, 8012, 1 }, // memory access via AHB {BDI_INIT_ARM_WGPR, 8013, 10 }, // Flash programming: needs 80 TCK's access delay for slow core clock {BDI_INIT_ARM_WGPR, 13, 0x20003ffc}, // set SP to top of internal 16kB SRAM }; static int StartupSTM32L15(void) { int result; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (6L << 8) | 2, // little endian, Cortex-M3, 8 MHz JTAG sizeof initListSTM32L15 / sizeof initListSTM32L15[0], initListSTM32L15); return result; } /* StartupSTM32L15 */ static int ProgramSTM32L15(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time // (0L << 16) | (6L << 8) | 2, // BDI2000: LE, Cortex-M3, 8MHz (0L << 16) | (6L << 8) | 6, // BDI3000: LE, Cortex-M3, 4MHz sizeof initListSTM32L15 / sizeof initListSTM32L15[0], initListSTM32L15); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_STM32L15, 0x20000, // 128K 0, 32, 0x20000000); // workspace internal SRAM if (result != BDI_OKAY) return result; /* erase 256 pages */ addr = 0x08010000; for (sector = 0; sector < 256; sector++) { printf("erasing page 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 256; } /* for */ /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("E:/temp/dump64k.bin", 0x08010000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("E:/temp/dump64k.bin", 0x08010000, &errorAddr); printf("passed\n"); return result; } /* ProgramSTM32L15 */ /**************************************************************************** **************************************************************************** Erase/Program ProgramSTM32F2 flash : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListSTM32F2[] = { {BDI_INIT_ARM_WGPR, 8006, 100 }, // Wakeup time after reset released {BDI_INIT_ARM_WGPR, 8001, 1 }, // Number of JTAG devices before the core {BDI_INIT_ARM_WGPR, 8002, 5 }, // Total IR length before the core {BDI_INIT_ARM_WGPR, 8003, 0 }, // Number of JTAG devices after the core {BDI_INIT_ARM_WGPR, 8004, 0 }, // Total IR length after the core {BDI_INIT_ARM_WGPR, 8012, 1 }, // memory access via AHB {BDI_INIT_ARM_WGPR, 8013, 2 }, // 16 TCK's access delay {BDI_INIT_ARM_WGPR, 13, 0x2000fffc}, // set SP to top of internal SRAM }; static int StartupSTM32F2(void) { int result; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (6L << 8) | 2, // little endian, Cortex-M3, 8 MHz JTAG sizeof initListSTM32F2 / sizeof initListSTM32F2[0], initListSTM32F2); return result; } /* StartupSTM32F2 */ static int ProgramSTM32F2(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time // (0L << 16) | (6L << 8) | 2, // BDI2000: LE, Cortex-M3, 8MHz (0L << 16) | (6L << 8) | 4, // BDI3000: LE, Cortex-M3, 8MHz sizeof initListSTM32F2 / sizeof initListSTM32F2[0], initListSTM32F2); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_STM32F2, 0x100000, // 1MB 0, 32, // x32 Program/Erase parallelism (2.7V - 3.6V) 0x20000000); // workspace internal SRAM if (result != BDI_OKAY) return result; /* erase a 16K sector */ addr = 0x08008000; printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); /* erase a 16K sector */ addr = 0x0800C000; printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); /* erase the 64K sector */ addr = 0x08010000; printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); /* erase all 128K Sectors */ addr = 0x08020000; for (sector = 5; sector <= 11; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x20000; } /* for */ /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("E:/temp/dump512k.bin", 0x08008000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("E:/temp/dump512k.bin", 0x08008000, &errorAddr); printf("passed\n"); return result; } /* ProgramSTM32F2 */ /**************************************************************************** **************************************************************************** Erase/Program ProgramSTM32F4 flash: INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListSTM32F4[] = { {BDI_INIT_ARM_WGPR, 8006, 100 }, // Wakeup time after reset released {BDI_INIT_ARM_WGPR, 8001, 1 }, // Number of JTAG devices before the core {BDI_INIT_ARM_WGPR, 8002, 5 }, // Total IR length before the core {BDI_INIT_ARM_WGPR, 8003, 0 }, // Number of JTAG devices after the core {BDI_INIT_ARM_WGPR, 8004, 0 }, // Total IR length after the core {BDI_INIT_ARM_WGPR, 8012, 1 }, // memory access via AHB {BDI_INIT_ARM_WGPR, 8013, 2 }, // 16 TCK's access delay {BDI_INIT_ARM_WGPR, 13, 0x2000fffc}, // set SP to top of internal SRAM }; static int StartupSTM32F4(void) { int result; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time // (0L << 16) | (11L << 8) | 2, // BDI2000: LE, Cortex-M4, 8MHz (0L << 16) | (11L << 8) | 4, // BDI3000: LE, Cortex-M4, 8MHz sizeof initListSTM32F4 / sizeof initListSTM32F4[0], initListSTM32F4); return result; } /* StartupSTM32F4 */ static int ProgramSTM32F4(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time // (0L << 16) | (11L << 8) | 2, // BDI2000: LE, Cortex-M4, 8MHz (0L << 16) | (11L << 8) | 4, // BDI3000: LE, Cortex-M4, 8MHz sizeof initListSTM32F4 / sizeof initListSTM32F4[0], initListSTM32F4); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_STM32F4, 0x100000, // 1MB 0, 32, // x32 Program/Erase parallelism (2.7V - 3.6V) 0x20000000); // workspace internal SRAM if (result != BDI_OKAY) return result; /* erase a 16K sector */ addr = 0x08008000; printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); /* erase a 16K sector */ addr = 0x0800C000; printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); /* erase the 64K sector */ addr = 0x08010000; printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); /* erase all 128K Sectors */ addr = 0x08020000; for (sector = 5; sector <= 11; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x20000; } /* for */ /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("E:/temp/dump512k.bin", 0x08008000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("E:/temp/dump512k.bin", 0x08008000, &errorAddr); printf("passed\n"); return result; } /* ProgramSTM32F4 */ /**************************************************************************** **************************************************************************** Startup/Program LM3S : INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListLM3S[] = { {BDI_INIT_ARM11_WGPR, 8006, 100 }, // Wakeup time after reset released {BDI_INIT_ARM11_WGPR, 8007, 3 }, // assert reset via Reset Control Register {BDI_INIT_ARM11_WGPR, 13, 0x2000fffc}, // set SP to top of internal SRAM {BDI_INIT_ARM11_WM32, 0x400FE060, 0x078e3ad1}, // RCC : bypass, internal {BDI_INIT_ARM11_WM32, 0x400FE070, 0x07802810}, // RCC2: bypass, internal {BDI_INIT_ARM11_WM32, 0x400FE060, 0x078e3ad0}, // RCC : enable main oscillator {BDI_INIT_ARM11_DELAY, 0, 100 }, // let main oscillator startup {BDI_INIT_ARM11_WM32, 0x400FE060, 0x078e0b80}, // RCC : XTAL is 8 MHz, power-up PLL, select main {BDI_INIT_ARM11_WM32, 0x400FE070, 0x07800800}, // RCC2: power-up PLL, select main {BDI_INIT_ARM11_WM32, 0x400FE060, 0x01ce0b80}, // RCC : set SYSDIV for 50MHz {BDI_INIT_ARM11_WM32, 0x400FE070, 0x01800800}, // RCC2: set SYSDIV for 50MHz {BDI_INIT_ARM11_DELAY, 0, 100 }, // let PLL lock {BDI_INIT_ARM11_WM32, 0x400FE060, 0x01ce0380}, // RCC : clear bypass {BDI_INIT_ARM11_WM32, 0x400FE070, 0x01800000}, // RCC2: clear bypass {BDI_INIT_ARM11_WM32, 0x400FE060, 0x01d40380}, // RCC : set PWMDIV {BDI_INIT_ARM11_WM32, 0x400FE140, 49 }, // USECRL: Flash USec Reload for 50 MHz }; static int StartupLM3S(void) { int result; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (6L << 8) | 2, // little endian, Cortex-M3, 8 MHz JTAG sizeof initListLM3S / sizeof initListLM3S[0], initListLM3S); if (result != BDI_OKAY) return result; return result; } /* StartupLM3S */ static int ProgramLM3S(void) { int result; int sector; DWORD addr; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (6L << 8) | 2, // little endian, Cortex-M3, 8 MHz JTAG sizeof initListLM3S / sizeof initListLM3S[0], initListLM3S); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_LM3S, 0x40000, 0, 32, 0x20000000); // workspace in internal SRAM if (result != BDI_OKAY) return result; /* erase sectors */ addr = 0x00030000; for (sector = 0; sector < 16; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x400; } /* for */ /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("e:/temp/dump16k.bin", 0x00030000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifying... "); result = BDI_VerifyBinary("e:/temp/dump16k.bin", 0x00030000, &errorAddr); printf("passed\n"); return result; } /* ProgramLM3S */ static int EraseLM3S(void) { int result; int sector; DWORD addr; /* reset and init target */ result = BDI_TargetStartup(100, // 100ms reset time (0L << 16) | (6L << 8) | 2, // little endian, Cortex-M3, 8 MHz JTAG sizeof initListLM3S / sizeof initListLM3S[0], initListLM3S); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_LM3S, 0x40000, 0, 32, 0x20000000); // workspace in internal SRAM if (result != BDI_OKAY) return result; /* erase sectors */ addr = 0x00030000; for (sector = 0; sector < 16; sector++) { printf("erasing sector 0x%08lx ... ", addr); result = BDI_FlashEraseSector(addr); if (result != BDI_OKAY) return result; printf("passed\n"); addr += 0x400; } /* for */ return result; } /* EraseLM3S */ /**************************************************************************** **************************************************************************** Erase/Program ProgramMAC7116 flash : Programming speed with a BDI3000 is about 200 kBytes/s Programming the 1MB internal flash takes about 5 seconds. INPUT : OUTPUT : RETURN error code ****************************************************************************/ static BDI_InitTypeT initListMAC7116[] = { {BDI_INIT_ARM_WGPR, 8008, 0x40000000}, // Set save debug PC to internal SRAM // Speed-up to fsys = 50MHz {BDI_INIT_ARM_WM8, 0xFC088001, 0x07 }, // REFDV : divide by 8 {BDI_INIT_ARM_WM8, 0xFC088000, 0x18 }, // SYNR : multiply by 25 {BDI_INIT_ARM_DELAY, 0, 100 }, // let PLL lock {BDI_INIT_ARM_WM8, 0xFC088005, 0x80 }, // CLKSEL: Select PLL {BDI_INIT_ARM_WM8, 0xFC088003, 0x72 }, // CRGFLG: Clear the flags {BDI_INIT_ARM_WGPR, 8005, 0x00000006}, // Set new JTAG clock to 4 MHz // Setup Flash Programming {BDI_INIT_ARM_WM32, 0xFC0F0010, 0x00000000}, // CFMPROT: disable program flash protection {BDI_INIT_ARM_WM8, 0xFC0F0044, 0x00 }, // CFMDFPROT: disable data flash protection {BDI_INIT_ARM_WM8, 0xFC0F0002, 0x4F }, // CFMCLKD: set clock divider for 25.0 MHz IP clock }; static int ProgramMAC7116(void) { int result; DWORD errorAddr; /* reset and init target */ result = BDI_TargetStartup(500, // 500ms reset time (1L << 16) | (13L << 8) | 7, // big endian, MAC71xx, 1 MHz JTAG sizeof initListMAC7116 / sizeof initListMAC7116[0], initListMAC7116); if (result != BDI_OKAY) return result; /* setup flash type */ result = BDI_FlashSetType(BDI_FLASH_CFM32, 0x80000, // 512K 0, 32, 0x40000000); // workspace in internal SRAM if (result != BDI_OKAY) return result; /* erase all */ printf("erasing ... "); result = BDI_FlashErase(BDI_ERASE_CHIP, 0xFC100000); if (result != BDI_OKAY) return result; printf("passed\n"); /* program/verify from a file */ printf("programming..."); result = BDI_FlashWriteBinary("e:/temp/dump512k.bin", 0xFC110000, &errorAddr); if (result != BDI_OKAY) return result; printf("passed\n"); printf("verifing... "); result = BDI_VerifyBinary("e:/temp/dump512k.bin", 0xFC110000, &errorAddr); printf("passed\n"); return result; } /* ProgramMAC7116 */