Commit Graph

18 Commits

Author SHA1 Message Date
Stefan Rueger cf64837391
Silence page erase in cache code 2023-01-04 19:04:16 +00:00
Stefan Rueger fdcfb543fc
Improve guessBootloaderStart() for modern AVR 2023-01-04 18:52:51 +00:00
Stefan Rueger 9bd4dee254
Merge pull request #1205 from janegilruud/jtag3-tpi-jer
Added TPI support for Microchip tools
2022-12-13 23:56:25 +00:00
Jan Egil Ruud 8db18e64ed Remove redundant mem-check. 2022-12-01 20:12:26 +01:00
Jan Egil Ruud dc64fb716f Fix wrongfully call to initCache() according to stefanrueger's instructions. 2022-12-01 20:05:55 +01:00
Jan Egil Ruud f78e14ee96 Revert "Skip chaching when size of memory is 0."
This reverts commit bb808e8d5f.
2022-12-01 20:01:11 +01:00
Jan Egil Ruud bb808e8d5f Skip chaching when size of memory is 0. 2022-12-01 15:16:23 +01:00
Stefan Rueger 0e0a0ba0eb
Get boot section info from avrdude.conf and not from avrintel.c 2022-11-26 13:53:46 +00:00
Stefan Rueger 68c6ffd7fc
Silence compiler warnings, change comments, remove typos 2022-11-24 12:14:54 +00:00
Stefan Rueger 82b9491cbd
Harden urclock against bootloader bricking
- Detect write restrictions with new pgm->readonly(..., addr)
 - Check in byte-wise cached write whether mem/addr allows write
 - Emulated chip erase tells user CE is delayed until first -U
 - After bootloader CE urclock_chip_erase will init reset vector
 - Low level paged write @ 0 unconditionally protects reset vector
 - Low level paged read @ 0 checks and repairs reset vector
2022-11-16 00:08:46 +00: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 b864d7e73a
Update NEWS and resolve minor residual messaging issues 2022-10-17 16:39: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 714c2fbf95
Rename variable for clarity in avrcache.c 2022-10-12 15:55:22 +01:00
Stefan Rueger 8a3864d263
Fall back on bytewise r/w if paged access fails for avr cache 2022-10-12 15:53:54 +01:00
Stefan Rueger 48919f59b3
Use byte-wise read/write when page size is 1 in terminal cache 2022-10-11 15:31:18 +01:00
Stefan Rueger d3a3257cf7
Improve help message in terminal and provide new command pgerase (#1113) 2022-10-11 14:40:37 +01:00
Stefan Rueger d74b17b9b4
Provide cached byte-wise read/write API (#1106)
* Provide cached byte-wise read/write API

int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
  AVRMEM *mem, unsigned long addr, unsigned char *value);

int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const
 AVRMEM *mem, unsigned long addr, unsigned char data);

int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p);

int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);

int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p);

avr_read_byte_cached() and avr_write_byte_cached() use a cache if paged
routines are available and if the device memory is EEPROM or flash,
otherwise they fall back to pgm->read_byte() and pgm->write_byte(),
respectively. Byte-wise cached read always gets its data from the cache,
possibly after reading a page from the device memory. Byte-wise cached
write with an address in memory range only ever modifies the cache. Any
modifications are written to the device after calling avr_flush_cache() or
when attempting to read or write from a location outside the address range
of the device memory.

avr_flush_cache() synchronises pending writes to EEPROM and flash with the
device. With some programmer and part combinations, flash (and sometimes
EEPROM, too) looks like a NOR memory, ie, one can only write 0 bits, not 1
bits. When this is detected, either page erase is deployed (eg, with parts
that have PDI/UPDI interfaces), or if that is not available, both EEPROM
and flash caches are fully read in, a pgm->chip_erase() command is issued
and both EEPROM and flash are written back to the device. Hence, it can
take minutes to ensure that a single previously cleared bit is set and,
therefore, this routine should be called sparingly.

avr_chip_erase_cached() erases the chip and discards pending writes() to
flash or EEPROM. It presets the flash cache to all 0xff alleviating the
need to read from the device flash. However, if the programmer serves
bootloaders (pgm->prog_modes & PM_SPM) then the flash cache is reset
instead, necessitating flash memory be fetched from the device on first
read; the reason for this is that bootloaders emulate chip erase and they
won't overwrite themselves (some bootloaders, eg, optiboot ignore chip
erase commands altogether) making it truly unknowable what the flash
contents on device is after a chip erase. 

For EEPROM avr_chip_erase_cached() concludes that it has been deleted if a
previously cached EEPROM page that contained cleared bits now no longer
has these clear bits on the device. Only with this evidence is the EEPROM
cache preset to all 0xff otherwise the cache discards all pending writes
to EEPROM and is left unchanged otherwise.

Finally, avr_reset_cache() resets the cache without synchronising pending
writes() to the device.
2022-10-05 22:16:15 +01:00