Commit Graph

49 Commits

Author SHA1 Message Date
Dawid Buchwald b6e72dce4c Implemented basic serial code refactoring for upcoming SerialUPDI implementation
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/branches/serial_refactoring@1511 81a1dc3b-b13d-400b-aceb-764788c761c2
2021-12-18 15:25:27 +01:00
Axel Wachtler c6788bd795 added verbose level in avrdude_message()
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1321 81a1dc3b-b13d-400b-aceb-764788c761c2
2014-06-13 20:07:40 +00:00
Joerg Wunsch d09bc2e1fb Join the former "public" header files (avr.h avrpart.h pindefs.h
serial.h fileio.h safemode.h update.h pgm_type.h config.h confwin.h
lists.h) into a single header that can be included by anyone wanting
to link against the library.

Adapt everything to cope with this situation.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1311 81a1dc3b-b13d-400b-aceb-764788c761c2
2014-05-19 10:01:59 +00:00
Axel Wachtler eb5fcb581f Exchange of fprintf(stderr, ...) with avrdude_message(...).
This change was made for the shared library, since library functions
should not write to std-streams directly. Instead avrdude_message()
has to be implemented by the library user. For the avrdude application
this function is implemented in main.c.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1305 81a1dc3b-b13d-400b-aceb-764788c761c2
2014-05-18 08:41:46 +00:00
Joerg Wunsch 57903bdeb8 Replace all occurences of exit() in potential library code
by appropriate return values.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1301 81a1dc3b-b13d-400b-aceb-764788c761c2
2014-05-16 15:52:25 +00:00
Joerg Wunsch f80f51f6a9 Change the second parameter of the ser_open method from "baud" into a
"union pinfo", so the USB parameters can be passed without hacks.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1276 81a1dc3b-b13d-400b-aceb-764788c761c2
2014-02-21 13:44:11 +00:00
Joerg Wunsch 715249e2d4 Submitted by Brane Zdralo:
patch #7769: Write flash fails for AVR910 programmers
* avr910.c (avr910_paged_write): Fix flash addresses in
'A' command.




git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1206 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-09-03 21:43:24 +00:00
Joerg Wunsch db1cce8bf4 bug #39794: warnings when building avrdude 6.0rc1 under CentOS 6.4
* buspirate.c: Turn the "cmd" argument of the various methods into
a "const unsigned char *"; while doing this, declare all arrays being
passed as arguments to be pointers rather than arrays, as the latter
obfuscates the way arrays are being passed to a callee in C.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1196 81a1dc3b-b13d-400b-aceb-764788c761c2
2013-09-02 20:22:53 +00:00
Joerg Wunsch 147137a218 Replace outdated FSF postal address by a reference to
the GPL info on their website.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1107 81a1dc3b-b13d-400b-aceb-764788c761c2
2012-11-20 14:03:50 +00:00
Rene Liebscher c1095de822 Parser does not need to know all programmer types now, new programmers
will update only the table in pgm_type.c.
  * config_gram.y, lexer.l: removed programmer type keywords,
    use now locate_programmer_type() function
  * pgm_type.[ch]: added new files for table of programmer types
  * main.c: allow list of programmer types by -c ?type
  * avrdude.conf.in: changed all type keywords to quoted strings
  * doc/avrdude.texi: changed description of type definition, list
    of valid types is now included from generated file
  * doc/Makefile.am: generate list of programmer types for doc
  * all programmers [hc]: add xxx_desc string for description of programmer


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1051 81a1dc3b-b13d-400b-aceb-764788c761c2
2012-01-31 17:03:43 +00:00
Rene Liebscher d34978a124 Fixed following findings reported by cppcheck
* avr910.c:625 (error) Possible null pointer dereference: cmd - otherwise it is redundant to check if cmd is null at line 624
	* avr910.c:626 (error) Possible null pointer dereference: cmd - otherwise it is redundant to check if cmd is null at line 624
	* avr910.c:168 (information) The scope of the variable 'devtype_1st' can be reduced
	* avr910.c:169 (information) The scope of the variable 'dev_supported' can be reduced
	* avrftdi.c:647 (error) Using sizeof for array given as function argument returns the size of pointer.
	* stk500v2.c:3347 (error) Memory leak: b
	* stk500v2.c:3452 (error) Memory leak: b
	* usbasp.c:554 (error) Using sizeof for array given as function argument returns the size of pointer.
	* usbasp.c:485 (information) The scope of the variable 'dly' can be reduced

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1035 81a1dc3b-b13d-400b-aceb-764788c761c2
2012-01-08 17:09:40 +00:00
Joerg Wunsch d742827da1 Mega-commit to bring in memory tagging.
Each memory image byte is now tagged as it's being read from a file.
Only bytes read from a file will be written or verified (modulo page
granularity requirements).



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1007 81a1dc3b-b13d-400b-aceb-764788c761c2
2011-09-14 21:49:42 +00:00
Nils Springob 0c603e4791 * serial_open() calls will now return -1 on error (no call to exit())
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@948 81a1dc3b-b13d-400b-aceb-764788c761c2
2010-10-22 14:29:56 +00:00
Joerg Wunsch 8ffc939aff Cleanup Cygwin builds.
* windows/Makefile.am (loaddrv_LDFLAGS): remove, the -mno-cygwin
flag is supposed to be set in CFLAGS by ./configure
* configure.ac: add a check for the presence of usleep(), add a
check whether the linker accepts -static
* avrdude.h: protect prototype for usleep by !defined(HAVE_USLEEP)
* ppwin.c (usleep): protect by !defined(HAVE_USLEEP)
* main.c: silence "array subscript of type char" compiler warnings
by casting all arguments to tolower()/toupper() and isspace()/
isdigit()/ispunct() to "int"
* butterfly.c: (Dito.)
* avr910.c: (Dito.)




