Commit Graph

775 Commits

Author SHA1 Message Date
Stefan Rueger f276d325ec
Handle verification errors in read only memory areas gracefully 2022-11-20 00:27:49 +00:00
Stefan Rueger ee25a62df6
Emulate chip erase in terminal when pgm->chip_erase() soft fails 2022-11-19 23:09:18 +00:00
Stefan Rueger d65a9a3cee
Adapt -c urclock to new reset vector protection in urboot v7.7 2022-11-19 19:39:39 +00:00
Joerg Wunsch 77ad26ddf4 Replace the hint to AUTHORS by an URL
Suggested by: Hans
2022-11-18 21:24:10 +01:00
Joerg Wunsch efad24e3de Rewrite authors/copyrights 2022-11-18 10:31:45 +01:00
Joerg Wunsch 9df522a219 Add <sys/select.h> where appropriate
Under Posix systems, this header is documented to be required
when using select().
2022-11-17 14:14:22 +01:00
Joerg Wunsch 01be288b18 Add fallback for EM_AVR
OpenBSD still lacks this definition, so provide our own for
them.
2022-11-16 21:21:51 +01:00
Stefan Rueger a3eeedd176
Silence some compiler warnings 2022-11-16 02:32:32 +00:00
Stefan Rueger 2abb666bd2
Prepare urclock for autobaud synchronisation 2022-11-16 02:08:13 +00:00
Stefan Rueger d901e0a768
Update urbootPutVersion() to reflect urboot v7.7 changes 2022-11-16 00:42:36 +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 afc2f7cf0c
Hint at option -xdelay=... for urclock programmer not responding messages 2022-11-12 13:47:48 +00:00
Stefan Rueger ff9c8bbe46
Silence min()/max() compiler warnings, fix urclock.c typo etc 2022-11-12 13:32:53 +00:00
Stefan Rueger e2b69dec75
Remove MacOS compiler warnings for urclock.c 2022-11-12 01:12:31 +00:00
Stefan Rueger b178deef5f
Handle n_page_erase in urclock for parts t441, t841 and t1634 2022-11-11 01:33:42 +00:00
Stefan Rueger 6e3a99be87
Add write statistics for patched flash input files at notice2 level 2022-11-11 01:27:55 +00:00
Stefan Rueger 22bd977365
Indent erasing chip message in main 2022-11-10 23:18:43 +00:00
Stefan Rueger c67bfe39a3
Show input file staistics before patching in update.c 2022-11-10 23:00:18 +00:00
Stefan Rueger 321bddbf7b
Rename urclock's option forcetrim to restore 2022-11-10 22:35:40 +00:00
Stefan Rueger 2434c3f7f6
Make terminal write's automatic number width less surprising 2022-11-10 19:38:21 +00:00
Stefan Rueger 4c4952d4f6
Ensure default_programmer from config files is used 2022-11-10 18:20:13 +00:00
Stefan Rueger afa408e2c6
Make urclock.c iron out a bug in some bootloaders 2022-11-09 21:00:16 +00:00
Stefan Rueger d5d0b940cc
Harden vector bootloaders more against reset overwrites 2022-11-09 19:28:29 +00:00
Stefan Rueger 84a3e2cc2b
Fix avr.c comment 2022-11-09 19:27:34 +00:00
Stefan Rueger c7ba53bca0
Harden urclock against terminal time outs and vector overwrites 2022-11-09 16:16:59 +00:00
Stefan Rueger ea65918dca
Omit verify after write failure in term.c 2022-11-09 15:43:57 +00:00
Stefan Rueger 20b86fb739
Warn in uclock when bootloader cannot read/write memories 2022-11-08 20:16:05 +00:00
Stefan Rueger 6a6d333849
Update urclock documentation 2022-11-08 15:18:30 +00:00
Stefan Rueger cf3c81f714
Update urclock's -x parameters 2022-11-07 18:01:23 +00:00
Stefan Rueger 715db4c690
Make -A default for urclock programmer 2022-11-07 02:43:34 +00:00
Stefan Rueger 21d93ec8cb
Update urclock programmer 2022-11-07 01:26:47 +00:00
Stefan Rueger e6c26d8db4
Provide urclock programmer 2022-11-06 01:29:07 +00:00
Stefan Rueger d211c4e5f5
Merge pull request #1164 from MCUdude/hvupdi-type2-fix
Fix Type 2 HV UPDI
2022-11-01 18:17:52 +00:00
Stefan Rueger 02fe08aed2
Open programmer before allocating part
So any programmer that knows exactly which part it is connected to
can set the -p part option should the user not have done so.

