Commit Graph

39 Commits

Author SHA1 Message Date
Stefan Rueger 4070ca9012
Distinguish different JTAG programming modes 2022-09-20 18:36:46 +01:00
Stefan Rueger ac8fbadff4
Add assignment injection code for -c*/si 2022-09-14 18:04:12 +01:00
Stefan Rueger dab99c0823
Update NEWS 2022-08-31 17:35:03 +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 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 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 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 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
Stefan Rueger ccb576ebc1
Ensure memories are printed at most once for -p */S 2022-08-10 22:25:19 +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 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 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 42c8169c37 Add ordered list of known memories to avr.c with access functions 2022-08-02 23:53:00 +01:00
Stefan Rueger 004b46b594 Move useful CMDBIT/part functions from developer_opts.c to avrpart.c 2022-07-27 00:12:57 +01:00
Stefan Rueger 62dcc2e6e8 Declare useful CMDBIT/part functions of developer_opts.c in libavrdude.h 2022-07-26 23:55:42 +01:00
Stefan Rueger 78754b8ccc Add parent id output for developer options -p*/s for parts 2022-07-26 23:43:56 +01:00
Stefan Rueger 1549273529 Add comments with part names to -p*/s output 2022-07-25 20:30:40 +01:00
Stefan Rueger d5d3a0e09e Improve help message -p/h for developer option -p 2022-07-24 23:38:51 +01:00
Stefan Rueger 5a517fb74d Make developer opts portable: change statement exprs and index(); use size_t 2022-07-22 23:50:22 +01:00
Stefan Rueger 572849ec2a Provide avr_set_addr_mem() to set addresses in SPI opcodes within boundaries
The function avr_set_addr_mem(AVRMEM *mem, int opnum, unsigned char *cmd,
unsigned long addr) is meant to replace avr_set_addr(OPCODE *op, unsigned
char *cmd, unsigned long addr) in future.

avr_set_addr_mem() has more information about the context of the task in that
it knows the memory size, memory page size, whether or not the memory is a
flash memory (which gets words addressees supplied) and, crucially, knows
which SPI operation it is meant to compute the address bits for.

avr_set_addr_mem() first computes the interval of bit numbers that must be
supplied for the SPI command to stand a chance to work. The function only
sets those address bits that are needed. Once all avr_set_addr() function
calls have been replaced by avr_set_addr_mem(), the SPI commands that need an
address can afford to declare in avrdude.conf all 16 address bits in the
middle two bytes of the SPI command. This over-declaration will be corrected
during runtime by avr_set_addr_mem(). One consequence of this is that parts
can inherit smaller or larger memories from parents without the need to use
different SPI codes in avrdude.conf. Another consequence is that
avr_set_addr_mem() can, and does, tell the caller whether vital address bits
were not declared in the SPI opcode. During parsing of avrdude.conf this
might be utilised to generate a corresponding warning. This will uncover
problematic SPI codes in avrdude.conf that in the past went undetected.
2022-07-21 21:42:07 +01:00
Stefan Rueger 55f6765ea5 Make more useful functions from developer_optc.c available 2022-07-21 18:47:48 +01:00
Stefan Rueger 192e118d2c Make useful functions from developer_optc.c available 2022-07-21 18:36:04 +01:00
Stefan Rueger 696574d1eb Replace !fnmatch(p, s, 0) with own part_match(p, s) 2022-07-21 18:04:41 +01:00
Stefan Rueger 6afa115a5f Make -p*/s print SPI opcodes like "0100.0000--000.aaaa--aaaa.aaaa--iiii.iiii" 2022-07-19 23:44:58 +01:00
Stefan Rueger bdb5ba6055 Add avrdude.conf syntax ((pp|hvsp)_controlstack|(eeprom|flash)_instr) = NULL; 2022-07-19 16:16:55 +01:00
Stefan Rueger 8989e6515b Change macros __f() to _f() and adapt to config_file and hvupdi changes 2022-07-19 14:38:34 +01:00
Stefan Rueger 9e2cea3ada Implement developer options -p */[*cdosSrwt] for part descriptions 2022-07-07 18:32:19 +01:00
Stefan Rueger 3bd75e74c6 Move developer options into own source file and expand part description -p \*
-p \*/c  check address bits in SPI commands
  -p \*/d  description of core part features
  -p \*/o  opcodes for SPI programming parts and memories
  -p \*/s  show avrdude.conf entries of parts
  -p \*/ss show full avrdude.conf entry as tab separated table
  -p \*/w  wd_... constants for ISP parts
  -p \*/\* all of the above except -p \*/s
  -p \*    same as -p\*/\*
2022-06-28 20:34:31 +01:00