Merge branch 'main' into pages-test

This commit is contained in:
Joerg Wunsch 2022-03-13 00:29:54 +01:00
commit c5f7939fca
7 changed files with 142 additions and 133 deletions

4
NEWS
View File

@ -72,6 +72,7 @@ Changes since version 6.4:
- Rework HID support for Windows #881 - Rework HID support for Windows #881
- List of signing keys? #884 - List of signing keys? #884
- Pickit4 UPDI is writing at offset 0x4000 into flash instead of 0x0000. #892 - Pickit4 UPDI is writing at offset 0x4000 into flash instead of 0x0000. #892
- SerialUPDI programmer can't write to usersig/userrow in terminal mode #889
- Signature read command for ATmega165* was wrong (no-id) - Signature read command for ATmega165* was wrong (no-id)
* Pull requests: * Pull requests:
@ -145,6 +146,9 @@ Changes since version 6.4:
- Avrdude terminal write improvements #880 - Avrdude terminal write improvements #880
- Add userrow and usersig aliases #888 - Add userrow and usersig aliases #888
- For UPDI devices do not add offset when accessing flash. #895 - For UPDI devices do not add offset when accessing flash. #895
- Support both userrow and usersig names #893
- Fix ugly terminal write bug #896
- Improve terminal read functionality #894
* Internals: * Internals:

View File

@ -16748,15 +16748,15 @@ part parent ".avr8x"
desc = "AVR8X tiny family common values"; desc = "AVR8X tiny family common values";
family_id = "tinyAVR"; family_id = "tinyAVR";
memory "usersig" memory "userrow"
size = 0x20; size = 0x20;
offset = 0x1300; offset = 0x1300;
page_size = 0x20; page_size = 0x20;
readsize = 0x100; readsize = 0x100;
; ;
memory "userrow" memory "usersig"
alias "usersig"; alias "userrow";
; ;
; ;
@ -16769,15 +16769,15 @@ part parent ".avr8x"
desc = "AVR8X mega family common values"; desc = "AVR8X mega family common values";
family_id = "megaAVR"; family_id = "megaAVR";
memory "usersig" memory "userrow"
size = 0x40; size = 0x40;
offset = 0x1300; offset = 0x1300;
page_size = 0x40; page_size = 0x40;
readsize = 0x100; readsize = 0x100;
; ;
memory "userrow" memory "usersig"
alias "usersig"; alias "userrow";
; ;
; ;

View File

