From 56ef0aafe84ad77e2e2c44963591b65cdda64d73 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Tue, 23 May 2006 22:27:43 +0000 Subject: [PATCH] Start implementing support for ATmega256x; jtag2 and bitbang programmers are working, stk500v2 still needs to be done. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@581 81a1dc3b-b13d-400b-aceb-764788c761c2 --- avrdude/ChangeLog | 11 ++ avrdude/avr.c | 28 +++- avrdude/avrdude.conf.in | 310 ++++++++++++++++++++++++++++++++++++++++ avrdude/avrpart.c | 1 + avrdude/avrpart.h | 1 + avrdude/config_gram.y | 3 + avrdude/lexer.l | 1 + 7 files changed, 353 insertions(+), 2 deletions(-) diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog index 6a333339..3fa740df 100644 --- a/avrdude/ChangeLog +++ b/avrdude/ChangeLog @@ -1,3 +1,14 @@ +2006-04-18 Joerg Wunsch + + * avr.c: Start implementing support for ATmega256x; + jtag2 and bitbang programmers are working, stk500v2 + still needs to be done. + * avrdude.conf.in: (Ditto.) + * avrpart.c: (Ditto.) + * avrpart.h: (Ditto.) + * config_gram.y: (Ditto.) + * lexer.l: (Ditto.) + 2006-04-18 Joerg Wunsch Contributed by Julius Luukko : diff --git a/avrdude/avr.c b/avrdude/avr.c index 51e60271..6846aa9f 100644 --- a/avrdude/avr.c +++ b/avrdude/avr.c @@ -51,7 +51,7 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, unsigned char cmd[4]; unsigned char res[4]; unsigned char data; - OPCODE * readop; + OPCODE * readop, * lext; pgm->pgm_led(pgm, ON); pgm->err_led(pgm, OFF); @@ -79,6 +79,18 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, return -1; } + /* + * If this device has a "load extended address" command, issue it. + */ + lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; + if (lext != NULL) { + memset(cmd, 0, sizeof(cmd)); + + avr_set_bits(lext, cmd); + avr_set_addr(lext, cmd, addr); + pgm->cmd(pgm, cmd, res); + } + memset(cmd, 0, sizeof(cmd)); avr_set_bits(readop, cmd); @@ -234,7 +246,7 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, { unsigned char cmd[4]; unsigned char res[4]; - OPCODE * wp; + OPCODE * wp, * lext; wp = mem->op[AVR_OP_WRITEPAGE]; if (wp == NULL) { @@ -254,6 +266,18 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, pgm->pgm_led(pgm, ON); pgm->err_led(pgm, OFF); + /* + * If this device has a "load extended address" command, issue it. + */ + lext = mem->op[AVR_OP_LOAD_EXT_ADDR]; + if (lext != NULL) { + memset(cmd, 0, sizeof(cmd)); + + avr_set_bits(lext, cmd); + avr_set_addr(lext, cmd, addr); + pgm->cmd(pgm, cmd, res); + } + memset(cmd, 0, sizeof(cmd)); avr_set_bits(wp, cmd); diff --git a/avrdude/avrdude.conf.in b/avrdude/avrdude.conf.in index dc23e35c..8384883c 100644 --- a/avrdude/avrdude.conf.in +++ b/avrdude/avrdude.conf.in @@ -6500,6 +6500,316 @@ part ; ; +#------------------------------------------------------------ +# ATmega2560 +#------------------------------------------------------------ + +part + id = "m2560"; + desc = "ATMEGA2560"; + signature = 0x1e 0x98 0x01; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 262144; + page_size = 256; + num_pages = 1024; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + load_ext_addr = " 0 1 0 0 1 1 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 a16", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + +#------------------------------------------------------------ +# ATmega2561 +#------------------------------------------------------------ + +part + id = "m2561"; + desc = "ATMEGA2561"; + signature = 0x1e 0x98 0x02; + has_jtag = yes; +# stk500_devcode = 0xB2; +# avr910_devcode = 0x43; + chip_erase_delay = 9000; + pagel = 0xD7; + bs2 = 0xA0; + reset = dedicated; + pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", + "x x x x x x x x x x x x x x x x"; + + chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", + "x x x x x x x x x x x x x x x x"; + + timeout = 200; + stabdelay = 100; + cmdexedelay = 25; + synchloops = 32; + bytedelay = 0; + pollindex = 3; + pollvalue = 0x53; + predelay = 1; + postdelay = 1; + pollmethod = 1; + + idr = 0x31; + spmcr = 0x57; + rampz = 0x3b; + allowfullpagebitstream = no; + + memory "eeprom" + paged = no; /* leave this "no" */ + page_size = 8; /* for parallel programming */ + size = 4096; + min_write_delay = 9000; + max_write_delay = 9000; + readback_p1 = 0x00; + readback_p2 = 0x00; + read = " 1 0 1 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + write = " 1 1 0 0 0 0 0 0", + " x x x x a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + mode = 0x41; + delay = 10; + blocksize = 8; + readsize = 256; + ; + + memory "flash" + paged = yes; + size = 262144; + page_size = 256; + num_pages = 1024; + min_write_delay = 4500; + max_write_delay = 4500; + readback_p1 = 0x00; + readback_p2 = 0x00; + read_lo = " 0 0 1 0 0 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + read_hi = " 0 0 1 0 1 0 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 a6 a5 a4 a3 a2 a1 a0", + " o o o o o o o o"; + + loadpage_lo = " 0 1 0 0 0 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + loadpage_hi = " 0 1 0 0 1 0 0 0", + " x x x x x x x x", + " x a6 a5 a4 a3 a2 a1 a0", + " i i i i i i i i"; + + writepage = " 0 1 0 0 1 1 0 0", + "a15 a14 a13 a12 a11 a10 a9 a8", + " a7 x x x x x x x", + " x x x x x x x x"; + + load_ext_addr = " 0 1 0 0 1 1 0 1", + " 0 0 0 0 0 0 0 0", + " 0 0 0 0 0 0 0 a16", + " 0 0 0 0 0 0 0 0"; + + mode = 0x41; + delay = 6; + blocksize = 256; + readsize = 256; + ; + + memory "lfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "hfuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", + "x x x x x x x x i i i i i i i i"; + + read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "efuse" + size = 1; + write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", + "x x x x x x x x x x x x x x i i"; + + read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", + "x x x x x x x x o o o o o o o o"; + ; + + memory "lock" + size = 1; + read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", + "x x x x x x x x x x o o o o o o"; + + write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", + "x x x x x x x x 1 1 i i i i i i"; + ; + + memory "calibration" + size = 1; + read = "0 0 1 1 1 0 0 0 x x x x x x x x", + "0 0 0 0 0 0 0 0 o o o o o o o o"; + ; + + memory "signature" + size = 3; + read = "0 0 1 1 0 0 0 0 x x x x x x x x", + "x x x x x x a1 a0 o o o o o o o o"; + ; + ; + #------------------------------------------------------------ # ATtiny24 #------------------------------------------------------------ diff --git a/avrdude/avrpart.c b/avrdude/avrpart.c index b4ef574a..cabea278 100644 --- a/avrdude/avrpart.c +++ b/avrdude/avrpart.c @@ -174,6 +174,7 @@ char * avr_op_str(int op) case AVR_OP_WRITE_HI : return "WRITE_HI"; break; case AVR_OP_LOADPAGE_LO : return "LOADPAGE_LO"; break; case AVR_OP_LOADPAGE_HI : return "LOADPAGE_HI"; break; + case AVR_OP_LOAD_EXT_ADDR : return "LOAD_EXT_ADDR"; break; case AVR_OP_WRITEPAGE : return "WRITEPAGE"; break; case AVR_OP_CHIP_ERASE : return "CHIP_ERASE"; break; case AVR_OP_PGM_ENABLE : return "PGM_ENABLE"; break; diff --git a/avrdude/avrpart.h b/avrdude/avrpart.h index 410595f1..84d01622 100644 --- a/avrdude/avrpart.h +++ b/avrdude/avrpart.h @@ -41,6 +41,7 @@ enum { AVR_OP_WRITE_HI, AVR_OP_LOADPAGE_LO, AVR_OP_LOADPAGE_HI, + AVR_OP_LOAD_EXT_ADDR, AVR_OP_WRITEPAGE, AVR_OP_CHIP_ERASE, AVR_OP_PGM_ENABLE, diff --git a/avrdude/config_gram.y b/avrdude/config_gram.y index e655527b..08896cf9 100644 --- a/avrdude/config_gram.y +++ b/avrdude/config_gram.y @@ -65,6 +65,7 @@ static int parse_cmdbits(OPCODE * op); %token K_WRITE_HI %token K_LOADPAGE_LO %token K_LOADPAGE_HI +%token K_LOAD_EXT_ADDR %token K_WRITEPAGE %token K_CHIP_ERASE %token K_PGM_ENABLE @@ -468,6 +469,7 @@ opcode : K_WRITE_HI | K_LOADPAGE_LO | K_LOADPAGE_HI | + K_LOAD_EXT_ADDR | K_WRITEPAGE | K_CHIP_ERASE | K_PGM_ENABLE @@ -927,6 +929,7 @@ static int which_opcode(TOKEN * opcode) case K_WRITE_HI : return AVR_OP_WRITE_HI; break; case K_LOADPAGE_LO : return AVR_OP_LOADPAGE_LO; break; case K_LOADPAGE_HI : return AVR_OP_LOADPAGE_HI; break; + case K_LOAD_EXT_ADDR : return AVR_OP_LOAD_EXT_ADDR; break; case K_WRITEPAGE : return AVR_OP_WRITEPAGE; break; case K_CHIP_ERASE : return AVR_OP_CHIP_ERASE; break; case K_PGM_ENABLE : return AVR_OP_PGM_ENABLE; break; diff --git a/avrdude/lexer.l b/avrdude/lexer.l index 1fb9bfe9..5d48144b 100644 --- a/avrdude/lexer.l +++ b/avrdude/lexer.l @@ -208,6 +208,7 @@ write_lo { yylval=new_token(K_WRITE_LO); return K_WRITE_LO; } write_hi { yylval=new_token(K_WRITE_HI); return K_WRITE_HI; } loadpage_lo { yylval=new_token(K_LOADPAGE_LO); return K_LOADPAGE_LO; } loadpage_hi { yylval=new_token(K_LOADPAGE_HI); return K_LOADPAGE_HI; } +load_ext_addr { yylval=new_token(K_LOAD_EXT_ADDR); return K_LOAD_EXT_ADDR; } writepage { yylval=new_token(K_WRITEPAGE); return K_WRITEPAGE; } chip_erase { yylval=new_token(K_CHIP_ERASE); return K_CHIP_ERASE; } pgm_enable { yylval=new_token(K_PGM_ENABLE); return K_PGM_ENABLE; }