git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@936 81a1dc3b-b13d-400b-aceb-764788c761c2
2010-01-22 16:40:17 +00:00
Joerg Wunsch c2bda1f468 * avr910.c (avr910_read_byte_flash): Eliminate a static variable that
hasn't been in use for 5 years.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@814 81a1dc3b-b13d-400b-aceb-764788c761c2
2009-02-28 10:07:01 +00:00
Joerg Wunsch 6a633ea9f1 Fix a bunch of warnings.
* avr910.c (avr910_paged_load): possible unitialized use of
rd_size
* jtagmkI.c (jtagmkI_initialize): pointer signedness mixup
* jtagmkII.c (jtagmkII_print_parms1): propagate const'ness
of parameter
* usbasp.c (usbasp_transmit): poiner signedness mixup


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@775 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-07-25 21:14:43 +00:00
Joerg Wunsch cc8b75040f Contributed by Klaus Leidinger <klaus@mikrocontroller-projekte.de>:
* main.c: Realign verbose messages.
* avrpart.c: (Ditto.)
* avr910.c: Print the device code selected in verbose mode.
* butterfly.c: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@772 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-06-07 21:03:41 +00:00
Joerg Wunsch 2ce7151a23 Contributed by Klaus Leidinger <klaus@mikrocontroller-projekte.de>:
Add check for buffermode feature, and use it if present.  Can be
turned off using -x no_blockmode.
* avr910.c: Implement buffermode test and usage.
* avrdude.1: Document -x no_blockmode.
* doc/avrdude.texi: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@771 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-06-07 20:55:04 +00:00
Joerg Wunsch 8339bfa6f7 Add support for the -x devcode option, and document it.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@769 81a1dc3b-b13d-400b-aceb-764788c761c2
2008-03-24 21:22:04 +00:00
Joerg Wunsch 58a3d35757 main.c, pgm.c, pgm.h: Add setup and teardown hooks to the programmer
definition.  If present, call the setup hook immediately after finding
the respective programmer object, and schedule the teardown hook to be
called upon exit.  This allows the programmer implementation to
dynamically allocate private programmer data.

avr910.c, butterfly.c, jtagmkI.c, jtagmkII.c, stk500v2.c, usbasp.c,
usbtiny.c: Convert static programmer data into dynamically allocated
data.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@764 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-11-07 20:36:12 +00:00
Joerg Wunsch 6fb700fe6f Fall back to avr_{read,write}_byte_default().
Fixes bug #18803: Fuse reading regression in avrdude 5.3.1 with avr910
programmer


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@738 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-05-15 22:00:29 +00:00
Joerg Wunsch b8a306c048 safemode.c: Obtain progname from avrdude.h rather than trying to roll our
own (duplicate) copy of it.

other files: Constify char pointers.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@725 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-01-30 13:41:54 +00:00
Joerg Wunsch 5bf9e2d9f2 Major code cleanup.
- Make all internal functions "static".
- Make sure each module's header and implementation file match.
- Remove all library-like functionality from main.c, so only
  the actual frontend remains in main.c.
- Add C++ brackets to all header files.