@ -28,9 +28,7 @@ This file documents the avrdude program.
For avrdude version @value{VERSION}, @value{UPDATED}. For avrdude version @value{VERSION}, @value{UPDATED}.
Copyright @copyright{} 2003, 2005 Brian Dean Copyright @copyright{} Brian Dean, J@"org Wunsch
Copyright @copyright{} 2006 - 2021 J@"org Wunsch
Permission is granted to make and distribute verbatim copies of Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice this manual provided the copyright notice and this permission notice
@ -66,11 +64,9 @@ the terms of the GNU Free Documentation License (FDL), version 1.3.
@page @page
Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}. Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}.
Use @uref{http://savannah.nongnu.org/bugs/?group=avrdude} to report bugs. Use @uref{https://github.com/avrdudes/avrdude/issues} to report bugs.
Copyright @copyright{} 2003,2005 Brian S. Dean Copyright @copyright{} Brian S. Dean, J@"org Wunsch
Copyright @copyright{} 2006 - 2013 J@"org Wunsch
@sp 2 @sp 2
Permission is granted to make and distribute verbatim copies of Permission is granted to make and distribute verbatim copies of
@ -104,11 +100,9 @@ For avrdude version @value{VERSION}, @value{UPDATED}.
Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}. Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}.
Use @uref{http://savannah.nongnu.org/bugs/?group=avrdude} to report bugs. Use @uref{https://github.com/avrdudes/avrdude/issues} to report bugs.
Copyright @copyright{} 2003,2005 Brian S. Dean Copyright @copyright{} Brian S. Dean, J@"org Wunsch
Copyright @copyright{} 2006 J@"org Wunsch
@end ifinfo @end ifinfo
@menu @menu
@ -353,13 +347,15 @@ AVRDUDE when interest grew in a Windows port of the software so that the
name did not conflict with AVRPROG.EXE which is the name of Atmel's name did not conflict with AVRPROG.EXE which is the name of Atmel's
Windows programming software. Windows programming software.
The AVRDUDE source now resides in the public CVS repository on For many years, the AVRDUDE source resided in public repositories on
savannah.gnu.org (@url{http://savannah.gnu.org/projects/avrdude/}), savannah.nongnu.org,
where it continues to be enhanced and ported to other systems. In where it continued to be enhanced and ported to other systems. In
addition to FreeBSD, AVRDUDE now runs on Linux and Windows. The addition to FreeBSD, AVRDUDE now runs on Linux and Windows. The
developers behind the porting effort primarily were Ted Roth, Eric developers behind the porting effort primarily were Ted Roth, Eric
Weddington, and Joerg Wunsch. Weddington, and Joerg Wunsch.
In 2022, the project moved to Github (@url{https://github.com/avrdudes/avrdude/}).
And in the spirit of many open source projects, this manual also draws And in the spirit of many open source projects, this manual also draws
on the work of others. The initial revision was composed of parts of on the work of others. The initial revision was composed of parts of
the original Unix manual page written by Joerg Wunsch, the original web the original Unix manual page written by Joerg Wunsch, the original web
@ -2446,7 +2442,7 @@ such as @option{--prefix} and @option{--datadir}.
@noindent @noindent
In general, please report any bugs encountered via In general, please report any bugs encountered via
@* @*
@url{http://savannah.nongnu.org/bugs/?group=avrdude}. @url{https://github.com/avrdudes/avrdude/issues}.
@itemize @bullet @itemize @bullet

View File

@ -1174,7 +1174,8 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
u32_to_b4(xd.nvm_fuse_offset, m->offset & ~7); u32_to_b4(xd.nvm_fuse_offset, m->offset & ~7);
} else if (matches(m->desc, "lock")) { } else if (matches(m->desc, "lock")) {
u32_to_b4(xd.nvm_lock_offset, m->offset); u32_to_b4(xd.nvm_lock_offset, m->offset);
} else if (strcmp(m->desc, "usersig") == 0) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
u32_to_b4(xd.nvm_user_sig_offset, m->offset); u32_to_b4(xd.nvm_user_sig_offset, m->offset);
} else if (strcmp(m->desc, "prodsig") == 0) { } else if (strcmp(m->desc, "prodsig") == 0) {
u32_to_b4(xd.nvm_prod_sig_offset, m->offset); u32_to_b4(xd.nvm_prod_sig_offset, m->offset);
@ -1225,7 +1226,8 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
u16_to_b2(xd.eeprom_bytes, m->size); u16_to_b2(xd.eeprom_bytes, m->size);
u16_to_b2(xd.eeprom_base, m->offset); u16_to_b2(xd.eeprom_base, m->offset);
} }
else if (strcmp(m->desc, "usersig") == 0) else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0)
{ {
u16_to_b2(xd.user_sig_bytes, m->size); u16_to_b2(xd.user_sig_bytes, m->size);
u16_to_b2(xd.user_sig_base, m->offset); u16_to_b2(xd.user_sig_base, m->offset);
@ -1686,9 +1688,10 @@ static int jtag3_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd[3] = XMEGA_ERASE_BOOT_PAGE; cmd[3] = XMEGA_ERASE_BOOT_PAGE;
} else if (strcmp(m->desc, "eeprom") == 0) { } else if (strcmp(m->desc, "eeprom") == 0) {
cmd[3] = XMEGA_ERASE_EEPROM_PAGE; cmd[3] = XMEGA_ERASE_EEPROM_PAGE;
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
cmd[3] = XMEGA_ERASE_USERSIG; cmd[3] = XMEGA_ERASE_USERSIG;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) { } else if (strcmp(m->desc, "boot") == 0) {
cmd[3] = XMEGA_ERASE_BOOT_PAGE; cmd[3] = XMEGA_ERASE_BOOT_PAGE;
} else { } else {
cmd[3] = XMEGA_ERASE_APP_PAGE; cmd[3] = XMEGA_ERASE_APP_PAGE;
@ -1760,9 +1763,10 @@ static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
} }
cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM_XMEGA : MTYPE_EEPROM_PAGE; cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM_XMEGA : MTYPE_EEPROM_PAGE;
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
cmd[3] = MTYPE_USERSIG; cmd[3] = MTYPE_USERSIG;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) { } else if (strcmp(m->desc, "boot") == 0) {
cmd[3] = MTYPE_BOOT_FLASH; cmd[3] = MTYPE_BOOT_FLASH;
} else if ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) { } else if ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) {
cmd[3] = MTYPE_FLASH; cmd[3] = MTYPE_FLASH;
@ -1849,11 +1853,12 @@ static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE; cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
if (pgm->flag & PGM_FL_IS_DW) if (pgm->flag & PGM_FL_IS_DW)
return -1; return -1;
} else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) { } else if (strcmp(m->desc, "prodsig") == 0) {
cmd[3] = MTYPE_PRODSIG; cmd[3] = MTYPE_PRODSIG;
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
cmd[3] = MTYPE_USERSIG; cmd[3] = MTYPE_USERSIG;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) { } else if (strcmp(m->desc, "boot") == 0) {
cmd[3] = MTYPE_BOOT_FLASH; cmd[3] = MTYPE_BOOT_FLASH;
} else if ( p->flags & AVRPART_HAS_PDI ) { } else if ( p->flags & AVRPART_HAS_PDI ) {
cmd[3] = MTYPE_FLASH; cmd[3] = MTYPE_FLASH;
@ -1965,7 +1970,8 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
cmd[3] = MTYPE_FUSE_BITS; cmd[3] = MTYPE_FUSE_BITS;
if (!(p->flags & AVRPART_HAS_UPDI)) if (!(p->flags & AVRPART_HAS_UPDI))
addr = mem->offset & 7; addr = mem->offset & 7;
} else if (strcmp(mem->desc, "usersig") == 0) { } else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
cmd[3] = MTYPE_USERSIG; cmd[3] = MTYPE_USERSIG;
} else if (strcmp(mem->desc, "prodsig") == 0) { } else if (strcmp(mem->desc, "prodsig") == 0) {
cmd[3] = MTYPE_PRODSIG; cmd[3] = MTYPE_PRODSIG;
@ -2126,7 +2132,8 @@ static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
cmd[3] = MTYPE_FUSE_BITS; cmd[3] = MTYPE_FUSE_BITS;
if (!(p->flags & AVRPART_HAS_UPDI)) if (!(p->flags & AVRPART_HAS_UPDI))
addr = mem->offset & 7; addr = mem->offset & 7;
} else if (strcmp(mem->desc, "usersig") == 0) { } else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
cmd[3] = MTYPE_USERSIG; cmd[3] = MTYPE_USERSIG;
} else if (strcmp(mem->desc, "prodsig") == 0) { } else if (strcmp(mem->desc, "prodsig") == 0) {
cmd[3] = MTYPE_PRODSIG; cmd[3] = MTYPE_PRODSIG;

View File

@ -1056,7 +1056,8 @@ static void jtagmkII_set_xmega_params(PROGRAMMER * pgm, AVRPART * p)
u32_to_b4(sendbuf.dd.nvm_fuse_offset, m->offset & ~7); u32_to_b4(sendbuf.dd.nvm_fuse_offset, m->offset & ~7);
} else if (strncmp(m->desc, "lock", 4) == 0) { } else if (strncmp(m->desc, "lock", 4) == 0) {
u32_to_b4(sendbuf.dd.nvm_lock_offset, m->offset); u32_to_b4(sendbuf.dd.nvm_lock_offset, m->offset);
} else if (strcmp(m->desc, "usersig") == 0) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
u32_to_b4(sendbuf.dd.nvm_user_sig_offset, m->offset); u32_to_b4(sendbuf.dd.nvm_user_sig_offset, m->offset);
} else if (strcmp(m->desc, "prodsig") == 0) { } else if (strcmp(m->desc, "prodsig") == 0) {
u32_to_b4(sendbuf.dd.nvm_prod_sig_offset, m->offset); u32_to_b4(sendbuf.dd.nvm_prod_sig_offset, m->offset);
@ -1933,9 +1934,10 @@ static int jtagmkII_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd[1] = XMEGA_ERASE_BOOT_PAGE; cmd[1] = XMEGA_ERASE_BOOT_PAGE;
} else if (strcmp(m->desc, "eeprom") == 0) { } else if (strcmp(m->desc, "eeprom") == 0) {
cmd[1] = XMEGA_ERASE_EEPROM_PAGE; cmd[1] = XMEGA_ERASE_EEPROM_PAGE;
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
cmd[1] = XMEGA_ERASE_USERSIG; cmd[1] = XMEGA_ERASE_USERSIG;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) { } else if (strcmp(m->desc, "boot") == 0) {
cmd[1] = XMEGA_ERASE_BOOT_PAGE; cmd[1] = XMEGA_ERASE_BOOT_PAGE;
} else { } else {
cmd[1] = XMEGA_ERASE_APP_PAGE; cmd[1] = XMEGA_ERASE_APP_PAGE;
@ -2044,13 +2046,14 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
free(cmd); free(cmd);
return n_bytes; return n_bytes;
} }
cmd[1] = ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE; cmd[1] = (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
cmd[1] = MTYPE_USERSIG; cmd[1] = MTYPE_USERSIG;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) { } else if (strcmp(m->desc, "boot") == 0) {
cmd[1] = MTYPE_BOOT_FLASH; cmd[1] = MTYPE_BOOT_FLASH;
} else if ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) { } else if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) {
cmd[1] = MTYPE_FLASH; cmd[1] = MTYPE_FLASH;
} else { } else {
cmd[1] = MTYPE_SPM; cmd[1] = MTYPE_SPM;
@ -2156,16 +2159,17 @@ static int jtagmkII_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
/* dynamically decide between flash/boot memtype */ /* dynamically decide between flash/boot memtype */
dynamic_memtype = 1; dynamic_memtype = 1;
} else if (strcmp(m->desc, "eeprom") == 0) { } else if (strcmp(m->desc, "eeprom") == 0) {
cmd[1] = ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE; cmd[1] = (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
if (pgm->flag & PGM_FL_IS_DW) if (pgm->flag & PGM_FL_IS_DW)
return -1; return -1;
} else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) { } else if (strcmp(m->desc, "prodsig") == 0) {
cmd[1] = MTYPE_PRODSIG; cmd[1] = MTYPE_PRODSIG;
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
cmd[1] = MTYPE_USERSIG; cmd[1] = MTYPE_USERSIG;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) { } else if (strcmp(m->desc, "boot") == 0) {
cmd[1] = MTYPE_BOOT_FLASH; cmd[1] = MTYPE_BOOT_FLASH;
} else if ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) { } else if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) {
cmd[1] = MTYPE_FLASH; cmd[1] = MTYPE_FLASH;
} else { } else {
cmd[1] = MTYPE_SPM; cmd[1] = MTYPE_SPM;
@ -2291,7 +2295,8 @@ static int jtagmkII_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsupp = 1; unsupp = 1;
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
cmd[1] = MTYPE_FUSE_BITS; cmd[1] = MTYPE_FUSE_BITS;
} else if (strcmp(mem->desc, "usersig") == 0) { } else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
cmd[1] = MTYPE_USERSIG; cmd[1] = MTYPE_USERSIG;
} else if (strcmp(mem->desc, "prodsig") == 0) { } else if (strcmp(mem->desc, "prodsig") == 0) {
cmd[1] = MTYPE_PRODSIG; cmd[1] = MTYPE_PRODSIG;
@ -2460,7 +2465,8 @@ static int jtagmkII_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsupp = 1; unsupp = 1;
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) { } else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
cmd[1] = MTYPE_FUSE_BITS; cmd[1] = MTYPE_FUSE_BITS;
} else if (strcmp(mem->desc, "usersig") == 0) { } else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
cmd[1] = MTYPE_USERSIG; cmd[1] = MTYPE_USERSIG;
} else if (strcmp(mem->desc, "prodsig") == 0) { } else if (strcmp(mem->desc, "prodsig") == 0) {
cmd[1] = MTYPE_PRODSIG; cmd[1] = MTYPE_PRODSIG;

View File

@ -3869,7 +3869,8 @@ static int stk600_xprog_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
* fuses. * fuses.
*/ */
need_erase = 1; need_erase = 1;
} else if (strcmp(mem->desc, "usersig") == 0) { } else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
memcode = XPRG_MEM_TYPE_USERSIG; memcode = XPRG_MEM_TYPE_USERSIG;
} else { } else {
avrdude_message(MSG_INFO, "%s: stk600_xprog_write_byte(): unknown memory \"%s\"\n", avrdude_message(MSG_INFO, "%s: stk600_xprog_write_byte(): unknown memory \"%s\"\n",
@ -3944,7 +3945,8 @@ static int stk600_xprog_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
} else if (strcmp(mem->desc, "calibration") == 0 || } else if (strcmp(mem->desc, "calibration") == 0 ||
strcmp(mem->desc, "prodsig") == 0) { strcmp(mem->desc, "prodsig") == 0) {
b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION; b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
} else if (strcmp(mem->desc, "usersig") == 0) { } else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
b[1] = XPRG_MEM_TYPE_USERSIG; b[1] = XPRG_MEM_TYPE_USERSIG;
} else { } else {
avrdude_message(MSG_INFO, "%s: stk600_xprog_read_byte(): unknown memory \"%s\"\n", avrdude_message(MSG_INFO, "%s: stk600_xprog_read_byte(): unknown memory \"%s\"\n",
@ -4019,7 +4021,8 @@ static int stk600_xprog_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
} else if (strcmp(mem->desc, "calibration") == 0 || } else if (strcmp(mem->desc, "calibration") == 0 ||
strcmp(mem->desc, "prodsig") == 0) { strcmp(mem->desc, "prodsig") == 0) {
memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION; memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
} else if (strcmp(mem->desc, "usersig") == 0) { } else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
memtype = XPRG_MEM_TYPE_USERSIG; memtype = XPRG_MEM_TYPE_USERSIG;
} else { } else {
avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_load(): unknown paged memory \"%s\"\n", avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_load(): unknown paged memory \"%s\"\n",
@ -4132,7 +4135,8 @@ static int stk600_xprog_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
} else if (strcmp(mem->desc, "calibration") == 0) { } else if (strcmp(mem->desc, "calibration") == 0) {
memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION; memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
writemode = (1 << XPRG_MEM_WRITE_WRITE); writemode = (1 << XPRG_MEM_WRITE_WRITE);
} else if (strcmp(mem->desc, "usersig") == 0) { } else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
memtype = XPRG_MEM_TYPE_USERSIG; memtype = XPRG_MEM_TYPE_USERSIG;
writemode = (1 << XPRG_MEM_WRITE_WRITE); writemode = (1 << XPRG_MEM_WRITE_WRITE);
} else { } else {
@ -4290,7 +4294,8 @@ static int stk600_xprog_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
b[1] = XPRG_ERASE_BOOT_PAGE; b[1] = XPRG_ERASE_BOOT_PAGE;
} else if (strcmp(m->desc, "eeprom") == 0) { } else if (strcmp(m->desc, "eeprom") == 0) {
b[1] = XPRG_ERASE_EEPROM_PAGE; b[1] = XPRG_ERASE_EEPROM_PAGE;
} else if (strcmp(m->desc, "usersig") == 0) { } else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
b[1] = XPRG_ERASE_USERSIG; b[1] = XPRG_ERASE_USERSIG;
} else { } else {
avrdude_message(MSG_INFO, "%s: stk600_xprog_page_erase(): unknown paged memory \"%s\"\n", avrdude_message(MSG_INFO, "%s: stk600_xprog_page_erase(): unknown paged memory \"%s\"\n",

View File

@ -149,12 +149,10 @@ static int nexttok(char * buf, char ** tok, char ** next)
static int hexdump_line(char * buffer, unsigned char * p, int n, int pad) static int hexdump_line(char * buffer, unsigned char * p, int n, int pad)
{ {
char * hexdata = "0123456789abcdef"; char * hexdata = "0123456789abcdef";
char * b; char * b = buffer;
int i, j; int32_t i = 0;
int32_t j = 0;
b = buffer;
j = 0;
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
if (i && ((i % 8) == 0)) if (i && ((i % 8) == 0))
b[j++] = ' '; b[j++] = ' ';
@ -183,7 +181,7 @@ static int chardump_line(char * buffer, unsigned char * p, int n, int pad)
int i; int i;
char b [ 128 ]; char b [ 128 ];
for (i=0; i<n; i++) { for (int32_t i = 0; i < n; i++) {
memcpy(b, p, n); memcpy(b, p, n);
buffer[i] = '.'; buffer[i] = '.';
if (isalpha((int)(b[i])) || isdigit((int)(b[i])) || ispunct((int)(b[i]))) if (isalpha((int)(b[i])) || isdigit((int)(b[i])) || ispunct((int)(b[i])))
@ -192,7 +190,7 @@ static int chardump_line(char * buffer, unsigned char * p, int n, int pad)
buffer[i] = ' '; buffer[i] = ' ';
} }
for (i=n; i<pad; i++) for (i = n; i < pad; i++)
buffer[i] = ' '; buffer[i] = ' ';
buffer[i] = 0; buffer[i] = 0;
@ -203,16 +201,13 @@ static int chardump_line(char * buffer, unsigned char * p, int n, int pad)
static int hexdump_buf(FILE * f, int startaddr, unsigned char * buf, int len) static int hexdump_buf(FILE * f, int startaddr, unsigned char * buf, int len)
{ {
int addr;
int n;
unsigned char * p;
char dst1[80]; char dst1[80];
char dst2[80]; char dst2[80];
addr = startaddr; int32_t addr = startaddr;
p = (unsigned char *)buf; unsigned char * p = (unsigned char *)buf;
while (len) { while (len) {
n = 16; int32_t n = 16;
if (n > len) if (n > len)
n = len; n = len;
hexdump_line(dst1, p, n, 48); hexdump_line(dst1, p, n, 48);
@ -230,83 +225,88 @@ static int hexdump_buf(FILE * f, int startaddr, unsigned char * buf, int len)
static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p, static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
int argc, char * argv[]) int argc, char * argv[])
{ {
static char prevmem[128] = {0}; if (argc < 2) {
char * e; avrdude_message(MSG_INFO, "Usage: %s <memtype> [<start addr> <len>]\n"
unsigned char * buf; " %s <memtype> [<start addr> <...>]\n"
int maxsize; " %s <memtype> <...>\n"
unsigned long i; " %s <memtype>\n",
static unsigned long addr=0; argv[0], argv[0], argv[0], argv[0]);
static int len=64; return -1;
AVRMEM * mem;
char * memtype = NULL;
int rc;
if (!((argc == 2) || (argc == 4))) {
avrdude_message(MSG_INFO, "Usage: dump <memtype> [<addr> <len>]\n");
return -1;
} }
memtype = argv[1]; enum { read_size = 256 };
static char prevmem[128] = {0x00};
if (strncmp(prevmem, memtype, strlen(memtype)) != 0) { char * memtype = argv[1];
addr = 0; AVRMEM * mem = avr_locate_mem(p, memtype);
len = 64;
strncpy(prevmem, memtype, sizeof(prevmem)-1);
prevmem[sizeof(prevmem)-1] = 0;
}
mem = avr_locate_mem(p, memtype);
if (mem == NULL) { if (mem == NULL) {
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n", avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
memtype, p->desc); memtype, p->desc);
return -1; return -1;
} }
uint32_t maxsize = mem->size;
// Get start address if present
char * end_ptr;
static uint32_t addr = 0;
if (argc == 4) { if (argc == 4) {
addr = strtoul(argv[2], &e, 0); addr = strtoul(argv[2], &end_ptr, 0);
if (*e || (e == argv[2])) { if (*end_ptr || (end_ptr == argv[2])) {
avrdude_message(MSG_INFO, "%s (dump): can't parse address \"%s\"\n", avrdude_message(MSG_INFO, "%s (%s): can't parse address \"%s\"\n",
progname, argv[2]); progname, argv[0], argv[2]);
return -1; return -1;
} } else if (addr >= maxsize) {
avrdude_message(MSG_INFO, "%s (%s): address 0x%05lx is out of range for %s memory\n",
len = strtol(argv[3], &e, 0); progname, argv[0], addr, mem->desc);
if (*e || (e == argv[3])) {
avrdude_message(MSG_INFO, "%s (dump): can't parse length \"%s\"\n",
progname, argv[3]);
return -1; return -1;
} }
} }
maxsize = mem->size; // Get no. bytes to read if present
static int32_t len = read_size;
if (addr >= maxsize) { if (argc >= 3) {
if (argc == 2) { memset(prevmem, 0x00, sizeof(prevmem));
/* wrap around */ if (strcmp(argv[argc - 1], "...") == 0) {
if (argc == 3)
addr = 0;
len = maxsize - addr;
} else if (argc == 4) {
len = strtol(argv[3], &end_ptr, 0);
if (*end_ptr || (end_ptr == argv[3])) {
avrdude_message(MSG_INFO, "%s (%s): can't parse length \"%s\"\n",
progname, argv[0], argv[3]);
return -1;
}
} else {
len = read_size;
}
}
// No address or length specified
else if (argc == 2) {
if (strncmp(prevmem, memtype, strlen(memtype)) != 0) {
addr = 0; addr = 0;
len = read_size;
strncpy(prevmem, memtype, sizeof(prevmem) - 1);
prevmem[sizeof(prevmem) - 1] = 0;
} }
else { if (addr >= maxsize)
avrdude_message(MSG_INFO, "%s (dump): address 0x%05lx is out of range for %s memory\n", addr = 0; // Wrap around
progname, addr, mem->desc);
return -1;
}
} }
/* trim len if nessary to not read past the end of memory */ // Trim len if nessary to not read past the end of memory
if ((addr + len) > maxsize) if ((addr + len) > maxsize)
len = maxsize - addr; len = maxsize - addr;
buf = malloc(len); uint8_t * buf = malloc(len);
if (buf == NULL) { if (buf == NULL) {
avrdude_message(MSG_INFO, "%s (dump): out of memory\n", progname); avrdude_message(MSG_INFO, "%s (dump): out of memory\n", progname);
return -1; return -1;
} }
for (i=0; i<len; i++) { for (uint32_t i = 0; i < len; i++) {
rc = pgm->read_byte(pgm, p, mem, addr+i, &buf[i]); int32_t rc = pgm->read_byte(pgm, p, mem, addr + i, &buf[i]);
if (rc != 0) { if (rc != 0) {
avrdude_message(MSG_INFO, "error reading %s address 0x%05lx of part %s\n", avrdude_message(MSG_INFO, "error reading %s address 0x%05lx of part %s\n",
mem->desc, addr+i, p->desc); mem->desc, addr + i, p->desc);
if (rc == -1) if (rc == -1)
avrdude_message(MSG_INFO, "read operation not supported on memory type \"%s\"\n", avrdude_message(MSG_INFO, "read operation not supported on memory type \"%s\"\n",
mem->desc); mem->desc);
@ -315,7 +315,6 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
} }
hexdump_buf(stdout, addr, buf, len); hexdump_buf(stdout, addr, buf, len);
fprintf(stdout, "\n"); fprintf(stdout, "\n");
free(buf); free(buf);
@ -334,7 +333,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
"Usage: write <memtype> <start addr> <data1> <data2> <dataN>\n" "Usage: write <memtype> <start addr> <data1> <data2> <dataN>\n"
" write <memtype> <start addr> <no. bytes> <data1> <dataN> <...>\n\n" " write <memtype> <start addr> <no. bytes> <data1> <dataN> <...>\n\n"
" Add a suffix to manually specify the size for each field:\n" " Add a suffix to manually specify the size for each field:\n"
" H/h/S/s: 16-bit, L/l: 32-bit, LL/ll: 6-bit, F/f: 32-bit float\n"); " HH/hh: 8-bit, H/h/S/s: 16-bit, L/l: 32-bit, LL/ll: 64-bit, F/f: 32-bit float\n");
return -1; return -1;
} }
@ -365,9 +364,16 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
return -1; return -1;
} }
// Figure out how many bytes there is to write to memory uint8_t * buf = malloc(mem->size);
if (buf == NULL) {
avrdude_message(MSG_INFO, "%s (write): out of memory\n", progname);
return -1;
}
// Find the first argument to write to flash and how many arguments to parse and write
if (strcmp(argv[argc - 1], "...") == 0) { if (strcmp(argv[argc - 1], "...") == 0) {
write_mode = WRITE_MODE_FILL; write_mode = WRITE_MODE_FILL;
start_offset = 4;
len = strtoul(argv[3], &end_ptr, 0); len = strtoul(argv[3], &end_ptr, 0);
if (*end_ptr || (end_ptr == argv[3])) { if (*end_ptr || (end_ptr == argv[3])) {
avrdude_message(MSG_INFO, "%s (write ...): can't parse address \"%s\"\n", avrdude_message(MSG_INFO, "%s (write ...): can't parse address \"%s\"\n",
@ -376,23 +382,8 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
} }
} else { } else {
write_mode = WRITE_MODE_STANDARD; write_mode = WRITE_MODE_STANDARD;
} start_offset = 3;
uint8_t * buf = malloc(mem->size);
if (buf == NULL) {
avrdude_message(MSG_INFO, "%s (write): out of memory\n", progname);
return -1;
}
if (write_mode == WRITE_MODE_STANDARD) {
start_offset = 3; // Argument number where data to write starts
len = argc - start_offset; len = argc - start_offset;
} else if (write_mode == WRITE_MODE_FILL)
start_offset = 4;
else {
avrdude_message(MSG_INFO, "%s (write): invalid write mode %d\n",
progname, write_mode);
return -1;
} }
// Structure related to data that is being written to memory // Structure related to data that is being written to memory
@ -410,7 +401,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
}; };
} data = {.bytes_grown = 0, .size = 0, .is_float = false, .ll = 0, .is_signed = false}; } data = {.bytes_grown = 0, .size = 0, .is_float = false, .ll = 0, .is_signed = false};
for (i = start_offset; i < len + start_offset - data.bytes_grown; i++) { for (i = start_offset; i < len + start_offset; i++) {
data.is_float = false; data.is_float = false;
data.size = 0; data.size = 0;