Also no longer exits main without closing open programmer.
2022-11-01 18:12:00 +00:00
MCUdude 577ee72db7 Fix Type 2 HV UPDI
Used on AVR-DD and AVR-Ex targets
2022-10-31 11:06:14 +01:00
Stefan Rueger 50046da923
Merge pull request #1151 from dbuchwald/serialupdi_page_erase
Implementation of SerialUPDI page erase operation
2022-10-29 11:02:17 +01:00
Stefan Rueger d87eb14dc9
Make -p variable partdesc global 2022-10-29 10:55:58 +01:00
Stefan Rueger 87df3216cb
Make fileio() and do_op() arguments const where possible 2022-10-29 10:48:47 +01:00
Stefan Rueger a1018999c4
Correct plural for message writing %d bytes in term.c 2022-10-26 08:42:03 +01:00
Stefan Rueger 418cf08e84
Change avrdude.conf.in comment on location of per-user config file 2022-10-25 18:13:28 +01:00
mcuee f2a413d2dc
Merge branch 'avrdudes:main' into Xplained_Pro_PDI 2022-10-24 07:57:55 +08:00
Stefan Rueger 3769332afd
Merge pull request #1142 from MCUdude/stk600-pdi
STK600 supports programming using PDI
2022-10-23 23:10:10 +01:00
Stefan Rueger ae5b460859
Merge pull request #1141 from stefanrueger/paged
Always use paged access for programmers that serve bootloaders
2022-10-23 22:33:31 +01: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 16922842be
Improve -B bitclock documentation 2022-10-23 22:26:07 +01:00
Stefan Rueger 2c7083f001
Merge pull request #1139 from steelman/isp-clock-error-message
Mention -B in the error message and document -F better
2022-10-23 21:59:21 +01:00
Stefan Rueger 4f6bab6303
Merge pull request #1138 from MCUdude/pic-detect-mode-cherry
Detect PICkit4 and SNAP in PIC mode
2022-10-23 21:57:26 +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
steelman 34fa2faba5
Look for ~/.config/avrdude/avrduce.rc configuration file (#1131)
* Look for ~/.config/avrdude/config configuration file

Traditionally per-user configuration files have been placed
in user's home directory with their names beginnig with a dot
to hide them from some tools like ls(1). However, the number
of programs following this convention have grown over time
to the point where the number of hidden files becomes inconvenient to
some users. For this reason the XDG Base Directory Specification[1]
specifies an alternate place to store configuration files under
~/.config directory.

This patch enables avrdude to look for ~/.config/avrdude/config
configuration file, if ~/.avrduderc doesn't exist.

[1] https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.8.html

* Safely concatenate directories and configurations files and minor changes in docs

* Make stats variable available for WIN32 again in main.c

* Utilise full usr_config[] array space

* Check for xdg-style avrdude.rc file first before fallback ~/.avrduderc

Co-authored-by: Stefan Rueger <stefan.rueger@urclocks.com>
2022-10-23 21:52:54 +01:00
Dawid Buchwald fa1c081a94 Implemented page erase operation for SerialUPDI 2022-10-23 15:06:06 +02:00
mcuee 4a5efa7635
Add xplainedpro_pdi programmer
This will fix https://github.com/avrdudes/avrdude/issues/1143.

Xplained Pro should be able to support PDI mode as per the documentation.

Reference: take note that the following document does not cover UPDI support.
https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42096-Microcontrollers-Embedded-Debugger_User-Guide.pdf

Reference discussion:
* https://github.com/avrdudes/avrdude/pull/1139#issuecomment-1286760773
* https://github.com/avrdudes/avrdude/discussions/1019#discussioncomment-3569440
2022-10-23 14:24:57 +08:00
MCUdude 992e9666a3 STK600 supports programming using PDI 2022-10-22 12:51:03 +02:00
Łukasz Stelmach c890ff90eb Mention -B in the error message
One of possible problems of failed initialization is too hight frequency
of ISP clock. Mention using -B option as a possible solution.

Closes #1133
2022-10-21 02:33:34 +02:00
Stefan Rueger b9396bcd02
Always use paged access for programmers that serve bootloaders 2022-10-21 00:56:43 +01:00
Łukasz Stelmach 9977f1ed12 Document meaning of -F during initialization 2022-10-20 19:52:35 +02:00
MCUdude 72da5c73db Fix formatting and replace tabs with spaces 2022-10-20 12:39:11 +02:00
MCUdude 867d83c215 Print error message if no HID device is connected when using hidapi 2022-10-20 12:27:59 +02:00
MCUdude 14446950df Check for PICkit4 or SNAP in PIC mode 2022-10-20 12:19:10 +02:00
MCUdude b083416e3b Let Avrdude use the valid SNAP USB PID first 2022-10-20 12:19:10 +02:00
MCUdude 13817459e1 Add missing USB VID/PIDs 2022-10-20 12:19:10 +02:00
MCUdude c999083b8f Change message type from error to warning and add additional USB info 2022-10-20 12:18:42 +02: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 2503ae03ce
Merge pull request #1125 from MCUdude/updi-lock-fix
Fix UPDI erase when target is locked
2022-10-17 14:17:32 +01:00
Stefan Rueger ff1d26ad18
Merge pull request #1122 from mariusgreuel/pr-teensy-warning
Suppress Teensy USB communication error message on reboot
2022-10-17 14:17:07 +01:00
Stefan Rueger 8e879cfae6
Merge pull request #1121 from stefanrueger/avr_cache
Use byte-wise read/write when page size is 1 in terminal cache
2022-10-17 14:16:43 +01:00
Dan Applegate 946b701b08
Fix writing of last word on DWORD TPI parts (#1115)
* Fix writing of last word on DWORD TPI parts

* Add n_word_writes AVRMEM config option

* TPI word chunk mode in avr_write_mem

* Simplify addition of n_words_write mem component to grammar

Co-authored-by: Stefan Rueger <stefan.rueger@urclocks.com>
2022-10-17 14:15:50 +01:00
Stefan Rueger 08f4f6c63f
Merge pull request #1112 from MCUdude/jtag3-page-erase-updi
Fix jtag3_page_erase for targets with UPDI
2022-10-17 14:12:17 +01:00
MCUdude bfec594ffd Fix issue where locked UPDI devices couldn't be erased
Resolves issue #1124
2022-10-13 14:14:46 +02: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
Marius Greuel 86155bdf66 Suppress Teensy USB communication error message on reboot 2022-10-11 18:23:03 +02: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 e14e5d2f74
Update NEWS 2022-10-11 14:49:44 +01:00
Stefan Rueger 22362e9f08
Merge branch 'main' into pr-pointer-truncation 2022-10-11 14:43:19 +01:00
Stefan Rueger d3a3257cf7
Improve help message in terminal and provide new command pgerase (#1113) 2022-10-11 14:40:37 +01:00
Marius Greuel 9377acee0e Fix pointer truncation for Windows x64 2022-10-08 19:02:03 +02:00
MCUdude 1ca1be0447 Use avr_mem_is_flash_type() instead of checking m->desc directly 2022-10-06 20:59:32 +02:00
MCUdude d5e4ed9f89 Fix jtag3_page_erase for targets with UPDI
Very handy to have now that #1106 is merged
2022-10-05 23:52:05 +02:00
Stefan Rueger cd79f81747
Merge pull request #1109 from MCUdude/jtag-mki-targets
Add missing AVR variants the original JTAG ICE supports
2022-10-05 22:21:42 +01:00
Stefan Rueger f2fb3b45b4
Merge pull request #1108 from MCUdude/avr109-xmega
AVR109: support for prodsig read and usersig read/write
2022-10-05 22:20:16 +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
Stefan Rueger c4cb242823
Merge pull request #1105 from MCUdude/power-debugger-features
Support for Power Debugger analog readings in terminal mode
2022-10-05 22:03:52 +01:00
Stefan Rueger bc9137854b
Merge pull request #1103 from s-wakaba/sunxi_linuxspi_support
saving errno of ioctl() call in a temporary variable to prevent overwrite
2022-10-05 22:02:42 +01:00
Stefan Rueger 83232bc7e1
Merge pull request #1102 from MCUdude/flip2-reset
Add support for Flip 2 reset on exit
2022-10-05 22:02:22 +01:00
Hans da275f8ef2 Adjust prog_modes on a few chip variants
Now variants of chips that the JTAG ICE supports will not cause a warning when used with the original JTAG ICE mkI.
Also, The ATmega165 isn't officially supported by the ICE mkI, so this should be properly tested with the ICE mkI first.
2022-10-05 19:24:40 +02:00
MCUdude 31c3db2617 Add support for prodsig read and usersig read/write
Currently only supported by the Xboot bootloader
2022-10-02 22:36:43 +02:00
MCUdude ffabab1fb2 Improve pgm->id detection handling 2022-10-02 11:48:30 +02:00
MCUdude 419fd35b72 Mention linuxspi and flip2 programmers
in the -E exitspecs section. linuxspi and flip2 supports "-E reset" and "-E noreset".
2022-10-01 22:12:37 +02:00
MCUdude e05aa16510 use pgm->id to identify Power Debugger instead of USB PID 2022-10-01 21:17:55 +02:00
MCUdude e39133daf5 Initial support for Power Debugger analog reading
Voltage and current though channel A and B
2022-10-01 21:17:01 +02:00
MCUdude 01ccab08b4 Improve exitspecs (-E) parsing
Use the same implementation as linuxspi does, instead of the one suggested in #733
2022-09-30 20:16:16 +02:00
MCUdude 521155c1c2 Improve punctuation in error message 2022-09-30 20:03:04 +02:00
MCUdude e1a317c670 Remove Flip 2 stub functions
Used when compiling without libusb. Print reasonable error instead
2022-09-27 19:35:25 +02:00
Shunichi Wakabayashi 2a64e78c7b bugfix: saving errno of ioctl() call in a temporary variable to prevent overwriting by following avrdude_message() call 2022-09-25 16:46:10 +09:00
MCUdude 80ca8a644e Add support for Flip 2 reset on exit
This makes it possible for the application to start immedeatly after the program has been loaded.
Simply use '-E reset' or '-E noreset'. Default is no reset.
Closes #733
2022-09-24 22:48:14 +02:00
MCUdude 62aa480876 Fix avr109 extended address
Closes #360 #454
2022-09-24 20:42:42 +02:00
Stefan Rueger 9a59941dfe
Merge pull request #1100 from s-wakaba/sunxi_linuxspi_support
add extended parameter "disable_no_sc" for linuxspi programmer
2022-09-24 13:23:38 +01:00
Stefan Rueger 94203eb441
Merge pull request #1099 from stefanrueger/prog_modes
Print compatible parts for programmer and vice versa using -c? or -p?
2022-09-24 13:23:12 +01:00
Stefan Rueger f172f05372
Merge pull request #1096 from mariusgreuel/pr-cmake-texinfo
CMake: Build docs
2022-09-24 13:22:55 +01:00
Stefan Rueger 7743051926
Merge pull request #1095 from mariusgreuel/pr-fix-multiline-configure
CMake: Fix dependency chain between avrdude.conf.in and avrdude.conf
2022-09-24 13:22:37 +01:00
Stefan Rueger db8b04f423
Merge pull request #1094 from papazoga/main
avrdude.conf.in: Adds digilent-hs2 dongle
2022-09-24 13:22:14 +01:00
Stefan Rueger 3b8ac76246
Merge pull request #1093 from stefanrueger/gemmaBoot
Create two bootloader programmers for gemmaBoot boards
2022-09-24 13:21:44 +01:00
Stefan Rueger fe991b8214
Merge pull request #917 from asmirnou/iss45256-sysfs-gpio
Fix permission denied error in linuxgpio programmer
2022-09-24 13:21:08 +01:00
Stefan Rueger f17a012325
Update documentation for linuxspi extended parameter disable_no_cs 2022-09-24 00:16:55 +01:00
Stefan Rueger 097c78098d
Change printf() to avrdude_message() in linuxgio.c 2022-09-23 23:28:47 +01:00
Stefan Rueger ca154f812f
Improve error messaging in linuxspi.c 2022-09-23 16:53:52 +01:00
Stefan Rueger aa789d4662
Change error messages in linuxspi.c to maintain single style 2022-09-22 10:39:31 +01:00
Stefan Rueger 93df07866a
Inform user of -x disable_no_spi when needed (without -v) 2022-09-22 10:31:59 +01:00
Stefan Rueger d8ff9bef6c
Improve error messaging when part or programmer are invalid 2022-09-21 15:38:05 +01:00
Stefan Rueger 9e836d7988
Ensure avrdude.conf (programmer, part) pairs allow max one programming mode 2022-09-21 12:12:06 +01:00
Stefan Rueger 4c29edbc41
Warn if a part shares multiple programming modes with a programmer 2022-09-21 12:10:24 +01:00
Stefan Rueger 0175ffd21f
Shorten more redundant programmer description for -c \? -p part 2022-09-20 22:03:40 +01:00
Stefan Rueger 505d53c2e1
Shorten redundant for bootloader description in -c ? -p part output 2022-09-20 21:55:29 +01:00
Stefan Rueger b04a83b1a2
Document conditional options -c ? -p part and -p ? -c programmer 2022-09-20 21:39:15 +01:00
Stefan Rueger 97c5ac312a
Shorten redundant programmer description for -c \? -p part 2022-09-20 21:37:49 +01:00
Stefan Rueger 4070ca9012
Distinguish different JTAG programming modes 2022-09-20 18:36:46 +01:00
Shunichi Wakabayashi be40d3b260 add extended parameter "disable_no_sc" for linuxspi programmer 2022-09-20 01:32:12 +09:00
Stefan Rueger 07f1f60020 Make cosmetic changes to avrdude.conf.in 2022-09-16 19:10:39 +01:00
Stefan Rueger fba2ac0330 Align = of -p? and -c? output 2022-09-16 19:09:35 +01:00
Stefan Rueger 7a76967851 Clarify desc lines for SPM programmers in avrdude.conf.in 2022-09-16 16:14:18 +01:00
Stefan Rueger 669796119a Add prog_modes lines for par programmers in avrdude.conf.in 2022-09-16 16:13:18 +01:00
Stefan Rueger f8a62cca34
Print compatible parts for programmer and vice versa using -c? or -p?
For example:
 $ avrdude -p m328p -c?
 $ avrdude -p? -c jtag2dw
2022-09-14 23:00:57 +01:00
Stefan Rueger 0d411f2879
Add prog_modes lines for programmers in avrdude.conf.in 2022-09-14 18:36:37 +01:00
Stefan Rueger ac8fbadff4
Add assignment injection code for -c*/si 2022-09-14 18:04:12 +01:00
Stefan Rueger 7087fd9f3e
Raise info level for overwriting mcuid to MSG_DEBUG 2022-09-11 23:08:48 +01:00
Stefan Rueger 168a8b92e9
Default mcuid without warning for parts known at compile time 2022-09-11 15:33:23 +01:00
Stefan Rueger a5f3885b50 Add and modify programmers for gemmaBoot in avrdude.conf.in 2022-09-07 09:56:28 +01:00
Marius Greuel 8ecae62f4a CMake: Add install commands for docs 2022-09-04 17:48:12 +02:00
Marius Greuel c633255c01 CMake: Add initial support for texinfo docs 2022-09-04 16:55:16 +02:00
Marius Greuel 07ed4746be CMake: Fix dependency chain between avrdude.conf.in and avrdude.conf 2022-09-04 16:19:01 +02:00
Stefan Rueger b99df388bd
Change comment for diligent-hs2 in avrdude.conf.in 2022-09-01 13:08:44 +01:00
Alex Papazoglou bf70b5fc8c avrdude.conf.in: Cosmetic changes
Corrected formatting using /s. Added a URL for the
reference manual.
2022-08-31 20:43:27 -07:00
Alex Papazoglou 4af49bb5fb avrdude.conf.in: Adds digilent-hs2 dongle
Adds support for Digilint JTAG HS2 in MPSSE mode.
2022-08-31 11:45:08 -07:00
Stefan Rueger a536a01ebf
Create a bespoke bootloader programmer for gammaBoot trinkets 2022-08-31 18:15:35 +01:00
Stefan Rueger dab99c0823
Update NEWS 2022-08-31 17:35:03 +01:00
Stefan Rueger 602fab481c
Relax uniqueness check of mcuid for parts that might be variants
Two parts are considered variants here if one part name starts with the name
of the other, flash memory sizes are the same, flash page sizes are the same
and the number of interrupts are the same.
2022-08-31 11:59:19 +01:00
Stefan Rueger fc970226b6
Add avrintel.[ch] to Makefile.am 2022-08-31 11:31:58 +01:00
Stefan Rueger 40896802af
Allow integer expressions in config file where numbers are expected
Notable exceptions are for pin numbers and where numbers are separated by
space only, eg, in signature and readback assignments.
2022-08-31 11:29:06 +01:00
Stefan Rueger b328067f87
Remove has_jtag, has_debugwire, etc assignments in avrdude.conf.in
These assignments have been removed as they are redundant and only
imitate the single prog_modes = PM_... | PM_....; assignment. They
are still allowed in the grammar, and would still work.
2022-08-30 23:25:00 +01:00
Stefan Rueger ffb8b7fcdf
Try different header files for Windows compatibility 2022-08-30 21:31:11 +01:00
Stefan Rueger 4f7868ef4b
Declare rather than define extern const uPcore_t uP_table[372]; 2022-08-30 19:54:41 +01:00
Stefan Rueger 626a43b139
Add avrintel.[ch] to the project and warn if mcuid incompatible with avrintel.c 2022-08-30 19:48:17 +01:00
Stefan Rueger b0198a319f
Offload the programming interface info from part->flags to part->prog_modes
flags now just hold parameters of the JTAG interface and some secondary
serial, parallel, pseudo parallel info. This separation brings clarity. It
used to be hard to augur whether a part has an ISP interface:

   (part->flags & (AVRPART_HAS_PDI | AVRPART_AVR32 | AVRPART_HAS_TPI
    | AVRPART_HAS_UPDI)) == 0 && (part->flags & AVRPART_SERIALOK) != 0

or had HVSP or HVPP capability, for that matter. Now it is just, eg,

  part->prog_modes & PM_ISP
  part->prog_modes & PM_HVPP
2022-08-30 16:33:42 +01:00
Stefan Rueger 0756b8e3ad
Declare rather than define current_strct in header config.h 2022-08-30 02:49:37 +01:00
Stefan Rueger 0df8b87eda
Set part prog_modes, mcuid, n_interrupts and n_page_erase in avrdude.conf.in 2022-08-30 02:31:57 +01:00
Stefan Rueger ed2b8342df
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
   or of programming modes
     + PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
     + PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
     + PM_ISP: SPI programming for In-System Programming (typ classic parts)
     + PM_PDI: Program and Debug Interface (xmega parts)
     + PM_UPDI: Unified Program and Debug Interface
     + PM_HVSP: High Voltage Serial Programming (some classic parts)
     + PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
     + PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
     + PM_JTAG: some classic parts, some xmega
     + PM_aWire: AVR32 parts
 - Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
 - Add n_interrupts, the number of interrupts, to part definition
 - Add n_page_erase to part definition (# of pages erased during NVM erase)

 - Implement a simple calculator in config_gram.y so numeric values can be
   expressed as simple expressions such as PM_SPM | PM_UPDI

 - Introduce a new method of assigning simple components to the grammar without
   touching config_gram.y via an eligible-component list in config.c; numeric
   expressions on the rhs of an assignment resolve to integer values

 - Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 02:08:15 +01:00
Stefan Rueger cddf2943eb
Line up assignment operators in avrdude.conf.in 2022-08-30 01:10:45 +01:00
Stefan Rueger 0ccdd24d7e
Ensure arrays in developer_opts.c have at least one element 2022-08-24 13:50:07 +01:00
Stefan Rueger c97eb85cd8
Fix reset=dedicated|io; in avrdude.conf.in
Done by adding code in developer_opts.c that allows to inject part
or memory parameters into a semi-automated rewrite of avrdude.conf
This is a generic method, whereby an external program can, eg.,
scrape atdf files for the right parameters and put them into a
source table into developer_opts.c
  - Then write parts description with -p*/i
  - Use the output in a new avrdude.conf
  - Output again with -p* (no /i) and use that for final avrdude.conf
  - Remove table entries
2022-08-24 12:55:00 +01:00
Stefan Rueger 7fab75336e
Replace tabs in avrdude.conf.in with spaces 2022-08-24 11:46:24 +01:00
Stefan Rueger 716984dbb1
Reformat conditional programmers in avrdude.conf.in using -c* 2022-08-24 10:57:25 +01:00
Stefan Rueger 57ebd36a01
Rewrite avrdude.conf.in file from avrdude -c* -p* output
Some manual editing is still necessary to cater for the
@HAVE_PARPORT_BEGIN@ etc sections. This commit also fixes
superfluous whitesapce at the end of avrdude.conf.in lines

Although the avrdude.conf file has changed much, the internal
representation in avrdude has not. This can be verified by
exporting the raw internal data through

  avrdude -c*/r -p*/r >/tmp/avrdude.raw

before the change and by comparing again after the change:

  avrdude -c*/r -p*/r | diff - /tmp/avrdude.raw
2022-08-24 01:10:51 +01:00
Stefan Rueger 09d14601af
Fix 4 parts wrt to their interfaces in avrdude.conf 2022-08-24 00:54:11 +01:00
Stefan Rueger 3e49f078b3
Harden list management in pgm.c/config_gram.y 2022-08-24 00:03:45 +01:00
Stefan Rueger 88c48cdf82
Merge pull request #1074 from stefanrueger/1073
Correct flash paged write for avrftdi.c
2022-08-23 17:09:46 +01:00
Stefan Rueger fc6ef68b98
Merge pull request #1083 from stefanrueger/1081
Make avr910 programmer initialize() less verbose
2022-08-23 17:08:23 +01:00
Stefan Rueger 61efb02ef8
Merge pull request #1078 from stefanrueger/terminal
Use const for programmer functions where useful
2022-08-23 17:06:53 +01:00
Stefan Rueger 5f910580b7
Extend const args to avr_set_*() and developer_opts.c
... and print programming modes for -p*/d
2022-08-23 16:57:49 +01:00
Stefan Rueger c6ef6a9b9b
Adapt indentation of a line in buspirate.c to neighbouring lines 2022-08-22 00:00:39 +01:00
Stefan Rueger c7951813ef
Make avr910 programmer initialize() less verbose 2022-08-21 23:49:54 +01:00
Stefan Rueger 56aae55737
Replace loop/if condition and reduce signed comparison warnings in avrftfi.c
Change (int) poll_index >= (int) addr to poll_index+1 > addr as the former
might turn out to be implementation-defined. The latter is always defined
and what we want here (poll_index+1 won't overflow). Originally, the
condition was poll_index > addr-1, which was always false for addr=0 owing to
2^n modulo arithmetic of unsigned.

Also changed a few comparisons so they no longer are between signed
and unsigned integers reducing compiler warnings.
2022-08-21 00:05:44 +01:00
Stefan Rueger f8dd9bc97d
Correct flash paged write for avrftdi.c 2022-08-20 14:08:04 +01:00
Stefan Rueger 38aa1313f9
Print device code in avr910.c as unsigned char 2022-08-19 23:14:19 +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 dfef8bb0a8
Add libavrdude functions avr_mem_is_flash_type() and avr_mem_is_eeprom_type() 2022-08-15 14:57:12 +01:00
Stefan Rueger e332ecf0b4
Change array for copy mem->desc to const char * in term.c 2022-08-15 14:25:58 +01:00
Stefan Rueger 4c6ba0aae6
Merge pull request #1063 from sbngross/main
man-page: Fix logfile short option
2022-08-15 00:49:39 +01:00
Stefan Rueger 0b94ffdd3b
Merge pull request #1059 from stefanrueger/programmer-devopts
Implement -c <wildcard>/dev_options for printing programmer entries of avrdude.conf
2022-08-15 00:48:35 +01:00
Stefan Rueger 297740db0e
Stop listing programmers where id starts with . 2022-08-13 22:57:54 +01:00
Stefan Rueger c9736a9db5
Specifying the full memory name now always works
... even if a memory with longer name and same initial part exists
2022-08-13 20:51:31 +01:00
brutzzl3r 266eb23207 man-page: Fix install dir
`avrdude.1` is installed into `man` dir instead of its proper section
location.
This is due to the definition of `TYPE MAN` which points to
`<DATAROOT>/man` according to cmake docs.

Use `DESTINATION` and add proper section subdir.

This allows for `man -M <YOUR INSTALL dir>/share/man -w 1 avrdude` to succeed
instead of throwing `No manual entry for avrdude in section 1`

Signed-off-by: brutzzl3r <s3b.gr0ss@gmail.com>
2022-08-12 19:49:47 +02:00
Stefan Rueger 533feec4ed
Revert grammar to remove introduced shift/reduce conflicts 2022-08-12 15:52:51 +01:00
Stefan Rueger 8420b27233
Address compiler warnings in 4 source files 2022-08-12 14:58:21 +01:00
Stefan Rueger c2c9053b13
Show comments with -p*/s or -c*/s and reduce -p */r raw output 2022-08-12 00:28:54 +01:00
brutzzl3r 346de71cd5 man-page: Fix logfile short option
man synopsis states [-n -logfile] option. Later on in avrdude.1 as well as in
main.c -l is used.
Also '-logfile' is no option alternative but a parameter.
This is a minor issue but still confusing when one uses / to search
through man pages.

-- Always leave the code cleaner than you found it --

Signed-off-by: brutzzl3r <s3b.gr0ss@gmail.com>
2022-08-11 20:11:48 +02:00
Stefan Rueger ccb576ebc1
Ensure memories are printed at most once for -p */S 2022-08-10 22:25:19 +01:00
Stefan Rueger c9cf308037
Include ctype.h in term.c to resolve missing functions 2022-08-10 16:24:39 +01:00
Stefan Rueger f4c5a8350d
Replace string arrays with const char * and allocated space (part 2)
This commit replaces fixed-string buffers in PROGRAMMER, AVRPART and AVRMEM
that are dealt with by the parser and grammar. Now, string assignments are
always to const char *, ie, these are read-only strings with arbitrary
length.

config_gram.y now only needs to consider one type of string assignment.

This commit also

  - Replaces the simple linear-search cache_string() function with faster
    hashed cache_string(). Either way, the returned value is likely to be
    shared, so should never be free()'d.

  - Duplicates hvupdi_support list in pgm_dup() and frees it in pgm_free()

  - Adds const qualifier to some function args in avrpart.c and pgm.c

  - Hardens some functions against being called with NULL pointers

  - Ensures _new() and _dup() functions for parts, programmers and memory
    return a suitable memory. Out of memory triggers exit in one of three
    functions, cfg_malloc(), cfg_realloc() and cfg_strdup(); there is
    rarely anything useful that AVRDUDE or, for that matter, any
    application compiled against libavrdude can do once you run out of
    memory as AVRDUDE/libavrdude rely heavily on allocation of memory.
2022-08-10 16:14:56 +01:00
Stefan Rueger 7375477f70
Replace string arrays with const char * and allocated space (part 1)
This commit deals with default_programmer, default_serial, default_parallel
and default_spi. The long term objective is to remove all fixed-size buffers
from the structures that lexer.l and config_gram.y deal with.
2022-08-10 11:36:17 +01:00
Stefan Rueger 22c4dbf23e
Harden string processing during parsing in lexer.l, config_gram.y and otherwise
- Replace strdup(s) with cfg_strdup(funname, s) that exits on out of mem
 - Replace malloc(n) with cfg_malloc(funname, n) that exits on out of mem
 - Change multiline string scanning in lexer.l to avoid core dump
 - Remove global variables string_buf and string_bug_ptr
 - Ensure reading strings unescapes strings C-Style
 - Ensure writing strings escapes strings C-Style again

Commit looks longer than needed as unescape() and auxiliary functions needed
to be moved from term.c (not in libavrdude) to config.c (in libavrdude).
2022-08-09 21:20:44 +01:00
Stefan Rueger 8a717987ec
Change unsigned short eecr; to unsigned char eecr; in libavrdude's AVRPART 2022-08-09 13:19:40 +01:00
Stefan Rueger 7c8d336e27
Change dev_info() to stdout and no longer redirect stderr to stdout 2022-08-09 09:23:26 +01:00
Stefan Rueger c21be27a7d
Replace const char array indexing with equivalent code in pindefs.c 2022-08-08 17:27:38 +01:00
Stefan Rueger 1da97f6825
Adjust declaration of locate_programmer_type_id() to definition 2022-08-08 17:21:21 +01:00
Stefan Rueger f25bc55806
Treat -c* the same as -c*/s 2022-08-08 17:03:06 +01:00
Stefan Rueger 49fcd8a96e
Implement -c */[sSA] (syntax-correct dump of programmer structure) 2022-08-08 16:52:09 +01:00
Stefan Rueger 075dee1dd3
Implement -c */r (raw dump of programmer structure) 2022-08-07 17:52:17 +01:00
Stefan Rueger 08049a40ea
Implement dev option -c */[ASsrt] skeleton
Also changed usbdev, usbsn, usbvendor and usbproduct components from
PROGRAMMER structure to be cached string pointers rather than fixed-size
arrays. These will be initialised by pgm_new() with a pointer to nul;
2022-08-07 14:06:04 +01:00
Stefan Rueger 81136688f6
Establish a third option to print out part definitions
Introduced -p <part>/A, which prints what -p <part>/S used to print, ie, all
components of the part structures including the default ones. Now -p <part>/S
prints the expanded part structure without use of parent and without printing
default values. This functionality is new and predominantly needed for
checking specific avrdude.conf entries, eg, avrdude -p*/St | grep pollindex

The option -p <part>/s continues to print a short entry of `avrdude.conf`
using its parent if so defined:

$ avrdude -p m328p/s

part parent "m328"
    desc                = "ATmega328P";
    id                  = "m328p";
    signature           = 0x1e 0x95 0x0f;
;
2022-08-07 08:53:24 +01:00
Stefan Rueger a8bbedcde3
Switch from strerror_r() to strerror() in update.c for portability 2022-08-06 00:20:43 +01:00
Stefan Rueger e681035cc4
Add strerror_r() and access() modes to MSVC compat file 2022-08-05 18:47:40 +01:00
Stefan Rueger e590aead93
Treat comparison of different signedness warning in fileio.c 2022-08-05 18:04:46 +01:00
Stefan Rueger b24a1cf667
Implement a dry run for -U updates before opening the programmer
This commit checks -U update requests for
  - Typos in memory names
  - Whether the files can be written or read
  - Automatic format detection if necessary

before opening the programmer. This to reduce the chances of the
programming failing midway through.

Minor additional changes:
  - Give strerror() system info when files are not read/writeable
  - Lift the auto detection message from MSG_INFO to MSG_NOTICE
  - Provide fileio_fmt_autodetect() in the AVRDUDE library
  - Rename fmtstr() in the AVRDUDE library to fileio_fmtstr() to
    avoid name clashes when an application links with it

Example:

$ avrdude -U - -U typo:r:.:h -U eeprom:w:testin:r -p ... -c ...
avrdude: can't auto detect file format for stdin/out, specify explicitly
avrdude: unknown memory type typo
avrdude: file . is not writeable (not a regular or character file?)
avrdude: file testin is not readable. No such file or directory
2022-08-05 17:38:59 +01:00
Stefan Rueger 5f5002eeaa Change name of update helper functions for print messages 2022-08-04 18:25:14 +01:00
Stefan Rueger ed36c7e1f6
Merge branch 'main' into fix_1041 2022-08-04 18:03:49 +01:00
Stefan Rueger 3412196cd9 Weaken -U memory type check and move after config file parsing in main.c
The check for typos in -U memory names against a list of known memory names
now happens after the config files have been read, so newly declared memory
names can be considered. This commit also weakens the check against existence
of a known memory: it is now sufficent for a name to pass when it could be
the initial string of any known memory of any part. Any -U memory that cannot
possibly be matched up with a known memory is considered a typo and leads to
an exit before the programmer is opened.

This to protect users from typos that leave a device partially programmed.

When every -U memory name might be matching one of the known memories, the
programming is attempted. If the part to be programmed turns out not to have
a particular -U memory, AVRDUDE warns the user and skips this -U update.

This to support unifying interfaces that call AVRDUDE with potentially more
memories than the actual part has (eg, efuse on ATmega8).
2022-08-04 00:14:19 +01:00
Stefan Rueger 648f3319a9 Ignore target memories not present in part
$ avrdude -qp m8 -c ... -U efuse:w:0xff:m && echo OK

avrdude: AVR device initialized and ready to accept instructions
avrdude: skipping -U efuse:... as memory not defined for part ATmega8

avrdude done.  Thank you.

OK
2022-08-03 00:23:15 +01:00
Stefan Rueger 9604a3ef36 Check -U option for unknown memories during parsing
$ avrdude -qp ATmega2560 -c usbtiny -U flesh:w:blink-mega2560+lext-test.hex:i
avrdude: unknown memory type flesh
avrdude: error parsing update operation 'flesh:w:blink-mega2560+lext-test.hex:i'
2022-08-03 00:04:14 +01:00
Stefan Rueger 42c8169c37 Add ordered list of known memories to avr.c with access functions 2022-08-02 23:53:00 +01:00