That effectively leaves the various module C files as something like
an "avrdude library", with main.c being the currently only frontend
program for that library.  In theory, it should be possible to write
different frontends using the same library backend functions though.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@722 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-01-24 22:43:46 +00:00
Joerg Wunsch 27e16e8371 Something I always wanted to do: replace all those private "extern"
declarations in each file by a central header file "avrdude.h".


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@721 81a1dc3b-b13d-400b-aceb-764788c761c2
2007-01-24 21:07:54 +00:00
Joerg Wunsch 7e20e7571f Make the code compile warning-free:
- declare a dummy "struct timezone" for some Win32 systems (MinGW)
- fix a few printf() argument types
- get rid off the prevailing "all filedescriptors are of type int"
  attitude

The last item required a large sweep across the code, in order to
replace all "int fd"s by "struct filedescriptor *fd"s, and pass
pointers (as we cannot pass a union directly).  In return, the
code is now supposed to be fully 64-bit safe, rather than relying
on a 64-bit pointer being converted to a (32-bit) int and back
to a pointer as we did previously.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@694 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-12-11 12:47:35 +00:00
Joerg Wunsch 73cfe88386 * avr910.c: As there is a lot of ambiguity about the AVR910
device codes, allow the user to override the device code
verification with the -F option.
* main.c: Make ovsigck a global variable.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@665 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-20 21:32:18 +00:00
Joerg Wunsch 4a55a6583a * butterfly.c: Remove the device support decision based on
the old AVR910 device codes; we've got signature verification
now so better rely on that.

* avr910.c: Revert the signature bytes returned, as it already
happened in butterfly.c.  This closes bug #14998: Signature Bytes
read in wrong order (avr910 mode)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@638 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-01 10:03:12 +00:00
Brian S. Dean 46db168b4f This is patch #3277 which appears to fix a number of issues with the
avr910 programmer.

Original Submission: The attached patch against avrdude 4.4.0 fixes
the following problems with paged writes in avr910.c:

  - failure to re-set address after page writes;
  - no polling or delay after page writes;
  - no page writes when not using auto-increment;
  - an extraneous page write when data ends on page boundary.

Submitted by: "Nic" <avrdude@schraudolph.org>


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@510 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-18 00:28:19 +00:00
Brian S. Dean e623fea507 Eliminate compiler warnings. GCC 4.x elicits many signedness warnings
when passing unsigned char * when char * is in the prototype and vice
versa.  Clean these up along with a few others.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@491 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-08-30 01:30:05 +00:00
Joerg Wunsch c2abd46745 Revert the serial_recv() timeout handling as it used to be before my
yesterday's changes (i.e. before rev. 1.10 of ser_posix.c), that is,
exit(1) in case of a timeout.  Previously, the upper layers didn't see
the timeout at all.

Quite possible that some of these drivers could handle a timeout more
intelligently though.  At least for the rather sophisticated STK500v2
protocol, I think it should be possible to retry the request.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@460 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-11 17:09:22 +00:00
Brian S. Dean 6249f94515 Update code copyrights.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@438 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-12-22 01:52:45 +00:00
kiwi64ajs be4f46c49e merged in changes to allow native Win32 build with no cygwin DLL dependancy
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@419 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-06-24 11:05:07 +00:00
Jan-Hinnerk Reichert c43a012c7a avr910.c: Hopefully fixed that weird "first byte not programmed"-error in a good way (previous fix was not working with all firmwares)
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@412 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-04-17 19:37:14 +00:00
Jan-Hinnerk Reichert 4f6c8867b5 * pgm.c, main.c, avr910.c, butterfly.c, stk500.c: Changed default for powerup, powerdown and LED-commands to do nothing and return OK. Then removed these commands from avr910, butterfly and stk500.
* pgm.c: Fixed wrong type for default_open introduced by the cleanup yesterday.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@409 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-01-29 13:23:59 +00:00
Jan-Hinnerk Reichert 51491c6916 * pgm.[ch], main.c, par.c, avr910.c, butterfly.c, stk500.c:
Move save/restore-functionality into open/close.
	* par.c: open/close now saves/restores PPICTRL, too.
	* TODO: exitspecs don't work if RESET is in PPICTRL.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@407 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-01-28 20:01:44 +00:00
Jan-Hinnerk Reichert 5b537c0cdb * avr910.c, avrpart.c, avrpart.h, doc/TODO: Look up devicecode and report device.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@399 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-01-12 22:48:50 +00:00
Jan-Hinnerk Reichert 816ff2623e * avr910.c, pgm.c, pgm.h, config_gram.y, lexer.l: Add new configuration parameter baudrate to support avr910-programmers with non-standard baudrates
* avrdude.conf.in, doc/avrdude.texi: Added "baudrate" to documentation.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@398 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-01-03 18:36:44 +00:00
Jan-Hinnerk Reichert ccd374d056 avr910.c: Removed debugging stuff that is no longer needed.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@397 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-01-03 18:18:57 +00:00
Theodore A. Roth b76fa0fbcd * avr.c (avr_read_byte): If pgm->read_byte method fails, retry with
avr_read_byte_default.
* avr.c (avr_write_byte): If pgm->write_byte method fails, retry with
avr_write_byte_default.
* avr910.c (avr910_cmd): Implement using universal command.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@364 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-09-05 16:40:55 +00:00
Eric Weddington 4f05a28329 * avr910.c:
* fileio.c:
    * main.c:
    * stk500.c:
    More code cleanup to remove warnings.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@352 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-08-28 23:02:25 +00:00
