Commit Graph

18 Commits

Author SHA1 Message Date
Stefan Rueger 7d5ab433ca
Replace gratuitous references to slave and master with technical terms 2022-11-22 17:11:33 +00:00
Stefan Rueger baaad71aa5
Support optiboot, optiboot_dx and optiboot_x bootloaders for -c arduino (#1140)
* If bootloaders are served, send word addresses for classic parts and
  byte addresses for newer parts, eg, UPDI and PDI
* Load ext addr for stk500v1 bootloaders after grazing 64k boundaries
* Fix bootloader stk500v1 EEPROM r/w for classic parts with page size 1
2022-10-23 22:32:29 +01:00
Stefan Rueger 5b008a04cf
Revamp terminal output: progress bar, callback and stdout/stderr (#1132)
* Print parms output to stdout
* Flush terminal writes and other minor changes
* Prepare terminal for periodic calls to programmer to reset bootloader WDT
* Only show progress reports for memories > 32 bytes or on -vv
* Freeze progress bar on serious error
* Allow cached r/w byte routines to be used in pgm->read_byte and pgm->write_byte
2022-10-23 21:56:45 +01:00
Stefan Rueger e172877724
Review and overhaul AVRDUDE's messaging system (#1126)
* Change avrdude_message(MSG_XYZ, ...) to msg_xyz(...)
* Define and use pmsg_xyz(...) instead of msg_xyz("%s: ...", progname, ...)
* Review and change avrdude_message() levels
   - Introduce new levels warning, error and ext_error
   - Distribute info level to info, warning, error, ext_error
   - Assign levels (more) consistently
   - Unify grammar, punctuation and style of messages
* Use imsg_xyz() to print indented messages
* Show function name in errors and warnings on -v
* Reduce effective verbosity level by number of -q above one
2022-10-17 15:44:55 +01:00
Stefan Rueger c03f4a7925
Use const in PROGRAMMER function arguments where appropriate
In order to get meaningful const properties for the PROGRAMMER, AVRPART and
AVRMEM arguments, some code needed to be moved around, otherwise a network of
"tainted" assignments risked rendering nothing const:

 - Change void (*enable)(PROGRAMMER *pgm) to void (*enable)(PROGRAMMER *pgm,
   const AVRPART *p); this allows changes in the PROGRAMMER structure after
   the part is known. For example, use TPI, UPDI, PDI functions in that
   programmer appropriate to the part. This used to be done later in the
   process, eg, in the initialize() function, which "taints" all other
   programmer functions wrt const and sometimes requires other finessing with
   flags etc. Much clearer with the modified enable() interface.

 - Move TPI initpgm-type code from initialize() to enable() --- note that
   initpgm() does not have the info at the time when it is called whether or
   not TPI is required

 - buspirate.c: move pgm->flag to PDATA(pgm)->flag (so legitimate
   modification of the flag does not change PROGRAMMER structure)

 - Move AVRPART_INIT_SMC and AVRPART_WRITE bits from the flags field in
   AVRPART to jtagmkII.c's private data flags32 fiels as FLAGS32_INIT_SMC and
   FLAGS32_WRITE bits

 - Move the xbeeResetPin component to private data in stk500.c as this is
   needed by xbee when it saddles on the stk500 code (previously, the flags
   component of the part was re-dedicated to this)

 - Change the way the "chained" private data are used in jtag3.c whilst
   keeping the PROGRAMMER structure read-only otherwise

 - In stk500v2.c move the STK600 pgm update from stk500v2_initialize() to
   stk500v2_enable() so the former keeps the PROGRAMMER structure read-only
   (for const assertion).

 - In usbasp change the code from changing PROGRAMMER functions late to
   dispatching to TPI or regular SPI protocol functions at runtime; reason
   being the decision whether to use TPI protocol is done at run-time
   depending on the capability of the attached programmer

Also fixes Issue #1071, the treatment of default eecr value.
2022-08-17 16:05:28 +01:00
Stefan Rueger 3d06457a16
Deprecate original STK500 v1 protocol in favour of optiboot and Arduino as ISP
For paged read/write early AVRDUDE implementations of the STK500 v1 protocol
communicated a word address (below a_div=2) or byte address (a_div=1) based
on the following code irrespective of which memories were used:

  if(m->op[AVR_OP_LOADPAGE_LO] || m->op[AVR_OP_READ_LO])
    a_div = 2;
  else
    a_div = 1;

This turned out to be a bug: it really should have been a_div=2 for flash and
a_div=1 for eeprom. At the time presumably no one noted because Atmel was at
the cusp of replacing their FW 1.x with FW 2 (and the STK500 v2 protocol).

It seems that the world (optiboot, Arduino as ISP, ...) has compensated for
the bug by assuming AVRDUDE sends *all* eeprom addresses as word addresses.
Actually these programmers overcompensated for the bug because for six out of
the 146 known SPI programmable parts with eeprom and page size > 1, AVRDUDE
would still send the eeprom addresses as byte addresses (ATmega8 ATmega8A
ATmega64 ATmega64A ATmega128 ATmega128A) owing to above code.

It makes no sense to correct the bug now seeing that virtually no one uses
the old 2005 STK 500 v1 firmware. This commit now follows optiboot, Arduino
as ISP and other projects, and simply sends all addresses for paged read or
write as word addresses. There are no longer (little known) exceptions for
ATmega8 et al that surprised some optiboot etc users.
2022-07-24 20:39:14 +01:00
Stefan Rueger 29c6645abc
Resolve signed/unsigned comparisons in stk500.c and stk500v2.c 2022-07-24 19:41:42 +01:00
Stefan Rueger 535004ee3d
Consolidate error messages for stk500.c 2022-07-24 19:27:07 +01:00
Stefan Rueger 7310df030f
Check stk500_recv() actually worked before accepting SYNC byte 2022-07-24 18:48:22 +01:00
Stefan Rueger 4babe183da
Initialise memory before avr_set_bits() calls in stk500.c and stk500v2.c 2022-07-24 18:20:35 +01:00
MCUdude 7144a9f2ae Replace incorrect warning message
Was mistakenly added in PR #854.
2022-01-29 20:08:43 +01:00
MCUdude 28be45d8b6 Fix Ardino sync attempts
In order for the Arduino bootloader to re-sync with Avrdude, the microcontroller needs to be reset to start the bootloader again.
2022-01-29 19:53:42 +01:00
MCUdude ad6eff0f76 Set number of Arduino/STK500 connection retry attempts
Using the extended parameter flag -x. Usage: . Default number of attempts is still 10 if not -x flag is specified
2022-01-25 09:40:24 +01:00
MCUdude 286c0f5e2a Don't print irrelevant information for the Arduino programmer 2022-01-24 22:16:31 +01:00
Marius Greuel fe6f08d48f Use alloca for stack based memory allocation 2022-01-07 17:54:36 +01:00
Marius Greuel c035c91db5 Add compatibility shim for MSVC 2022-01-07 17:54:36 +01:00
Dawid Buchwald 291549d021 Merged AVRDUDES/main into SerialUPDI branch 2021-12-21 21:38:51 +01:00
Marius Greuel 5633a6d88a Move source files to 'src' folder 2021-12-17 09:17:42 +01:00