* jtagmkII.c: Stylistic changes: move #defines out into
jtagmkII_private.h, drop all #if 0 blocks, fold overly long lines, move the *_initpgm() functions to the end of the file; while being here, remove all trailing whitespace. * jtagmkII_private.h: move AVR32 #defines here. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@909 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
c879205c05
commit
3e2e779436
|
@ -1,3 +1,11 @@
|
|||
2010-01-13 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* jtagmkII.c: Stylistic changes: move #defines out into
|
||||
jtagmkII_private.h, drop all #if 0 blocks, fold overly long lines,
|
||||
move the *_initpgm() functions to the end of the file; while being
|
||||
here, remove all trailing whitespace.
|
||||
* jtagmkII_private.h: move AVR32 #defines here.
|
||||
|
||||
2010-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* bootstrap: autoconf 2.62 works well.
|
||||
|
|
567
jtagmkII.c
567
jtagmkII.c
|
@ -2342,193 +2342,8 @@ static void jtagmkII_print_parms(PROGRAMMER * pgm)
|
|||
#pragma mark -
|
||||
#endif
|
||||
|
||||
void jtagmkII_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "JTAGMKII");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase;
|
||||
pgm->open = jtagmkII_open;
|
||||
pgm->close = jtagmkII_close;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write;
|
||||
pgm->paged_load = jtagmkII_paged_load;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
pgm->set_sck_period = jtagmkII_set_sck_period;
|
||||
pgm->parseextparams = jtagmkII_parseextparms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
}
|
||||
|
||||
void jtagmkII_dw_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "JTAGMKII_DW");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase_dw;
|
||||
pgm->open = jtagmkII_open_dw;
|
||||
pgm->close = jtagmkII_close;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write;
|
||||
pgm->paged_load = jtagmkII_paged_load;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
pgm->flag = PGM_FL_IS_DW;
|
||||
}
|
||||
|
||||
|
||||
void jtagmkII_dragon_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "DRAGON_JTAG");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase;
|
||||
pgm->open = jtagmkII_dragon_open;
|
||||
pgm->close = jtagmkII_close;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write;
|
||||
pgm->paged_load = jtagmkII_paged_load;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
pgm->set_sck_period = jtagmkII_set_sck_period;
|
||||
pgm->parseextparams = jtagmkII_parseextparms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
}
|
||||
|
||||
|
||||
void jtagmkII_dragon_dw_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "DRAGON_DW");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase_dw;
|
||||
pgm->open = jtagmkII_dragon_open_dw;
|
||||
pgm->close = jtagmkII_close;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write;
|
||||
pgm->paged_load = jtagmkII_paged_load;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
pgm->flag = PGM_FL_IS_DW;
|
||||
}
|
||||
|
||||
void jtagmkII_avr32_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "JTAGMKII_AVR32");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize32;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase32;
|
||||
pgm->open = jtagmkII_open32;
|
||||
pgm->close = jtagmkII_close32;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write32;
|
||||
pgm->paged_load = jtagmkII_paged_load32;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
//pgm->set_sck_period = jtagmkII_set_sck_period;
|
||||
//pgm->parseextparams = jtagmkII_parseextparms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
}
|
||||
|
||||
#ifdef __OBJC__
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
#define AVR32_FLASHC_FCR 0xFFFE1400
|
||||
#define AVR32_FLASHC_FCMD 0xFFFE1404
|
||||
#define AVR32_FLASHC_FCMD_KEY 0xA5000000
|
||||
#define AVR32_FLASHC_FCMD_WRITE_PAGE 1
|
||||
#define AVR32_FLASHC_FCMD_ERASE_PAGE 2
|
||||
#define AVR32_FLASHC_FCMD_CLEAR_PAGE_BUFFER 3
|
||||
#define AVR32_FLASHC_FCMD_LOCK 4
|
||||
#define AVR32_FLASHC_FCMD_UNLOCK 5
|
||||
#define AVR32_FLASHC_FSR 0xFFFE1408
|
||||
#define AVR32_FLASHC_FSR_RDY 0x00000001
|
||||
#define AVR32_FLASHC_FSR_ERR 0x00000008
|
||||
#define AVR32_FLASHC_FGPFRHI 0xFFFE140C
|
||||
#define AVR32_FLASHC_FGPFRLO 0xFFFE1410
|
||||
|
||||
#define AVR32_DC 0x00000008
|
||||
#define AVR32_DS 0x00000010
|
||||
#define AVR32_DINST 0x00000104
|
||||
#define AVR32_DCCPU 0x00000110
|
||||
#define AVR32_DCEMU 0x00000114
|
||||
#define AVR32_DCSR 0x00000118
|
||||
|
||||
#define AVR32_DC_ABORT 0x80000000
|
||||
#define AVR32_DC_RESET 0x40000000
|
||||
#define AVR32_DC_DBE 0x00002000
|
||||
#define AVR32_DC_DBR 0x00001000
|
||||
|
||||
|
||||
static int jtagmkII_avr32_reset(PROGRAMMER * pgm, unsigned char val, unsigned char ret1, unsigned char ret2)
|
||||
static int jtagmkII_avr32_reset(PROGRAMMER * pgm, unsigned char val,
|
||||
unsigned char ret1, unsigned char ret2)
|
||||
{
|
||||
int status;
|
||||
unsigned char buf[3], *resp;
|
||||
|
@ -2570,12 +2385,6 @@ static int jtagmkII_avr32_reset(PROGRAMMER * pgm, unsigned char val, unsigned ch
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define AVR32_RESET_READ 0x0001
|
||||
#define AVR32_RESET_WRITE 0x0002
|
||||
#define AVR32_RESET_CHIP_ERASE 0x0004
|
||||
#define AVR32_SET4RUNNING 0x0008
|
||||
//#define AVR32_RESET_COMMON (AVR32_RESET_READ | AVR32_RESET_WRITE | AVR32_RESET_CHIP_ERASE )
|
||||
|
||||
// At init: AVR32_RESET_READ_IR | AVR32_RESET_READ_READ_CHIPINFO
|
||||
static int jtagmkII_reset32(PROGRAMMER * pgm, unsigned short flags)
|
||||
{
|
||||
|
@ -2620,12 +2429,14 @@ static int jtagmkII_reset32(PROGRAMMER * pgm, unsigned short flags)
|
|||
}
|
||||
|
||||
if(flags & (AVR32_RESET_READ | AVR32_RESET_CHIP_ERASE)) {
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_DC, 0x01, AVR32_DC_DBE | AVR32_DC_DBR);
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_DC, 0x01,
|
||||
AVR32_DC_DBE | AVR32_DC_DBR);
|
||||
if(status < 0) return -1;
|
||||
}
|
||||
|
||||
if(flags & (AVR32_RESET_WRITE | AVR32_SET4RUNNING)) {
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_DC, 0x01, AVR32_DC_ABORT | AVR32_DC_RESET | AVR32_DC_DBE | AVR32_DC_DBR);
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_DC, 0x01,
|
||||
AVR32_DC_ABORT | AVR32_DC_RESET | AVR32_DC_DBE | AVR32_DC_DBR);
|
||||
if(status < 0) return -1;
|
||||
for(j=0; j<21; ++j) {
|
||||
val = jtagmkII_read_SABaddr(pgm, AVR32_DS, 0x01);
|
||||
|
@ -2777,74 +2588,89 @@ static int jtagmkII_smc_init32(PROGRAMMER * pgm)
|
|||
unsigned long val;
|
||||
|
||||
// HMATRIX 0xFFFF1000
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x04000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x04000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x04000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x04000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x04000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x04000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x04000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x04000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x04000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x04000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x08000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x08000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x08000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x08000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x08000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x08000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x08000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x08000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x08000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x08000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x10000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x10000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x10000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x10000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x10000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x10000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x10000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x10000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x10000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x10000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x00020000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x00020000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x00020000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x00020000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x00020000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x00020000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x00020000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x00020000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x00020000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x00020000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x02000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x02000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x02000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x02000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x02000000); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1018, 0x05, 0x02000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1024, 0x05, 0x02000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1008, 0x05, 0x02000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1078, 0x05, 0x02000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff1088, 0x05, 0x02000000);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xfffe1c00, 0x05, 0x00010001); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xfffe1c04, 0x05, 0x05070a0b); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xfffe1c08, 0x05, 0x000b000c); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xfffe1c0c, 0x05, 0x00031103); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xfffe1c00, 0x05, 0x00010001);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xfffe1c04, 0x05, 0x05070a0b);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xfffe1c08, 0x05, 0x000b000c);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xfffe1c0c, 0x05, 0x00031103);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
// switchToClockSource
|
||||
val = jtagmkII_read_SABaddr(pgm, 0xffff0c28, 0x05); if(val != 0x00000000) {lineno = __LINE__; goto eRR;} // OSC 0
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff0c28, 0x05, 0x0000607); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
val = jtagmkII_read_SABaddr(pgm, 0xffff0c00, 0x05); if(val != 0x00000000) {lineno = __LINE__; goto eRR;} // PLL 0
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff0c00, 0x05, 0x0000004); if(status < 0) {lineno = __LINE__; goto eRR;} // Power Manager
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff0c00, 0x05, 0x0000005); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
val = jtagmkII_read_SABaddr(pgm, 0xffff0c28, 0x05);
|
||||
if (val != 0x00000000) {lineno = __LINE__; goto eRR;} // OSC 0
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff0c28, 0x05, 0x0000607);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
val = jtagmkII_read_SABaddr(pgm, 0xffff0c00, 0x05);
|
||||
if (val != 0x00000000) {lineno = __LINE__; goto eRR;} // PLL 0
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff0c00, 0x05, 0x0000004);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;} // Power Manager
|
||||
status = jtagmkII_write_SABaddr(pgm, 0xffff0c00, 0x05, 0x0000005);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
usleep(1000000);
|
||||
|
||||
val = jtagmkII_read_SABaddr(pgm, 0xfffe1408, 0x05); if(val != 0x0000a001) {lineno = __LINE__; goto eRR;} // PLL 0
|
||||
val = jtagmkII_read_SABaddr(pgm, 0xfffe1408, 0x05);
|
||||
if (val != 0x0000a001) {lineno = __LINE__; goto eRR;} // PLL 0
|
||||
|
||||
// need a small delay to let clock stabliize
|
||||
{
|
||||
usleep(50*1000);
|
||||
#if 0
|
||||
struct timeval tm_ref, tm_new;
|
||||
time_t t_ref, t_new;
|
||||
|
||||
gettimeofday(&tm_ref, NULL);
|
||||
while(1) {
|
||||
gettimeofday(&tm_new, NULL);
|
||||
if(tm_ref.tv_sec == tm_new.tv_sec) {
|
||||
t_ref = tm_ref.tv_usec;
|
||||
t_new = tm_new.tv_usec;
|
||||
} else {
|
||||
t_new = (tm_new.tv_sec - tm_ref.tv_sec) * 1000000 + tm_new.tv_usec;
|
||||
t_ref = tm_ref.tv_usec;
|
||||
}
|
||||
// 1 ms
|
||||
if((t_new-t_ref) > 1000) break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
usleep(50*1000);
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -3003,7 +2829,8 @@ static int jtagmkII_chip_erase32(PROGRAMMER * pgm, AVRPART * p)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static unsigned long jtagmkII_read_SABaddr(PROGRAMMER * pgm, unsigned long addr, unsigned int prefix)
|
||||
static unsigned long jtagmkII_read_SABaddr(PROGRAMMER * pgm, unsigned long addr,
|
||||
unsigned int prefix)
|
||||
{
|
||||
unsigned char buf[6], *resp;
|
||||
int status;
|
||||
|
@ -3067,7 +2894,8 @@ static unsigned long jtagmkII_read_SABaddr(PROGRAMMER * pgm, unsigned long addr,
|
|||
return val;
|
||||
}
|
||||
|
||||
static int jtagmkII_write_SABaddr(PROGRAMMER * pgm, unsigned long addr, unsigned int prefix, unsigned long val)
|
||||
static int jtagmkII_write_SABaddr(PROGRAMMER * pgm, unsigned long addr,
|
||||
unsigned int prefix, unsigned long val)
|
||||
{
|
||||
unsigned char buf[10], *resp;
|
||||
int status;
|
||||
|
@ -3194,41 +3022,6 @@ static void jtagmkII_close32(PROGRAMMER * pgm)
|
|||
if(status < 0 || resp[0] != RSP_OK) {lineno = __LINE__; goto eRR;}
|
||||
free(resp);
|
||||
|
||||
#if 0
|
||||
if (PDATA(pgm)->device_descriptor_length) {
|
||||
/* When in JTAG mode, restart target. */
|
||||
buf[0] = CMND_GO;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkII_close(): Sending GO command: ",
|
||||
progname);
|
||||
jtagmkII_send(pgm, buf, 1);
|
||||
|
||||
status = jtagmkII_recv(pgm, &resp);
|
||||
if (status <= 0) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkII_close(): "
|
||||
"timeout/error communicating with programmer (status %d)\n",
|
||||
progname, status);
|
||||
} else {
|
||||
if (verbose >= 3) {
|
||||
putc('\n', stderr);
|
||||
jtagmkII_prmsg(pgm, resp, status);
|
||||
} else if (verbose == 2)
|
||||
fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status);
|
||||
c = resp[0];
|
||||
free(resp);
|
||||
if (c != RSP_OK) {
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkII_close(): "
|
||||
"bad response to GO command: %s\n",
|
||||
progname, jtagmkII_get_rc(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
buf[0] = CMND_SIGN_OFF;
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkII_close(): Sending sign-off command: ",
|
||||
|
@ -3307,7 +3100,8 @@ static int jtagmkII_paged_load32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
p->flags |= AVRPART_INIT_SMC;
|
||||
}
|
||||
|
||||
//fprintf(stderr, "\n pageSize=%d bytes=%d pages=%d m->offset=0x%x pgm->page_size %d\n", page_size, n_bytes, pages, m->offset, pgm->page_size);
|
||||
//fprintf(stderr, "\n pageSize=%d bytes=%d pages=%d m->offset=0x%x pgm->page_size %d\n",
|
||||
// page_size, n_bytes, pages, m->offset, pgm->page_size);
|
||||
|
||||
cmd[0] = CMND_READ_MEMORY32;
|
||||
cmd[1] = 0x40;
|
||||
|
@ -3325,8 +3119,10 @@ static int jtagmkII_paged_load32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
|
||||
u32_to_b4r(cmd + 3, m->offset + addr);
|
||||
|
||||
status = jtagmkII_send(pgm, cmd, 7); if(status<0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_recv(pgm, &resp); if(status<0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_send(pgm, cmd, 7);
|
||||
if(status<0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_recv(pgm, &resp);
|
||||
if(status<0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
if (verbose >= 3) {
|
||||
putc('\n', stderr);
|
||||
|
@ -3381,7 +3177,8 @@ static int jtagmkII_paged_write32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
p->flags |= AVRPART_WRITE;
|
||||
|
||||
pages = (n_bytes-1)/page_size + 1;
|
||||
//fprintf(stderr, "\n pageSize=%d bytes=%d pages=%d m->offset=0x%x pgm->page_size %d\n", page_size, n_bytes, pages, m->offset, pgm->page_size);
|
||||
//fprintf(stderr, "\n pageSize=%d bytes=%d pages=%d m->offset=0x%x pgm->page_size %d\n",
|
||||
// page_size, n_bytes, pages, m->offset, pgm->page_size);
|
||||
|
||||
// Before any errors can happen
|
||||
if ((cmd = malloc(pgm->page_size + 10)) == NULL) {
|
||||
|
@ -3417,12 +3214,8 @@ static int jtagmkII_paged_write32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
|
||||
report_progress(addr, n_bytes, NULL);
|
||||
|
||||
#if 0
|
||||
val = jtagmkII_read_SABaddr(pgm, AVR32_FLASHC_FSR, 0x05);
|
||||
if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;}
|
||||
if(!(val&AVR32_FLASHC_FSR_RDY)) {lineno = __LINE__; goto eRR;} // Flash better be ready
|
||||
#endif
|
||||
status = jtagmkII_flash_clear_pagebuffer32(pgm); if(status != 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_flash_clear_pagebuffer32(pgm);
|
||||
if(status != 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
for(blocks=0; blocks<2; ++blocks) {
|
||||
block_size = ((n_bytes-addr) < pgm->page_size) ? (n_bytes - addr) : pgm->page_size;
|
||||
|
@ -3435,8 +3228,10 @@ static int jtagmkII_paged_write32(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
memset(cmd + 10, 0xff, pgm->page_size);
|
||||
memcpy(cmd + 10, m->buf + addr, block_size);
|
||||
|
||||
status = jtagmkII_send(pgm, cmd, pgm->page_size + 10); if(status<0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_recv(pgm, &resp); if(status<0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_send(pgm, cmd, pgm->page_size + 10);
|
||||
if(status<0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_recv(pgm, &resp);
|
||||
if (status<0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
if (verbose >= 3) {
|
||||
putc('\n', stderr);
|
||||
|
@ -3495,13 +3290,8 @@ static int jtagmkII_flash_lock32(PROGRAMMER * pgm, unsigned char lock, unsigned
|
|||
|
||||
page <<= 8;
|
||||
cmd = AVR32_FLASHC_FCMD_KEY | page | (lock ? AVR32_FLASHC_FCMD_LOCK : AVR32_FLASHC_FCMD_UNLOCK);
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
#if 0
|
||||
val = jtagmkII_read_SABaddr(pgm, AVR32_FLASHC_FSR, 0x05);
|
||||
if(val == ERROR_SAB) {lineno = __LINE__; goto eRR;}
|
||||
if(val & AVR32_FLASHC_FSR_ERR) {lineno = __LINE__; goto eRR;} // PLL 0
|
||||
#endif
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -3528,7 +3318,8 @@ static int jtagmkII_flash_erase32(PROGRAMMER * pgm, unsigned int page)
|
|||
|
||||
page <<= 8;
|
||||
cmd = AVR32_FLASHC_FCMD_KEY | page | AVR32_FLASHC_FCMD_ERASE_PAGE;
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
//fprintf(stderr, "ERASE %x -> %x\n", cmd, AVR32_FLASHC_FCMD);
|
||||
|
||||
|
@ -3560,7 +3351,8 @@ static int jtagmkII_flash_write_page32(PROGRAMMER * pgm, unsigned int page)
|
|||
|
||||
page <<= 8;
|
||||
cmd = AVR32_FLASHC_FCMD_KEY | page | AVR32_FLASHC_FCMD_WRITE_PAGE;
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
err = 0;
|
||||
for(i=0; i<256; ++i) {
|
||||
|
@ -3582,13 +3374,15 @@ static int jtagmkII_flash_write_page32(PROGRAMMER * pgm, unsigned int page)
|
|||
progname, lineno, page, cmd, val);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int jtagmkII_flash_clear_pagebuffer32(PROGRAMMER * pgm)
|
||||
{
|
||||
int status, lineno, i;
|
||||
unsigned long val=0, cmd, err;
|
||||
|
||||
cmd = AVR32_FLASHC_FCMD_KEY | AVR32_FLASHC_FCMD_CLEAR_PAGE_BUFFER;
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd); if(status < 0) {lineno = __LINE__; goto eRR;}
|
||||
status = jtagmkII_write_SABaddr(pgm, AVR32_FLASHC_FCMD, 0x05, cmd);
|
||||
if (status < 0) {lineno = __LINE__; goto eRR;}
|
||||
|
||||
err = 0;
|
||||
for(i=0; i<256; ++i) {
|
||||
|
@ -3611,9 +3405,162 @@ static int jtagmkII_flash_clear_pagebuffer32(PROGRAMMER * pgm)
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __OBJC__
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
void jtagmkII_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "JTAGMKII");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase;
|
||||
pgm->open = jtagmkII_open;
|
||||
pgm->close = jtagmkII_close;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write;
|
||||
pgm->paged_load = jtagmkII_paged_load;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
pgm->set_sck_period = jtagmkII_set_sck_period;
|
||||
pgm->parseextparams = jtagmkII_parseextparms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
}
|
||||
|
||||
void jtagmkII_dw_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "JTAGMKII_DW");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase_dw;
|
||||
pgm->open = jtagmkII_open_dw;
|
||||
pgm->close = jtagmkII_close;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write;
|
||||
pgm->paged_load = jtagmkII_paged_load;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
pgm->flag = PGM_FL_IS_DW;
|
||||
}
|
||||
|
||||
|
||||
void jtagmkII_dragon_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "DRAGON_JTAG");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase;
|
||||
pgm->open = jtagmkII_dragon_open;
|
||||
pgm->close = jtagmkII_close;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write;
|
||||
pgm->paged_load = jtagmkII_paged_load;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
pgm->set_sck_period = jtagmkII_set_sck_period;
|
||||
pgm->parseextparams = jtagmkII_parseextparms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
}
|
||||
|
||||
|
||||
void jtagmkII_dragon_dw_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "DRAGON_DW");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase_dw;
|
||||
pgm->open = jtagmkII_dragon_open_dw;
|
||||
pgm->close = jtagmkII_close;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write;
|
||||
pgm->paged_load = jtagmkII_paged_load;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
pgm->flag = PGM_FL_IS_DW;
|
||||
}
|
||||
|
||||
void jtagmkII_avr32_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
strcpy(pgm->type, "JTAGMKII_AVR32");
|
||||
|
||||
/*
|
||||
* mandatory functions
|
||||
*/
|
||||
pgm->initialize = jtagmkII_initialize32;
|
||||
pgm->display = jtagmkII_display;
|
||||
pgm->enable = jtagmkII_enable;
|
||||
pgm->disable = jtagmkII_disable;
|
||||
pgm->program_enable = jtagmkII_program_enable_dummy;
|
||||
pgm->chip_erase = jtagmkII_chip_erase32;
|
||||
pgm->open = jtagmkII_open32;
|
||||
pgm->close = jtagmkII_close32;
|
||||
pgm->read_byte = jtagmkII_read_byte;
|
||||
pgm->write_byte = jtagmkII_write_byte;
|
||||
|
||||
/*
|
||||
* optional functions
|
||||
*/
|
||||
pgm->paged_write = jtagmkII_paged_write32;
|
||||
pgm->paged_load = jtagmkII_paged_load32;
|
||||
pgm->print_parms = jtagmkII_print_parms;
|
||||
//pgm->set_sck_period = jtagmkII_set_sck_period;
|
||||
//pgm->parseextparams = jtagmkII_parseextparms;
|
||||
pgm->setup = jtagmkII_setup;
|
||||
pgm->teardown = jtagmkII_teardown;
|
||||
pgm->page_size = 256;
|
||||
}
|
||||
|
||||
|
|
|
@ -262,6 +262,40 @@
|
|||
#define XMEGA_ERASE_EEPROM_PAGE 0x06
|
||||
#define XMEGA_ERASE_USERSIG 0x07
|
||||
|
||||
/* AVR32 related definitions */
|
||||
#define AVR32_FLASHC_FCR 0xFFFE1400
|
||||
#define AVR32_FLASHC_FCMD 0xFFFE1404
|
||||
#define AVR32_FLASHC_FCMD_KEY 0xA5000000
|
||||
#define AVR32_FLASHC_FCMD_WRITE_PAGE 1
|
||||
#define AVR32_FLASHC_FCMD_ERASE_PAGE 2
|
||||
#define AVR32_FLASHC_FCMD_CLEAR_PAGE_BUFFER 3
|
||||
#define AVR32_FLASHC_FCMD_LOCK 4
|
||||
#define AVR32_FLASHC_FCMD_UNLOCK 5
|
||||
#define AVR32_FLASHC_FSR 0xFFFE1408
|
||||
#define AVR32_FLASHC_FSR_RDY 0x00000001
|
||||
#define AVR32_FLASHC_FSR_ERR 0x00000008
|
||||
#define AVR32_FLASHC_FGPFRHI 0xFFFE140C
|
||||
#define AVR32_FLASHC_FGPFRLO 0xFFFE1410
|
||||
|
||||
#define AVR32_DC 0x00000008
|
||||
#define AVR32_DS 0x00000010
|
||||
#define AVR32_DINST 0x00000104
|
||||
#define AVR32_DCCPU 0x00000110
|
||||
#define AVR32_DCEMU 0x00000114
|
||||
#define AVR32_DCSR 0x00000118
|
||||
|
||||
#define AVR32_DC_ABORT 0x80000000
|
||||
#define AVR32_DC_RESET 0x40000000
|
||||
#define AVR32_DC_DBE 0x00002000
|
||||
#define AVR32_DC_DBR 0x00001000
|
||||
|
||||
#define AVR32_RESET_READ 0x0001
|
||||
#define AVR32_RESET_WRITE 0x0002
|
||||
#define AVR32_RESET_CHIP_ERASE 0x0004
|
||||
#define AVR32_SET4RUNNING 0x0008
|
||||
//#define AVR32_RESET_COMMON (AVR32_RESET_READ | AVR32_RESET_WRITE | AVR32_RESET_CHIP_ERASE )
|
||||
|
||||
|
||||
#if !defined(JTAGMKII_PRIVATE_EXPORTED)
|
||||
/*
|
||||
* In appnote AVR067, struct device_descriptor is written with
|
||||
|
|
Loading…
Reference in New Issue