Submitted by Maciej:

patch #9185: Add extended_param to usbasp.c - erasing
configuration section in ATtiny 4...40 (TPI)
* usbasp.c: Implement extended parameter parsing, and modify
usbasp_tpi_chip_erase() appropriately
* avrdude.1: Document USBasp extended parameters
* doc/avrdude.texi: (Dito)




git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1419 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2018-01-16 22:40:28 +00:00
parent 6543ee1df6
commit 0bd9e3e48b
4 changed files with 83 additions and 7 deletions

View File

@ -1,3 +1,13 @@
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Maciej:
patch #9185: Add extended_param to usbasp.c - erasing
configuration section in ATtiny 4...40 (TPI)
* usbasp.c: Implement extended parameter parsing, and modify
usbasp_tpi_chip_erase() appropriately
* avrdude.1: Document USBasp extended parameters
* doc/avrdude.texi: (Dito)
2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2018-01-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Tom Carney: Submitted by Tom Carney:

View File

@ -1047,6 +1047,15 @@ Sets the SPI clocking rate in Hz (default is 100kHz). Alternately the -B or -i o
.It Ar timeout=<usb-transaction-timeout> .It Ar timeout=<usb-transaction-timeout>
Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms). Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms).
.El .El
.It Ar USBasp
Extended parameters:
.Bl -tag -offset indent -width indent
.It Ar section_config
Programmer will erase configuration section with option
.Fl e
(chip erase), rather than entire chip.
Only applicable to TPI devices (ATtiny 4/5/9/10/20/40).
.El
.El .El
.Sh FILES .Sh FILES
.Bl -tag -offset indent -width /dev/ppi0XXX .Bl -tag -offset indent -width /dev/ppi0XXX

View File

@ -909,6 +909,16 @@ Sets the SPI clocking rate in Hz (default is 100kHz). Alternately the -B or -i o
Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms). Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms).
@end table @end table
@item USBasp
Extended parameters:
@table @code
@item @samp{section_config}
Programmer will erase
configuration section with option '-e' (chip erase),
rather than entire chip.
Only applicable to TPI devices (ATtiny 4/5/9/10/20/40).
@end table
@end table @end table
@page @page

View File

@ -120,6 +120,7 @@ struct pdata
int sckfreq_hz; int sckfreq_hz;
unsigned int capabilities; unsigned int capabilities;
int use_tpi; int use_tpi;
int section_e;
}; };
#define PDATA(pgm) ((struct pdata *)(pgm->cookie)) #define PDATA(pgm) ((struct pdata *)(pgm->cookie))
@ -131,6 +132,7 @@ struct pdata
// interface - management // interface - management
static void usbasp_setup(PROGRAMMER * pgm); static void usbasp_setup(PROGRAMMER * pgm);
static void usbasp_teardown(PROGRAMMER * pgm); static void usbasp_teardown(PROGRAMMER * pgm);
static int usbasp_parseextparms(PROGRAMMER * pgm, LISTID extparms);
// internal functions // internal functions
static int usbasp_transmit(PROGRAMMER * pgm, unsigned char receive, static int usbasp_transmit(PROGRAMMER * pgm, unsigned char receive,
unsigned char functionid, const unsigned char *send, unsigned char functionid, const unsigned char *send,
@ -192,6 +194,31 @@ static void usbasp_teardown(PROGRAMMER * pgm)
free(pgm->cookie); free(pgm->cookie);
} }
static int usbasp_parseextparms(PROGRAMMER * pgm, LISTID extparms)
{
LNODEID ln;
const char *extended_param;
int rv = 0;
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
extended_param = ldata(ln);
if (strncmp(extended_param, "section_config", strlen("section_config")) == 0) {
avrdude_message(MSG_NOTICE2, "%s: usbasp_parseextparms(): set section_e to 1 (config section)\n",
progname);
PDATA(pgm)->section_e = 1;
continue;
}
avrdude_message(MSG_INFO, "%s: usbasp_parseextparms(): invalid extended parameter '%s'\n",
progname, extended_param);
rv = -1;
}
return rv;
}
/* Internal functions */ /* Internal functions */
static const char *usbasp_get_funcname(unsigned char functionid) static const char *usbasp_get_funcname(unsigned char functionid)
@ -1015,21 +1042,40 @@ static int usbasp_tpi_program_enable(PROGRAMMER * pgm, AVRPART * p)
static int usbasp_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p) static int usbasp_tpi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
{ {
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_chip_erase()\n", progname); int pr_0;
int pr_1;
int nvm_cmd;
/* Set PR to flash */ switch (PDATA(pgm)->section_e) {
/* Config bits section erase */
case 1:
pr_0 = 0x41;
pr_1 = 0x3F;
nvm_cmd = NVMCMD_SECTION_ERASE;
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_chip_erase() - section erase\n", progname);
break;
/* Chip erase (flash only) */
default:
pr_0 = 0x01;
pr_1 = 0x40;
nvm_cmd = NVMCMD_CHIP_ERASE;
avrdude_message(MSG_DEBUG, "%s: usbasp_tpi_chip_erase() - chip erase\n", progname);
break;
}
/* Set PR */
usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(0)); usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(0));
usbasp_tpi_send_byte(pgm, 0x01); usbasp_tpi_send_byte(pgm, pr_0);
usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(1)); usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(1));
usbasp_tpi_send_byte(pgm, 0x40); usbasp_tpi_send_byte(pgm, pr_1);
/* select ERASE */ /* select what been erase */
usbasp_tpi_send_byte(pgm, TPI_OP_SOUT(NVMCMD)); usbasp_tpi_send_byte(pgm, TPI_OP_SOUT(NVMCMD));
usbasp_tpi_send_byte(pgm, NVMCMD_CHIP_ERASE); usbasp_tpi_send_byte(pgm, nvm_cmd);
/* dummy write */ /* dummy write */
usbasp_tpi_send_byte(pgm, TPI_OP_SST_INC); usbasp_tpi_send_byte(pgm, TPI_OP_SST_INC);
usbasp_tpi_send_byte(pgm, 0x00); usbasp_tpi_send_byte(pgm, 0x00);
usbasp_tpi_nvm_waitbusy(pgm); usbasp_tpi_nvm_waitbusy(pgm);
usleep(p->chip_erase_delay); usleep(p->chip_erase_delay);
pgm->initialize(pgm, p); pgm->initialize(pgm, p);
@ -1194,6 +1240,7 @@ void usbasp_initpgm(PROGRAMMER * pgm)
pgm->setup = usbasp_setup; pgm->setup = usbasp_setup;
pgm->teardown = usbasp_teardown; pgm->teardown = usbasp_teardown;
pgm->set_sck_period = usbasp_spi_set_sck_period; pgm->set_sck_period = usbasp_spi_set_sck_period;
pgm->parseextparams = usbasp_parseextparms;
} }