Theodore A. Roth 71536a7097 * avr.c:
* avr.h:
* avr910.c:
* main.c:
* stk500.c:
New progress reporting implementation.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@337 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-07-29 22:08:21 +00:00
Theodore A. Roth bd584d1af1 * avr910.c (avr910_paged_write_flash): Add code to send the 'm'
command ("issue page write" cmd) for each page.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@329 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-05-14 05:14:32 +00:00
Theodore A. Roth 6cdc223d7d * avr910.c: Reading a 16 bit word in paged load needs to swap the
bytes since the 'R' command returns MSB first and the internal buffer
stores LSB first.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@307 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-04-09 20:37:28 +00:00
Theodore A. Roth 14d9d4b189 * avr910.c: Re-add the avr910 byte read/write methods which were
removed in my previous patch. Terminal mode read/writes are broken
without those methods. D'oh!


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@305 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-04-06 07:10:44 +00:00
Theodore A. Roth abc3e76bf8 * avr910.c: Refactor to allow probing for auto addr increment. If auto
incr supported by programmer hw, don't send addr for every byte.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@304 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-04-06 00:47:16 +00:00
Theodore A. Roth 4415c52f08 * avr.c (avr_write): Add call to pgm->write_setup() before the write loop.
* avr910.c: Change all show_func_info() calls to no_show_func_info().
Add read/write to/from flash/eeprom memory functionality.
* pgm.c: Initialize pgm->write_setup.
* pgm.h: Add write_setup field to PROGRAMMER structure.
* ser_posix.c: Remove unneeded cast in verbosity code.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@299 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-03-24 07:09:16 +00:00
Theodore A. Roth 3782460fb5 * avr.c (avr_read): Use pgm->read_sig_bytes to read signature bytes if
available.
* avr910.c (avr910_vfy_cmd_sent): New function.
(avr910_chip_erase): Add support for chip erase.
(avr910_enter_prog_mode): New function.
(avr910_leave_prog_mode): New function.
(avr910_initialize): Add code to select device type and enter prog mode.
(avr910_close): Leave programming mode before closing serial port.
(avr910_read_sig_bytes): New function.
(avr910_initpgm): Add avr910_read_sig_bytes method to pgm initializer.
* avrdude.conf.in: Add note about deprecating devicecode.
Change all occurences of devicecode to stk500_devcode.
Add avr910_devcode to a few parts for testing.
* avrpart.h (struct avrpart): Change devicecode field to stk500_devcode.
(struct avrpart): Add avr910_devcode field.
* config_gram.y: Add K_STK500_DEVCODE and K_AVR910_DEVCODE tokens.
Generate an error if devicecode is found in the config file.
Handle parsing of avr910_devcode and stk500_devcode.
* lexer.l: Handle parsing of avr910_devcode and stk500_devcode.
* pgm.c: Initialize pgm->read_sig_bytes field.
* pgm.h: Add pgm->read_sig_bytes field.
* stk500.c: Use stk500_devcode instead of devicecode.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@293 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-03-17 06:20:02 +00:00
Theodore A. Roth 63d0ccdd19 * avrdude.conf.in: Add avr910 and pavr programmers.
* config_gram.y: Add parsing of avr910 programmer.
* lexer.l: Add avr910 token.
* avr910.c: [this is still work in progress]
Add some debug output.
Add probe for programmer presense.
* main.c: Set port to default_serial if programmer type is avr910.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@292 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-03-16 18:19:37 +00:00
Theodore A. Roth 09c3137489 * Makefile.am (avrdude_SOURCES): Add avr910.[ch], serial.h and
ser_posix.c files.
* avr910.c: New file (stubs for avr910 serial programmer).
* avr910.h: New file.
* ser_posix.c: New file.
* ser_win32.c: New file (just stubs for now).
* serial.h: New file.
* stk500.c: Move all the code for accessing the posix serial ports
into ser_posix. This will make a native win32 port easier and allows
the avr910 programmer to share the serial code.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@289 81a1dc3b-b13d-400b-aceb-764788c761c2
2003-03-13 03:52:19 +00:00