Merge pull request #1108 from MCUdude/avr109-xmega

AVR109: support for prodsig read and usersig read/write
This commit is contained in:
Stefan Rueger 2022-10-05 22:20:16 +01:00 committed by GitHub
commit f2fb3b45b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 7 deletions

View File

@ -506,9 +506,13 @@ static int butterfly_read_byte_flash(const PROGRAMMER *pgm, const AVRPART *p, co
} else {
butterfly_set_addr(pgm, addr >> 1);
}
butterfly_send(pgm, "g\000\002F", 4);
// Defaults to flash read ('F')
char msg[4] = {'g', 0x00, 0x02, 'F'};
if (strcmp(m->desc, "prodsig") == 0)
msg[3] = 'P';
else if (strcmp(m->desc, "usersig") == 0)
msg[3] = 'U';
butterfly_send(pgm, msg, 4);
/* Read back the program mem word (MSB first) */
butterfly_recv(pgm, buf, sizeof(buf));
@ -551,7 +555,9 @@ static int butterfly_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AV
{
char cmd;
if (strcmp(m->desc, "flash") == 0) {
if (strcmp(m->desc, "flash") == 0 ||
strcmp(m->desc, "prodsig") == 0 ||
strcmp(m->desc, "usersig") == 0) {
return butterfly_read_byte_flash(pgm, p, m, addr, value);
}
@ -592,7 +598,9 @@ static int butterfly_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
int use_ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL;
unsigned int wr_size = 2;
if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom"))
if (strcmp(m->desc, "flash") &&
strcmp(m->desc, "eeprom") &&
strcmp(m->desc, "usersig"))
return -2;
if (m->desc[0] == 'e')
@ -646,8 +654,10 @@ static int butterfly_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const A
int blocksize = PDATA(pgm)->buffersize;
int use_ext_addr = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL;
/* check parameter syntax: only "flash" or "eeprom" is allowed */
if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom"))
/* check parameter syntax: only "flash", "eeprom" or "usersig" is allowed */
if (strcmp(m->desc, "flash") &&
strcmp(m->desc, "eeprom") &&
strcmp(m->desc, "usersig"))
return -2;
if (m->desc[0] == 'e')