Commit Graph

14 Commits

Author SHA1 Message Date
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 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 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
Stefan Rueger 0edb77bdf8
Merge branch 'main' into issue918 2022-07-12 15:05:45 +01:00
Stefan Rueger 64ee4858fd Update 2nd debug message in avr.c with correct function name 2022-07-05 01:00:45 +01:00
Stefan Rueger d3b22fa3c6 Update debug message in avr.c with correct function name 2022-07-05 00:57:40 +01:00
Joerg Wunsch 3082630430 Replace internal knowledge in jtag3.c by a public API
In certain situations (CRC failure, device locked), that JTAG3
read functions need to return an indication to the caller that
it is OK to proceed, and allow erasing the device anyway.

Historically, the JTAG3 code passed the respective protocol
errors directly (and unexplained) up to the caller, leaving
the decision to the caller how to handle the situation.

Replace that by a more common return value API. New code should
prefer this API instead of any hardcoded return values.
2022-06-15 23:32:22 +02:00
Stefan Rueger e18d436f88 Move evaluating 'is flash' from caller to callee avr_mem_hiaddr() 2022-04-15 20:48:46 +01:00
Stefan Rueger ed38456f83 Piggy-back 'Do not remove trailing 0xff' onto option -D 2022-04-15 20:46:40 +01:00
Joerg Wunsch 8c6c6a14ec Remove the "safemode" feature.
This feature has been designed with the sometimes quite flakey direct
(parallel or serial port attached) bitbang programming adapters in
mind that were quite common about two decades ago.

With parallel ports vanishing from modern PCs almost completely, and
the advent of various USB-attached low-cost programming devices,
this class of programmers disappeared almost completely.

Furthermore, the fuse combinations that were covered by the feature
are no longer around on all recent AVR devices, so for an ever
increasing number of devices, safemode already became meaningless and
was turned off anyway.

With the prospective version 7.x release, it's a good point in time to
introduce a major change like this one.
2022-01-31 20:44:32 +01:00
Joerg Wunsch 65d5cfadc1 Fix for TPI fuse write
In get_fuse_bitmask(), ensure the AVR_OP_READ and AVR_OP_WRITE
m->op[] fields are actually filled in, before referencing them.
If they are missing, just return a full byte mask (0xFF).

In avr_write(), for TPI memory, if the write consist of one byte onle
(which is the case for fuse byte writing), resort to avr_write_byte()
instead as it already implements everything needed. This leaves the
avr_write() implementation to handle full paged writes with an even
number of bytes only.
2022-01-11 22:00:22 +01:00
Marius Greuel 55251ea6f5 Fix avr_read() for page reads with page sizes that are not a multiple of the memory size 2021-12-26 16:57:23 +01:00
Marius Greuel 5633a6d88a Move source files to 'src' folder 2021-12-17 09:17:42 +01:00