236 Commits

Author SHA1 Message Date
Joerg Wunsch
71714c3e5f This commit was manufactured by cvs2svn to create tag
'RELEASE_5_2_0'.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/tags/RELEASE_5_2_0@673 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-10-09 14:47:30 +00:00
Joerg Wunsch
79ce8f34bf Bump version for release 5.2.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@672 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-10-09 14:47:29 +00:00
Joerg Wunsch
2ccc76a66d Submitted by John Voltz: add AVR053 oscillator calibration.
* main.c: Add the -O option.
* pgm.c: Add the hook for the perform_osccal() method.
* pgm.h: (Ditto.)
* stk500v2.c: Implement perform_osccal().
* avrdude.1: Document the -O option.
* doc/avrdude.texi: (Ditto.)
Partially closes bug #17487: AVR RC oscillator calibration
routine not supported (feature request)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@671 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-10-09 14:34:24 +00:00
Joerg Wunsch
6b8fa85a0b Submitted by freckle@sf.net:
* stk500.c (stk500_paged_write): Send the command and the data
payload within a single write().
patch #5025: Improve stk500.c robustness

Submitted by Matthias Ringwald:
* stk500.c (stk500_open): do not flush the serial line after
getting in sync with the programmer.
patch #5293: stk500.c: no drain after sync (-> allow BTnode
Bootloader to work on cygwin)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@670 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-10-09 09:56:10 +00:00
Joerg Wunsch
8c215d1da5 Make the private prototype for gettimeofday() only visible if the
autoconfiguration figured out we need it.  The private implementation
has already been protected that way.

This should finally really fix bug #17884: another gettimeofday
conflict under win32/cygwin


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@669 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-30 20:48:17 +00:00
Joerg Wunsch
860aea6e04 The return type of gettimeofday() is actually int' not void'.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@668 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-30 19:36:22 +00:00
Joerg Wunsch
0353e3ade9 Fix prototype for gettimeofday().
Closes bug #17884: another gettimeofday conflict under win32/cygwin


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@667 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-29 20:52:32 +00:00
Joerg Wunsch
f39e957354 Submitted by Thomas Fischl (initially):
Add the CoreFoundation and IOKit framework linker flags on MacOS X
when configuring for USB support.

patch #4685: Libusb on MacOS X: detection and additional includes

Thanks to Matthias Ringwald for testing the reworked patch.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@666 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-24 13:35:40 +00:00
Joerg Wunsch
b8d0a34c44 * 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@665 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-20 21:32:18 +00:00
Joerg Wunsch
0734c16f98 Sync NEWS with latest changes.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@664 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-19 22:33:53 +00:00
Joerg Wunsch
73f657ac41 Add the "stk500generic" programmer that auto-probes for STK500
either firmware version 1 or 2.
* Makefile.am (avrdude_SOURCES): add the new files
stk500generic.c and stk500generic.h.
* avrdude.conf.in: Add the stk500generic programmer type, and
change the "stk500" entry to point to this programmer.
* config_gram.y: Add the stk500generic keyword.
* lexer.l: (Ditto.)
* stk500.c: Change the stk500v1 code to not call exit()
prematurely when failing to open the programmer, but instead
return an error status.
* stk500generic.c: (New file.) Stub programmer implementation.
Probe for either stk500v1 or stk500v2, and adjust the current pgm
appropriately.
* stk500generic.h: (New file.) Declare the public interface(s)
of stk500generic.c.
* doc/avrdude.texi: Document the changed behaviour of stk500.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@663 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-19 22:27:30 +00:00
Joerg Wunsch
2e86c833ce Various fixes for ancient processors and their capabilities. For the
AT90S1200 and the AT90S8515, fuse bit handling via ISP, and lock bit
reading via ISP are not supported at all.  For the AT90S4414 (small
brother of the AT90S8515), add the ability to write the lock bits, and
add a definition for the fuse bits (usable for HV programming).  For
the AT90S2313, add the "fuse" memory range, so it's available for HV
programming.

Resolves bug #17796: avrdude will not program or verify lockbits with
Atmel STK protocol programmers


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@662 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-18 21:48:36 +00:00
Joerg Wunsch
f3dfeb6ecf Submitted by Thomas Fischl:
* usbasp.c: Check for USBasp with new as well as old VID/PID
pair, warn the user about upgrading the firmware in case an
old one has been found.
* usbasp.h: Add new VID/PID.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@661 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-17 20:35:36 +00:00
Joerg Wunsch
8e5f9c7e1b Fix some mistakes for the ATtinyX61 family:
. high fuse has 8 bits
. there is an extended fuse (just one bit)
. the calibration area is only 1 byte


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@660 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-15 21:41:29 +00:00
Joerg Wunsch
af4f648cf5 More texinfo incompatibilities to avoid: replace @headitem by @item
and @strong{}


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@659 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-14 20:07:14 +00:00
Joerg Wunsch
4f9cd863b8 Not all texinfo versions understand indicateurl{}, so resort to url{}.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@658 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-14 20:00:55 +00:00
Joerg Wunsch
84ed521326 Convert some of the tables to multitables
in order to beautify the result.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@657 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-12 12:01:34 +00:00
Joerg Wunsch
c788c75014 Contributed by Thomas Fischl: add support for USBasp.
patch #4686: Add support for USBasp, a simple USB programmer
* usbasp.c: New file, implement the USBasp driver.
* usbasp.h: New file, interface declarations for USBasp.
* Makefile.am: Wire the new files into the build.
* avrdude.conf.in: Add the usbasp programmer entry.
* config_gram.y: Add the usbasp token.
* lexer.l: (Ditto.)
* avrdude.1: Document the USBasp programmer.
* doc/avrdude.texi: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@656 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-10 20:41:00 +00:00
Joerg Wunsch
c4e4fa62c3 Implement -U filename as a shorthand for -U flash:w:filename:a.
This has once been suggested by Brian Dean.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@655 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-08 21:52:45 +00:00
Joerg Wunsch
16c7a11538 Implement numerical output formats for decimal, hexadecimal, octal,
and binary numbers.

Closes bug #16129: more output formats for fuse bits (avrdude
enhancement request)

* fileio.c: Implement fileio_num() and the itoa_simple() helper function.
* fileio.h: Add new file formats to FILEFMT.
* main.c: Parse the new file formats.
* avrdude.1: Document all this.
* doc/avrdude.texi: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@654 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-08 21:28:24 +00:00
Joerg Wunsch
ac7bf0624c Hide two debug/trace statements behind "verbose".
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@653 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-08 21:10:05 +00:00
Joerg Wunsch
6e45624477 CPP statements start in column #1.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@652 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-08 19:46:45 +00:00
Joerg Wunsch
4bc635da8c Describe how to disable the DWEN fuse.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@651 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-07 20:42:01 +00:00
Joerg Wunsch
3318df48ed Translate numerical response codes to strings.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@650 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-07 19:57:59 +00:00
Joerg Wunsch
f615f8cbad Fix a broken indentation.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@649 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-07 19:37:41 +00:00
Joerg Wunsch
3b69ebd4e9 The avr109 programmer type no longer chokes on a wrong avr910 device
ID, so remove that description.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@648 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-07 19:34:17 +00:00
Joerg Wunsch
9a2971fb35 When failing to start in ISP mode, try debugWire instead. This
requires the user to eventually restart AVRDUE from scratch then.

jtagmkII_reset() had to get a second parameter in order to record
the reset mode.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@647 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-06 22:37:30 +00:00
Joerg Wunsch
66fa9f0689 In stk500v2_jtagmkII_open(), when the ICE synchronization failed,
still call the close method so we sign off correctly from the ICE:


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@646 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-06 22:33:59 +00:00
Joerg Wunsch
1abf521ee3 jtagmkII_open() is not needed externally.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@645 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-06 22:30:00 +00:00
Joerg Wunsch
8962bec663 Fix the maxsize comparision in stk500v2_jtagmkII_recv(), it was off
by one.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@644 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-06 22:29:27 +00:00
Joerg Wunsch
d973ae28e3 Add support for the JTAG ICE mkII in ISP mode.
* avrdude.conf.in (jtag2isp): New programmer entry.
* config_gram.y: Add K_JTAG_MKII_ISP.
* jtagmkII.c: Restructure and export some more functions.
* jtagmkII.h: Declare exported functions.
* jtagmkII_private.h: Prepare file to be included in stk500v2.c.
* lexer.l: Add jtagmkii_isp token.
* stk500v2.c: Implement glue to jtagmkII.c.
* stk500v2.h: Declare stk500v2_jtagmkII_initpgm().
* avrdude.1: Document the new programmer support.
* doc/avrdude.texi: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@643 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-06 20:06:07 +00:00
Joerg Wunsch
4074a28682 Add date and time of compilation to the verbose greeting message.
Idea taken from patch #3172: Adds date and time of compile to usage
message


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@642 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-01 21:15:03 +00:00
Joerg Wunsch
cba56a46fe Contributed by <avrdude@zevv.nl> as
patch #4372: Better synchronization for stk500

Sync three times, and drop any noise inbetween.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@641 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-01 21:00:36 +00:00
Joerg Wunsch
82a9e3cd60 Add entries for the ATtiny261/461/861 devices.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@640 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-01 20:48:04 +00:00
Joerg Wunsch
74f8cf9dd5 Remove unused variable.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@639 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-01 10:06:53 +00:00
Joerg Wunsch
1c121a456a * 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@638 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-09-01 10:03:12 +00:00
Joerg Wunsch
c71e4d3674 Submitted by Wim Lewis.
Improve error handling.

patch #4923: Better error reporting for serial-bitbang programmers


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@637 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-31 22:07:39 +00:00
Joerg Wunsch
54b633cace Introduce a "stk500v1" entry, so we can switch the default "stk500" to
"stk500v2" some day.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@636 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-31 21:19:58 +00:00
Joerg Wunsch
6eeab88fd4 The major part of this change has been contributed by
<andyw@pobox.com>.

Implements patch #4635: Add support for terminal/console servers for
serial programmers

* ser_posix.c: Add net_open(), and divert to it for net:host:port.
* ser_win32.c: Recognize net:host:port, and bail out.
* avrdude.1: Document the net:host:port connection option.
* doc/avrdude.texi: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@635 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-31 20:52:47 +00:00
Joerg Wunsch
fc87fe433a Fix for bug #16627: Butterfly programmer does not reset after programming
Wait for the device's response after sending an "E" command.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@634 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-31 11:02:25 +00:00
Joerg Wunsch
5dbc32c73e Tentative fix for bug #16156: Problem with Si-Prog
Disable reset before closing.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@633 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-31 10:55:20 +00:00
Joerg Wunsch
fa5465b63f Rewrite the serbb code so the pin numbering matches the
DB9 connector, and fix some related bugs in serbb_posix.c.

Closes bug #16265: dasa2 does not work under posix

* avrdude.conf.in: New serbb pin numbering; added "siprog"
as an alias for "ponyser".
* serbb_posix.c: New pin numbering, fix some confusion.
* serbb_win32.c: New pin numbering.

The generic and Posix-related parts of these changes have
been contributed by Hanns-Konrad Unger


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@632 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-30 14:09:58 +00:00
Joerg Wunsch
6460235802 Rewrite the serbb code so the pin numbering matches the
DB9 connector, and fix some related bugs in serbb_posix.c.
Closes bug #16265: dasa2 does not work under posix

* avrdude.conf.in: New serbb pin numbering; added "siprog"
as an alias for "ponyser".
* serbb_posix.c: New pin numbering, fix some confusion.
* serbb_win32.c: New pin numbering.

The generic and Posix-related parts of these changes have
been contributed by Hanns-Konrad Unger


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@631 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-30 14:08:37 +00:00
Joerg Wunsch
4b97ebc9ad Contributed by the anonymous developer of patch #5096:
Add an entry for the Altera byteblaster.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@630 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-30 05:13:15 +00:00
Joerg Wunsch
00791df09d Rework the exit specs so they actually work again. It should be
possible to extend them for other programmers than PPI now (serbb,
stk500*).

* pgm.h: Keep the exit specs in an abstract form inside struct
programmer_t.  (Should be moved out into some programmer-specific
structure.)  Rename the getexitspecs() method into
parseexitspecs().
* main.c: Move the exit specs stuff out to the programmer
implementation.
* par.c: Implement the new exit spec handling.  Everything is now
done using the generic abstraction layer.

Closes bug #16443: No disable Resetsignal at the end of
Programming Session

Obviates need for patch #5057: quick and dirty Hack to unset Reset
after Programming


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@629 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-29 23:12:15 +00:00
Joerg Wunsch
9473243b2c This patch has been contributed by an anonymous developer
via the patch tracking system.

patch #5096: Allow VCC and BUFF to be any pin in parallel mode

* config_gram.y: Release the restriction to PPIDATA pins.
* par.c: Rework the code to introduce a function par_setmany()
that builds on top of par_setpin(), and use that function for the
PPI_AVR_VCC and PPI_AVR_BUFF pin collections.  This also abstracts
the polarity of these signals appropriately.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@628 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-29 21:39:26 +00:00
Joerg Wunsch
8a833f921e Contributed by Ned Konz:
Open the serial port with O_NONBLOCK, and save and restore the port
state before exiting.

patch #5008: Patch for (5.1) ser_posix.c for O_NONBLOCK open and
restoring serial port state on close

Closes bug #12622: avrdude hangs on macosx/darwin with PL-2303
usb-to-serial and Butterfly


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@627 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-28 21:17:01 +00:00
Joerg Wunsch
ca1ed48a5e Move the bitbang prerequisite checks out from
main() into their own bitbang_check_prerequisites().


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@626 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-23 21:06:28 +00:00
Joerg Wunsch
d54f7a4fdb So finally, also ignore the Makefile.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@625 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-23 15:02:07 +00:00
Joerg Wunsch
879dd88de5 Two more things to ignore by CVS.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@624 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-23 15:01:04 +00:00
Joerg Wunsch
291c0515b9 Make CVS ignore all generated files.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@623 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-23 15:00:11 +00:00
Joerg Wunsch
fc2bb33bb6 * avrdude.conf.in: Add page mode parameters for all "eeprom" memory
definitions that are organized in pages.

* avr.c (avr_write_byte_default): Consider using the loadpage
instructions only if the respective memory is marked "paged".

Closes bug #17199: EEPROM fails verification on ATmega645 with
pony-stk200 hardware
Closes bug #16849: EEPROM write fails for AT90USB1287 with mode 0x41
Closes bug #15146: stk500v2_paged_write: loadpage instruction not
defined for part


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@622 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-22 22:05:19 +00:00
Joerg Wunsch
1ac704aa18 Change "avrispmk2" into "avrisp2" (in the description of the -d
option) as that is the programmer actually supported by
avrdude.conf.in.

Closes bug #15677: documentation mentions wrong programmer-id "avrispmk2"


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@621 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-22 20:01:25 +00:00
Joerg Wunsch
7c00e9ce8d Fix various AVR910 device codes. Add the code tables from both,
AVR910 and AVR109.  Change avr910_devcode of the ATtiny2313 to 0x5e
(ATtiny26).

Closes bug #16671: Tiny2313 avr910_devcode is bad
Closes bug #15826: avr910 device type for ATmega8 wrong


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@620 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-21 21:00:45 +00:00
Joerg Wunsch
1066d7cbb2 Add (rather conservative) write delay timing values to the *fuse and
lock memory spaces of all devices where they have been missing.  Add
the lock memory space to the ATmega48 section.

Closes bug #14920: tiny2313 fuses and AVRDUDE 5.0
Closes bug #15751: atmega48: no lock bits defined


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@619 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-21 20:19:35 +00:00
Joerg Wunsch
656a37122e Fix the size of the calibration memory space for ATtiny13, ATmega64,
ATmega16, ATmega32, ATmega8535, ATtiny25, ATtiny45, ATtiny85.

Closes bug #17383: Wrong calibration section in avrdude.conf...


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@618 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-21 19:43:05 +00:00
Joerg Wunsch
c4770ee293 Correct the pagesize of the ATmega324 from 256 to 128.
This closes bug #16410: ATMega164/324/644 cannot be programmed


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@617 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-21 19:09:32 +00:00
Joerg Wunsch
13ae062376 * configure.ac: Check for gettimeofday().
* ppiwin.c (gettimeofday): Define gettimeofday() replacement
only if !defined(HAVE_GETTIMEOFDAY); use correct protype.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@616 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-20 06:49:11 +00:00
Joerg Wunsch
fafd64f35d Some more STK500 vs. AVRISP cleanup: don't announce STK500-only
parameters on AVRISPs.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@615 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-19 21:02:45 +00:00
Joerg Wunsch
3f6708683a Minor cosmetic changes: STK500 firmware version numbers are M.NN, so
always display the minor number as two digits.  Examine the response
to the sign-on command to see which programmer hardware we are talking
to, and then restrict the STK500 topcard display to devices detected
as STK500.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@614 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-18 21:23:34 +00:00
Joerg Wunsch
be32054156 Add a dist-hook, and make it remove lexer.c, config_gram.c, and
config_gram.h from the source distribution archive.  These files are
supposed to be generated on the target system.

Closes bug #15536: avrdude-5.1 compilation fails on Gentoo/amd64


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@613 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-18 20:10:20 +00:00
Joerg Wunsch
8e64e0b3ca (AC_CHECK_LIB[usb]) Fix the generation of HAVE_LIBUSB in ac_cfg.h.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@612 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-17 22:44:34 +00:00
Joerg Wunsch
de999a4df4 Unreverse the argument order for CMD_CHIP_ERASE_HVSP; Atmel says
AVR068 is right, and stk500.exe is wrong.  (This reverts rev 1.19)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@611 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-17 16:01:34 +00:00
Joerg Wunsch
1c27d0b72c Submitted by Neil Davey:
patch #4539: Ability to control the bit clock (usleep) delay
for ppi interface
* bitbang.c: Implement bitbang_delay() and its calibration.
* bitbang.h: Declare bitbang_delay().
* main.c: Add the ispdelay option (-i).
* pgm.h (struct programmer_t): Add the ispdelay parameter.
* par.c: Add calls to bitbang_delay() when requested.
* serbb_posix.c: (Ditto.)
* serbb_win32.c: (Ditto.)
* avrdude.1: Document the new -i option.
* doc/avrdude.texi: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@610 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-17 15:06:20 +00:00
Joerg Wunsch
72b22aa078 Submitted by <chris@awaretechs.com>:
* avrdude.conf.in (ATmega48, ATmega88, ATmega168): patch #5100:
mega88 EEPROM support (extended for ATmega48 and ATmega168 - jw).


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@609 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-14 22:00:47 +00:00
Joerg Wunsch
cf07755f50 Submitted by <eolson@mit.edu>:
* stk500v2.c (stk500v2_open): patch #5273: Emit error message
if user requests usb and no libusb support


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@608 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-14 21:30:04 +00:00
Joerg Wunsch
2ff1624077 Beautify: replace indentation spaces by TABs,
remove trailing white space.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@607 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-14 05:16:56 +00:00
Joerg Wunsch
9243abcf3b Update most important recent additions.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@606 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-13 22:34:42 +00:00
Joerg Wunsch
9a055d4128 Add HVSP/PP mode parameters for all AVRs.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@605 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-13 22:26:45 +00:00
Joerg Wunsch
29daef32db Pretty-print the control stack argument.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@604 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-13 21:57:52 +00:00
Joerg Wunsch
e860b3091f New file, extract high-voltage programming parameters from Atmel XML
files, and produce an avrdude.conf[.in] snippet.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@603 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-13 21:10:13 +00:00
Joerg Wunsch
75bf98f073 * configure.ac (AC_CHECK_LIB([usb]): implement a private LIBUSB
macro to add this library to, to prevent it from being
automatically linked to all binaries.  This should fix the Win32
build of loaddrv.
* Makefile.am (avrdude_LDADD): add LIBUSB here.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@602 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-11 16:00:12 +00:00
Eric Weddington
3745f482d9 Patch #4780. Provide support for mega325, mega3250, mega645, mega6450.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@601 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-10 17:31:56 +00:00
Joerg Wunsch
f638a4caab Reverse the argument order for
CMD_CHIP_ERASE_HVSP; AVR068 and stk500.exe differ here.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@600 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-10 15:41:19 +00:00
Joerg Wunsch
4cf622cbf9 ATtiny11: fix the HVSP control stack,
add delay values required for flash and EEPROM.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@599 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-10 15:40:33 +00:00
Joerg Wunsch
688e194b10 stk500v2_program_enable(): Fix a typo (synchloops vs. synchcycles).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@598 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-09 19:56:48 +00:00
Joerg Wunsch
bb60925d96 Add parallel programming definitions for the ATmega8/48/88/168.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@597 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-08-04 20:49:00 +00:00
Joerg Wunsch
e663123831 Add the ATtiny11, an HVSP-only device.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@596 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-22 20:21:38 +00:00
Joerg Wunsch
6ed65069bf Implement STK500 (v2) HVSP mode.
* stk500v2.c: Add new functions for HVSP support.
* stk500v2.h: Add prototype for the stk500hvsp programmer.
* avrpart.h: Add fields to struct avrpart for new features.
* config_gram.y: Extend the configuration syntax for new
features required for HVSP support.
* lexer.l: (Ditto.)
* avrdude.conf.in: Add HVSP support for ATtiny13 and
ATtiny45 as an example.
* avrdude.1: Document stk500hvsp.
* doc/avrdude.texi: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@595 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-21 21:53:49 +00:00
Joerg Wunsch
e2e97bca93 Print the very verbose memory details only in debug level > 4.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@594 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-21 21:51:13 +00:00
Joerg Wunsch
c8c576ff35 Document the stk500pp support.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@593 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-19 21:34:34 +00:00
Joerg Wunsch
c814037d98 Document the new PP mode parameters.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@592 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-19 21:28:14 +00:00
Joerg Wunsch
4d5a479c86 Add more parameters for PP mode.
Fix the non-paged write operations for old AVRs.

In avrdude.conf.in, use the new PP mode parameters; add PP mode
definitions for AT90S8515.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@591 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-19 21:25:08 +00:00
Joerg Wunsch
2d146130a6 Hide stk500v2_set_sck_period_mk2() behind an #if defined(HAVE_LIBUSB)
as it is only used there (for the AVRISP mkII).


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@590 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-19 21:19:42 +00:00
Joerg Wunsch
a8a9ed2ca1 Fix all bugs in the stk500pp implementation.
Eliminate pagebuf, and use stack-allocated buffers instead.  The
pagesize of all current AVRs is at most 256 only anyway, and this is
unlikely to change with the STK500v2 protocol.  The previous pagebuf
implementation suffered from some possible buffer overrun.

In stk500pp_write_page(), do always write full pages, rather than
attempting to write a partial last page which did not get written at
all.  Fill the remaining bytes with 0xff.

For (paged) write operations, correctly synthesize the mode byte.
This mode byte is very different from the ISP mode byte (sigh).

In stk500pp_read_byte(), when performing read operations on paged
memory, start reading at the previous page boundary rather than the
current address.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@589 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-17 21:25:59 +00:00
Joerg Wunsch
285ae1ab31 Use mem->desc in place of upd->memtype in more places to
give the full name of the respective memory area, instead of
the (possibly abbreviated) name the user typed in the -U option.

(Previous attempt in rev 1.110 was obviously not complete.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@588 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-17 19:58:50 +00:00
Joerg Wunsch
a8e190bd30 First stab at an implementation of the STK500 parallel programming
feature (v2 firmware only), named "stk500pp".  Still not yet
complete: EEPROM writes not working, documentation missing, only
ATmega16 parameters available in avrdude.conf.in, some parameters
not yet implemented.

* avrdude.conf.in: Add sample parameters for PP mode to ATmega16.
* avrpart.h: Add the parallel programming control parameters.
* avrpart.c: (Ditto.)
* config_gram.y: Add stk500pp configuration grammar.
* lexer.l: Add stk500pp token recognition.
* stk500v2.h: Add declaration for stk500pp_initpgm().
* stk500v2.c: Add stk500pp implementation.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@587 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-16 21:30:14 +00:00
Joerg Wunsch
f76b51b554 Fix the signatures for the ATmega164/324 devices.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@586 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-11 21:05:33 +00:00
Joerg Wunsch
51770e1a4b Enter the signatures for the ATmega164/324/644 devices.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@585 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-07-10 20:24:27 +00:00
Joerg Wunsch
a71e6218b8 Implement extended addressing needed for the ATmega256x devices.
Document ATmega256x support.  Also document Solaris port defaults
in avrdude.texi.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@584 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-05-25 14:38:08 +00:00
Joerg Wunsch
7f81f23269 Fix date in last commit.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@583 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-05-23 22:37:17 +00:00
Joerg Wunsch
ed1637d25c Mention ATmega256x support.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@582 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-05-23 22:28:43 +00:00
Joerg Wunsch
56ef0aafe8 Start implementing support for ATmega256x;
jtag2 and bitbang programmers are working, stk500v2
still needs to be done.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@581 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-05-23 22:27:43 +00:00
Joerg Wunsch
4d4b87df15 Fix syntax error in previous commit (missing semicolon).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@580 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-04-21 12:50:17 +00:00
Joerg Wunsch
e20799eefe Contributed by Julius Luukko <Julius.Luukko@lut.fi>:
Add the "ere-isp-avr" programmer.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@579 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-04-18 15:32:01 +00:00
Joerg Wunsch
06a5af36ba Contributed by Bram Daams:
Add the "atisp" programmer entry that makes use of negated signals.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@578 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-04-14 12:18:39 +00:00
Joerg Wunsch
cee67f5f4b Add logic to handle inverted signals for parallel ports as well, using
a tilde in avrdude.conf.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@577 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-04-13 20:10:55 +00:00
Joerg Wunsch
bbe2807089 Add support for AT90USB646/647/1286/1287.
The 64 KB devices are actually guessed, as the datasheet and XML
files obviously contain a number of errors there.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@576 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-03-28 20:35:21 +00:00
Joerg Wunsch
b17ff40a09 Cosmetical changes: items are indented by one hard tab.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@575 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-03-28 19:37:54 +00:00
Colin O Flynn
db16162922 Colin O'Flynn - March 23, 2006 - <coflynn@newae.com>
Contributed by Wim Lewis, fix a few typos (patch #4987)
    *avrdude.1: Typo fix


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@574 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-03-24 02:49:09 +00:00
Colin O Flynn
cb4000d7d3 2006-02-27 Colin O'Flynn <coflynn@newae.com>
Contributed by Wim Lewis, add support for checking device
        signatures in detail (patch #4924 and #4925)
    * avrdude.conf.in: Add signatures
    * avrpart.c: Set default signature
    * avrpart.h: Variable for signature
    * config_gram.y: More signature reading
    * lexer.l: Define that signatures exist
    * main.c: Read signatures and check them against hardware


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@573 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-02-27 17:18:42 +00:00
Joerg Wunsch
d7bddada25 Fixed paged flash write operations for AT90PWMx devices
(error in datasheet).


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@572 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-02-21 21:17:08 +00:00
Joerg Wunsch
df364f59c3 This is now post-release.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@571 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-01-23 21:04:13 +00:00
Joerg Wunsch
cd07291aae Pre-release mode.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@569 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-01-23 20:53:59 +00:00
Colin O Flynn
ede97a0ed2 * main.c, stk500v2.c: Added patch 4804 from eolson@mit.edu
Which stops sck from being writtend needlessly


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@568 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-01-17 21:11:39 +00:00
Colin O Flynn
caec621eaa *avrdude.conf.in : Added bs2 and pagel to m162, patch 4766
CVS  ----------------------------------------------------------------------


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@567 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-01-17 21:01:25 +00:00
Colin O Flynn
c23519f392 Colin O'Flynn <coflynn@newae.com>
* main.c: Fixed a typo in safemode variable names, fixed bug 15113


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@566 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-01-17 20:17:43 +00:00
Joerg Wunsch
4cbcbe84ec Replace David's email address by his full name in the copyrights.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@565 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-01-12 23:24:35 +00:00
Joerg Wunsch
fddb673ee8 Contributed by dcm@mit.edu: add support for the
AVRISP mkII device. (Savannah patch #4789.)
* serial.h: Declare usb_serdev_frame device descriptor.
* stk500v2.c: Implementation of the AVRISP mkII handling.
* usb_libusb.c: Add USB handling for short-frame delimited
AVRISP mkII USB protocol; add distinction of different
devices in usbdev_open().
* jtagmkII.c: Tell usbdev_open() to search for the JTAG ICE mkII.
* usbdevs.h: (New file.)
* Makefile.am: Add usbdevs.h, as well as some other forgotten
files "make distcheck" complained about.
* avrdude.conf.in: Add more aliases for the AVRISP mkII.
* avrdude.1: Document how to use the AVRISP mkII.
* doc/avrdude.texi: (Ditto.)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@564 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-01-12 23:13:50 +00:00
Joerg Wunsch
b561874f07 Add EEPROM page instructions for the
ATmega169 so it will work for STK500v2.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@563 81a1dc3b-b13d-400b-aceb-764788c761c2
2006-01-12 20:56:43 +00:00
Joerg Wunsch
5e68193a6c Add support for ATtiny24/44/84.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@562 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-12-16 22:39:39 +00:00
Colin O Flynn
d9866f6219 *avrdude.conf.in: added support for m162 using stk500v2
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@561 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-12-07 19:19:20 +00:00
Joerg Wunsch
645961163d Fix the number of significant bits for the efuse memory in
ATmega48/88/168; the datasheet is a bit off here as well.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@560 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-12-01 19:55:17 +00:00
Joerg Wunsch
e9750a7712 Document the JTAG ICE mkI support.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@559 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-29 22:58:04 +00:00
Joerg Wunsch
0b197a6c6f Submitted by Galen Seitz:
patch #4459: Fix for rpm package builds
* avrdude.spec.in: update the RPM spec file:
  - Default to enable-doc=yes during configure.
  - Move info file to docs package.
  - Make building of docs package conditional.  Basic
    idea copied from avr-gcc.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@558 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-29 20:28:51 +00:00
Joerg Wunsch
70fdf3082e Submitted by someone who thinks he's called "Daper":
Fix bug #15013: Wrong use of PPICLAIM (kernel: ppdev0: claim the
port first)

* par.c: don't claim/release here (thus win_ppdev.h not needed
anymore)
* ppi.c: claim/release here.
* freebsd_ppi.h: ppi_claim/ppi_release now take an fd as parameter.
* solaris_ecpp.h: (Ditto.)
* linux_ppdev.h: (Ditto.)  (Also add copyright.)
* win_ppdev.h: Not needed anymore, remove.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@557 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-29 20:20:22 +00:00
Joerg Wunsch
e58b699f41 Fix the size of a response array.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@556 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-28 21:11:18 +00:00
Joerg Wunsch
6b379d8842 Improve the communication startup with the ICE in particular after a
powerup.  Ideas taken from AVaRICE.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@555 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-28 20:46:21 +00:00
Joerg Wunsch
6fa8db276f Enable parport access on x86_64 Linux and amd64 FreeBSD systems.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@554 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-28 09:47:23 +00:00
Joerg Wunsch
7f7974ce25 Add a forgotten newline at EOF.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@553 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-27 21:20:48 +00:00
Joerg Wunsch
f0c7b52223 Add a forgotten changelog entry about the ATmega168 support.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@552 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-27 21:02:53 +00:00
Joerg Wunsch
0935636c7b Update ChangeLog for my JTAG ICE mkI support.
Beautify Colin's recent entries while being here.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@551 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-25 21:32:21 +00:00
Colin O Flynn
1b38485a23 Fixed bug 15051
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@550 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-25 14:48:22 +00:00
Colin O Flynn
fa935481aa Fixed bug 15051, building for Windows breaks.
*par.c: ppi_claim and ppi_release definitions now in a Windows header file
*ppi.c: Only included if you are building for Windows
*win_ppdev.h: Initial Commit, see par.c

CV: ----------------------------------------------------------------------


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@549 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-25 14:46:43 +00:00
Colin O Flynn
5ea6e54f96 Fixed bug 14681
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@548 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-25 12:46:23 +00:00
Joerg Wunsch
92010244dc Initial import of JTAG ICE mkI support.
The very basic functionality (paged flash read/write, erase, terminal
mode reads, fuse writes) works fine.  There are still the following
issues right now:

. paged EEPROM write (i.e. through -U eeprom:w:...) only works on an
  erased EEPROM
. byte-access flash and EEPROM writes (i.e. in terminal mode) fail
. documentation needs to be updated still


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@547 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-25 06:14:06 +00:00
Colin O Flynn
85e827043d *Added Brian Dean's patch to ser_win32.c, fixing bug 14681 "-vvvv causes communication to fail"
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@546 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-24 15:00:49 +00:00
Colin O Flynn
25d844791c Added support for stk500v2 for AtMega168
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@545 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-05 13:02:55 +00:00
Colin O Flynn
3ef11e335a avrdude.conf.in:
-added support for ATMega168, patch #4532 thanks to Manfred Bartz


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@544 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-04 13:51:32 +00:00
Joerg Wunsch
58233bbed4 Update Changelog.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@543 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-03 22:41:18 +00:00
Joerg Wunsch
ad9238b29e Add ecpp(7D) (parallel port) for Solaris.
* configure.ac: add Solaris' default parallel port.
* linux_ppdev.h: change parallel port access to the new style.
* freebsd_ppi.h: New file, abstract FreeBSD's ppi(4).
* solaris_ecpp.h: New file, abstract Solaris' ecpp(7D).
* par.c: change header inclusion sequence.
* pgm.h: remove obsolete ppi_claim() and ppi_release() dummies.
* ppi.c: change header inclusion sequence, use new parport
abstraction, drop obsolete dummy implementation.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@542 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-03 22:37:37 +00:00
Joerg Wunsch
5ce121ab1c Make the lexer work with Solaris' (10) default lex(1).
While Solaris' lex understands start conditions, they cannot be grouped,
so unfold the <strng> group.

All actions need braces, even if they only consist of a comment.

As the classic lex uses semi-static resource allocation, we need to bump
the resource limits quite a bit.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@541 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-02 21:49:52 +00:00
Joerg Wunsch
5105a871be Instead of defining YYSTYPE to be a struct token_t *, make this a
two-step declaration, and first define token_p to be a token_t *,
and then define YYSTYPE to token_p.  That works around a bug in
Solaris' yacc.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@540 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-02 21:03:51 +00:00
Joerg Wunsch
496ab3fd81 Make avrdude Solaris-compatible.
* Makefile.am: distclean avrdude.conf.
* avrdude.conf.in: make the parallel-port programmers optional.
* bitbang.c: move the bitbang features out into PROGRAMMER.
* configure.ac: introduce --enable-parport, add Solaris.
* lexer.l: replace str by strng to work around problems in some
versions of flex.
* main.c: move getexitspecs into the respective programmer's
domain; replace rindex by the C-standard strrchr.
* par.c: make parallel port optional.
* par.h: everything but par_initpgm() is private now.
* pgm.h: add setping/getping/highpulsepin/getexitspecs.
* serbb_posix.c: generalize bitbang interface; replace
cfmakeraw() by explicit code.
* serbb_win32.c: generalize bitbang interface.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@539 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-11-01 23:02:06 +00:00
Joerg Wunsch
a1c528dbe2 Fix yet another sign extension bug introduced by renaming "unsigned char"
to "char".


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@538 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-10-20 11:36:19 +00:00
Joerg Wunsch
50b587155d Add the required address bits for calibration memory space...
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@537 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-10-14 20:00:01 +00:00
Joerg Wunsch
d1342a1984 Fix the size of the calibration memory in the ATmega8515.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@536 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-10-14 19:33:19 +00:00
Joerg Wunsch
f9331bc6b4 Add support for the ATmega640/1280/1281 devices.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@535 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-10-09 09:29:24 +00:00
Joerg Wunsch
08e0114447 Polish up the docs a bit. Use smallexample instead of example for
wide tty output.  Document a trick to find out about the serial
numbers of all JTAG ICEs attached to USB.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@534 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-27 08:25:18 +00:00
Joerg Wunsch
0f12718ab6 A number of fixes for the libusb handling:
. use the correct endpoint, depending on whether we are going to read
  or write
. when opening the USB device, set the configuration according to the
  config entry, and properly claim the interface
. when closing, release the interface again

With these changes, it works now with libusb-win32 as well.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@533 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-26 12:19:01 +00:00
Joerg Wunsch
1b3d1fb776 In jtagmkII_paged_write(), default the pages size to 256 early enough
so the buffer will then be allocated correctly.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@532 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-26 12:16:45 +00:00
Brian S. Dean
63aab0383c Previous commit was the wrong fix, instead look for an alternate file
for the texi2html split conditional.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@530 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-22 17:51:59 +00:00
Joerg Wunsch
367a80150f * main.c(do_op): use mem->desc in place of upd->memtype to
give the full name of the respective memory area, instead of
the (possibly abbreviated) name the user typed in the -U option.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@529 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-22 14:14:14 +00:00
Brian S. Dean
551aff83c5 Fix conditional for the directory existance test.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@528 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 21:06:15 +00:00
Joerg Wunsch
f366d16c75 Add the forgotten -B option (JTAG bit clock) to the getopt() option
string.  Actually evaluate that number as microseconds then, as the
documentation used to state already.

While being there, re-sort the -s option into alphabetical order.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@527 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 15:02:02 +00:00
Brian S. Dean
736905dcdb Reset the version to 5.0cvs for post 5.0 release development.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@526 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 02:32:49 +00:00
Brian S. Dean
3fc237abff Document the -s option.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@525 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 02:00:58 +00:00
Brian S. Dean
e792a592f5 Provide more information on safemode operation.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@524 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 01:54:19 +00:00
Brian S. Dean
93105b3214 Document Version 5.0.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@523 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 01:45:48 +00:00
Brian S. Dean
d9a67805b5 Add Colin O'Flynn to the contributors list for his safemode support.
Document the addition of the latest safemode update in the change log.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@522 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 01:43:19 +00:00
Brian S. Dean
ee515ad636 Update version to 5.0.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@521 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 01:37:02 +00:00
Brian S. Dean
e5fb5ed3a6 All declarations need to be at the top of the block.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@520 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 01:26:54 +00:00
Brian S. Dean
e2a99a00a4 This is Colin O'Flynn's mega patch for updating safemode support:
* add support for parts with just 'fuse' memory

    * if any fuse memories are altered, reflect those changes in the
      post-programming safemode check so that safemode no longer
      complains about fuses which were intentionally altered; this
      eliminates the need to completely disable safemode using -u in
      order to program fuses.

    * provide -s option which will not ask to restore fuses, it will
      just do it

Submitted by: Colin O'Flynn <coflynn@newae.com>


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@519 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-21 00:20:32 +00:00
Joerg Wunsch
56b04c2511 Use a slightly different approach to avoid the signed/unsigned warning.
Pointed out by: Brian Dean


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@518 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-20 04:53:09 +00:00
Joerg Wunsch
71aa89490e Make the device code received unsigned, so it wouldn't sign-extend if
it is beyond 0x80.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@517 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-19 14:22:30 +00:00
Joerg Wunsch
9823296d6f Forgot to add Michael Holzt to that file in my previous commit.
He's the author of the serbb contribution.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@516 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-19 05:36:37 +00:00
Joerg Wunsch
305c28943d In lieu of Michael Holzt, add his serbb serial bit-bang code so it
will be available in the upcoming avrdude release.

His addition has been implemented by means of a generalized bit-bang
interface that contains the common part between serial and paralle
bit-bang devices, and specialed backends for the serial and parallel
port connections.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@515 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-18 20:12:23 +00:00
Joerg Wunsch
2d992bd6ea Record my recent changes.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@514 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-18 19:43:04 +00:00
Brian S. Dean
3cd7546e74 Bring this file up to date.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@513 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-18 01:16:39 +00:00
Brian S. Dean
61157b7985 Document some recent changes.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@512 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-18 01:01:57 +00:00
Brian S. Dean
733391725b Patch #4078: add VCC pin definition for DAPA programmer. This patch
was the whole programmer submission which was already added through
another request, but the former lacked the VCC definition.  Pick it up
from this patch.

Submitted by: tmohr@s.netic.de


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@511 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-18 00:44:20 +00:00
Brian S. Dean
bfbe775df8 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@510 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-18 00:28:19 +00:00
Joerg Wunsch
afbe273a6a Fix the poll values for the ATmega103's EEPROM so they eventually
match the XML file.

This fixes
bug #7492: EEPROM writing fail on atmega103 with atavrisp


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@509 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-17 21:01:35 +00:00
Joerg Wunsch
859a5aee59 Improve the doc generation a bit.
Do not rebuild the docs again if they are up-to-date.  This avoids as
well that they are rebuilt during "make install".

Use mv -f instead of plain mv in order to install the docs into the
respective subdirs, in order to avoid silly questions for non-writable
destination files.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@508 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-17 20:04:31 +00:00
Joerg Wunsch
133e824f8d Oops, forgot to implement the calibration byte address bits.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@507 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-17 19:57:15 +00:00
Joerg Wunsch
12d7cceb2b The ATmega128 has four oscillator calibration bytes, not only a single
one.

This closes
bug #11496: Memory bank calibration on atmega128 should have 4 bytes


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@506 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-17 19:54:47 +00:00
Joerg Wunsch
8c1da56fe2 Merge the changes from avrdude.1 rev 1.47.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@505 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-17 19:12:20 +00:00
Brian S. Dean
814abdde80 Document -q -q. Expand a little on the description of the 'part'
command.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@504 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-17 15:23:05 +00:00
Brian S. Dean
17d6c4e14c Implement -q -q to be very very quiet.
Submitted by: andyw@pobox.com


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@503 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-16 21:52:42 +00:00
Brian S. Dean
8cb8923eca Add DAPA programmer.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@502 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-16 21:34:22 +00:00
Brian S. Dean
ae1a671a68 I thought I had already committed this but I don't see it in CVS.
This fixes EEPROM access using the STK500V2 programmer, partially
undoing part of a previous general fixup commit.  Choose the correct
read/write operations with the stk500v2 program function - the correct
one depends on the memory type.  EEPROM is byte addressable so uses
read/write.  FLASH is word addressable and so uses read_lo/write_lo.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@501 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-16 21:23:14 +00:00
Joerg Wunsch
66a5f13b2c avrdude.1: document the memtypes for -U
doc/avrdude.texi: (Ditto.)
Closes bug #13501: <memtype> should be listed in the man page


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@500 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-16 20:38:29 +00:00
Joerg Wunsch
f6c2213871 * doc/Makefile.am: add logic to detect the misf^H^H^H^H
gratitous API change in recent versions of texi2html where
the output directory has changed names.
Fix for:
bug #13026: The build fails with texi2html 1.76
bug #12715: make issues during install
patch #3091: commandline fix for latest version of texi2html


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@499 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-16 20:18:37 +00:00
Joerg Wunsch
dccd12548d * jtagmkII.c (jtagmkII_paged_load): return the number of bytes read.
This makes EEPROM block reads work again.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@498 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-16 15:52:28 +00:00
Joerg Wunsch
59e0241a40 * usb_libusb.c (usbdev_drain): actually implement draining to aid
synchronizing against a JTAG ICE in weird state.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@497 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-16 15:01:52 +00:00
Joerg Wunsch
2d30c6588b Improve the initializion sequence of the butterfly so it is more likely
to synchronize with the device.

bug #9787 overview: avrdude 4.4.0 correct butterfly interface


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@496 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-16 14:54:55 +00:00
Joerg Wunsch
a4f79a194a Make "jtag2" an alias for "jtag2fast", people will certainly love it
that way. ;-)  For those who want the 19200 Bd one, add "jtag2slow".


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@495 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-14 19:49:27 +00:00
Brian S. Dean
2e7ce68927 Change bit 0 of the ATmega169 efuse 'write' opcode from 'x' (ignore)
to 'i' (input).  Even though this bit should be ignored, it should not
be changed.  The 'x' setting sets the bit to zero which programs it
and could cause undefined behaviour.  Setting to 'i' enables it to be
rewritten to its old value.

A better solution might be to read the fuse byte, apply the new value
while leaving the 'x' bit alone, then writing the value back.  The
current fix is a workaround which allows the developer to change the
bit.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@494 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-09-14 02:11:49 +00:00
Joerg Wunsch
cfe306e66d Add Brian's ChangeLog entry for the warning cleanup.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@493 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-08-30 04:47:23 +00:00
Joerg Wunsch
6d420f9a61 Consitently use unsigned char for buffers to avoid warnings.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@492 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-08-30 04:44:29 +00:00
Brian S. Dean
5b6506ff17 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@491 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-08-30 01:30:05 +00:00
Brian S. Dean
b7810ccb40 This is patch # 4338, obsoletes patch #4327, provides fixes for bugs
#13693, #13871, and #14212.

This provides bug fixes to the STK500V2 programmer type.  From the
patch information:

    - incorrect token used from avrdude.conf.in

    - wrong command sent to programmer, hence no write to eeprom.

    - programmer was said to start writing at 0x0000 and continue page
      by page and was not repositionned when a gap was found in the
      hex file, or when the hex file start address was not
      0x0000. Hence the verify procedure was correct, not the write
      procedure.

    - speed up of flash write to skip empty pages (full of 0xFF) by
      re-enabling a dedicated function for that task.

    - stk500v2_paged_load() was not returning the number of byte read,
      so empty hex files were generated when reading memory.

Submitted by:  Bernard Fouch <bernard.fouche@kuantic.com>


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@490 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-08-28 22:23:35 +00:00
Joerg Wunsch
7a68b92089 Add support for the ATtiny25/45/85. Note that only the ATtiny45
appears to have a complete XML description right now.

Document all the recently added new devices: AT90PWM2/3,
ATmega164/324/644, ATmega329x/649x, ATtiny25/45/85.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@489 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-08-28 19:37:59 +00:00
Joerg Wunsch
d89d05867d Fix the EEPROM sizes for the ATmega329x/649x devices. I somehow got them
twice initially.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@488 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-08-17 19:40:21 +00:00
Joerg Wunsch
37e8d60512 Add support for the AT90PWM2/3. The XML files don't appear to list
all the details right now, so some of the parameters are guessed.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@487 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-08-16 19:34:56 +00:00
Joerg Wunsch
c047f5ce52 Extend the butterfly code to fully support AVR109 boot loaders. Notable
changes to butterfly.c include:

. do not exit for unsupported devices but return -1 from the init function
  instead; that way the -F option can be used to continue anyway

. honor the -b option as arbitrary bootloaders could be implemented with
  any baud rate, not just the fixed 19200 Bd used by the butterfly

. implement functionality to read the fuse and lock bits, and write the
  (boot) lock bits, resp.

. fix the signature byte order

The remaining files document the new functionality.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@486 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-07-28 16:06:35 +00:00
Brian S. Dean
36bc2d37df Note my last few changes.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@485 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-07-26 05:04:12 +00:00
Brian S. Dean
434ee1d708 Remove some debug code accidentally left in.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@484 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-07-26 04:59:50 +00:00
Brian S. Dean
12b9d0a8d7 Don't call exit() directly here - set the exit value and jump to the
main_exit: label to ensure the programmer is released correctly.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@483 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-07-26 04:13:34 +00:00
Brian S. Dean
7a27c1840c The stk500v2_getsync() function was improperly checking for success,
thus it was falsely reporting that it failed when it was actually
working correctly.  Fixed.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@482 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-07-26 02:56:29 +00:00
Joerg Wunsch
749c20d5d1 On one of my systems (a not-too-current FreeBSD 5.x), libusb appears
to have problems sending a control message (returns an "I/O error").
At least try to recover gracefully in the bening case where the user
did not request a particular serial number, so we could continue
anyway without knowing it.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@481 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-07-25 19:52:20 +00:00
Joerg Wunsch
21b946baa5 Change the check for libusb from using usb_open() to
usb_get_string_simple() as the latter is only found in recent enough
versions of libusb.  That way, silently build without USB support
unless a recent version is available.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@480 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-06-20 18:15:13 +00:00
Joerg Wunsch
069e3d4a2b Remove the check for the root dev. The required functionality is only
available in recent versions of libusb, and the check isn't really
needed anyway (as the check for vendor and product ID will cover that
as well).


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@479 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-06-20 18:12:04 +00:00
Joerg Wunsch
4d9e862ef0 Implement and document a libusb-based USB transport for the JTAG ICE
mkII.

The serial transport methods have been moved out into a record of
function pointers for that purpose, defaulting to the actual serial
connection that natively applies to the hosting system.  Iff inside
the JTAG ICE mkII handler a port name starting with "usb" has been
detected, the record of function pointers is switched to USB.
Optionally, a serial number might be specified, so only the JTAG ICE
mkII matching the given serial number will be opened.  The match is
done right-to-left, so only the least significant bytes of the serial
number need to be given.

In order to make the change as least intrusive to existing drivers as
possible, the entire naming scheme of the serial_foo() function entry
points has been maintained as access macros that encapsulate these
into the respective indirect function calls via serdev->foo().


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@478 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-06-19 21:38:03 +00:00
Joerg Wunsch
7dea3d5801 According to the part description XML file, set AllowFullPageBitStream for
the AT90CAN128 to "no".


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@477 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-06-15 04:46:12 +00:00
Joerg Wunsch
f6b3053f39 Add "efuse" sections to the ATmega164/324/644 definitions.
Iff enter_progmode failed with RSP_ILLEGAL_JTAG_ID, give the user a
hint that their JTAGEN fuse might be unset.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@476 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-06-14 21:44:34 +00:00
Joerg Wunsch
f83a8bb29d Add support for the ATmega164/324/644.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@475 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-06-14 20:18:42 +00:00
Joerg Wunsch
615054330b Fix broken page/intrapage address bit assignments for the ATmega649x.
Now loading flash works on these devices even for simple parallel ISP
adapters.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@474 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-06-13 21:24:06 +00:00
Joerg Wunsch
e889417afb Add support for the ATmega329x/649x chips. Note that STK500v1 is not
officially supported for this device.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@473 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-06-11 21:27:09 +00:00
Joerg Wunsch
949a24ec44 Fix a signedness bug when shifting bits; this caused the length field
of the packet to occasionally been misinterpreted as a negative
number.

When discarding a packet for being overly long, restart the state
machine instead of attempting to drop a preposterous amount of data.
It is unlikely in that case that preposterous amount of data would
ever arrive, so rather attempt to re-align the reading algorithm
(supposedly resulting in a timeout and retransmit).


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@472 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-27 12:15:28 +00:00
Joerg Wunsch
c51374cfe2 Document that the JTAG ICE mkII code currently cannot write to flash
one byte at a time.  Also mention the bug tracker interface on
savannah.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@471 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-19 04:49:46 +00:00
Brian S. Dean
8387b93696 Update version after tagging the beta release.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@470 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-14 15:53:00 +00:00
Brian S. Dean
143ee7d79d Catch up on my updates.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@468 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-14 15:22:31 +00:00
Brian S. Dean
3e222a978a Update version and copyright message.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@467 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-14 14:56:00 +00:00
Brian S. Dean
e7ee18fa4b Change the default port to 'serial' for the newly added serial
programmers stk500v2 and jtagmkii.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@466 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-14 14:49:39 +00:00
Joerg Wunsch
b141abc41f Umm, add the new programmer types to the texinfo documentation as well.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@465 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-14 08:06:18 +00:00
Joerg Wunsch
b6d759569a Add a ChangeLog entry for all the STK500v2 and JTAG ICE mkII modifications.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@464 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-14 07:57:58 +00:00
Joerg Wunsch
025e464387 Add an "jtag2fast" programmer that connects to the JTAG ICE at 115200 Bd.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@463 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-14 07:57:24 +00:00
Joerg Wunsch
e10928ada9 Rename the BAUD_xxx baud rate defines to PAR_BAUD_xxx to avoid a name
clash with the Win32 API names for baud rates.

Reported by: Eric


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@462 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-11 20:48:05 +00:00
Joerg Wunsch
039fe615c0 Quite some cleanup of the JTAG ICE mkII stuff.
. Implement the new EECRAddress field in the device descriptor that is
  required by the 4.x firmware; make an uneducated guess about what
  firmware requires what length of device descriptor -- perhaps Atmel
  can be convinced to publish an official matrix for that.

. Specify EECR in the config file where required.  Obviously, only
  locations that differ from the 0x3c default are mentioned in the
  XML files, so by now, this only affects the AT90CAN128 for us.

. After clarification with Atmel, EnablePageProgramming should really
  default to 1, and only cleared if specified by an XML parameter.  So
  far, only the XML files for the ATmega256x and ATmega406 do specify
  it at all, and they specify a 1, too.

. Drop the entire OCDEN fuse heuristic.  If OCDEN is unprogrammed at
  startup, issue a warning that single-byte EEPROM updates won't be
  possible.  Leave it to the user to program the fuse if desired.
  That way, we won't run into any issue of prematurely wearing out the
  hfuse EEPROM cell.  Interestingly enough, this also solved the
  problem of the target not restarting from scratch upon sign-off.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@461 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-11 20:06:23 +00:00
Joerg Wunsch
6757ebee57 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@460 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-11 17:09:22 +00:00
Joerg Wunsch
5cc4ed40bd Try reading/writing more than one byte at a time, to improve overall
performance.

Note that many consumers still read one byte at a time though.

This patch has once been submitted to me by Bernd Walter
<ticso@cicely.de>, minor tweak by me (mainly to get it running under
Linux, too).


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@459 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-11 17:00:11 +00:00
Joerg Wunsch
6af6fe9b3a Make the retrier in case of rx timeouts more robust, by increasing
the receive timeout once a timeout happened.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@458 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-11 16:58:12 +00:00
Joerg Wunsch
6d05dfda8c Sorry, I accidentally spammed a local modification over the repository.
Backout rev 1.8 of bootstrap.h.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@457 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 21:06:44 +00:00
Joerg Wunsch
df37b7faf5 I missed to commit the allowfullpagebitstream attributes.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@456 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 21:04:55 +00:00
Joerg Wunsch
083406de7c Properly close commend in $ Id $.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@455 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 20:58:45 +00:00
Joerg Wunsch
c136e38a1d serial_setattr() has been renamed to serial_setspeed().
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@454 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 20:57:52 +00:00
Joerg Wunsch
da412d2274 Oops, more files I forgot to add during the last commit.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@453 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:53:56 +00:00
Joerg Wunsch
546761708d I forgot to add these files in the previous commit. They are
basically obtained from Atmel's appnote AVR067.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@452 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:43:44 +00:00
Joerg Wunsch
872f75d4fb Mega-commit to bring in both, the STK500v2 support from Erik
Walthinsen, as well as JTAG ICE mkII support (by me).

Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).

The JTAG ICE mkII support should be considered alpha to beta quality
at this point.  Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required.  Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).

Note that for the JTAG ICE, I did change a few things in the internal
API.  Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation).  Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character.  The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery.  The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
Brian S. Dean
c8b9561f1e Exit non-zero if safe-mode reverts fuse bits that were requested on
the command-line.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@450 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-02-11 19:03:53 +00:00
Brian S. Dean
8a2d4aa7f2 Variable declarations must only appear at the beginning of a block.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@449 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-02-10 18:37:37 +00:00
Brian S. Dean
e77bacaac6 Document -u option to disable safe mode.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@448 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-02-10 18:03:32 +00:00
Brian S. Dean
3ad88ee11c Style police: white space only change; consistent indentation, wrap
long lines to < 80 columns.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@447 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-02-10 16:34:55 +00:00
Brian S. Dean
aa3b5ee436 doc/Makefile is now dependent on whether or not doc is enabled.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@446 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-02-10 15:39:42 +00:00
Brian S. Dean
978b2bfa3b Patch to disable the doc build by default; the tools needed to build
doc are either not available on all systems or are at best
inconvenient to build and install.  The doc can still be built, one
just needs to specify --enable-doc at configure time.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@445 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-02-10 14:54:57 +00:00
Eric Weddington
c3e97730b0 Entry for new Safe Mode feature.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@444 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-01-24 21:35:52 +00:00
Eric Weddington
4b5a5be064 Document new Safe Mode feature and switch.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@443 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-01-24 21:26:14 +00:00
Eric Weddington
9482eea8b6 New file. Safe Mode support.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@442 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-01-24 21:26:13 +00:00
Eric Weddington
a11bc3dd8f Add new files, safemode.c, safemode.h
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@441 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-01-24 21:26:12 +00:00
Eric Weddington
27e53d7aac Add Safe Mode. Fuse settings will be restored at the end of a programming session unless the -u switch is specified.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@440 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-01-24 21:26:11 +00:00
Brian S. Dean
c5cfb14c31 Replace my e-mail address with my url when displaying copyright
information.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@439 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-12-22 02:06:13 +00:00
Brian S. Dean
2f1ab78f45 Update code copyrights.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@438 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-12-22 01:52:45 +00:00
Brian S. Dean
95e9010c9e Add support for "Xilinx JTAG cable".
Contributed by: Tymm <tymm@booyaka.com>


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@437 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-12-22 01:30:30 +00:00
Brian S. Dean
5f5919e607 Add support for the AT90CAN128. Not sure if all the instruction
encoding is correct, specifically the address bits don't exactly match
those of the preliminary datasheet that I have, but I don't see how
they could be right.  Tested with STK500 and it works there.
Instruction encodings have not been tested due to lack of a parallel
port on my Mac.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@436 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-12-22 01:24:39 +00:00
Theodore A. Roth
6bf083fdb3 * avrdude.1: Remove reference to ppi programmer schematic.
* configure.ac (AC_INIT): Set version to "4.4.0cvs".


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@435 81a1dc3b-b13d-400b-aceb-764788c761c2
2004-07-19 22:09:09 +00:00
76 changed files with 21620 additions and 1246 deletions

View File

@@ -4,17 +4,30 @@ y.output
y.tab.h
lexer.c
config_gram.c
config_gram.h
.cvsignore
.depend
.deps
INSTALL
Makefile.in
Makefile
ac_cfg.h.in
aclocal.m4
autom4te.cache
configure
depcomp
install-sh
compile
missing
mkinstalldirs
stamp-h.in
stamp-h1
ac_cfg.h
avrdude.conf
avrdude.conf.tmp
avrdude.spec
config.guess
config.log
config.status
config.sub
avrdude

View File

@@ -1,6 +1,6 @@
AVRDUDE was written by:
Brian S. Dean <bsd@bsdhome.com>.
Brian S. Dean <bsd@bdmicro.com>
Contributors:
@@ -10,6 +10,8 @@ Contributors:
Alex Shepherd <maillists@ajsystems.co.nz>
Martin Thomas <mthomas@rhrk.uni-kl.de>
Theodore A. Roth <troth@openavr.org>
Michael Holzt <kju-avr@fqdn.org>
Colin O'Flynn <coflynn@newae.com>
For minor contributions, please see the ChangeLog files.

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,7 @@
#
EXTRA_DIST = \
ChangeLog \
ChangeLog-2001 \
ChangeLog-2002 \
ChangeLog-2003 \
@@ -34,8 +35,11 @@ CLEANFILES = \
config_gram.h \
lexer.c
SUBDIRS = doc @WINDOWS_DIRS@
DIST_SUBDIRS = doc windows
#SUBDIRS = doc @WINDOWS_DIRS@
#DIST_SUBDIRS = doc windows
SUBDIRS = @SUBDIRS_AC@
DIST_SUBDIRS = @DIST_SUBDIRS_AC@
AM_YFLAGS = -d
@@ -43,8 +47,25 @@ avrdude_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\"
avrdude_CFLAGS = @ENABLE_WARNINGS@
avrdude_LDADD = @LIBUSB@
bin_PROGRAMS = avrdude
# automake thinks these generated files should be in the distribution,
# but this might cause trouble for some users, so we rather don't want
# to have them there.
#
# See
#
# https://savannah.nongnu.org/bugs/index.php?func=detailitem&item_id=15536
#
# for why we don't want to have them.
dist-hook:
rm -f \
$(distdir)/lexer.c \
$(distdir)/config_gram.c \
$(distdir)/config_gram.h
avrdude_SOURCES = \
config_gram.y \
lexer.l \
@@ -54,14 +75,25 @@ avrdude_SOURCES = \
avr910.h \
avrpart.c \
avrpart.h \
bitbang.c \
bitbang.h \
butterfly.c \
butterfly.h \
config.c \
config.h \
confwin.c \
confwin.h \
crc16.c \
crc16.h \
fileio.c \
fileio.h \
freebsd_ppi.h \
jtagmkI.c \
jtagmkI.h \
jtagmkI_private.h \
jtagmkII.c \
jtagmkII.h \
jtagmkII_private.h \
linux_ppdev.h \
lists.c \
lists.h \
@@ -74,14 +106,29 @@ avrdude_SOURCES = \
ppi.c \
ppi.h \
ppiwin.c \
safemode.c \
safemode.h \
serial.h \
serbb.h \
serbb_posix.c \
serbb_win32.c \
ser_posix.c \
ser_win32.c \
solaris_ecpp.h \
stk500.c \
stk500.h \
stk500_private.h \
stk500v2.c \
stk500v2.h \
stk500v2_private.h \
stk500generic.c \
stk500generic.h \
term.c \
term.h
term.h \
usbasp.c \
usbasp.h \
usbdevs.h \
usb_libusb.c
man_MANS = avrdude.1
@@ -89,6 +136,9 @@ sysconf_DATA = avrdude.conf
install-exec-local: backup-avrdude-conf
distclean-local:
rm -f avrdude.conf
# This will get run before the config file is installed.
backup-avrdude-conf:
@echo "Backing up avrdude.conf in ${DESTDIR}${sysconfdir}"

View File

@@ -5,9 +5,89 @@ Approximate change log for AVRDUDE by version.
(For more detailed changes, see the ChangeLog file.)
----------------------------------------------------------------------
Current:
* New devices supported:
- AT90USB646/647/1286/1287
- ATmega2560/2561
- ATmega325/3250/645/6450
- ATtiny11 (HVSP only device)
- ATtiny261/461/861
* Fixed paged flash write operations for AT90PWMx devices
(error in datasheet).
* Add signature verification.
* Add high-voltage mode programming for the STK500 (both,
parallel, and high-voltage serial programming).
* Add support for using the JTAG ICE mkII as a generic ISP
programmer.
* Allow for specifying the ISP clock delay as an option for
bit-bang programming adapters.
* Add support for Thomas Fischl's USBasp low-cost USB-attached
programmer.
* The "stk500" programmer type is now implemented as a stub
that tries to probe for either "stk500v1" or "stk500v2".
* Many bugfixes.
Version 5.1:
* New devices supported:
- ATmega640/1280/1281
- ATtiny24/44/84
* JTAG mkII support now works with libusb-win32, too
* JTAG ICE mkI support has been added
* Solaris support has been added (including ecpp(7D) parallel-port
bit-bang mode)
Version 5.0:
* Support for JTAGICE MkII device
* Support for STK500 Version 2 Protocol
* New devices supported:
- AT90CAN128
- ATmega329x/649x
- ATmega164/324/644
- AT90PWM2/3,
- ATmega164/324/644
- ATmega329x/649x
- ATtiny25/45/85
* Support for serial bit-bang adapters: Ponyprog serial, UISP DASA,
UISP DASA3.
* DAPA programmer pinout supported
* New "safemode" feature where fuse bits are verified before exit
and if possible recovered if they have changed. This is intended
to protect against changed fuses which were not requested which is
reported to sometimes happen due to improper power supply or other
reasons.
* Various fixes for avr910 and butterfly programmers
* Full support for AVR109 boot loaders (butterfly)
* Adding -q -q suppresses most terminal output
Version 4.4.0:
* Native Win32 support: The windows build doesn't need Cygwin
anymore. Additionally, the delay timing on windows should be
more accurate now.

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,6 +33,7 @@
#include "lists.h"
#include "pindefs.h"
#include "ppi.h"
#include "safemode.h"
#define DEBUG 0
@@ -50,7 +51,7 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned char cmd[4];
unsigned char res[4];
unsigned char data;
OPCODE * readop;
OPCODE * readop, * lext;
pgm->pgm_led(pgm, ON);
pgm->err_led(pgm, OFF);
@@ -78,6 +79,18 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
return -1;
}
/*
* If this device has a "load extended address" command, issue it.
*/
lext = mem->op[AVR_OP_LOAD_EXT_ADDR];
if (lext != NULL) {
memset(cmd, 0, sizeof(cmd));
avr_set_bits(lext, cmd);
avr_set_addr(lext, cmd, addr);
pgm->cmd(pgm, cmd, res);
}
memset(cmd, 0, sizeof(cmd));
avr_set_bits(readop, cmd);
@@ -233,7 +246,7 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
{
unsigned char cmd[4];
unsigned char res[4];
OPCODE * wp;
OPCODE * wp, * lext;
wp = mem->op[AVR_OP_WRITEPAGE];
if (wp == NULL) {
@@ -253,6 +266,18 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
pgm->pgm_led(pgm, ON);
pgm->err_led(pgm, OFF);
/*
* If this device has a "load extended address" command, issue it.
*/
lext = mem->op[AVR_OP_LOAD_EXT_ADDR];
if (lext != NULL) {
memset(cmd, 0, sizeof(cmd));
avr_set_bits(lext, cmd);
avr_set_addr(lext, cmd, addr);
pgm->cmd(pgm, cmd, res);
}
memset(cmd, 0, sizeof(cmd));
avr_set_bits(wp, cmd);
@@ -320,7 +345,7 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
writeop = mem->op[AVR_OP_WRITE_LO];
caddr = addr / 2;
}
else if (mem->op[AVR_OP_LOADPAGE_LO]) {
else if (mem->paged && mem->op[AVR_OP_LOADPAGE_LO]) {
if (addr & 0x01)
writeop = mem->op[AVR_OP_LOADPAGE_HI];
else
@@ -479,8 +504,31 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char data)
{
unsigned char safemode_lfuse;
unsigned char safemode_hfuse;
unsigned char safemode_efuse;
unsigned char safemode_fuse;
int rc;
/* If we write the fuses, then we need to tell safemode that they *should* change */
safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
if (strcmp(mem->desc, "fuse")==0) {
safemode_fuse = data;
}
if (strcmp(mem->desc, "lfuse")==0) {
safemode_lfuse = data;
}
if (strcmp(mem->desc, "hfuse")==0) {
safemode_hfuse = data;
}
if (strcmp(mem->desc, "efuse")==0) {
safemode_efuse = data;
}
safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
if (pgm->write_byte) {
rc = pgm->write_byte(pgm, p, mem, addr, data);
if (rc == 0) {
@@ -592,6 +640,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
pgm->err_led(pgm, ON);
}
}
return i;
}

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Theodore A. Roth <troth@openavr.org>
* Copyright (C) 2003-2004 Theodore A. Roth <troth@openavr.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,19 +40,29 @@
extern char * progname;
extern int do_cycles;
extern int ovsigck;
static char has_auto_incr_addr;
static int avr910_send(PROGRAMMER * pgm, char * buf, size_t len)
{
return serial_send(pgm->fd, buf, len);
return serial_send(pgm->fd, (unsigned char *)buf, len);
}
static int avr910_recv(PROGRAMMER * pgm, char * buf, size_t len)
{
return serial_recv(pgm->fd, buf, len);
int rv;
rv = serial_recv(pgm->fd, (unsigned char *)buf, len);
if (rv < 0) {
fprintf(stderr,
"%s: avr910_recv(): programmer is not responding\n",
progname);
exit(1);
}
return 0;
}
@@ -125,7 +135,7 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
char hw[2];
char buf[10];
char type;
unsigned char c;
char c, devtype_1st;
int dev_supported = 0;
AVRPART * part;
@@ -164,8 +174,11 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
avr910_send(pgm, "t", 1);
fprintf(stderr, "\nProgrammer supports the following devices:\n");
devtype_1st = 0;
while (1) {
avr910_recv(pgm, &c, 1);
if (devtype_1st == 0)
devtype_1st = c;
if (c == 0)
break;
part = locate_part_by_avr910_devcode(part_list, c);
@@ -181,15 +194,18 @@ static int avr910_initialize(PROGRAMMER * pgm, AVRPART * p)
if (!dev_supported) {
fprintf(stderr,
"%s: error: selected device is not supported by programmer: %s\n",
progname, p->id);
exit(1);
"%s: %s: selected device is not supported by programmer: %s\n",
progname, ovsigck? "warning": "error", p->id);
if (!ovsigck)
exit(1);
}
/* Tell the programmer which part we selected. */
/* Tell the programmer which part we selected.
If the user forced the selection, use the first device
type that is supported by the programmer. */
buf[0] = 'T';
buf[1] = p->avr910_devcode;
buf[1] = ovsigck? devtype_1st: p->avr910_devcode;
avr910_send(pgm, buf, 2);
avr910_vfy_cmd_sent(pgm, "select device");
@@ -223,7 +239,7 @@ static void avr910_enable(PROGRAMMER * pgm)
static int avr910_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4])
{
unsigned char buf[5];
char buf[5];
/* FIXME: Insert version check here */
@@ -282,7 +298,7 @@ static void avr910_display(PROGRAMMER * pgm, char * p)
static void avr910_set_addr(PROGRAMMER * pgm, unsigned long addr)
{
unsigned char cmd[3];
char cmd[3];
cmd[0] = 'A';
cmd[1] = (addr >> 8) & 0xff;
@@ -296,7 +312,7 @@ static void avr910_set_addr(PROGRAMMER * pgm, unsigned long addr)
static int avr910_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned long addr, unsigned char value)
{
unsigned char cmd[2];
char cmd[2];
if (strcmp(m->desc, "flash") == 0) {
if (addr & 0x01) {
@@ -338,7 +354,7 @@ static int avr910_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cached = 0;
}
else {
unsigned char buf[2];
char buf[2];
avr910_set_addr(pgm, addr >> 1);
@@ -349,7 +365,7 @@ static int avr910_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if ((addr & 0x01) == 0) {
*value = buf[1];
cached = 1;
// cached = 1;
cvalue = buf[0];
caddr = addr;
}
@@ -367,7 +383,7 @@ static int avr910_read_byte_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
{
avr910_set_addr(pgm, addr);
avr910_send(pgm, "d", 1);
avr910_recv(pgm, value, 1);
avr910_recv(pgm, (char *)value, 1);
return 0;
}
@@ -392,7 +408,7 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes)
{
unsigned char cmd[] = {'c', 'C'};
unsigned char buf[2];
char buf[2];
unsigned int addr = 0;
unsigned int max_addr = n_bytes;
unsigned int page_addr;
@@ -412,21 +428,25 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
addr++;
page_bytes--;
if ((has_auto_incr_addr != 'Y') && ((addr & 0x01) == 0)) {
avr910_set_addr(pgm, addr>>1);
}
else if (m->paged && (page_bytes == 0)) {
if (m->paged && (page_bytes == 0)) {
/* Send the "Issue Page Write" if we have sent a whole page. */
avr910_set_addr(pgm, page_addr>>1);
avr910_send(pgm, "m", 1);
avr910_vfy_cmd_sent(pgm, "flush page");
page_wr_cmd_pending = 0;
usleep(m->max_write_delay);
avr910_set_addr(pgm, addr>>1);
/* Set page address for next page. */
page_addr = addr;
page_bytes = page_size;
}
else if ((has_auto_incr_addr != 'Y') && ((addr & 0x01) == 0)) {
avr910_set_addr(pgm, addr>>1);
}
report_progress (addr, max_addr, NULL);
}
@@ -438,6 +458,7 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
avr910_set_addr(pgm, page_addr>>1);
avr910_send(pgm, "m", 1);
avr910_vfy_cmd_sent(pgm, "flush final page");
usleep(m->max_write_delay);
}
return addr;
@@ -447,7 +468,7 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
static int avr910_paged_write_eeprom(PROGRAMMER * pgm, AVRPART * p,
AVRMEM * m, int page_size, int n_bytes)
{
unsigned char cmd[2];
char cmd[2];
unsigned int addr = 0;
unsigned int max_addr = n_bytes;
@@ -459,6 +480,7 @@ static int avr910_paged_write_eeprom(PROGRAMMER * pgm, AVRPART * p,
cmd[1] = m->buf[addr];
avr910_send(pgm, cmd, sizeof(cmd));
avr910_vfy_cmd_sent(pgm, "write byte");
usleep(m->max_write_delay);
addr++;
@@ -491,11 +513,11 @@ static int avr910_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes)
{
unsigned char cmd;
char cmd;
int rd_size;
unsigned int addr = 0;
unsigned int max_addr;
unsigned char buf[2];
char buf[2];
if (strcmp(m->desc, "flash") == 0) {
cmd = 'R';
@@ -523,7 +545,7 @@ static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
m->buf[addr*2+1] = buf[0]; /* MSB */
}
else {
avr910_recv(pgm, &m->buf[addr], 1);
avr910_recv(pgm, (char *)&m->buf[addr], 1);
}
addr++;
@@ -542,13 +564,19 @@ static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
static int avr910_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
{
unsigned char tmp;
if (m->size < 3) {
fprintf(stderr, "%s: memsize too small for sig byte read", progname);
return -1;
}
avr910_send(pgm, "s", 1);
avr910_recv(pgm, m->buf, 3);
avr910_recv(pgm, (char *)m->buf, 3);
/* Returned signature has wrong order. */
tmp = m->buf[2];
m->buf[2] = m->buf[0];
m->buf[0] = tmp;
return 3;
}

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Theodore A. Roth <troth@openavr.org>
* Copyright (C) 2003-2004 Theodore A. Roth <troth@openavr.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
.\"
.\" avrdude - A Downloader/Uploader for AVR device programmers
.\" Copyright (C) 2001, 2002, 2003 Joerg Wunsch
.\" Copyright (C) 2001, 2002, 2003, 2005, 2006 Joerg Wunsch
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
.\"
.\" $Id$
.\"
.Dd DATE November 26, 2003
.Dd DATE October 9, 2006
.Os
.Dt AVRDUDE 1
.Sh NAME
@@ -28,6 +28,8 @@
.Sh SYNOPSIS
.Nm
.Fl p Ar partno
.Op Fl b Ar baudrate
.Op Fl B Ar bitclock
.Op Fl c Ar programmer-id
.Op Fl C Ar config-file
.Op Fl D
@@ -36,10 +38,14 @@
.Op \&, Ns Ar exitspec
.Oc
.Op Fl F
.Op Fl i Ar delay
.Op Fl n
.Op Fl O
.Op Fl P Ar port
.Op Fl q
.Op Fl s
.Op Fl t
.Op Fl u
.Op Fl U Ar memtype:op:filename:filefmt
.Op Fl v
.Op Fl V
@@ -50,10 +56,17 @@
is a program for downloading code and data to Atmel AVR
microcontrollers.
.Nm Avrdude
supports Atmel's STK500 programmer as well as a simple hard-wired
supports Atmel's STK500 programmer,
Atmel's AVRISP and AVRISP mkII devices,
Atmel's JTAG ICE (both mkI and mkII, the latter also in ISP mode),
programmers complying to AppNote AVR910 and AVR109 (including the Butterfly),
as well as a simple hard-wired
programmer connected directly to a
.Xr ppi 4
parallel port. In the simplest case, the hardware consists just of a
or
.Xr parport 4
parallel port, or to a standard serial port.
In the simplest case, the hardware consists just of a
cable connecting the respective AVR signal lines to the parallel port.
.Pp
The MCU is programmed in
@@ -69,20 +82,43 @@ and
need to be connected to the parallel port. Optionally, some otherwise
unused output pins of the parallel port can be used to supply power
for the MCU part, so it is also possible to construct a passive
standalone programming device. Some status LEDs indicating the
stand-alone programming device. Some status LEDs indicating the
current operating state of the programmer can be connected, and a
signal is available to control a buffer/driver IC 74LS367 (or
74HCT367). The latter can be useful to decouple the parallel port
from the MCU when in-system programming is used.
.Pp
See the file
.Pa ${PREFIX}/share/doc/avrdude/avrdude.pdf
for a schematic of the
.Xr ppi 4
based programming hardware.
A number of equally simple bit-bang programming adapters that connect
to a serial port are supported as well, among them the popular
Ponyprog serial adapter, and the DASA and DASA3 adapters that used to
be supported by uisp(1).
Note that these adapters are meant to be attached to a physical serial
port.
Connecting to a serial port emulated on top of USB is likely to not
work at all, or to work abysmally slow.
.Pp
Atmel's STK500 programmer is also supported and connects to a serial
port.
Both, firmware versions 1.x and 2.x can be handled, but require a
different programmer type specification (by now).
Using firmware version 2, high-voltage programming is also supported,
both parallel and serial
(programmer types stk500pp and stk500hvsp).
.Pp
The simple serial programmer described in Atmel's application note
AVR910, and the bootloader described in Atmel's application note
AVR109 (which is also used by the AVR Butterfly evaluation board), are
supported on a serial port.
.Pp
Atmel's JTAG ICE (both mkI and mkII) is supported as well to up- or download memory
areas from/to an AVR target (no support for on-chip debugging).
For the JTAG ICE mkII, both JTAG and ISP mode are supported.
.Pp
The USBasp ISP adapter is also supported, provided
.Nm avrdude
has been compiled with libusb support.
It features a simple firwmare-only USB implementation, running on
an ATmega8 (or ATmega88).
.Pp
Input files can be provided, and output files can be written in
different file formats, such as raw binary files containing the data
@@ -99,7 +135,7 @@ can program the EEPROM and flash ROM memory cells of supported AVR
parts. Where supported by the serial instruction set, fuse bits and
lock bits can be programmed as well. These are implemented within
.Nm
as seperate memory types and can be programmed using data from a file
as separate memory types and can be programmed using data from a file
(see the
.Fl m
option) or from terminal mode (see the
@@ -132,7 +168,9 @@ the format. Currently, the following MCU types are understood:
.TS
ll.
\fBOption tag\fP \fBOfficial part name\fP
t15 ATtiny15
c128 AT90CAN128
pwm2 AT90PWM2
pwm3 AT90PWM3
1200 AT90S1200
2313 AT90S2313
2333 AT90S2333
@@ -142,19 +180,62 @@ t15 ATtiny15
4434 AT90S4434
8515 AT90S8515
8535 AT90S8535
m163 ATMEGA163
m169 ATMEGA169
m128 ATMEGA128
m103 ATMEGA103
m16 ATMEGA16
m48 ATMEGA48
m8 ATMEGA8
m88 ATMEGA88
m103 ATmega103
m128 ATmega128
m1280 ATmega1280
m1281 ATmega1281
m16 ATmega16
m161 ATmega161
m162 ATmega162
m163 ATmega163
m164 ATmega164
m169 ATmega169
m2560 ATmega2560 (**)
m2561 ATmega2561 (**)
m32 ATmega32
m324 ATmega324
m329 ATmega329
m3290 ATmega3290
m48 ATmega48
m64 ATmega64
m640 ATmega640
m644 ATmega644
m649 ATmega649
m6490 ATmega6490
m8 ATmega8
m8515 ATmega8515
m8535 ATmega8535
m88 ATmega88
t12 ATtiny12
t13 ATtiny13
t15 ATtiny15
t2313 ATtiny2313
t25 ATtiny25
t26 ATtiny26
t45 ATtiny45
t85 ATtiny85
.TE
.Bl -tag -width "(*) "
.Bl -tag -width "(**) "
.It "(*)"
The AT90S2323 uses the same algorithm.
The AT90S2323 and ATtiny22 use the same algorithm.
.It "(**)"
Flash addressing above 128 KB is not supported by all
programming hardware. Known to work are jtag2, stk500v2,
and bit-bang programmers.
.El
.It Fl b Ar baudrate
Override the RS-232 connection baud rate specified in the respective
programmer's entry of the configuration file.
.It Fl B Ar bitclock
Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only).
The value is a floating-point number in microseconds.
The default value of the JTAG ICE results in about 1 microsecond bit
clock period, suitable for target MCUs running at 4 MHz clock and
above.
Unlike certain parameters in the STK500, the JTAG ICE resets all its
parameters to default values when the programming software signs
off from the ICE, so for MCUs running at lower clock speeds, this
parameter must be specified on the command-line.
.It Fl c Ar programmer-id
Use the pin configuration specified by the argument. Pin
configurations are read from the config file (see the
@@ -258,10 +339,34 @@ reasonable before continuing. Since it can happen from time to time
that a device has a broken (erased or overwritten) device signature
but is otherwise operating normally, this options is provided to
override the check.
.It Fl i Ar delay
For bitbang-type programmers, delay for approximately
.Ar delay
microseconds between each bit state change.
If the host system is very fast, or the target runs off a slow clock
(like a 32 kHz crystal, or the 128 kHz internal RC oscillator), this
can become necessary to satisfy the requirement that the ISP clock
frequency must not be higher than 1/4 of the CPU clock frequency.
This is implemented as a spin-loop delay to allow even for very
short delays.
On Unix-style operating systems, the spin loop is initially calibrated
against a system timer, so the number of microseconds might be rather
realistic, assuming a constant system load while
.Nm
is running.
On Win32 operating systems, a preconfigured number of cycles per
microsecond is assumed that might be off a bit for very fast or very
slow machines.
.It Fl n
No-write - disables actually writing data to the MCU (useful for debugging
.Nm avrdude
).
.It Fl O
Perform a RC oscillator run-time calibration according to Atmel
application note AVR053.
This is only supported on the STK500v2, AVRISP mkII, and JTAG ICE mkII
hardware.
Note that the result will be stored in the EEPROM cell at address 0.
.It Fl P Ar port
Use
.Ar port
@@ -273,14 +378,71 @@ serial port, the
.Pa /dev/cuaa0
port is the default. If you need to use a different parallel or
serial port, use this option to specify the alternate port name.
.Pp
For the JTAG ICE mkII, if
.Nm
has been configured with libusb support,
.Ar port
can alternatively be specified as
.Pa usb Ns Op \&: Ns Ar serialno .
This will cause
.Nm
to search a JTAG ICE mkII on USB.
If
.Ar serialno
is also specified, it will be matched against the serial number read
from any JTAG ICE mkII found on USB.
The match is done after stripping any existing colons from the given
serial number, and right-to-left, so only the least significant bytes
from the serial number need to be given.
.Pp
As the AVRISP mkII device can only be talked to over USB, the very
same method of specifying the port is required there.
.Pp
For programmers that attach to a serial port using some kind of
higher level protocol (as opposed to bit-bang style programmers),
.Ar port
can be specified as
.Pa net Ns \&: Ns Ar host Ns \&: Ns Ar port .
In this case, instead of trying to open a local device, a TCP
network connection to (TCP)
.Ar port
on
.Ar host
is established.
The remote endpoint is assumed to be a terminal or console server
that connects the network stream to a local serial port where the
actual programmer has been attached to.
The port is assumed to be properly configured, for example using a
transparent 8-bit data connection without parity at 115200 Baud
for a STK500.
.Em This feature is currently not implemented for Win32 systems.
.It Fl q
Disable (or quell) output of the progress bar while reading or writing
to the device.
to the device. Specify it a second time for even quieter operation.
.It Fl s
Disable safemode prompting. When safemode discovers that one or more
fuse bits have unintentionally changed, it will prompt for
confirmation regarding whether or not it should attempt to recover the
fuse bit(s). Specifying this flag disables the prompt and assumes
that the fuse bit(s) should be recovered without asking for
confirmation first.
.It Fl t
Tells
.Nm
to enter the interactive ``terminal'' mode instead of up- or downloading
files. See below for a detailed description of the terminal mode.
.It Fl u
Disable the safemode fuse bit checks. Safemode is enabled by default
and is intended to prevent unintentional fuse bit changes. When
enabled, safemode will issue a warning if the any fuse bits are found
to be different at program exit than they were when
.Nm
was invoked. Safemode won't alter fuse bits itself, but rather will
prompt for instructions, unless the terminal is non-interactive, in
which case safemode is disabled. See the
.Fl s
option to disable safemode prompting.
.It Xo Fl U Ar memtype Ns
.Ar \&: Ns Ar op Ns
.Ar \&: Ns Ar filename Ns
@@ -288,7 +450,39 @@ files. See below for a detailed description of the terminal mode.
.Xc
Perform a memory operation as indicated. The
.Ar memtype
field specifies the memory type to operate on. The
field specifies the memory type to operate on.
The available memory types are device-dependent, the actual
configuration can be viewed with the
.Cm part
command in terminal mode.
Typically, a device's memory configuration at least contains
the memory types
.Ar flash
and
.Ar eeprom .
All memory types currently known are:
.Bl -tag -width "calibration" -compact
.It calibration
One or more bytes of RC oscillator calibration data.
.It eeprom
The EEPROM of the device.
.It efuse
The extended fuse byte.
.It flash
The flash ROM of the device.
.It fuse
The fuse byte in devices that have only a single fuse byte.
.It hfuse
The high fuse byte.
.It lfuse
The low fuse byte.
.It lock
The lock byte.
.It signature
The three device signature bytes (device ID).
.El
.Pp
The
.Ar op
field specifies what operation to perform:
.Bl -tag -width noreset
@@ -317,13 +511,31 @@ Motorola S-record
.It Ar r
raw binary; little-endian byte order, in the case of the flash ROM data
.It Ar m
immediate; actual byte values specified on the command line, seperated
immediate; actual byte values specified on the command line, separated
by commas or spaces. This is good for programming fuse bytes without
having to create a single-byte file or enter terminal mode.
.It Ar a
auto detect; valid for input only, and only if the input is not
provided at
.Em stdin .
.It Ar d
decimal; this and the following formats are only valid on output.
They generate one line of output for the respective memory section,
forming a comma-separated list of the values.
This can be particularly useful for subsequent processing, like for
fuse bit settings.
.It Ar h
hexadecimal; each value will get the string
.Em 0x
prepended.
.It Ar o
octal; each value will get a
.Em 0
prepended unless it is less than 8 in which case it gets no prefix.
.It Ar b
binary; each value will get the string
.Em 0b
prepended.
.El
.Pp
The default is to use auto detection for input files, and raw binary
@@ -335,6 +547,14 @@ contains a colon, the
field is no longer optional since the filename part following the colon
would otherwise be misinterpreted as
.Ar format .
.Pp
As an abbreviation, the form
.Fl U Ar filename
is equivalent to specifying
.Fl U Em flash:w: Ns Ar filename Ns :a .
This will only work if
.Ar filename
does not have a colon in it.
.It Fl v
Enable verbose output.
.It Fl V
@@ -407,7 +627,9 @@ does not implement the command.
.It Ar sig
Display the device signature bytes.
.It Ar part
Display the current part settings.
Display the current part settings and parameters. Includes chip
specific information including all memory types supported by the
device, read/write timing, etc.
.It Ar vtarg voltage
Set the target's supply voltage to
.Ar voltage
@@ -435,13 +657,26 @@ by 1E3.
Turn the master oscillator off.
.Em Only supported on the STK500 programmer.
.It Ar sck period
.Em STK500 programmer only:
Set the SCK clock period to
.Ar period
microseconds.
.Em Only supported on the STK500 programmer.
.Pp
.Em JTAG ICE only:
Set the JTAG ICE bit clock period to
.Ar period
microseconds.
Note that unlike STK500 settings, this setting will be reverted to
its default value (approximately 1 microsecond) when the programming
software signs off from the JTAG ICE.
This parameter can also be used on the JTAG ICE mkII to specify the
ISP clock period when operating the ICE in ISP mode.
.It Ar parms
.Em STK500 programmer only:
Display the current voltage and master oscillator parameters.
.Em Only supported on the STK500 programmer.
.Pp
.Em JTAG ICE only:
Display the current target supply voltage and JTAG bit clock rate/period.
.It Ar \&?
.It Ar help
Give a short on-line summary of the available commands.
@@ -480,7 +715,31 @@ library
Schematic of programming hardware
.El
.\" .Sh EXAMPLES
.\" .Sh DIAGNOSTICS
.Sh DIAGNOSTICS
.Bd -literal
avrdude: jtagmkII_setparm(): bad response to set parameter command: RSP_FAILED
avrdude: jtagmkII_getsync(): ISP activation failed, trying debugWire
avrdude: Target prepared for ISP, signed off.
avrdude: Please restart avrdude without power-cycling the target.
.Ed
.Pp
If the target AVR has been set up for debugWire mode (i. e. the
.Em DWEN
fuse is programmed), normal ISP connection attempts will fail as
the
.Em /RESET
pin is not available.
When using the JTAG ICE mkII in ISP mode, the message shown indicates
that
.Nm
has guessed this condition, and tried to initiate a debugWire reset
to the target.
When successful, this will leave the target AVR in a state where it
can respond to normal ISP communication again (until the next power
cycle).
Typically, the same command is going to be retried again immediately
afterwards, and will then succeed connecting to the target using
normal ISP communication.
.Sh SEE ALSO
.Xr avr-objcopy 1 ,
.Xr ppi 4 ,
@@ -498,4 +757,20 @@ This man page by
.ie t J\(:org Wunsch.
.el Joerg Wunsch.
.Sh BUGS
Please report bugs to avrdude-dev@nongnu.org.
Please report bugs via
.Dl "http://savannah.nongnu.org/bugs/?group=avrdude" .
.Pp
The JTAG ICE programmers currently cannot write to the flash ROM
one byte at a time.
For that reason, updating the flash ROM from terminal mode does not
work.
.Pp
Page-mode programming the EEPROM through JTAG (i.e. through an
.Fl U
option) requires a prior chip erase.
This is an inherent feature of the way JTAG EEPROM programming works.
This also applies to the STK500 in parallel programming mode.
.Pp
The USBasp driver does not offer any option to distinguish multiple
devices connected simultaneously, so effectively only a single device
is supported.

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,9 @@
%define debug_package %{nil}
%define _with_docs 1
%{?_without_docs: %define _with_docs 0}
Summary: AVRDUDE is software for programming Atmel AVR Microcontrollers.
Name: avrdude
Version: @VERSION@
@@ -20,12 +23,14 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
AVRDUDE is software for programming Atmel AVR Microcontrollers.
%if %{_with_docs}
## The avrdude-docs subpackage
%package docs
Summary: Documentation for AVRDUDE.
Group: Documentation
%description docs
Documentation for avrdude in html, postscript and pdf formats.
Documentation for avrdude in info, html, postscript and pdf formats.
%endif
%prep
%setup -q
@@ -33,7 +38,12 @@ Documentation for avrdude in html, postscript and pdf formats.
%build
./configure --prefix=%{_prefix} --sysconfdir=/etc --mandir=%{_mandir} \
--infodir=%{_infodir}
--infodir=%{_infodir} \
%if %{_with_docs}
--enable-doc=yes
%else
--enable-doc=no
%endif
make
@@ -51,34 +61,43 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%clean
rm -rf $RPM_BUILD_ROOT
%post
%if %{_with_docs}
%post docs
[ -f %{_infodir}/avrdude.info ] && \
/sbin/install-info %{_infodir}/avrdude.info %{_infodir}/dir || :
[ -f %{_infodir}/avrdude.info.gz ] && \
/sbin/install-info %{_infodir}/avrdude.info.gz %{_infodir}/dir || :
%preun
%preun docs
if [ $1 = 0 ]; then
[ -f %{_infodir}/avrdude.info ] && \
/sbin/install-info --delete %{_infodir}/avrdude.info %{_infodir}/dir || :
[ -f %{_infodir}/avrdude.info.gz ] && \
/sbin/install-info --delete %{_infodir}/avrdude.info.gz %{_infodir}/dir || :
fi
%endif
%files
%defattr(-,root,root)
%{_prefix}/bin/avrdude
%{_mandir}/man1/avrdude.1.gz
%{_infodir}/*info*
%attr(0644,root,root) %config /etc/avrdude.conf
%if %{_with_docs}
%files docs
%doc %{_infodir}/*info*
%doc doc/avrdude-html/*.html
%doc doc/TODO
%doc doc/avrdude.ps
%doc doc/avrdude.pdf
%endif
%changelog
* Fri Sep 23 2005 Galen Seitz <galens@seitzassoc.com>
- Default to enable-doc=yes during configure.
- Move info file to docs package.
- Make building of docs package conditional. Basic idea copied from avr-gcc.
* Wed Aug 27 2003 Theodore A. Roth <troth@openavr.org>
[Thanks to Artur Lipowski <LAL@pro.onet.pl>]
- Do not build debug package.

View File

@@ -1,7 +1,8 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -174,6 +175,7 @@ char * avr_op_str(int op)
case AVR_OP_WRITE_HI : return "WRITE_HI"; break;
case AVR_OP_LOADPAGE_LO : return "LOADPAGE_LO"; break;
case AVR_OP_LOADPAGE_HI : return "LOADPAGE_HI"; break;
case AVR_OP_LOAD_EXT_ADDR : return "LOAD_EXT_ADDR"; break;
case AVR_OP_WRITEPAGE : return "WRITEPAGE"; break;
case AVR_OP_CHIP_ERASE : return "CHIP_ERASE"; break;
case AVR_OP_PGM_ENABLE : return "PGM_ENABLE"; break;
@@ -292,23 +294,23 @@ void avr_mem_display(char * prefix, FILE * f, AVRMEM * m, int type,
char * optr;
if (m == NULL) {
fprintf(f,
"%s Page Polled\n"
"%sMemory Type Paged Size Size #Pages MinW MaxW ReadBack\n"
"%s----------- ------ ------ ---- ------ ----- ----- ---------\n",
fprintf(f,
"%s Block Poll Page Polled\n"
"%sMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n"
"%s----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n",
prefix, prefix, prefix);
}
else {
if (verbose > 2) {
fprintf(f,
"%s Page Polled\n"
"%sMemory Type Paged Size Size #Pages MinW MaxW ReadBack\n"
"%s----------- ------ ------ ---- ------ ----- ----- ---------\n",
"%s Block Poll Page Polled\n"
"%sMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n"
"%s----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n",
prefix, prefix, prefix);
}
fprintf(f,
"%s%-11s %-6s %6d %4d %5d %5d %5d 0x%02x 0x%02x\n",
prefix, m->desc,
"%s%-11s %4d %5d %5d %4d %-6s %6d %4d %6d %5d %5d 0x%02x 0x%02x\n",
prefix, m->desc, m->mode, m->delay, m->blocksize, m->pollindex,
m->paged ? "yes" : "no",
m->size,
m->page_size,
@@ -317,7 +319,7 @@ void avr_mem_display(char * prefix, FILE * f, AVRMEM * m, int type,
m->max_write_delay,
m->readback[0],
m->readback[1]);
if (verbose > 2) {
if (verbose > 4) {
fprintf(stderr,
"%s Memory Ops:\n"
"%s Oeration Inst Bit Bit Type Bitno Value\n"
@@ -366,9 +368,11 @@ AVRPART * avr_new_part(void)
p->desc[0] = 0;
p->reset_disposition = RESET_DEDICATED;
p->retry_pulse = PIN_AVR_SCK;
p->flags = AVRPART_SERIALOK | AVRPART_PARALLELOK;
p->flags = AVRPART_SERIALOK | AVRPART_PARALLELOK | AVRPART_ENABLEPAGEPROGRAMMING;
p->config_file[0] = 0;
p->lineno = 0;
memset(p->signature, 0xFF, 3);
p->ctl_stack_type = CTL_STACK_NONE;
p->mem = lcreat(NULL, 0);
@@ -486,6 +490,13 @@ void avr_display(FILE * f, AVRPART * p, char * prefix, int verbose)
"%sRETRY pulse : %s\n"
"%sserial program mode : %s\n"
"%sparallel program mode : %s\n"
"%sTimeout : %d\n"
"%sStabDelay : %d\n"
"%sCmdexeDelay : %d\n"
"%sSyncLoops : %d\n"
"%sByteDelay : %d\n"
"%sPollIndex : %d\n"
"%sPollValue : 0x%02x\n"
"%sMemory Detail :\n\n",
prefix, p->desc,
prefix, p->chip_erase_delay,
@@ -496,6 +507,13 @@ void avr_display(FILE * f, AVRPART * p, char * prefix, int verbose)
prefix, (p->flags & AVRPART_SERIALOK) ? "yes" : "no",
prefix, (p->flags & AVRPART_PARALLELOK) ?
((p->flags & AVRPART_PSEUDOPARALLEL) ? "psuedo" : "yes") : "no",
prefix, p->timeout,
prefix, p->stabdelay,
prefix, p->cmdexedelay,
prefix, p->synchloops,
prefix, p->bytedelay,
prefix, p->pollindex,
prefix, p->pollvalue,
prefix);
px = prefix;

View File

@@ -1,6 +1,7 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2003-2004 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,6 +42,7 @@ enum {
AVR_OP_WRITE_HI,
AVR_OP_LOADPAGE_LO,
AVR_OP_LOADPAGE_HI,
AVR_OP_LOAD_EXT_ADDR,
AVR_OP_WRITEPAGE,
AVR_OP_CHIP_ERASE,
AVR_OP_PGM_ENABLE,
@@ -61,6 +63,12 @@ enum { /* these are assigned to reset_disposition of AVRPART */
RESET_IO /* reset pin might be configured as an I/O pin */
};
enum ctl_stack_t {
CTL_STACK_NONE, /* no control stack defined */
CTL_STACK_PP, /* parallel programming control stack */
CTL_STACK_HVSP /* high voltage serial programming control stack */
};
/*
* serial programming instruction bit specifications
*/
@@ -78,9 +86,13 @@ typedef struct opcode {
#define AVRPART_SERIALOK 0x0001 /* part supports serial programming */
#define AVRPART_PARALLELOK 0x0002 /* part supports parallel programming */
#define AVRPART_PSEUDOPARALLEL 0x0004 /* part has pseudo parallel support */
#define AVRPART_HAS_JTAG 0x0008 /* part has a JTAG i/f */
#define AVRPART_ALLOWFULLPAGEBITSTREAM 0x0010 /* JTAG ICE mkII param. */
#define AVRPART_ENABLEPAGEPROGRAMMING 0x0020 /* JTAG ICE mkII param. */
#define AVR_DESCLEN 64
#define AVR_IDLEN 32
#define CTL_STACK_SIZE 32
typedef struct avrpart {
char desc[AVR_DESCLEN]; /* long part name */
char id[AVR_IDLEN]; /* short part name */
@@ -89,11 +101,50 @@ typedef struct avrpart {
int chip_erase_delay; /* microseconds */
unsigned char pagel; /* for parallel programming */
unsigned char bs2; /* for parallel programming */
unsigned char signature[3]; /* expected value of signature bytes */
int reset_disposition; /* see RESET_ enums */
int retry_pulse; /* retry program enable by pulsing
this pin (PIN_AVR_*) */
unsigned flags; /* see AVRPART_ masks */
int timeout; /* stk500 v2 xml file parameter */
int stabdelay; /* stk500 v2 xml file parameter */
int cmdexedelay; /* stk500 v2 xml file parameter */
int synchloops; /* stk500 v2 xml file parameter */
int bytedelay; /* stk500 v2 xml file parameter */
int pollindex; /* stk500 v2 xml file parameter */
unsigned char pollvalue; /* stk500 v2 xml file parameter */
int predelay; /* stk500 v2 xml file parameter */
int postdelay; /* stk500 v2 xml file parameter */
int pollmethod; /* stk500 v2 xml file parameter */
enum ctl_stack_t ctl_stack_type; /* what to use the ctl stack for */
unsigned char controlstack[CTL_STACK_SIZE]; /* stk500v2 PP/HVSP ctl stack */
int hventerstabdelay; /* stk500 v2 hv mode parameter */
int progmodedelay; /* stk500 v2 hv mode parameter */
int latchcycles; /* stk500 v2 hv mode parameter */
int togglevtg; /* stk500 v2 hv mode parameter */
int poweroffdelay; /* stk500 v2 hv mode parameter */
int resetdelayms; /* stk500 v2 hv mode parameter */
int resetdelayus; /* stk500 v2 hv mode parameter */
int hvleavestabdelay; /* stk500 v2 hv mode parameter */
int resetdelay; /* stk500 v2 hv mode parameter */
int chiperasepulsewidth; /* stk500 v2 hv mode parameter */
int chiperasepolltimeout; /* stk500 v2 hv mode parameter */
int chiperasetime; /* stk500 v2 hv mode parameter */
int programfusepulsewidth; /* stk500 v2 hv mode parameter */
int programfusepolltimeout; /* stk500 v2 hv mode parameter */
int programlockpulsewidth; /* stk500 v2 hv mode parameter */
int programlockpolltimeout; /* stk500 v2 hv mode parameter */
int synchcycles; /* stk500 v2 hv mode parameter */
int hvspcmdexedelay; /* stk500 v2 xml file parameter */
unsigned char idr; /* JTAG ICE mkII XML file parameter */
unsigned char rampz; /* JTAG ICE mkII XML file parameter */
unsigned char spmcr; /* JTAG ICE mkII XML file parameter */
unsigned short eecr; /* JTAC ICE mkII XML file parameter */
OPCODE * op[AVR_OP_MAX]; /* opcodes */
LISTID mem; /* avr memory definitions */
@@ -115,6 +166,13 @@ typedef struct avrmem {
back on, see errata
http://www.atmel.com/atmel/acrobat/doc1280.pdf */
unsigned char readback[2]; /* polled read-back values */
int mode; /* stk500 v2 xml file parameter */
int delay; /* stk500 v2 xml file parameter */
int blocksize; /* stk500 v2 xml file parameter */
int readsize; /* stk500 v2 xml file parameter */
int pollindex; /* stk500 v2 xml file parameter */
unsigned char * buf; /* pointer to memory buffer */
OPCODE * op[AVR_OP_MAX]; /* opcodes */
} AVRMEM;

358
avrdude/bitbang.c Normal file
View File

@@ -0,0 +1,358 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#include "ac_cfg.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#if !defined(WIN32NATIVE)
# include <signal.h>
# include <sys/time.h>
#endif
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
#include "par.h"
#include "serbb.h"
extern char * progname;
extern int do_cycles;
extern int verbose;
static int delay_decrement;
#if !defined(WIN32NATIVE)
static volatile int done;
typedef void (*mysighandler_t)(int);
static mysighandler_t saved_alarmhandler;
static void alarmhandler(int signo)
{
done = 1;
signal(SIGALRM, saved_alarmhandler);
}
#endif /* !WIN32NATIVE */
/*
* Calibrate the microsecond delay loop below.
*/
static void bitbang_calibrate_delay(void)
{
/*
* Right now, we don't have any Win32 implementation for this, so we
* can only run on a preconfigured delay stepping there. The figure
* below should at least be correct within an order of magnitude,
* judging from the auto-calibration figures seen on various Unix
* systems on comparable hardware.
*/
#if defined(WIN32NATIVE)
delay_decrement = 100;
#else /* !WIN32NATIVE */
struct itimerval itv;
volatile int i;
if (verbose >= 2)
fprintf(stderr,
"%s: Calibrating delay loop...",
progname);
i = 0;
done = 0;
saved_alarmhandler = signal(SIGALRM, alarmhandler);
/*
* Set ITIMER_REAL to 100 ms. All known systems have a timer
* granularity of 10 ms or better, so counting the delay cycles
* accumulating over 100 ms should give us a rather realistic
* picture, without annoying the user by a lengthy startup time (as
* an alarm(1) would do). Of course, if heavy system activity
* happens just during calibration but stops before the remaining
* part of AVRDUDE runs, this will yield wrong values. There's not
* much we can do about this.
*/
itv.it_value.tv_sec = 0;
itv.it_value.tv_usec = 100000;
itv.it_interval.tv_sec = itv.it_interval.tv_usec = 0;
setitimer(ITIMER_REAL, &itv, 0);
while (!done)
i--;
itv.it_value.tv_sec = itv.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &itv, 0);
/*
* Calculate back from 100 ms to 1 us.
*/
delay_decrement = -i / 100000;
if (verbose >= 2)
fprintf(stderr,
" calibrated to %d cycles per us\n",
delay_decrement);
#endif /* WIN32NATIVE */
}
/*
* Delay for approximately the number of microseconds specified.
* usleep()'s granularity is usually like 1 ms or 10 ms, so it's not
* really suitable for short delays in bit-bang algorithms.
*/
void bitbang_delay(int us)
{
volatile int del = us * delay_decrement;
while (del > 0)
del--;
}
/*
* transmit and receive a byte of data to/from the AVR device
*/
static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte)
{
int i;
unsigned char r, b, rbyte;
rbyte = 0;
for (i=7; i>=0; i--) {
/*
* Write and read one bit on SPI.
* Some notes on timing: Let T be the time it takes to do
* one pgm->setpin()-call resp. par clrpin()-call, then
* - SCK is high for 2T
* - SCK is low for 2T
* - MOSI setuptime is 1T
* - MOSI holdtime is 3T
* - SCK low to MISO read is 2T to 3T
* So we are within programming specs (expect for AT90S1200),
* if and only if T>t_CLCL (t_CLCL=clock period of target system).
*
* Due to the delay introduced by "IN" and "OUT"-commands,
* T is greater than 1us (more like 2us) on x86-architectures.
* So programming works safely down to 1MHz target clock.
*/
b = (byte >> i) & 0x01;
/* set the data input line as desired */
pgm->setpin(pgm, pgm->pinno[PIN_AVR_MOSI], b);
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 1);
/*
* read the result bit (it is either valid from a previous falling
* edge or it is ignored in the current context)
*/
r = pgm->getpin(pgm, pgm->pinno[PIN_AVR_MISO]);
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
rbyte |= r << i;
}
return rbyte;
}
int bitbang_rdy_led(PROGRAMMER * pgm, int value)
{
pgm->setpin(pgm, pgm->pinno[PIN_LED_RDY], !value);
return 0;
}
int bitbang_err_led(PROGRAMMER * pgm, int value)
{
pgm->setpin(pgm, pgm->pinno[PIN_LED_ERR], !value);
return 0;
}
int bitbang_pgm_led(PROGRAMMER * pgm, int value)
{
pgm->setpin(pgm, pgm->pinno[PIN_LED_PGM], !value);
return 0;
}
int bitbang_vfy_led(PROGRAMMER * pgm, int value)
{
pgm->setpin(pgm, pgm->pinno[PIN_LED_VFY], !value);
return 0;
}
/*
* transmit an AVR device command and return the results; 'cmd' and
* 'res' must point to at least a 4 byte data buffer
*/
int bitbang_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4])
{
int i;
for (i=0; i<4; i++) {
res[i] = bitbang_txrx(pgm, cmd[i]);
}
if(verbose >= 2)
{
fprintf(stderr, "bitbang_cmd(): [ ");
for(i = 0; i < 4; i++)
fprintf(stderr, "%02X ", cmd[i]);
fprintf(stderr, "] [ ");
for(i = 0; i < 4; i++)
{
fprintf(stderr, "%02X ", res[i]);
}
fprintf(stderr, "]\n");
}
return 0;
}
/*
* issue the 'chip erase' command to the AVR device
*/
int bitbang_chip_erase(PROGRAMMER * pgm, AVRPART * p)
{
unsigned char cmd[4];
unsigned char res[4];
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
p->desc);
return -1;
}
pgm->pgm_led(pgm, ON);
memset(cmd, 0, sizeof(cmd));
avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd);
pgm->cmd(pgm, cmd, res);
usleep(p->chip_erase_delay);
pgm->initialize(pgm, p);
pgm->pgm_led(pgm, OFF);
return 0;
}
/*
* issue the 'program enable' command to the AVR device
*/
int bitbang_program_enable(PROGRAMMER * pgm, AVRPART * p)
{
unsigned char cmd[4];
unsigned char res[4];
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
fprintf(stderr, "program enable instruction not defined for part \"%s\"\n",
p->desc);
return -1;
}
memset(cmd, 0, sizeof(cmd));
avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd);
pgm->cmd(pgm, cmd, res);
if (res[2] != cmd[1])
return -2;
return 0;
}
/*
* initialize the AVR device and prepare it to accept commands
*/
int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
{
int rc;
int tries;
bitbang_calibrate_delay();
pgm->powerup(pgm);
usleep(20000);
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
usleep(20000);
pgm->highpulsepin(pgm, pgm->pinno[PIN_AVR_RESET]);
usleep(20000); /* 20 ms XXX should be a per-chip parameter */
/*
* Enable programming mode. If we are programming an AT90S1200, we
* can only issue the command and hope it worked. If we are using
* one of the other chips, the chip will echo 0x53 when issuing the
* third byte of the command. In this case, try up to 32 times in
* order to possibly get back into sync with the chip if we are out
* of sync.
*/
if (strcmp(p->desc, "AT90S1200")==0) {
pgm->program_enable(pgm, p);
}
else {
tries = 0;
do {
rc = pgm->program_enable(pgm, p);
if ((rc == 0)||(rc == -1))
break;
pgm->highpulsepin(pgm, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]);
tries++;
} while (tries < 65);
/*
* can't sync with the device, maybe it's not attached?
*/
if (rc) {
fprintf(stderr, "%s: AVR device not responding\n", progname);
return -1;
}
}
return 0;
}
static void verify_pin_assigned(PROGRAMMER * pgm, int pin, char * desc)
{
if (pgm->pinno[pin] == 0) {
fprintf(stderr, "%s: error: no pin has been assigned for %s\n",
progname, desc);
exit(1);
}
}
/*
* Verify all prerequisites for a bit-bang programmer are present.
*/
void bitbang_check_prerequisites(PROGRAMMER *pgm)
{
verify_pin_assigned(pgm, PIN_AVR_RESET, "AVR RESET");
verify_pin_assigned(pgm, PIN_AVR_SCK, "AVR SCK");
verify_pin_assigned(pgm, PIN_AVR_MISO, "AVR MISO");
verify_pin_assigned(pgm, PIN_AVR_MOSI, "AVR MOSI");
}

46
avrdude/bitbang.h Normal file
View File

@@ -0,0 +1,46 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef bitbang_h
#define bitbang_h
int bitbang_setpin(int fd, int pin, int value);
int bitbang_getpin(int fd, int pin);
int bitbang_highpulsepin(int fd, int pin);
void bitbang_delay(unsigned int us);
void bitbang_check_prerequisites(PROGRAMMER *pgm);
int bitbang_rdy_led (PROGRAMMER * pgm, int value);
int bitbang_err_led (PROGRAMMER * pgm, int value);
int bitbang_pgm_led (PROGRAMMER * pgm, int value);
int bitbang_vfy_led (PROGRAMMER * pgm, int value);
int bitbang_cmd (PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4]);
int bitbang_chip_erase (PROGRAMMER * pgm, AVRPART * p);
int bitbang_program_enable (PROGRAMMER * pgm, AVRPART * p);
void bitbang_powerup (PROGRAMMER * pgm);
void bitbang_powerdown (PROGRAMMER * pgm);
int bitbang_initialize (PROGRAMMER * pgm, AVRPART * p);
void bitbang_disable (PROGRAMMER * pgm);
void bitbang_enable (PROGRAMMER * pgm);
#endif

View File

@@ -1,11 +1,11 @@
#! /bin/sh
# autoconf-2.57 is required
# autoconf-2.59 is required
: ${AUTOHEADER="autoheader${AC_VER}"}
: ${AUTOCONF="autoconf${AC_VER}"}
# automake-1.7.x is required
# automake-1.9.x is required
: ${ACLOCAL="aclocal${AM_VER}"}
: ${AUTOMAKE="automake${AM_VER}"}
@@ -14,9 +14,9 @@
AUTOCONF_VER=`(${AUTOCONF} --version 2>/dev/null | head -n 1 | \
cut -d ' ' -f 4) 2>/dev/null`
if [ "$AUTOCONF_VER" != "2.57" ]
if [ "$AUTOCONF_VER" != "2.59" ]
then
echo "You need to use autoconf version 2.57."
echo "You need to use autoconf version 2.59."
echo "You are using `${AUTOCONF} --version | head -n 1`."
exit 1
fi
@@ -25,9 +25,9 @@ fi
AUTOMAKE_VER=`(${AUTOMAKE} --version | head -n 1 | \
cut -d ' ' -f 4 | cut -d '.' -f -2) 2>/dev/null`
if [ "$AUTOMAKE_VER" != "1.7" ]
if [ "$AUTOMAKE_VER" != "1.9" ]
then
echo "You need to use automake version 1.7 (preferrably 1.7.3)."
echo "You need to use automake version 1.9."
echo "You are using `${AUTOMAKE} --version | head -n 1`."
exit 1
fi

View File

@@ -1,6 +1,7 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Theodore A. Roth <troth@openavr.org>
* Copyright (C) 2003-2004 Theodore A. Roth <troth@openavr.org>
* Copyright (C) 2005 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,6 +25,14 @@
* evaluation board. This board features a bootloader which uses a protocol
* very similar, but not identical, to the one described in application note
* avr910.
*
* Actually, the butterfly uses a predecessor of the avr910 protocol
* which is described in application notes avr109 (generic AVR
* bootloader) and avr911 (opensource programmer). This file now
* fully handles the features present in avr109. It should probably
* be renamed to avr109, but we rather stick with the old name inside
* the file. We'll provide aliases for "avr109" and "avr911" in
* avrdude.conf so users could call it by these name as well.
*/
@@ -60,15 +69,24 @@ static int butterfly_send(PROGRAMMER * pgm, char * buf, size_t len)
{
no_show_func_info();
return serial_send(pgm->fd, buf, len);
return serial_send(pgm->fd, (unsigned char *)buf, len);
}
static int butterfly_recv(PROGRAMMER * pgm, char * buf, size_t len)
{
int rv;
no_show_func_info();
return serial_recv(pgm->fd, buf, len);
rv = serial_recv(pgm->fd, (unsigned char *)buf, len);
if (rv < 0) {
fprintf(stderr,
"%s: butterfly_recv(): programmer is not responding\n",
progname);
exit(1);
}
return 0;
}
@@ -208,21 +226,33 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
char hw[2];
char buf[10];
char type;
unsigned char c;
int dev_supported = 0;
char c;
no_show_func_info();
/* send some ESC to activate butterfly bootloader */
butterfly_send(pgm, "\033\033\033\033", 4);
butterfly_drain(pgm, 0);
/* Get the programmer identifier. Programmer returns exactly 7 chars
_without_ the null.*/
butterfly_send(pgm, "S", 1);
memset (id, 0, sizeof(id));
butterfly_recv(pgm, id, sizeof(id)-1);
/*
* Send some ESC to activate butterfly bootloader. This is not needed
* for plain avr109 bootloaders but does not harm there either.
*/
fprintf(stderr, "Connecting to programmer: ");
do {
putc('.', stderr);
butterfly_send(pgm, "\033", 1);
butterfly_drain(pgm, 0);
butterfly_send(pgm, "S", 1);
butterfly_recv(pgm, &c, 1);
if (c != '?') {
putc('\n', stderr);
/*
* Got a useful response, continue getting the programmer
* identifier. Programmer returns exactly 7 chars _without_
* the null.
*/
id[0] = c;
butterfly_recv(pgm, &id[1], sizeof(id)-2);
id[sizeof(id)-1] = '\0';
}
} while (c == '?');
/* Get the HW and SW versions to see if the programmer is present. */
@@ -262,13 +292,13 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
if (c != 'Y') {
fprintf(stderr,
"%s: error: buffered memory access not supported. Maybe it isn't\n"\
"a butterfly but a AVR910 device?\n", progname);
"a butterfly/AVR109 but a AVR910 device?\n", progname);
exit(1);
};
butterfly_recv(pgm, &c, 1);
buffersize = c<<8;
buffersize = (unsigned int)(unsigned char)c<<8;
butterfly_recv(pgm, &c, 1);
buffersize += c;
buffersize += (unsigned int)(unsigned char)c;
fprintf(stderr,
"Programmer supports buffered memory access with buffersize=%i bytes.\n",
buffersize);
@@ -281,22 +311,10 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
butterfly_recv(pgm, &c, 1);
if (c == 0)
break;
fprintf(stderr, " Device code: 0x%02x\n", c);
/* FIXME: Need to lookup devcode and report the device. */
if (p->avr910_devcode == c)
dev_supported = 1;
fprintf(stderr, " Device code: 0x%02x\n", (unsigned int)(unsigned char)c);
};
fprintf(stderr,"\n");
if (!dev_supported) {
fprintf(stderr,
"%s: error: selected device is not supported by programmer: %s\n",
progname, p->id);
exit(1);
}
/* Tell the programmer which part we selected. */
buf[0] = 'T';
@@ -316,7 +334,7 @@ static void butterfly_disable(PROGRAMMER * pgm)
{
no_show_func_info();
/* Do nothing. */
butterfly_leave_prog_mode(pgm);
return;
}
@@ -326,8 +344,6 @@ static void butterfly_enable(PROGRAMMER * pgm)
{
no_show_func_info();
/* Do nothing. */
return;
}
@@ -337,7 +353,13 @@ static int butterfly_open(PROGRAMMER * pgm, char * port)
no_show_func_info();
strcpy(pgm->port, port);
pgm->fd = serial_open(port, 19200);
/*
* If baudrate was not specified use 19200 Baud
*/
if(pgm->baudrate == 0) {
pgm->baudrate = 19200;
}
pgm->fd = serial_open(port, pgm->baudrate);
/*
* drain any extraneous input
@@ -352,10 +374,9 @@ static void butterfly_close(PROGRAMMER * pgm)
{
no_show_func_info();
butterfly_leave_prog_mode(pgm);
/* "exit programmer" added by Martin Thomas 2/2004 */
/* "exit programmer" */
butterfly_send(pgm, "E", 1);
butterfly_vfy_cmd_sent(pgm, "exit bootloader");
serial_close(pgm->fd);
pgm->fd = -1;
@@ -372,7 +393,7 @@ static void butterfly_display(PROGRAMMER * pgm, char * p)
static void butterfly_set_addr(PROGRAMMER * pgm, unsigned long addr)
{
unsigned char cmd[3];
char cmd[3];
cmd[0] = 'A';
cmd[1] = (addr >> 8) & 0xff;
@@ -387,29 +408,36 @@ static void butterfly_set_addr(PROGRAMMER * pgm, unsigned long addr)
static int butterfly_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned long addr, unsigned char value)
{
unsigned char cmd[6];
char cmd[6];
int size;
no_show_func_info();
if ((strcmp(m->desc, "flash") != 0) && (strcmp(m->desc, "eeprom") != 0))
if ((strcmp(m->desc, "flash") == 0) || (strcmp(m->desc, "eeprom") == 0))
{
cmd[0] = 'B';
cmd[1] = 0;
if ((cmd[3] = toupper(m->desc[0])) == 'E') { /* write to eeprom */
cmd[2] = 1;
cmd[4] = value;
size = 5;
} else { /* write to flash */
/* @@@ not yet implemented */
cmd[2] = 2;
size = 6;
return -1;
}
butterfly_set_addr(pgm, addr);
}
else if (strcmp(m->desc, "lock") == 0)
{
cmd[0] = 'l';
cmd[1] = value;
size = 2;
}
else
return -1;
cmd[0] = 'B';
cmd[1] = 0;
if ((cmd[3] = toupper(m->desc[0])) == 'E') { /* write to eeprom */
cmd[2] = 1;
cmd[4] = value;
size = 5;
} else { /* write to flash */
/* @@@ not yet implemented */
cmd[2] = 2;
size = 6;
return -1;
};
butterfly_set_addr(pgm, addr);
butterfly_send(pgm, cmd, size);
butterfly_vfy_cmd_sent(pgm, "write byte");
@@ -429,7 +457,7 @@ static int butterfly_read_byte_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cached = 0;
}
else {
unsigned char buf[2];
char buf[2];
butterfly_set_addr(pgm, addr >> 1);
@@ -458,7 +486,7 @@ static int butterfly_read_byte_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
{
butterfly_set_addr(pgm, addr);
butterfly_send(pgm, "g\000\001E", 4);
butterfly_recv(pgm, value, 1);
butterfly_recv(pgm, (char *)value, 1);
return 0;
}
@@ -466,6 +494,8 @@ static int butterfly_read_byte_eeprom(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
static int butterfly_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned long addr, unsigned char * value)
{
char cmd;
no_show_func_info();
if (strcmp(m->desc, "flash") == 0) {
@@ -476,7 +506,25 @@ static int butterfly_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return butterfly_read_byte_eeprom(pgm, p, m, addr, value);
}
return -1;
if (strcmp(m->desc, "lfuse") == 0) {
cmd = 'F';
}
else if (strcmp(m->desc, "hfuse") == 0) {
cmd = 'N';
}
else if (strcmp(m->desc, "efuse") == 0) {
cmd = 'Q';
}
else if (strcmp(m->desc, "lock") == 0) {
cmd = 'r';
}
else
return -1;
butterfly_send(pgm, &cmd, 1);
butterfly_recv(pgm, (char *)value, 1);
return *value == '?'? -1: 0;
}
@@ -486,7 +534,7 @@ static int butterfly_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
{
unsigned int addr = 0;
unsigned int max_addr = n_bytes;
unsigned char *cmd;
char *cmd;
unsigned int blocksize = buffersize;
if (strcmp(m->desc, "flash") && strcmp(m->desc, "eeprom"))
@@ -542,7 +590,7 @@ static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -2;
{ /* use buffered mode */
unsigned char cmd[4];
char cmd[4];
int blocksize = buffersize;
cmd[0] = 'g';
@@ -557,7 +605,7 @@ static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd[2] = blocksize & 0xff;
butterfly_send(pgm, cmd, 4);
butterfly_recv(pgm, &m->buf[addr], blocksize);
butterfly_recv(pgm, (char *)&m->buf[addr], blocksize);
addr += blocksize;
@@ -572,6 +620,8 @@ static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
/* Signature byte reads are always 3 bytes. */
static int butterfly_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
{
unsigned char tmp;
no_show_func_info();
if (m->size < 3) {
@@ -580,7 +630,11 @@ static int butterfly_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
}
butterfly_send(pgm, "s", 1);
butterfly_recv(pgm, m->buf, 3);
butterfly_recv(pgm, (char *)m->buf, 3);
/* Returned signature has wrong order. */
tmp = m->buf[2];
m->buf[2] = m->buf[0];
m->buf[0] = tmp;
return 3;
}

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Theodore A. Roth <troth@openavr.org>
* Copyright (C) 2003-2004 Theodore A. Roth <troth@openavr.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,6 +41,7 @@ typedef struct token_t {
int primary;
VALUE value;
} TOKEN;
typedef struct token_t *token_p;
extern FILE * yyin;
@@ -58,7 +59,7 @@ extern char default_serial[];
#if !defined(HAS_YYSTYPE)
#define YYSTYPE struct token_t *
#define YYSTYPE token_p
#endif
extern YYSTYPE yylval;

View File

@@ -1,6 +1,7 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,13 +30,19 @@
#include "config.h"
#include "lists.h"
#include "par.h"
#include "serbb.h"
#include "pindefs.h"
#include "ppi.h"
#include "pgm.h"
#include "stk500.h"
#include "stk500v2.h"
#include "stk500generic.h"
#include "avr910.h"
#include "butterfly.h"
#include "usbasp.h"
#include "avr.h"
#include "jtagmkI.h"
#include "jtagmkII.h"
#if defined(WIN32NATIVE)
#define strtok_r( _s, _sep, _lasts ) \
@@ -47,7 +54,7 @@ extern char * progname;
int yylex(void);
int yyerror(char * errmsg);
static int assign_pin(int pinno, TOKEN * v);
static int assign_pin(int pinno, TOKEN * v, int invert);
static int which_opcode(TOKEN * opcode);
static int parse_cmdbits(OPCODE * op);
@@ -61,6 +68,7 @@ static int parse_cmdbits(OPCODE * op);
%token K_WRITE_HI
%token K_LOADPAGE_LO
%token K_LOADPAGE_HI
%token K_LOAD_EXT_ADDR
%token K_WRITEPAGE
%token K_CHIP_ERASE
%token K_PGM_ENABLE
@@ -87,6 +95,9 @@ static int parse_cmdbits(OPCODE * op);
%token K_FLASH
%token K_ID
%token K_IO
%token K_JTAG_MKI
%token K_JTAG_MKII
%token K_JTAG_MKII_ISP
%token K_LOADPAGE
%token K_MAX_WRITE_DELAY
%token K_MIN_WRITE_DELAY
@@ -107,11 +118,18 @@ static int parse_cmdbits(OPCODE * op);
%token K_READMEM
%token K_RESET
%token K_RETRY_PULSE
%token K_SERBB
%token K_SERIAL
%token K_SCK
%token K_SIGNATURE
%token K_SIZE
%token K_STK500
%token K_STK500HVSP
%token K_STK500PP
%token K_STK500V2
%token K_STK500GENERIC
%token K_AVR910
%token K_USBASP
%token K_BUTTERFLY
%token K_TYPE
%token K_VCC
@@ -121,9 +139,66 @@ static int parse_cmdbits(OPCODE * op);
%token K_NO
%token K_YES
/* stk500 v2 xml file parameters */
/* ISP */
%token K_TIMEOUT
%token K_STABDELAY
%token K_CMDEXEDELAY
%token K_HVSPCMDEXEDELAY
%token K_SYNCHLOOPS
%token K_BYTEDELAY
%token K_POLLVALUE
%token K_POLLINDEX
%token K_PREDELAY
%token K_POSTDELAY
%token K_POLLMETHOD
%token K_MODE
%token K_DELAY
%token K_BLOCKSIZE
%token K_READSIZE
/* HV mode */
%token K_HVENTERSTABDELAY
%token K_PROGMODEDELAY
%token K_LATCHCYCLES
%token K_TOGGLEVTG
%token K_POWEROFFDELAY
%token K_RESETDELAYMS
%token K_RESETDELAYUS
%token K_HVLEAVESTABDELAY
%token K_RESETDELAY
%token K_SYNCHCYCLES
%token K_HVCMDEXEDELAY
%token K_CHIPERASEPULSEWIDTH
%token K_CHIPERASEPOLLTIMEOUT
%token K_CHIPERASETIME
%token K_PROGRAMFUSEPULSEWIDTH
%token K_PROGRAMFUSEPOLLTIMEOUT
%token K_PROGRAMLOCKPULSEWIDTH
%token K_PROGRAMLOCKPOLLTIMEOUT
%token K_PP_CONTROLSTACK
%token K_HVSP_CONTROLSTACK
/* JTAG ICE mkII specific parameters */
%token K_ALLOWFULLPAGEBITSTREAM /*
* Internal parameter for the JTAG
* ICE; describes the internal JTAG
* streaming behaviour inside the MCU.
* 1 for all older chips, 0 for newer
* MCUs.
*/
%token K_ENABLEPAGEPROGRAMMING /* ? yes for mega256*, mega406 */
%token K_HAS_JTAG /* MCU has JTAG i/f. */
%token K_IDR /* address of OCD register in IO space */
%token K_RAMPZ /* address of RAMPZ reg. in IO space */
%token K_SPMCR /* address of SPMC[S]R in memory space */
%token K_EECR /* address of EECR in memory space */
%token TKN_COMMA
%token TKN_EQUAL
%token TKN_SEMI
%token TKN_TILDE
%token TKN_NUMBER
%token TKN_STRING
%token TKN_ID
@@ -290,24 +365,78 @@ prog_parm :
}
} |
K_TYPE TKN_EQUAL K_SERBB {
{
serbb_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_STK500 {
{
stk500_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_STK500V2 {
{
stk500v2_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_STK500HVSP {
{
stk500hvsp_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_STK500PP {
{
stk500pp_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_STK500GENERIC {
{
stk500generic_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_AVR910 {
{
avr910_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_USBASP {
{
usbasp_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_BUTTERFLY {
{
butterfly_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_JTAG_MKI {
{
jtagmkI_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_JTAG_MKII {
{
jtagmkII_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_JTAG_MKII_ISP {
{
stk500v2_jtagmkII_initpgm(current_prog);
}
} |
K_DESC TKN_EQUAL TKN_STRING {
strncpy(current_prog->desc, $3->value.string, PGM_DESCLEN);
current_prog->desc[PGM_DESCLEN-1] = 0;
@@ -324,15 +453,7 @@ prog_parm :
while (lsize(number_list)) {
t = lrmv_n(number_list, 1);
pin = t->value.number;
if ((pin < 2) || (pin > 9)) {
fprintf(stderr,
"%s: error at line %d of %s: VCC must be one or more "
"pins from the range 2-9\n",
progname, lineno, infile);
exit(1);
}
current_prog->pinno[PPI_AVR_VCC] |= (1 << (pin-2));
current_prog->pinno[PPI_AVR_VCC] |= (1 << pin);
free_token(t);
}
@@ -349,15 +470,7 @@ prog_parm :
while (lsize(number_list)) {
t = lrmv_n(number_list, 1);
pin = t->value.number;
if ((pin < 2) || (pin > 9)) {
fprintf(stderr,
"%s: error at line %d of %s: BUFF must be one or more "
"pins from the range 2-9\n",
progname, lineno, infile);
exit(1);
}
current_prog->pinno[PPI_AVR_BUFF] |= (1 << (pin-2));
current_prog->pinno[PPI_AVR_BUFF] |= (1 << pin);
free_token(t);
}
@@ -371,15 +484,26 @@ prog_parm :
} |
K_RESET TKN_EQUAL TKN_NUMBER { free_token($1);
assign_pin(PIN_AVR_RESET, $3); } |
assign_pin(PIN_AVR_RESET, $3, 0); } |
K_SCK TKN_EQUAL TKN_NUMBER { free_token($1);
assign_pin(PIN_AVR_SCK, $3); } |
K_MOSI TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_MOSI, $3); } |
K_MISO TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_MISO, $3); } |
K_ERRLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_ERR, $3); } |
K_RDYLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_RDY, $3); } |
K_PGMLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_PGM, $3); } |
K_VFYLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_VFY, $3); }
assign_pin(PIN_AVR_SCK, $3, 0); } |
K_MOSI TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_MOSI, $3, 0); } |
K_MISO TKN_EQUAL TKN_NUMBER { assign_pin(PIN_AVR_MISO, $3, 0); } |
K_ERRLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_ERR, $3, 0); } |
K_RDYLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_RDY, $3, 0); } |
K_PGMLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_PGM, $3, 0); } |
K_VFYLED TKN_EQUAL TKN_NUMBER { assign_pin(PIN_LED_VFY, $3, 0); } |
K_RESET TKN_EQUAL TKN_TILDE TKN_NUMBER { free_token($1);
assign_pin(PIN_AVR_RESET, $4, 1); } |
K_SCK TKN_EQUAL TKN_TILDE TKN_NUMBER { free_token($1);
assign_pin(PIN_AVR_SCK, $4, 1); } |
K_MOSI TKN_EQUAL TKN_TILDE TKN_NUMBER { assign_pin(PIN_AVR_MOSI, $4, 1); } |
K_MISO TKN_EQUAL TKN_TILDE TKN_NUMBER { assign_pin(PIN_AVR_MISO, $4, 1); } |
K_ERRLED TKN_EQUAL TKN_TILDE TKN_NUMBER { assign_pin(PIN_LED_ERR, $4, 1); } |
K_RDYLED TKN_EQUAL TKN_TILDE TKN_NUMBER { assign_pin(PIN_LED_RDY, $4, 1); } |
K_PGMLED TKN_EQUAL TKN_TILDE TKN_NUMBER { assign_pin(PIN_LED_PGM, $4, 1); } |
K_VFYLED TKN_EQUAL TKN_TILDE TKN_NUMBER { assign_pin(PIN_LED_VFY, $4, 1); }
;
@@ -392,6 +516,7 @@ opcode :
K_WRITE_HI |
K_LOADPAGE_LO |
K_LOADPAGE_HI |
K_LOAD_EXT_ADDR |
K_WRITEPAGE |
K_CHIP_ERASE |
K_PGM_ENABLE
@@ -455,6 +580,101 @@ part_parm :
}
} |
K_SIGNATURE TKN_EQUAL TKN_NUMBER TKN_NUMBER TKN_NUMBER {
{
current_part->signature[0] = $3->value.number;
current_part->signature[1] = $4->value.number;
current_part->signature[2] = $5->value.number;
free_token($3);
free_token($4);
free_token($5);
}
} |
K_PP_CONTROLSTACK TKN_EQUAL num_list {
{
TOKEN * t;
unsigned nbytes;
int ok;
if (current_part->ctl_stack_type != CTL_STACK_NONE)
{
fprintf(stderr,
"%s: error at line %d of %s: "
"control stack already defined\n",
progname, lineno, infile);
exit(1);
}
current_part->ctl_stack_type = CTL_STACK_PP;
nbytes = 0;
ok = 1;
while (lsize(number_list)) {
t = lrmv_n(number_list, 1);
if (nbytes < CTL_STACK_SIZE)
{
current_part->controlstack[nbytes] = t->value.number;
nbytes++;
}
else
{
ok = 0;
}
free_token(t);
}
if (!ok)
{
fprintf(stderr,
"%s: Warning: line %d of %s: "
"too many bytes in control stack\n",
progname, lineno, infile);
}
}
} |
K_HVSP_CONTROLSTACK TKN_EQUAL num_list {
{
TOKEN * t;
unsigned nbytes;
int ok;
if (current_part->ctl_stack_type != CTL_STACK_NONE)
{
fprintf(stderr,
"%s: error at line %d of %s: "
"control stack already defined\n",
progname, lineno, infile);
exit(1);
}
current_part->ctl_stack_type = CTL_STACK_HVSP;
nbytes = 0;
ok = 1;
while (lsize(number_list)) {
t = lrmv_n(number_list, 1);
if (nbytes < CTL_STACK_SIZE)
{
current_part->controlstack[nbytes] = t->value.number;
nbytes++;
}
else
{
ok = 0;
}
free_token(t);
}
if (!ok)
{
fprintf(stderr,
"%s: Warning: line %d of %s: "
"too many bytes in control stack\n",
progname, lineno, infile);
}
}
} |
K_CHIP_ERASE_DELAY TKN_EQUAL TKN_NUMBER
{
current_part->chip_erase_delay = $3->value.number;
@@ -483,6 +703,228 @@ part_parm :
free_tokens(2, $1, $3);
} |
K_TIMEOUT TKN_EQUAL TKN_NUMBER
{
current_part->timeout = $3->value.number;
free_token($3);
} |
K_STABDELAY TKN_EQUAL TKN_NUMBER
{
current_part->stabdelay = $3->value.number;
free_token($3);
} |
K_CMDEXEDELAY TKN_EQUAL TKN_NUMBER
{
current_part->cmdexedelay = $3->value.number;
free_token($3);
} |
K_HVSPCMDEXEDELAY TKN_EQUAL TKN_NUMBER
{
current_part->hvspcmdexedelay = $3->value.number;
free_token($3);
} |
K_SYNCHLOOPS TKN_EQUAL TKN_NUMBER
{
current_part->synchloops = $3->value.number;
free_token($3);
} |
K_BYTEDELAY TKN_EQUAL TKN_NUMBER
{
current_part->bytedelay = $3->value.number;
free_token($3);
} |
K_POLLVALUE TKN_EQUAL TKN_NUMBER
{
current_part->pollvalue = $3->value.number;
free_token($3);
} |
K_POLLINDEX TKN_EQUAL TKN_NUMBER
{
current_part->pollindex = $3->value.number;
free_token($3);
} |
K_PREDELAY TKN_EQUAL TKN_NUMBER
{
current_part->predelay = $3->value.number;
free_token($3);
} |
K_POSTDELAY TKN_EQUAL TKN_NUMBER
{
current_part->postdelay = $3->value.number;
free_token($3);
} |
K_POLLMETHOD TKN_EQUAL TKN_NUMBER
{
current_part->pollmethod = $3->value.number;
free_token($3);
} |
K_HVENTERSTABDELAY TKN_EQUAL TKN_NUMBER
{
current_part->hventerstabdelay = $3->value.number;
free_token($3);
} |
K_PROGMODEDELAY TKN_EQUAL TKN_NUMBER
{
current_part->progmodedelay = $3->value.number;
free_token($3);
} |
K_LATCHCYCLES TKN_EQUAL TKN_NUMBER
{
current_part->latchcycles = $3->value.number;
free_token($3);
} |
K_TOGGLEVTG TKN_EQUAL TKN_NUMBER
{
current_part->togglevtg = $3->value.number;
free_token($3);
} |
K_POWEROFFDELAY TKN_EQUAL TKN_NUMBER
{
current_part->poweroffdelay = $3->value.number;
free_token($3);
} |
K_RESETDELAYMS TKN_EQUAL TKN_NUMBER
{
current_part->resetdelayms = $3->value.number;
free_token($3);
} |
K_RESETDELAYUS TKN_EQUAL TKN_NUMBER
{
current_part->resetdelayus = $3->value.number;
free_token($3);
} |
K_HVLEAVESTABDELAY TKN_EQUAL TKN_NUMBER
{
current_part->hvleavestabdelay = $3->value.number;
free_token($3);
} |
K_RESETDELAY TKN_EQUAL TKN_NUMBER
{
current_part->resetdelay = $3->value.number;
free_token($3);
} |
K_CHIPERASEPULSEWIDTH TKN_EQUAL TKN_NUMBER
{
current_part->chiperasepulsewidth = $3->value.number;
free_token($3);
} |
K_CHIPERASEPOLLTIMEOUT TKN_EQUAL TKN_NUMBER
{
current_part->chiperasepolltimeout = $3->value.number;
free_token($3);
} |
K_CHIPERASETIME TKN_EQUAL TKN_NUMBER
{
current_part->chiperasetime = $3->value.number;
free_token($3);
} |
K_PROGRAMFUSEPULSEWIDTH TKN_EQUAL TKN_NUMBER
{
current_part->programfusepulsewidth = $3->value.number;
free_token($3);
} |
K_PROGRAMFUSEPOLLTIMEOUT TKN_EQUAL TKN_NUMBER
{
current_part->programfusepolltimeout = $3->value.number;
free_token($3);
} |
K_PROGRAMLOCKPULSEWIDTH TKN_EQUAL TKN_NUMBER
{
current_part->programlockpulsewidth = $3->value.number;
free_token($3);
} |
K_PROGRAMLOCKPOLLTIMEOUT TKN_EQUAL TKN_NUMBER
{
current_part->programlockpolltimeout = $3->value.number;
free_token($3);
} |
K_SYNCHCYCLES TKN_EQUAL TKN_NUMBER
{
current_part->synchcycles = $3->value.number;
free_token($3);
} |
K_HAS_JTAG TKN_EQUAL yesno
{
if ($3->primary == K_YES)
current_part->flags |= AVRPART_HAS_JTAG;
else if ($3->primary == K_NO)
current_part->flags &= ~AVRPART_HAS_JTAG;
free_token($3);
} |
K_ALLOWFULLPAGEBITSTREAM TKN_EQUAL yesno
{
if ($3->primary == K_YES)
current_part->flags |= AVRPART_ALLOWFULLPAGEBITSTREAM;
else if ($3->primary == K_NO)
current_part->flags &= ~AVRPART_ALLOWFULLPAGEBITSTREAM;
free_token($3);
} |
K_ENABLEPAGEPROGRAMMING TKN_EQUAL yesno
{
if ($3->primary == K_YES)
current_part->flags |= AVRPART_ENABLEPAGEPROGRAMMING;
else if ($3->primary == K_NO)
current_part->flags &= ~AVRPART_ENABLEPAGEPROGRAMMING;
free_token($3);
} |
K_IDR TKN_EQUAL TKN_NUMBER
{
current_part->idr = $3->value.number;
free_token($3);
} |
K_RAMPZ TKN_EQUAL TKN_NUMBER
{
current_part->rampz = $3->value.number;
free_token($3);
} |
K_SPMCR TKN_EQUAL TKN_NUMBER
{
current_part->spmcr = $3->value.number;
free_token($3);
} |
K_EECR TKN_EQUAL TKN_NUMBER
{
current_part->eecr = $3->value.number;
free_token($3);
} |
K_SERIAL TKN_EQUAL yesno
{
if ($3->primary == K_YES)
@@ -630,6 +1072,38 @@ mem_spec :
free_token($3);
} |
K_MODE TKN_EQUAL TKN_NUMBER
{
current_mem->mode = $3->value.number;
free_token($3);
} |
K_DELAY TKN_EQUAL TKN_NUMBER
{
current_mem->delay = $3->value.number;
free_token($3);
} |
K_BLOCKSIZE TKN_EQUAL TKN_NUMBER
{
current_mem->blocksize = $3->value.number;
free_token($3);
} |
K_READSIZE TKN_EQUAL TKN_NUMBER
{
current_mem->readsize = $3->value.number;
free_token($3);
} |
K_POLLINDEX TKN_EQUAL TKN_NUMBER
{
current_mem->pollindex = $3->value.number;
free_token($3);
} |
opcode TKN_EQUAL string_list {
{
int opnum;
@@ -661,7 +1135,7 @@ static char * vtypestr(int type)
#endif
static int assign_pin(int pinno, TOKEN * v)
static int assign_pin(int pinno, TOKEN * v, int invert)
{
int value;
@@ -674,6 +1148,8 @@ static int assign_pin(int pinno, TOKEN * v)
progname, lineno, infile);
exit(1);
}
if (invert)
value |= PIN_INVERSE;
current_prog->pinno[pinno] = value;
@@ -692,6 +1168,7 @@ static int which_opcode(TOKEN * opcode)
case K_WRITE_HI : return AVR_OP_WRITE_HI; break;
case K_LOADPAGE_LO : return AVR_OP_LOADPAGE_LO; break;
case K_LOADPAGE_HI : return AVR_OP_LOADPAGE_HI; break;
case K_LOAD_EXT_ADDR : return AVR_OP_LOAD_EXT_ADDR; break;
case K_WRITEPAGE : return AVR_OP_WRITEPAGE; break;
case K_CHIP_ERASE : return AVR_OP_CHIP_ERASE; break;
case K_PGM_ENABLE : return AVR_OP_PGM_ENABLE; break;

View File

@@ -24,7 +24,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT(avrdude, 4.4.0, avrdude-dev@nongnu.org)
AC_INIT(avrdude, 5.2, avrdude-dev@nongnu.org)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
@@ -32,7 +32,7 @@ AC_CANONICAL_TARGET
AC_CONFIG_SRCDIR([main.c])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER([ac_cfg.h])
AM_CONFIG_HEADER([ac_cfg.h])
# Checks for programs.
AC_PROG_CC
@@ -44,6 +44,21 @@ AM_PROG_LEX
AC_CHECK_LIB([termcap], [tputs])
AC_CHECK_LIB([ncurses], [tputs])
AC_CHECK_LIB([readline], [readline])
AH_TEMPLATE([HAVE_LIBUSB],
[Define if USB support is enabled via libusb])
AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes])
if test x$have_libusb = xyes; then
case $target in
*-*-darwin*)
LIBUSB="-lusb -framework CoreFoundation -framework IOKit"
;;
*)
LIBUSB="-lusb"
;;
esac
AC_DEFINE([HAVE_LIBUSB])
fi
AC_SUBST(LIBUSB, $LIBUSB)
# Checks for header files.
AC_HEADER_STDC
@@ -56,7 +71,7 @@ AC_HEADER_TIME
# Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strtoul])
AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strtoul gettimeofday])
# Checks for misc stuff.
@@ -78,12 +93,49 @@ else
DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude'
fi
AC_ARG_ENABLE(
[doc],
AC_HELP_STRING(
[--enable-doc],
[Enable building documents(default)]),
[case "${enableval}" in
yes) enabled_doc=yes ;;
no) enabled_doc=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for disable-doc option) ;;
esac],
[enabled_doc=no])
AC_ARG_ENABLE(
[parport],
AC_HELP_STRING(
[--enable-parport],
[Enable accessing parallel ports(default)]),
[case "${enableval}" in
yes) enabled_parport=yes ;;
no) enabled_parport=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;;
esac],
[enabled_parport=yes])
if test "$enabled_doc" = "yes"; then
SUBDIRS_AC='doc @WINDOWS_DIRS@'
DIST_SUBDIRS_AC='doc windows'
else
SUBDIRS_AC='@WINDOWS_DIRS@'
DIST_SUBDIRS_AC='windows'
fi
AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR)
AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC)
AC_SUBST(DIST_SUBDIRS_AC, $DIST_SUBDIRS_AC)
# Find the parallel serial device files based on target system
# If a system doesn't have a PC style parallel, mark it as unknown.
case $target in
i[[3456]]86-*-linux*)
i[[3456]]86-*-linux*|x86_64-*-linux*)
DEFAULT_PAR_PORT="/dev/parport0"
DEFAULT_SER_PORT="/dev/ttyS0"
;;
@@ -91,7 +143,7 @@ case $target in
DEFAULT_PAR_PORT="unknown"
DEFAULT_SER_PORT="/dev/ttyS0"
;;
i[[3456]]86-*-freebsd*)
i[[3456]]86-*-freebsd*|amd64-*-freebsd*)
DEFAULT_PAR_PORT="/dev/ppi0"
DEFAULT_SER_PORT="/dev/cuaa0"
;;
@@ -99,6 +151,10 @@ case $target in
DEFAULT_PAR_PORT="unknown"
DEFAULT_SER_PORT="/dev/cuaa0"
;;
*-*-solaris*)
DEFAULT_PAR_PORT="/dev/printers/0"
DEFAULT_SER_PORT="/dev/term/a"
;;
*-*-msdos* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
DEFAULT_PAR_PORT="lpt1"
DEFAULT_SER_PORT="com1"
@@ -109,14 +165,29 @@ case $target in
;;
esac
AC_MSG_CHECKING([for parallel device])
AC_MSG_RESULT([$DEFAULT_PAR_PORT])
AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT)
if test "$enabled_parport" = "yes"; then
AC_MSG_CHECKING([for parallel device])
if test "$DEFAULT_PAR_PORT" = "unknown"; then
AC_MSG_NOTICE([parallel port access disabled for this system])
enabled_parport=no
else
AC_MSG_RESULT([$DEFAULT_PAR_PORT])
fi
AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT)
fi
AC_MSG_CHECKING([for serial device])
AC_MSG_RESULT([$DEFAULT_SER_PORT])
AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT)
if test "$enabled_parport" = "yes"; then
AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled])
confsubst="-e /^@HAVE_PARPORT_/d"
else
confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d"
fi
export confsubst
# See if we need to drop into the windows subdir.
case $target in
*-*-mingw32* | *-*-cygwin* | *-*-windows*)
@@ -133,11 +204,24 @@ if test "$GCC" = yes; then
fi
AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS)
if test "$enabled_doc" = "yes"; then
AC_CONFIG_FILES([doc/Makefile])
fi
AC_CONFIG_FILES([
doc/Makefile
windows/Makefile
avrdude.spec
avrdude.conf
Makefile
windows/Makefile
avrdude.spec
Makefile
])
# The procedure to create avrdude.conf involves two steps. First,
# normal autoconf substitution will be applied, resulting in
# avrdude.conf.tmp. Finally, a sed command will be applied to filter
# out unwanted parts (currently the parallel port programmer types)
# based on previous configuration results, thereby producing the final
# avrdude.conf file.
AC_CONFIG_FILES([avrdude.conf.tmp:avrdude.conf.in],
[sed $confsubst avrdude.conf.tmp > avrdude.conf])
AC_OUTPUT

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Eric B. Weddington <eric@ecentral.com>
* Copyright (C) 2003-2004 Eric B. Weddington <eric@ecentral.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Eric B. Weddington <eric@ecentral.com>
* Copyright (C) 2003-2004 Eric B. Weddington <eric@ecentral.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

83
avrdude/crc16.c Normal file
View File

@@ -0,0 +1,83 @@
/*
* Derived from CRC algorithm for JTAG ICE mkII, published in Atmel
* Appnote AVR067. Converted from C++ to C.
*/
#include "crc16.h"
/* CRC16 Definitions */
const unsigned short crc_table[256] = {
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
};
/* CRC calculation macros */
#define CRC_INIT 0xFFFF
#define CRC(crcval,newchar) crcval = (crcval >> 8) ^ \
crc_table[(crcval ^ newchar) & 0x00ff]
unsigned short
crcsum(const unsigned char* message, unsigned long length,
unsigned short crc)
{
unsigned long i;
for(i = 0; i < length; i++)
{
CRC(crc, message[i]);
}
return crc;
}
int
crcverify(const unsigned char* message, unsigned long length)
{
/*
* Returns true if the last two bytes in a message is the crc of the
* preceding bytes.
*/
unsigned short expected;
expected = crcsum(message, length - 2, CRC_INIT);
return (expected & 0xff) == message[length - 2] &&
((expected >> 8) & 0xff) == message[length - 1];
}
void
crcappend(unsigned char* message, unsigned long length)
{
unsigned long crc;
crc = crcsum(message, length, CRC_INIT);
message[length] = (unsigned char)(crc & 0xff);
message[length+1] = (unsigned char)((crc >> 8) & 0xff);
}

25
avrdude/crc16.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef CRC16_H
#define CRC16_H
/*
* Derived from CRC algorithm for JTAG ICE mkII, published in Atmel
* Appnote AVR067. Converted from C++ to C.
*/
extern unsigned short crcsum(const unsigned char* message,
unsigned long length,
unsigned short crc);
/*
* Verify that the last two bytes is a (LSB first) valid CRC of the
* message.
*/
extern int crcverify(const unsigned char* message,
unsigned long length);
/*
* Append a two byte CRC (LSB first) to message. length is size of
* message excluding crc. Space for the CRC bytes must be allocated
* in advance!
*/
extern void crcappend(unsigned char* message,
unsigned long length);
#endif

22
avrdude/doc/.cvsignore Normal file
View File

@@ -0,0 +1,22 @@
.cvsignore
Makefile
Makefile.in
avrdude-html
avrdude.aux
avrdude.cp
avrdude.cps
avrdude.dvi
avrdude.fn
avrdude.info
avrdude.ky
avrdude.log
avrdude.pdf
avrdude.pg
avrdude.ps
avrdude.toc
avrdude.tp
avrdude.vr
mdate-sh
stamp-vti
texinfo.tex
version.texi

View File

@@ -29,10 +29,16 @@ info_TEXINFOS = avrdude.texi
all-local: info html ps pdf
html:
mkdir -p avrdude-html
html: avrdude-html/avrdude.html
avrdude-html/avrdude.html: $(srcdir)/$(info_TEXINFOS)
texi2html -split_node $(srcdir)/$(info_TEXINFOS)
mv *.html avrdude-html
if [ -e ./avrdude.html -o -e ./avrdude_1.html ]; then \
mkdir -p avrdude-html ; \
mv -f *.html avrdude-html ; \
else \
mv -f avrdude avrdude-html; \
fi;
clean-local:
rm -rf avrdude-html *.info

View File

@@ -28,7 +28,9 @@ This file documents the avrdude program.
For avrdude version @value{VERSION}, @value{UPDATED}.
Copyright @copyright{} 2003 Brian Dean
Copyright @copyright{} 2003, 2005 Brian Dean
Copyright @copyright{} 2006 J@"org Wunsch
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -59,11 +61,13 @@ by the Free Software Foundation.
@author by Brian S. Dean
@page
@hfill (Send bugs and comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}.)
Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}.
@vfill
Use @uref{http://savannah.nongnu.org/bugs/?group=avrdude} to report bugs.
Copyright @copyright{} 2003 Brian S. Dean
Copyright @copyright{} 2003,2005 Brian S. Dean
Copyright @copyright{} 2006 J@"org Wunsch
@sp 2
Permission is granted to make and distribute verbatim copies of
@@ -94,6 +98,14 @@ This file documents the avrdude program for downloading/uploading
programs to Atmel AVR microcontrollers.
For avrdude version @value{VERSION}, @value{UPDATED}.
Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}.
Use @uref{http://savannah.nongnu.org/bugs/?group=avrdude} to report bugs.
Copyright @copyright{} 2003,2005 Brian S. Dean
Copyright @copyright{} 2006 J@"org Wunsch
@end ifinfo
@menu
@@ -129,24 +141,54 @@ from the contents of a file, while interactive mode is useful for
exploring memory contents, modifing individual bytes of eeprom,
programming fuse/lock bits, etc.
AVRDUDE supports three basic programmer types: Atmel's STK500, appnote
avr910 and the PPI (parallel port interface). PPI represents a class
AVRDUDE supports the following basic programmer types: Atmel's STK500,
Atmel's AVRISP and AVRISP mkII devices,
Atmel's JTAG ICE (both mkI and mkII, the latter also in ISP mode), appnote
avr910, appnote avr109 (including the AVR Butterfly),
serial bit-bang adapters,
and the PPI (parallel port interface). PPI represents a class
of simple programmers where the programming lines are directly
connected to the PC parallel port. Several pin configurations exist
for several variations of the PPI programmers, and AVRDUDE can be be
configured to work with them by either specifying the appropriate
programmer on the command line or by creating a new entry in its
configuration file. All that's usually required for a new entry is to
tell AVRDUDE which pins to use for each programming function.
tell AVRDUDE which pins to use for each programming function.
The STK500 and avr910 use the serial port to communicate with the PC
and contains on-board logic to control the programming of the target
device. The fundamental difference between the two types lies in the
A number of equally simple bit-bang programming adapters that connect
to a serial port are supported as well, among them the popular
Ponyprog serial adapter, and the DASA and DASA3 adapters that used to
be supported by uisp(1). Note that these adapters are meant to be
attached to a physical serial port. Connecting to a serial port
emulated on top of USB is likely to not work at all, or to work
abysmally slow.
The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC.
The STK500, JTAG ICE, and avr910 contain on-board logic to control the programming of the target
device.
The avr109 bootloader implements a protocol similar to avr910, but is
actually implemented in the boot area of the target's flash ROM, as
opposed to being an external device.
The fundamental difference between the two types lies in the
protocol used to control the programmer. The avr910 protocol is very
simplistic and can easily be used as the basis for a simple, home made
programer since the firmware is available online. On the other hand,
the STK500 protocol is more robust and complicated and the firmware is
not openly available.
The JTAG ICE also uses a serial communication protocol which is similar
to the STK500 firmware version 2 one. However, as the JTAG ICE is
intented to allow on-chip debugging as well as memory programming, the
protocol is more sophisticated.
(The JTAG ICE mkII protocol can also be run on top of USB.)
Only the memory programming functionality of the JTAG ICE is supported
by AVRDUDE.
For the JTAG ICE mkII, both JTAG and ISP mode are supported.
The USBasp ISP adapter is also supported, provided AVRDUDE
has been compiled with libusb support.
It features a simple firwmare-only USB implementation, running on
an ATmega8 (or ATmega88).
@menu
* History::
@@ -201,9 +243,9 @@ Roth.
@noindent
AVRDUDE is a command line tool, used as follows:
@example
@smallexample
avrdude -p partno @var{options} @dots{}
@end example
@end smallexample
@noindent
Command line options are used to control AVRDUDE's behaviour. The
@@ -220,88 +262,75 @@ but it can be added to the configuration file if you have the Atmel
datasheet so that you can enter the programming specifications.
Currently, the following MCU types are understood:
@table @code
@itemx 1200
AT90S1200
@multitable @columnfractions .15 .3
@item @code{c128} @tab AT90CAN128
@item @code{pwm2} @tab AT90PWM2
@item @code{pwm3} @tab AT90PWM3
@item @code{1200} @tab AT90S1200
@item @code{2313} @tab AT90S2313
@item @code{2333} @tab AT90S2333
@item @code{2343} @tab AT90S2343 (*)
@item @code{4414} @tab AT90S4414
@item @code{4433} @tab AT90S4433
@item @code{4434} @tab AT90S4434
@item @code{8515} @tab AT90S8515
@item @code{8535} @tab AT90S8535
@item @code{m103} @tab ATmega103
@item @code{m128} @tab ATmega128
@item @code{m1280} @tab ATmega1280
@item @code{m1281} @tab ATmega1281
@item @code{m16} @tab ATmega16
@item @code{m161} @tab ATmega161
@item @code{m162} @tab ATmega162
@item @code{m163} @tab ATmega163
@item @code{m164} @tab ATmega164
@item @code{m169} @tab ATmega169
@item @code{m2560} @tab ATmega2560 (**)
@item @code{m2561} @tab ATmega2561 (**)
@item @code{m32} @tab ATmega32
@item @code{m324} @tab ATmega324
@item @code{m329} @tab ATmega329
@item @code{m3290} @tab ATmega3290
@item @code{m48} @tab ATmega48
@item @code{m64} @tab ATmega64
@item @code{m640} @tab ATmega640
@item @code{m644} @tab ATmega644
@item @code{m649} @tab ATmega649
@item @code{m6490} @tab ATmega6490
@item @code{m8} @tab ATmega8
@item @code{m8515} @tab ATmega8515
@item @code{m8535} @tab ATmega8535
@item @code{m88} @tab ATmega88
@item @code{t12} @tab ATtiny12
@item @code{t13} @tab ATtiny13
@item @code{t15} @tab ATtiny15
@item @code{t2313} @tab ATtiny2313
@item @code{t25} @tab ATtiny25
@item @code{t26} @tab ATtiny26
@item @code{t45} @tab ATtiny45
@item @code{t85} @tab ATtiny85
@end multitable
@itemx 2313
AT90S2313
(*) The AT90S2323 and ATtiny22 use the same algorithm.
@itemx 2333
AT90S2333
(**) Flash addressing above 128 KB is not supported by all
programming hardware. Known to work are jtag2, stk500v2,
and bit-bang programmers.
@itemx 2343
AT90S2343 (*)
@item -b @var{baudrate}
Override the RS-232 connection baud rate specified in the respective
programmer's entry of the configuration file.
@itemx 4414
AT90S4414
@itemx 4433
AT90S4433
@itemx 4434
AT90S4434
@itemx 8515
AT90S8515
@itemx 8535
AT90S8535
@itemx m103
ATMEGA103
@itemx m128
ATMEGA128
@itemx m16
ATMEGA16
@itemx m161
ATMEGA161
@itemx m162
ATMEGA162
@itemx m163
ATMEGA163
@itemx m169
ATMEGA169
@itemx m32
ATMEGA32
@itemx m48
ATMEGA48
@itemx m64
ATMEGA64
@itemx m8
ATMEGA8
@itemx m8515
ATMEGA8515
@itemx m8535
ATMEGA8535
@itemx m88
ATMEGA88
@itemx t12
ATtiny12
@itemx t15
ATtiny15
@itemx t26
ATTINY26
@end table
(*) The AT90S2323 uses the same algorithm.
@item -B @var{bitclock}
Specify the bit clock period for the JTAG interface or the ISP clock (JTAG ICE only).
The value is a floating-point number in microseconds.
The default value of the JTAG ICE results in about 1 microsecond bit
clock period, suitable for target MCUs running at 4 MHz clock and
above.
Unlike certain parameters in the STK500, the JTAG ICE resets all its
parameters to default values when the programming software signs
off from the ICE, so for MCUs running at lower clock speeds, this
parameter must be specified on the command-line.
@item -c @var{programmer-id}
Specify the programmer to be used. AVRDUDE knows about several common
@@ -315,51 +344,73 @@ file without any code changes to AVRDUDE. Simply copy an existing entry
and change the pin definitions to match that of the unknown programmer.
Currently, the following programmer ids are understood and supported:
@table @code
@itemx abcmini
@multitable @columnfractions .2 .6
@item @code{abcmini} @tab
ABCmini Board, aka Dick Smith HOTCHIP
@itemx alf
Nightshade ALF-PgmAVR, http://nightshade.homeip.net/
@itemx avr910
@item @code{alf} @tab
Nightshade ALF-PgmAVR,@*
@url{http://nightshade.homeip.net/}
@item @code{avr109} @tab
Atmel AppNote AVR109 Boot Loader
@item @code{avr910} @tab
Atmel Low Cost Serial Programmer
@itemx avrisp
Atmel AVR ISP
@itemx bascom
@item @code{avr911} @tab
Atmel AppNote AVR911 AVROSP (an alias for avr109)
@item @code{avrisp} @tab
Atmel AVR ISP (an alias for stk500)
@item @code{avrispv2} @tab
Atmel AVR ISP, running a version 2.x firmware (an alias for stk500v2)
@item @code{avrispmkII} @tab
Atmel AVR ISP mkII (alias for stk500v2)
@item @code{avrispmk2} @tab
Atmel AVR ISP mkII (alias for stk500v2)
@item @code{bascom} @tab
Bascom SAMPLE programming cable
@itemx bsd
Brian Dean's Programmer, http://www.bsdhome.com/avrdude/
@itemx butterfly
@item @code{bsd} @tab
Brian Dean's Programmer,@*
@url{http://www.bsdhome.com/avrdude/}
@item @code{butterfly} @tab
Atmel Butterfly Development Board
@itemx dt006
@item @code{dt006} @tab
Dontronics DT006
@itemx pavr
@item @code{jtagmkI} @tab
Atmel JTAG ICE mkI, running at 115200 Bd
@item @code{jtag1} @tab
@emph{Same as before.}
@item @code{jtag1slow} @tab
Atmel JTAG ICE mkI, running at 19200 Bd
@item @code{jtagmkII} @tab
Atmel JTAG ICE mkII (default speed 19200 Bd)
@item @code{jtag2slow} @tab
@emph{Same as before.}
@item @code{jtag2fast} @tab
Atmel JTAG ICE mkII, running at 115200 Bd
@item @code{jtag2} @tab
@emph{Same as before.}
@item @code{jtag2isp} @tab
Atmel JTAG ICE mkII in ISP mode.
@item @code{pavr} @tab
Jason Kyle's pAVR Serial Programmer
@itemx picoweb
Picoweb Programming Cable, http://www.picoweb.net/
@itemx pony-stk200
@item @code{picoweb} @tab
Picoweb Programming Cable,@*
@url{http://www.picoweb.net/}
@item @code{pony-stk200} @tab
Pony Prog STK200
@itemx sp12
@item @code{sp12} @tab
Steve Bolt's Programmer
@itemx stk200
@item @code{stk200} @tab
STK200
@itemx stk500
Atmel STK500
@end table
@item @code{stk500} @tab
Atmel STK500, probing for either version 1.x or 2.x firmware
@item @code{stk500v1} @tab
Atmel STK500, running a version 1.x firmware
@item @code{stk500hvsp} @tab
Atmel STK500 in high-voltage serial programming mode(version 2.x firmware only)
@item @code{stk500pp} @tab
Atmel STK500 in parallel programming mode (version 2.xfirmware only)
@item @code{stk500v2} @tab
Atmel STK500, running a version 2.x firmware
@end multitable
@@ -433,10 +484,34 @@ to time that a device has a broken (erased or overwritten) device
signature but is otherwise operating normally, this options is provided
to override the check.
@item -i @var{delay}
For bitbang-type programmers, delay for approximately
@var{delay}
microseconds between each bit state change.
If the host system is very fast, or the target runs off a slow clock
(like a 32 kHz crystal, or the 128 kHz internal RC oscillator), this
can become necessary to satisfy the requirement that the ISP clock
frequency must not be higher than 1/4 of the CPU clock frequency.
This is implemented as a spin-loop delay to allow even for very
short delays.
On Unix-style operating systems, the spin loop is initially calibrated
against a system timer, so the number of microseconds might be rather
realistic, assuming a constant system load while AVRDUDE is running.
On Win32 operating systems, a preconfigured number of cycles per
microsecond is assumed that might be off a bit for very fast or very
slow machines.
@item -n
No-write - disables actually writing data to the MCU (useful for
debugging AVRDUDE).
@item -O
Perform a RC oscillator run-time calibration according to Atmel
application note AVR053.
This is only supported on the STK500v2, AVRISP mkII, and JTAG ICE mkII
hardware.
Note that the result will be stored in the EEPROM cell at address 0.
@item -P @var{port}
Use port to identify the device to which the programmer is attached.
Normally, the default parallel port is used, but if the programmer type
@@ -445,9 +520,47 @@ used. See Appendix A, Platform Dependent Information, to find out the
default port names for your platform. If you need to use a different
parallel or serial port, use this option to specify the alternate port name.
For the JTAG ICE mkII, if AVRDUDE has been built with libusb support,
@var{port} may alternatively be specified as
@code{usb}[:@var{serialno}]. In that case, the JTAG ICE mkII will be
looked up on USB. If @var{serialno} is also specified, it will be
matched against the serial number read from any JTAG ICE mkII found on
USB. The match is done after stripping any existing colons from the
given serial number, and right-to-left, so only the least significant
bytes from the serial number need to be given.
For a trick how to find out the serial numbers of all JTAG ICEs
attached to USB, see @ref{Example Command Line Invocations}.
As the AVRISP mkII device can only be talked to over USB, the very
same method of specifying the port is required there.
For programmers that attach to a serial port using some kind of
higher level protocol (as opposed to bit-bang style programmers),
@var{port} can be specified as @code{net}:@var{host}:@var{port}.
In this case, instead of trying to open a local device, a TCP
network connection to (TCP) @var{port} on @var{host}
is established.
The remote endpoint is assumed to be a terminal or console server
that connects the network stream to a local serial port where the
actual programmer has been attached to.
The port is assumed to be properly configured, for example using a
transparent 8-bit data connection without parity at 115200 Baud
for a STK500.
@emph{This feature is currently not implemented for Win32 systems.}
@item -q
Disable (or quell) output of the progress bar while reading or writing
to the device.
to the device. Specify it a second time for even quieter operation.
@item -u
Disables the default behaviour of reading out the fuses three times before
programming, then verifying at the end of programming that the fuses have not
changed. If you want to change fuses you will need to specify this option,
as avrdude will see the fuses have changed (even though you wanted to) and
will change them back for your "saftey". This option was designed to
prevent cases of fuse bits magically changing (usually called @emph{safemode}).
@item -t
Tells AVRDUDE to enter the interactive ``terminal'' mode instead of up-
@@ -463,6 +576,33 @@ mulitple memories on the same command-line invocation. The
the @option{-v} option on the command line or the @code{part} command from
terminal mode to display all the memory types supported by a particular
device.
Typically, a device's memory configuration at least contains
the memory types
@code{flash}
and
@code{eeprom}.
All memory types currently known are:
@table @code
@item calibration
One or more bytes of RC oscillator calibration data.
@item eeprom
The EEPROM of the device.
@item efuse
The extended fuse byte.
@item flash
The flash ROM of the device.
@item fuse
The fuse byte in devices that have only a single fuse byte.
@item hfuse
The high fuse byte.
@item lfuse
The low fuse byte.
@item lock
The lock byte.
@item signature
The three device signature bytes (device ID).
@end table
The @var{op} field specifies what operation to perform:
@table @code
@@ -505,6 +645,23 @@ treated as decimal.
auto detect; valid for input only, and only if the input is not provided
at stdin.
@itemx d
decimal; this and the following formats are only valid on output.
They generate one line of output for the respective memory section,
forming a comma-separated list of the values.
This can be particularly useful for subsequent processing, like for
fuse bit settings.
@itemx h
hexadecimal; each value will get the string @emph{0x} prepended.
@itemx o
octal; each value will get a @emph{0}
prepended unless it is less than 8 in which case it gets no prefix.
@itemx b
binary; each value will get the string @emph{0b} prepended.
@end table
The default is to use auto detection for input files, and raw binary
@@ -514,6 +671,11 @@ Note that if @var{filename} contains a colon, the @var{format} field is
no longer optional since the filename part following the colon would
otherwise be misinterpreted as @var{format}.
As an abbreviation, the form @code{-U} @var{filename}
is equivalent to specifying
@code{-U} @emph{flash:w:}@var{filename}@emph{:a}.
This will only work if @var{filename} does not have a colon in it.
@item -v
Enable verbose output.
@@ -543,6 +705,7 @@ should not be used.
@end table
@page
@c
@c Node
@c
@@ -553,7 +716,7 @@ should not be used.
Download the file @code{diag.hex} to the ATmega128 chip using the
STK500 programmer connected to the default serial port:
@example
@smallexample
@cartouche
% avrdude -p m128 -c stk500 -e -U flash:w:diag.hex
@@ -583,18 +746,21 @@ Reading | ################################################## | 100% 6.83s
avrdude: verifying ...
avrdude: 19278 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
%
@end cartouche
@end example
@end smallexample
@page
@noindent
Upload the flash memory from the ATmega128 connected to the STK500
programmer and save it in raw binary format in the file named
@code{c:/diag flash.bin}:
@example
@smallexample
@cartouche
% avrdude -p m128 -c stk500 -U flash:r:"c:/diag flash.bin":r
@@ -609,21 +775,24 @@ Reading | ################################################## | 100% 46.10s
avrdude: writing output file "c:/diag flash.bin"
avrdude: safemode: Fuses OK
avrdude done. Thank you.
%
@end cartouche
@end example
@end smallexample
@page
@noindent
Using the default programmer, download the file @code{diag.hex} to
flash, @code{eeprom.hex} to EEPROM, and set the Extended, High, and Low
fuse bytes to 0xff, 0x89, and 0x2e respectively:
@example
@smallexample
@cartouche
% avrdude -p m128 -U flash:w:diag.hex \
% avrdude -p m128 -u -U flash:w:diag.hex \
> -U eeprom:w:eeprom.hex \
> -U efuse:w:0xff:m \
> -U hfuse:w:0x89:m \
@@ -661,8 +830,50 @@ avrdude done. Thank you.
%
@end cartouche
@end example
@end smallexample
@page
@noindent
Connect to the JTAG ICE mkII which serial number ends up in 1C37 via
USB, and enter terminal mode:
@smallexample
@cartouche
% avrdude -c jtag2 -p m649 -P usb:1c:37 -t
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.03s
avrdude: Device signature = 0x1e9603
[ ... terminal mode output skipped for brevity ... ]
avrdude done. Thank you.
@end cartouche
@end smallexample
@noindent
List the serial numbers of all JTAG ICEs attached to USB. This is
done by specifying an invalid serial number, and increasing the
verbosity level.
@smallexample
@cartouche
% avrdude -c jtag2 -p m128 -P usb:xx -v
[...]
Using Port : usb:xxx
Using Programmer : jtag2
avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C6B
avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C3A
avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C30
avrdude: usbdev_open(): did not find any (matching) USB device "usb:xxx"
@end cartouche
@end smallexample
@c
@@ -720,7 +931,9 @@ command.
Display the device signature bytes.
@item part
Display the current part settings.
Display the current part settings and parameters. Includes chip
specific information including all memory types supported by the
device, read/write timing, etc.
@item ?
@itemx help
@@ -754,11 +967,24 @@ multiplies by 1E6, a trailing letter @var{k} by 1E3.
Turn the master oscillator off.
@item sck @var{period}
@emph{STK500 only:}
Set the SCK clock period to @var{period} microseconds.
@emph{JTAG ICE only:}
Set the JTAG ICE bit clock period to @var{period} microseconds.
Note that unlike STK500 settings, this setting will be reverted to
its default value (approximately 1 microsecond) when the programming
software signs off from the JTAG ICE.
This parameter can also be used on the JTAG ICE mkII to specify the
ISP clock period when operating the ICE in ISP mode.
@item parms
@emph{STK500 only:}
Display the current voltage and master oscillator parameters.
@emph{JTAG ICE only:}
Display the current target supply voltage and JTAG bit clock rate/period.
@end table
@c
@@ -770,7 +996,7 @@ Display the current voltage and master oscillator parameters.
@noindent
Display part parameters, modify eeprom cells, perform a chip erase:
@example
@smallexample
@cartouche
% avrdude -p m128 -c stk500 -t
@@ -822,17 +1048,19 @@ avrdude> dump eeprom 0 16
avrdude>
@end cartouche
@end example
@end smallexample
@noindent
Program the fuse bits of an ATmega128 (disable M103 compatibility,
enable high speed external crystal, enable brown-out detection, slowly
rising power). First display the factory defaults, then reprogram:
rising power). Note since we are working with fuse bits the -u (unsafe)
option is specified, which allows you to modify the fuse bits. First
display the factory defaults, then reprogram:
@example
@smallexample
@cartouche
% avrdude -p m128 -c stk500 -t
% avrdude -p m128 -u -c stk500 -t
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9702
@@ -860,7 +1088,7 @@ avrdude> w lfuse 0 0x2f
avrdude>
@end cartouche
@end example
@end smallexample
@c
@@ -929,12 +1157,12 @@ option.
@noindent
The format of the programmer definition is as follows:
@example
@smallexample
programmer
id = <id1> [, <id2> [, <id3>] ...] ; # <idN> are quoted strings
desc = <description> ; # quoted string
type = par | stk500 ; # programmer type
baudrate = <num> ; # baudrate for avr910
baudrate = <num> ; # baudrate for serial ports
vcc = <num1> [, <num2> ... ] ; # pin number(s)
reset = <num> ; # pin number
sck = <num> ; # pin number
@@ -945,7 +1173,7 @@ programmer
pgmled = <num> ; # pin number
vfyled = <num> ; # pin number
;
@end example
@end smallexample
@c
@@ -954,7 +1182,7 @@ programmer
@node Part Definitions, Other Notes, Programmer Definitions, Configuration File
@section Part Definitions
@example
@smallexample
part
id = <id> ; # quoted string
desc = <description> ; # quoted string
@@ -987,7 +1215,7 @@ part
writepage = <instruction format> ;
;
;
@end example
@end smallexample
@menu
* Instruction Format::
@@ -1036,7 +1264,7 @@ specification closely follows the instruction data provided in Atmel's
data sheets for their parts. For example, the EEPROM read and write
instruction for an AT90S2313 AVR part could be encoded as:
@example
@smallexample
read = "1 0 1 0 0 0 0 0 x x x x x x x x",
"x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
@@ -1044,7 +1272,7 @@ read = "1 0 1 0 0 0 0 0 x x x x x x x x",
write = "1 1 0 0 0 0 0 0 x x x x x x x x",
"x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
@end example
@end smallexample
@@ -1087,6 +1315,24 @@ problem with the at90s4433/2333's; see the at90s4433 errata at:
@url{http://www.atmel.com/atmel/acrobat/doc1280.pdf}
@item
The boot loader from application note AVR109 (and thus also the AVR
Butterfly) does not support writing of fuse bits. Writing lock bits
is supported, but is restricted to the boot lock bits (BLBxx). These
are restrictions imposed by the underlying SPM instruction that is used
to program the device from inside the boot loader. Note that programming
the boot lock bits can result in a ``shoot-into-your-foot'' scenario as
the only way to unprogram these bits is a chip erase, which will also
erase the boot loader code.
The boot loader implements the ``chip erase'' function by erasing the
flash pages of the application section.
Reading fuse and lock bits is fully supported.
Note that due to the unability to write the fuse bits, the safemode
functionality does not make sense for these boot loaders.
@end itemize
@@ -1256,6 +1502,9 @@ The following table lists the default names for a given system.
@item Linux
@tab @code{/dev/parport0}
@tab @code{/dev/ttyS0}
@item Solaris
@tab @code{/dev/printers/0}
@tab @code{/dev/term/a}
@end multitable
On FreeBSD systems, AVRDUDE uses the ppi(4) interface for
@@ -1266,6 +1515,10 @@ On Linux systems, AVRDUDE uses the ppdev interface for
accessing the parallel port and the tty driver for serial port
access.
On Solaris systems, AVRDUDE uses the ecpp(7D) driver for
accessing the parallel port and the asy(7D) driver for serial port
access.
@c
@c Node
@c
@@ -1540,6 +1793,12 @@ line driven and for writing the batch files.
@node Troubleshooting, ,Platform Dependent Information ,Top
@appendix Troubleshooting
@noindent
In general, please report any bugs encountered via
@*
@url{http://savannah.nongnu.org/bugs/?group=avrdude}.
@itemize @bullet
@item
@@ -1578,7 +1837,75 @@ Problem: I'm not using linux and my AVR910 programmer is really slow.
Solutions: The reasons for this are the same as above.
If you know how to work around this on your OS, please let us know.
@item
Problem: Updating the flash ROM from terminal mode does not work with the
JTAG ICEs.
Solution: None at this time. Currently, the JTAG ICE code cannot
write to the flash ROM one byte at a time.
@item
Problem: Page-mode programming the EEPROM (using the -U option) does
not erase EEPROM cells before writing, and thus cannot overwrite any
previous value != 0xff.
Solution: None. This is an inherent feature of the way JTAG EEPROM
programming works, and is documented that way in the Atmel AVR
datasheets.
In order to successfully program the EEPROM that way, a prior chip
erase (with the EESAVE fuse unprogrammed) is required.
This also applies to the STK500 in high-voltage programming mode.
@item
Problem: How do I turn off the @var{DWEN} fuse?
Solution: If the @var{DWEN} (debugWire enable) fuse is activated,
the @var{/RESET} pin is not functional anymore, so normal ISP
communication cannot be established.
There are two options to deactivate that fuse again: high-voltage
programming, or getting the JTAG ICE mkII talk debugWire, and
prepare the target AVR to accept normal ISP communication again.
The first option requires a programmer that is capable of high-voltage
programming (either serial or parallel, depending on the AVR device),
for example the STK500. In high-voltage programming mode, the
@var{/RESET} pin is activated initially using a 12 V pulse (thus the
name @emph{high voltage}), so the target AVR can subsequently be
reprogrammed, and the @var{DWEN} fuse can be cleared. Typically, this
operation cannot be performed while the AVR is located in the target
circuit though.
The second option requires a JTAG ICE mkII that can talk the debugWire
protocol. The ICE needs to be connected to the target using the
JTAG-to-ISP adapter, so the JTAG ICE mkII can be used as a debugWire
initiator as well as an ISP programmer. AVRDUDE will then be activated
using the @var{jtag2isp} programmer type. The initial ISP
communication attempt will fail, but AVRDUDE then tries to iniate a
debugWire reset. When successful, this will leave the target AVR in a
state where it can accept standard ISP communication. The ICE is then
signed off (which will make it signing off from the USB as well), so
AVRDUDE has to be called again afterwards. This time, standard ISP
communication can work, so the @var{DWEN} fuse can be cleared.
The pin mapping for the JTAG-to-ISP adapter is:
@multitable @columnfractions .2 .2
@item @strong{JTAG pin} @tab @strong{ISP pin}
@item 1 @tab 3
@item 2 @tab 6
@item 3 @tab 1
@item 4 @tab 2
@item 6 @tab 5
@item 9 @tab 4
@end multitable
@item
Problem: Multiple USBasp programmers connected simultaneously are not
found.
Solution: none at this time. The simplicity of the USBasp programmer
doesn't offer a method to distinguish multiple programmers that are
connected simultaneously, so effectively only one USBasp is supported.
@end itemize

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -48,6 +48,7 @@ struct ihexrec {
extern char * progname;
extern char progbuf[];
extern int quell_progress;
int b2ihex(unsigned char * inbuf, int bufsize,
int recsize, int startaddr,
@@ -76,6 +77,10 @@ int fileio_ihex(struct fioparms * fio,
int fileio_srec(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size);
int fileio_num(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size,
FILEFMT fmt);
int fmt_autodetect(char * fname);
@@ -657,6 +662,45 @@ int srec2b(char * infile, FILE * inf,
return maxaddr;
}
/*
* Simple itoa() implementation. Caller needs to allocate enough
* space in buf. Only positive integers are handled.
*/
static char *itoa_simple(int n, char *buf, int base)
{
div_t q;
char c, *cp, *cp2;
cp = buf;
/*
* Divide by base until the number disappeared, but ensure at least
* one digit will be emitted.
*/
do {
q = div(n, base);
n = q.quot;
if (q.rem >= 10)
c = q.rem - 10 + 'a';
else
c = q.rem + '0';
*cp++ = c;
} while (q.quot != 0);
/* Terminate the string. */
*cp-- = '\0';
/* Now revert the result string. */
cp2 = buf;
while (cp > cp2) {
c = *cp;
*cp-- = *cp2;
*cp2++ = c;
}
return buf;
}
int fileio_rbin(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size)
@@ -792,6 +836,78 @@ int fileio_srec(struct fioparms * fio,
}
int fileio_num(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size,
FILEFMT fmt)
{
const char *prefix;
char cbuf[20];
int base, i, num;
switch (fmt) {
case FMT_HEX:
prefix = "0x";
base = 16;
break;
default:
case FMT_DEC:
prefix = "";
base = 10;
break;
case FMT_OCT:
prefix = "0";
base = 8;
break;
case FMT_BIN:
prefix = "0b";
base = 2;
break;
}
switch (fio->op) {
case FIO_WRITE:
break;
default:
fprintf(stderr, "%s: fileio: invalid operation=%d\n",
progname, fio->op);
return -1;
}
for (i = 0; i < size; i++) {
if (i > 0) {
if (putc(',', f) == EOF)
goto writeerr;
}
num = (unsigned int)buf[i];
/*
* For a base of 8 and a value < 8 to convert, don't write the
* prefix. The conversion will be indistinguishable from a
* decimal one then.
*/
if (prefix[0] != '\0' && !(base == 8 && num < 8)) {
if (fputs(prefix, f) == EOF)
goto writeerr;
}
itoa_simple(num, cbuf, base);
if (fputs(cbuf, f) == EOF)
goto writeerr;
}
if (putc('\n', f) == EOF)
goto writeerr;
return 0;
writeerr:
fprintf(stderr, "%s: error writing to %s: %s\n",
progname, filename, strerror(errno));
return -1;
}
int fileio_setparms(int op, struct fioparms * fp)
{
fp->op = op;
@@ -910,7 +1026,7 @@ int fileio(int op, char * filename, FILEFMT format,
if (rc < 0)
return -1;
#if defined(WIN32NATIVE)
#if defined(WIN32NATIVE)
/* Open Raw Binary format in binary mode on Windows.*/
if(format == FMT_RBIN)
{
@@ -923,7 +1039,7 @@ int fileio(int op, char * filename, FILEFMT format,
fio.mode = "wb";
}
}
#endif
#endif
/* point at the requested memory buffer */
buf = mem->buf;
@@ -970,8 +1086,10 @@ int fileio(int op, char * filename, FILEFMT format,
return -1;
}
fprintf(stderr, "%s: %s file %s auto detected as %s\n",
progname, fio.iodesc, fname, fmtstr(format));
if (quell_progress < 2) {
fprintf(stderr, "%s: %s file %s auto detected as %s\n",
progname, fio.iodesc, fname, fmtstr(format));
}
}
if (format != FMT_IMM) {
@@ -1002,6 +1120,13 @@ int fileio(int op, char * filename, FILEFMT format,
rc = fileio_imm(&fio, fname, f, buf, size);
break;
case FMT_HEX:
case FMT_DEC:
case FMT_OCT:
case FMT_BIN:
rc = fileio_num(&fio, fname, f, buf, size, format);
break;
default:
fprintf(stderr, "%s: invalid %s file format: %d\n",
progname, fio.iodesc, format);

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,7 +27,11 @@ typedef enum {
FMT_SREC,
FMT_IHEX,
FMT_RBIN,
FMT_IMM
FMT_IMM,
FMT_HEX,
FMT_DEC,
FMT_OCT,
FMT_BIN
} FILEFMT;
struct fioparms {

40
avrdude/freebsd_ppi.h Normal file
View File

@@ -0,0 +1,40 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2005 Joerg Wunsch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef freebsd_ppi_h
#define freebsd_ppi_h
#include <dev/ppbus/ppi.h>
#define ppi_claim(fd) {}
#define ppi_release(fd) {}
#define DO_PPI_READ(fd, reg, valp) \
(void)ioctl(fd, \
(reg) == PPIDATA? PPIGDATA: ((reg) == PPICTRL? PPIGCTRL: PPIGSTATUS), \
valp)
#define DO_PPI_WRITE(fd, reg, valp) \
(void)ioctl(fd, \
(reg) == PPIDATA? PPISDATA: ((reg) == PPICTRL? PPISCTRL: PPISSTATUS), \
valp)
#endif /* freebsd_ppi_h */

1392
avrdude/jtagmkI.c Normal file

File diff suppressed because it is too large Load Diff

28
avrdude/jtagmkI.h Normal file
View File

@@ -0,0 +1,28 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef jtagmkI_h
#define jtagmkI_h
void jtagmkI_initpgm (PROGRAMMER * pgm);
#endif

1915
avrdude/jtagmkII.c Normal file

File diff suppressed because it is too large Load Diff

35
avrdude/jtagmkII.h Normal file
View File

@@ -0,0 +1,35 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2002-2004, 2006 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef jtagmkII_h
#define jtagmkII_h
int jtagmkII_send(PROGRAMMER * pgm, unsigned char * data, size_t len);
int jtagmkII_recv(PROGRAMMER * pgm, unsigned char **msg);
void jtagmkII_close(PROGRAMMER * pgm);
int jtagmkII_getsync(PROGRAMMER * pgm, int mode);
int jtagmkII_getparm(PROGRAMMER * pgm, unsigned char parm,
unsigned char * value);
void jtagmkII_initpgm (PROGRAMMER * pgm);
#endif

296
avrdude/jtagmkII_private.h Normal file
View File

@@ -0,0 +1,296 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2005, 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
/*
* JTAG ICE mkII definitions
* Taken from Appnote AVR067
*/
#if !defined(JTAGMKII_PRIVATE_EXPORTED)
/*
* Communication with the JTAG ICE works in frames. The protocol
* somewhat resembles the STK500v2 protocol, yet it is sufficiently
* different to prevent a direct code reuse. :-(
*
* Frame format:
*
* +---------------------------------------------------------------+
* | 0 | 1 . 2 | 3 . 4 . 5 . 6 | 7 | ... | N-1 . N |
* | | | | | | |
* | start | LSB MSB | LSB ....... MSB | token | msg | LSB MSB |
* | 0x1B | sequence# | message size | 0x0E | | CRC16 |
* +---------------------------------------------------------------+
*
* Each request message will be returned by a response with a matching
* sequence #. Sequence # 0xffff is reserved for asynchronous event
* notifications that will be sent by the ICE without a request
* message (e.g. when the target hit a breakpoint).
*
* The message size excludes the framing overhead (10 bytes).
*
* The first byte of the message is always the request or response
* code, which is roughly classified as:
*
* . Messages (commands) use 0x00 through 0x3f. (The documentation
* claims that messages start at 0x01, but actually CMND_SIGN_OFF is
* 0x00.)
* . Internal commands use 0x40 through 0x7f (not documented).
* . Success responses use 0x80 through 0x9f.
* . Failure responses use 0xa0 through 0xbf.
* . Events use 0xe0 through 0xff.
*/
#define MESSAGE_START 0x1b
#define TOKEN 0x0e
/*
* Max message size we are willing to accept. Prevents us from trying
* to allocate too much VM in case we received a nonsensical packet
* length. We have to allocate the buffer as soon as we've got the
* length information (and thus have to trust that information by that
* time at first), as the final CRC check can only be done once the
* entire packet came it.
*/
#define MAX_MESSAGE 100000
#endif /* JTAGMKII_PRIVATE_EXPORTED */
/* ICE command codes */
#define CMND_CHIP_ERASE 0x13
#define CMND_CLEAR_EVENTS 0x22
#define CMND_CLR_BREAK 0x1A
#define CMND_ENTER_PROGMODE 0x14
#define CMND_ERASEPAGE_SPM 0x0D
#define CMND_FORCED_STOP 0x0A
#define CMND_GET_BREAK 0x12
#define CMND_GET_PARAMETER 0x03
#define CMND_GET_SIGN_ON 0x01
#define CMND_GET_SYNC 0x0f
#define CMND_GO 0x08
#define CMND_ISP_PACKET 0x2F
#define CMND_LEAVE_PROGMODE 0x15
#define CMND_READ_MEMORY 0x05
#define CMND_READ_PC 0x07
#define CMND_RESET 0x0B
#define CMND_RESTORE_TARGET 0x23
#define CMND_RUN_TO_ADDR 0x1C
#define CMND_SELFTEST 0x10
#define CMND_SET_BREAK 0x11
#define CMND_SET_DEVICE_DESCRIPTOR 0x0C
#define CMND_SET_N_PARAMETERS 0x16
#define CMND_SET_PARAMETER 0x02
#define CMND_SIGN_OFF 0x00
#define CMND_SINGLE_STEP 0x09
#define CMND_SPI_CMD 0x1D
#define CMND_WRITE_MEMORY 0x04
#define CMND_WRITE_PC 0x06
/* ICE responses */
#define RSP_DEBUGWIRE_SYNC_FAILED 0xAC
#define RSP_FAILED 0xA0
#define RSP_GET_BREAK 0x83
#define RSP_ILLEGAL_BREAKPOINT 0xA8
#define RSP_ILLEGAL_COMMAND 0xAA
#define RSP_ILLEGAL_EMULATOR_MODE 0xA4
#define RSP_ILLEGAL_JTAG_ID 0xA9
#define RSP_ILLEGAL_MCU_STATE 0xA5
#define RSP_ILLEGAL_MEMORY_TYPE 0xA2
#define RSP_ILLEGAL_MEMORY_RANGE 0xA3
#define RSP_ILLEGAL_PARAMETER 0xA1
#define RSP_ILLEGAL_POWER_STATE 0xAD
#define RSP_ILLEGAL_VALUE 0xA6
#define RSP_MEMORY 0x82
#define RSP_NO_TARGET_POWER 0xAB
#define RSP_OK 0x80
#define RSP_PARAMETER 0x81
#define RSP_PC 0x84
#define RSP_SELFTEST 0x85
#define RSP_SET_N_PARAMETERS 0xA7
#define RSP_SIGN_ON 0x86
#define RSP_SPI_DATA 0x88
/* ICE events */
#define EVT_BREAK 0xE0
#define EVT_DEBUG 0xE6
#define EVT_ERROR_PHY_FORCE_BREAK_TIMEOUT 0xE2
#define EVT_ERROR_PHY_MAX_BIT_LENGTH_DIFF 0xED
#define EVT_ERROR_PHY_OPT_RECEIVE_TIMEOUT 0xF9
#define EVT_ERROR_PHY_OPT_RECEIVED_BREAK 0xFA
#define EVT_ERROR_PHY_RECEIVED_BREAK 0xF8
#define EVT_ERROR_PHY_RECEIVE_TIMEOUT 0xF7
#define EVT_ERROR_PHY_RELEASE_BREAK_TIMEOUT 0xE3
#define EVT_ERROR_PHY_SYNC_OUT_OF_RANGE 0xF5
#define EVT_ERROR_PHY_SYNC_TIMEOUT 0xF0
#define EVT_ERROR_PHY_SYNC_TIMEOUT_BAUD 0xF4
#define EVT_ERROR_PHY_SYNC_WAIT_TIMEOUT 0xF6
#define EVT_RESULT_PHY_NO_ACTIVITY 0xFB
#define EVT_EXT_RESET 0xE7
#define EVT_ICE_POWER_ERROR_STATE 0xEA
#define EVT_ICE_POWER_OK 0xEB
#define EVT_IDR_DIRTY 0xEC
#define EVT_NONE 0xEF
#define EVT_PDSB_BREAK 0xF2
#define EVT_PDSMB_BREAK 0xF3
#define EVT_PROGRAM_BREAK 0xF1
#define EVT_RUN 0xE1
#define EVT_TARGET_POWER_OFF 0xE5
#define EVT_TARGET_POWER_ON 0xE4
#define EVT_TARGET_SLEEP 0xE8
#define EVT_TARGET_WAKEUP 0xE9
/* memory types for CMND_{READ,WRITE}_MEMORY */
#define MTYPE_IO_SHADOW 0x30 /* cached IO registers? */
#define MTYPE_SRAM 0x20 /* target's SRAM or [ext.] IO registers */
#define MTYPE_EEPROM 0x22 /* EEPROM, what way? */
#define MTYPE_EVENT 0x60 /* ICE event memory */
#define MTYPE_SPM 0xA0 /* flash through LPM/SPM */
#define MTYPE_FLASH_PAGE 0xB0 /* flash in programming mode */
#define MTYPE_EEPROM_PAGE 0xB1 /* EEPROM in programming mode */
#define MTYPE_FUSE_BITS 0xB2 /* fuse bits in programming mode */
#define MTYPE_LOCK_BITS 0xB3 /* lock bits in programming mode */
#define MTYPE_SIGN_JTAG 0xB4 /* signature in programming mode */
#define MTYPE_OSCCAL_BYTE 0xB5 /* osccal cells in programming mode */
#define MTYPE_CAN 0xB6 /* CAN mailbox */
/* (some) ICE parameters, for CMND_{GET,SET}_PARAMETER */
#define PAR_HW_VERSION 0x01
#define PAR_FW_VERSION 0x02
#define PAR_EMULATOR_MODE 0x03
# define EMULATOR_MODE_DEBUGWIRE 0x00
# define EMULATOR_MODE_JTAG 0x01
# define EMULATOR_MODE_UNKNOWN 0x02
# define EMULATOR_MODE_SPI 0x03
#define PAR_IREG 0x04
#define PAR_BAUD_RATE 0x05
# define PAR_BAUD_2400 0x01
# define PAR_BAUD_4800 0x02
# define PAR_BAUD_9600 0x03
# define PAR_BAUD_19200 0x04 /* default */
# define PAR_BAUD_38400 0x05
# define PAR_BAUD_57600 0x06
# define PAR_BAUD_115200 0x07
# define PAR_BAUD_14400 0x08
#define PAR_OCD_VTARGET 0x06
#define PAR_OCD_JTAG_CLK 0x07
#define PAR_OCD_BREAK_CAUSE 0x08
#define PAR_TIMERS_RUNNING 0x09
#define PAR_BREAK_ON_CHANGE_FLOW 0x0A
#define PAR_BREAK_ADDR1 0x0B
#define PAR_BREAK_ADDR2 0x0C
#define PAR_COMBBREAKCTRL 0x0D
#define PAR_JTAGID 0x0E
#define PAR_UNITS_BEFORE 0x0F
#define PAR_UNITS_AFTER 0x10
#define PAR_BIT_BEFORE 0x11
#define PAR_BIT_ATER 0x12
#define PAR_EXTERNAL_RESET 0x13
#define PAR_FLASH_PAGE_SIZE 0x14
#define PAR_EEPROM_PAGE_SIZE 0x15
#define PAR_UNUSED1 0x16
#define PAR_PSB0 0x17
#define PAR_PSB1 0x18
#define PAR_PROTOCOL_DEBUG_EVENT 0x19
#define PAR_MCU_STATE 0x1A
# define STOPPED 0x00
# define RUNNING 0x01
# define PROGRAMMING 0x02
#define PAR_DAISY_CHAIN_INFO 0x1B
#define PAR_BOOT_ADDRESS 0x1C
#define PAR_TARGET_SIGNATURE 0x1D
#define PAR_DEBUGWIRE_BAUDRATE 0x1E
#define PAR_PROGRAM_ENTRY_POINT 0x1F
#define PAR_PACKET_PARSING_ERRORS 0x40
#define PAR_VALID_PACKETS_RECEIVED 0x41
#define PAR_INTERCOMMUNICATION_TX_FAILURES 0x42
#define PAR_INTERCOMMUNICATION_RX_FAILURES 0x43
#define PAR_CRC_ERRORS 0x44
#define PAR_POWER_SOURCE 0x45
# define POWER_EXTERNAL 0x00
# define POWER_USB 0x01
#define PAR_CAN_FLAG 0x22
# define DONT_READ_CAN_MAILBOX 0x00
# define READ_CAN_MAILBOX 0x01
#define PAR_ENABLE_IDR_IN_RUN_MODE 0x23
# define ACCESS_OSCCAL 0x00
# define ACCESS_IDR 0x01
#define PAR_ALLOW_PAGEPROGRAMMING_IN_SCANCHAIN 0x24
# define PAGEPROG_NOT_ALLOWED 0x00
# define PAGEPROG_ALLOWED 0x01
#if !defined(JTAGMKII_PRIVATE_EXPORTED)
/*
* In appnote AVR067, struct device_descriptor is written with
* int/long field types. We cannot use them directly, as they were
* neither properly aligned for portability, nor did they care for
* endianess issues. We thus use arrays of unsigned chars, plus
* conversion macros.
*/
struct device_descriptor
{
unsigned char ucReadIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */
unsigned char ucReadIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */
unsigned char ucWriteIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */
unsigned char ucWriteIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */
unsigned char ucReadExtIO[52]; /*LSB = IOloc 96, MSB = IOloc511 */
unsigned char ucReadIOExtShadow[52]; /*LSB = IOloc 96, MSB = IOloc511 */
unsigned char ucWriteExtIO[52]; /*LSB = IOloc 96, MSB = IOloc511 */
unsigned char ucWriteIOExtShadow[52];/*LSB = IOloc 96, MSB = IOloc511 */
unsigned char ucIDRAddress; /*IDR address */
unsigned char ucSPMCRAddress; /*SPMCR Register address and dW BasePC */
unsigned char ucRAMPZAddress; /*RAMPZ Register address in SRAM I/O */
/*space */
unsigned char uiFlashPageSize[2]; /*Device Flash Page Size, Size = */
/*2 exp ucFlashPageSize */
unsigned char ucEepromPageSize; /*Device Eeprom Page Size in bytes */
unsigned char ulBootAddress[4]; /*Device Boot Loader Start Address */
unsigned char uiUpperExtIOLoc[2]; /*Topmost (last) extended I/O */
/*location, 0 if no external I/O */
unsigned char ulFlashSize[4]; /*Device Flash Size */
unsigned char ucEepromInst[20]; /*Instructions for W/R EEPROM */
unsigned char ucFlashInst[3]; /*Instructions for W/R FLASH */
unsigned char ucSPHaddr; /* stack pointer high */
unsigned char ucSPLaddr; /* stack pointer low */
/* new as of 16-02-2004 */
unsigned char uiFlashpages[2]; /* number of pages in flash */
unsigned char ucDWDRAddress; /* DWDR register address */
unsigned char ucDWBasePC; /* base/mask value of the PC */
/* new as of 30-04-2004 */
unsigned char ucAllowFullPageBitstream; /* FALSE on ALL new */
/*parts */
unsigned char uiStartSmallestBootLoaderSection[2]; /* */
/* new as of 18-10-2004 */
unsigned char EnablePageProgramming; /* For JTAG parts only, */
/* default TRUE */
unsigned char ucCacheType; /* CacheType_Normal 0x00, */
/* CacheType_CAN 0x01, */
/* CacheType_HEIMDALL 0x02 */
/* new as of 27-10-2004 */
unsigned char uiSramStartAddr[2]; /* Start of SRAM */
unsigned char ucResetType; /* Selects reset type. ResetNormal = 0x00 */
/* ResetAT76CXXX = 0x01 */
unsigned char ucPCMaskExtended; /* For parts with extended PC */
unsigned char ucPCMaskHigh; /* PC high mask */
unsigned char ucEindAddress; /* Selects reset type. [EIND address...] */
/* new as of early 2005, firmware 4.x */
unsigned char EECRAddress[2]; /* EECR memory-mapped IO address */
};
#endif /* JTAGMKII_PRIVATE_EXPORTED */

169
avrdude/jtagmkI_private.h Normal file
View File

@@ -0,0 +1,169 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2005 Joerg Wunsch <j@uriah.heep.sax.de>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
/*
* JTAG ICE mkI definitions
*/
/* ICE command codes */
/* 0x20 Get Synch [Resp_OK] */
#define CMD_GET_SYNC ' '
/* 0x31 Single Step [Sync_CRC/EOP] [Resp_OK] */
/* 0x32 Read PC [Sync_CRC/EOP] [Resp_OK] [program counter]
* [Resp_OK] */
/* 0x33 Write PC [program counter] [Sync_CRC/EOP] [Resp_OK]
* [Resp_OK] */
/* 0xA2 Firmware Upgrade [upgrade string] [Sync_CRC/EOP] [Resp_OK]
* [Resp_OK] */
/* 0xA0 Set Device Descriptor [device info] [Sync_CRC/EOP] [Resp_OK]
* [Resp_OK] */
#define CMD_SET_DEVICE_DESCRIPTOR 0xA0
/* 0x42 Set Parameter [parameter] [setting] [Sync_CRC/EOP] [Resp_OK]
* [Resp_OK] */
#define CMD_SET_PARAM 'B'
/* 0x46 Forced Stop [Sync_CRC/EOP] [Resp_OK] [checksum][program
* counter] [Resp_OK] */
#define CMD_STOP 'F'
/* 0x47 Go [Sync_CRC/EOP] [Resp_OK] */
#define CMD_GO 'G'
/* 0x52 Read Memory [memory type] [word count] [start address]
* [Sync_CRC/EOP] [Resp_OK] [word 0] ... [word n] [checksum]
* [Resp_OK] */
#define CMD_READ_MEM 'R'
/* 0x53 Get Sign On [Sync_CRC/EOP] [Resp_OK] ["AVRNOCD"] [Resp_OK] */
#define CMD_GET_SIGNON 'S'
/* 0XA1 Erase Page spm [address] [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */
/* 0x57 Write Memory [memory type] [word count] [start address]
* [Sync_CRC/EOP] [Resp_OK] [Cmd_DATA] [word 0] ... [word n] */
#define CMD_WRITE_MEM 'W'
/* Second half of write memory: the data command. Undocumented. */
#define CMD_DATA 'h'
/* 0x64 Get Debug Info [Sync_CRC/EOP] [Resp_OK] [0x00] [Resp_OK] */
/* 0x71 Get Parameter [parameter] [Sync_CRC/EOP] [Resp_OK] [setting]
* [Resp_OK] */
#define CMD_GET_PARAM 'q'
/* 0x78 Reset [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */
#define CMD_RESET 'x'
/* 0xA3 Enter Progmode [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */
#define CMD_ENTER_PROGMODE 0xa3
/* 0xA4 Leave Progmode [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */
#define CMD_LEAVE_PROGMODE 0xa4
/* 0xA5 Chip Erase [Sync_CRC/EOP] [Resp_OK] [Resp_OK] */
#define CMD_CHIP_ERASE 0xa5
/* ICE responses */
#define RESP_OK 'A'
#define RESP_BREAK 'B'
#define RESP_INFO 'G'
#define RESP_FAILED 'F'
#define RESP_SYNC_ERROR 'E'
#define RESP_SLEEP 'H'
#define RESP_POWER 'I'
#define PARM_BITRATE 'b'
#define PARM_SW_VERSION 0x7b
#define PARM_HW_VERSION 0x7a
#define PARM_IREG_HIGH 0x81
#define PARM_IREG_LOW 0x82
#define PARM_OCD_VTARGET 0x84
#define PARM_OCD_BREAK_CAUSE 0x85
#define PARM_CLOCK 0x86
#define PARM_EXTERNAL_RESET 0x8b
#define PARM_FLASH_PAGESIZE_LOW 0x88
#define PARM_FLASH_PAGESIZE_HIGH 0x89
#define PARM_EEPROM_PAGESIZE 0x8a
#define PARM_TIMERS_RUNNING 0xa0
#define PARM_BP_FLOW 0xa1
#define PARM_BP_X_HIGH 0xa2
#define PARM_BP_X_LOW 0xa3
#define PARM_BP_Y_HIGH 0xa4
#define PARM_BP_Y_LOW 0xa5
#define PARM_BP_MODE 0xa6
#define PARM_JTAGID_BYTE0 0xa7
#define PARM_JTAGID_BYTE1 0xa8
#define PARM_JTAGID_BYTE2 0xa9
#define PARM_JTAGID_BYTE3 0xaa
#define PARM_UNITS_BEFORE 0xab
#define PARM_UNITS_AFTER 0xac
#define PARM_BIT_BEFORE 0xad
#define PARM_BIT_AFTER 0xae
#define PARM_PSB0_LOW 0xaf
#define PARM_PSBO_HIGH 0xb0
#define PARM_PSB1_LOW 0xb1
#define PARM_PSB1_HIGH 0xb2
#define PARM_MCU_MODE 0xb3
#define JTAG_BITRATE_1_MHz 0xff
#define JTAG_BITRATE_500_kHz 0xfe
#define JTAG_BITRATE_250_kHz 0xfd
#define JTAG_BITRATE_125_kHz 0xfb
/* memory types for CMND_{READ,WRITE}_MEMORY */
#define MTYPE_IO_SHADOW 0x30 /* cached IO registers? */
#define MTYPE_SRAM 0x20 /* target's SRAM or [ext.] IO registers */
#define MTYPE_EEPROM 0x22 /* EEPROM, what way? */
#define MTYPE_EVENT 0x60 /* ICE event memory */
#define MTYPE_SPM 0xA0 /* flash through LPM/SPM */
#define MTYPE_FLASH_PAGE 0xB0 /* flash in programming mode */
#define MTYPE_EEPROM_PAGE 0xB1 /* EEPROM in programming mode */
#define MTYPE_FUSE_BITS 0xB2 /* fuse bits in programming mode */
#define MTYPE_LOCK_BITS 0xB3 /* lock bits in programming mode */
#define MTYPE_SIGN_JTAG 0xB4 /* signature in programming mode */
#define MTYPE_OSCCAL_BYTE 0xB5 /* osccal cells in programming mode */
struct device_descriptor
{
unsigned char ucReadIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */
unsigned char ucWriteIO[8]; /*LSB = IOloc 0, MSB = IOloc63 */
unsigned char ucReadIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */
unsigned char ucWriteIOShadow[8]; /*LSB = IOloc 0, MSB = IOloc63 */
unsigned char ucReadExtIO[20]; /*LSB = IOloc 96, MSB = IOloc255 */
unsigned char ucWriteExtIO[20]; /*LSB = IOloc 96, MSB = IOloc255 */
unsigned char ucReadIOExtShadow[20]; /*LSB = IOloc 96, MSB = IOloc255 */
unsigned char ucWriteIOExtShadow[20];/*LSB = IOloc 96, MSB = IOloc255 */
unsigned char ucIDRAddress; /*IDR address */
unsigned char ucSPMCRAddress; /*SPMCR Register address and dW BasePC */
unsigned char ucRAMPZAddress; /*RAMPZ Register address in SRAM I/O */
/*space */
unsigned char uiFlashPageSize[2]; /*Device Flash Page Size, Size = */
/*2 exp ucFlashPageSize */
unsigned char ucEepromPageSize; /*Device Eeprom Page Size in bytes */
unsigned char ulBootAddress[4]; /*Device Boot Loader Start Address */
unsigned char uiUpperExtIOLoc; /*Topmost (last) extended I/O */
/*location, 0 if no external I/O */
};

View File

@@ -1,6 +1,7 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -46,17 +47,22 @@ HEXDIGIT [0-9a-fA-F]
ID [_a-zA-Z][_a-zA-Z0-9]*
SIGN [+-]
%x str
%x strng
%x incl
%x comment
/* Bump resources for classic lex. */
%e2000
%p5000
%n1000
%%
{SIGN}*{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; }
{SIGN}*{DIGIT}+"."{DIGIT}* { yylval = number(yytext); return TKN_NUMBER; }
{SIGN}*"."{DIGIT}* { yylval = number(yytext); return TKN_NUMBER; }
"\"" { string_buf_ptr = string_buf; BEGIN(str); }
"\"" { string_buf_ptr = string_buf; BEGIN(strng); }
0x{HEXDIGIT}+ { yylval = hexnumber(yytext); return TKN_NUMBER; }
@@ -64,7 +70,7 @@ SIGN [+-]
# { /* The following eats '#' style comments to end of line */
BEGIN(comment); }
<comment>[^\n] /* eat comments */
<comment>[^\n] { /* eat comments */ }
<comment>\n { lineno++; BEGIN(INITIAL); }
@@ -99,39 +105,47 @@ SIGN [+-]
}
<str>{
\" { *string_buf_ptr = 0; string_buf_ptr = string_buf;
yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; }
\\n *string_buf_ptr++ = '\n';
\\t *string_buf_ptr++ = '\t';
\\r *string_buf_ptr++ = '\r';
\\b *string_buf_ptr++ = '\b';
\\f *string_buf_ptr++ = '\f';
\\(.|\n) *(string_buf_ptr++) = yytext[1];
[^\\\n\"]+ { char *yptr = yytext; while (*yptr)
<strng>\" { *string_buf_ptr = 0; string_buf_ptr = string_buf;
yylval = string(string_buf_ptr); BEGIN(INITIAL); return TKN_STRING; }
<strng>\\n *string_buf_ptr++ = '\n';
<strng>\\t *string_buf_ptr++ = '\t';
<strng>\\r *string_buf_ptr++ = '\r';
<strng>\\b *string_buf_ptr++ = '\b';
<strng>\\f *string_buf_ptr++ = '\f';
<strng>\\(.|\n) *(string_buf_ptr++) = yytext[1];
<strng>[^\\\n\"]+ { char *yptr = yytext; while (*yptr)
*(string_buf_ptr++) = *(yptr++); }
\n { fprintf(stderr, "error at line %d: unterminated character constant\n",
lineno);
exit(1); }
}
<strng>\n { fprintf(stderr, "error at line %d: unterminated character constant\n",
lineno);
exit(1); }
allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; }
avr910 { yylval=NULL; return K_AVR910; }
avr910_devcode { yylval=NULL; return K_AVR910_DEVCODE; }
usbasp { yylval=NULL; return K_USBASP; }
bank_size { yylval=NULL; return K_PAGE_SIZE; }
banked { yylval=NULL; return K_PAGED; }
baudrate { yylval=NULL; return K_BAUDRATE; }
bs2 { yylval=NULL; return K_BS2; }
buff { yylval=NULL; return K_BUFF; }
butterfly { yylval=NULL; return K_BUTTERFLY; }
chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; }
desc { yylval=NULL; return K_DESC; }
default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; }
default_serial { yylval=NULL; return K_DEFAULT_SERIAL; }
devicecode { yylval=NULL; return K_DEVICECODE; }
stk500_devcode { yylval=NULL; return K_STK500_DEVCODE; }
avr910_devcode { yylval=NULL; return K_AVR910_DEVCODE; }
eecr { yylval=NULL; return K_EECR; }
eeprom { yylval=NULL; return K_EEPROM; }
enablepageprogramming { yylval=NULL; return K_ENABLEPAGEPROGRAMMING; }
errled { yylval=NULL; return K_ERRLED; }
flash { yylval=NULL; return K_FLASH; }
has_jtag { yylval=NULL; return K_HAS_JTAG; }
id { yylval=NULL; return K_ID; }
idr { yylval=NULL; return K_IDR; }
jtagmki { yylval=NULL; return K_JTAG_MKI; }
jtagmkii { yylval=NULL; return K_JTAG_MKII; }
jtagmkii_isp { yylval=NULL; return K_JTAG_MKII_ISP; }
max_write_delay { yylval=NULL; return K_MAX_WRITE_DELAY; }
memory { yylval=NULL; return K_MEMORY; }
min_write_delay { yylval=NULL; return K_MIN_WRITE_DELAY; }
@@ -148,19 +162,61 @@ part { yylval=NULL; return K_PART; }
pgmled { yylval=NULL; return K_PGMLED; }
programmer { yylval=NULL; return K_PROGRAMMER; }
pwroff_after_write { yylval=NULL; return K_PWROFF_AFTER_WRITE; }
rampz { yylval=NULL; return K_RAMPZ; }
rdyled { yylval=NULL; return K_RDYLED; }
readback_p1 { yylval=NULL; return K_READBACK_P1; }
readback_p2 { yylval=NULL; return K_READBACK_P2; }
retry_pulse { yylval=NULL; return K_RETRY_PULSE; }
serbb { yylval=NULL; return K_SERBB; }
serial { yylval=NULL; return K_SERIAL; }
signature { yylval=NULL; return K_SIGNATURE; }
size { yylval=NULL; return K_SIZE; }
spmcr { yylval=NULL; return K_SPMCR; }
stk500 { yylval=NULL; return K_STK500; }
avr910 { yylval=NULL; return K_AVR910; }
butterfly { yylval=NULL; return K_BUTTERFLY; }
stk500hvsp { yylval=NULL; return K_STK500HVSP; }
stk500pp { yylval=NULL; return K_STK500PP; }
stk500v2 { yylval=NULL; return K_STK500V2; }
stk500generic { yylval=NULL; return K_STK500GENERIC; }
stk500_devcode { yylval=NULL; return K_STK500_DEVCODE; }
type { yylval=NULL; return K_TYPE; }
vcc { yylval=NULL; return K_VCC; }
vfyled { yylval=NULL; return K_VFYLED; }
timeout { yylval=NULL; return K_TIMEOUT; }
stabdelay { yylval=NULL; return K_STABDELAY; }
cmdexedelay { yylval=NULL; return K_CMDEXEDELAY; }
hvspcmdexedelay { yylval=NULL; return K_HVSPCMDEXEDELAY; }
synchloops { yylval=NULL; return K_SYNCHLOOPS; }
bytedelay { yylval=NULL; return K_BYTEDELAY; }
pollvalue { yylval=NULL; return K_POLLVALUE; }
pollindex { yylval=NULL; return K_POLLINDEX; }
predelay { yylval=NULL; return K_PREDELAY; }
postdelay { yylval=NULL; return K_POSTDELAY; }
pollmethod { yylval=NULL; return K_POLLMETHOD; }
mode { yylval=NULL; return K_MODE; }
delay { yylval=NULL; return K_DELAY; }
blocksize { yylval=NULL; return K_BLOCKSIZE; }
readsize { yylval=NULL; return K_READSIZE; }
pp_controlstack { yylval=NULL; return K_PP_CONTROLSTACK; }
hvsp_controlstack { yylval=NULL; return K_HVSP_CONTROLSTACK; }
hventerstabdelay { yylval=NULL; return K_HVENTERSTABDELAY; }
progmodedelay { yylval=NULL; return K_PROGMODEDELAY; }
latchcycles { yylval=NULL; return K_LATCHCYCLES; }
togglevtg { yylval=NULL; return K_TOGGLEVTG; }
poweroffdelay { yylval=NULL; return K_POWEROFFDELAY; }
resetdelayms { yylval=NULL; return K_RESETDELAYMS; }
resetdelayus { yylval=NULL; return K_RESETDELAYUS; }
hvleavestabdelay { yylval=NULL; return K_HVLEAVESTABDELAY; }
resetdelay { yylval=NULL; return K_RESETDELAY; }
synchcycles { yylval=NULL; return K_SYNCHCYCLES; }
chiperasepulsewidth { yylval=NULL; return K_CHIPERASEPULSEWIDTH; }
chiperasepolltimeout { yylval=NULL; return K_CHIPERASEPOLLTIMEOUT; }
chiperasetime { yylval=NULL; return K_CHIPERASETIME; }
programfusepulsewidth { yylval=NULL; return K_PROGRAMFUSEPULSEWIDTH; }
programfusepolltimeout { yylval=NULL; return K_PROGRAMFUSEPOLLTIMEOUT; }
programlockpulsewidth { yylval=NULL; return K_PROGRAMLOCKPULSEWIDTH; }
programlockpolltimeout { yylval=NULL; return K_PROGRAMLOCKPOLLTIMEOUT; }
dedicated { yylval=new_token(K_DEDICATED); return K_DEDICATED; }
io { yylval=new_token(K_IO); return K_IO; }
@@ -177,6 +233,7 @@ write_lo { yylval=new_token(K_WRITE_LO); return K_WRITE_LO; }
write_hi { yylval=new_token(K_WRITE_HI); return K_WRITE_HI; }
loadpage_lo { yylval=new_token(K_LOADPAGE_LO); return K_LOADPAGE_LO; }
loadpage_hi { yylval=new_token(K_LOADPAGE_HI); return K_LOADPAGE_HI; }
load_ext_addr { yylval=new_token(K_LOAD_EXT_ADDR); return K_LOAD_EXT_ADDR; }
writepage { yylval=new_token(K_WRITEPAGE); return K_WRITEPAGE; }
chip_erase { yylval=new_token(K_CHIP_ERASE); return K_CHIP_ERASE; }
pgm_enable { yylval=new_token(K_PGM_ENABLE); return K_PGM_ENABLE; }
@@ -187,9 +244,10 @@ yes { yylval=new_token(K_YES); return K_YES; }
"," { yylval = NULL; pyytext(); return TKN_COMMA; }
"=" { yylval = NULL; pyytext(); return TKN_EQUAL; }
";" { yylval = NULL; pyytext(); return TKN_SEMI; }
"~" { yylval = NULL; pyytext(); return TKN_TILDE; }
"\n" { lineno++; }
[ \r\t]+ /* ignore whitespace */
[ \r\t]+ { /* ignore whitespace */ }
c: { fprintf(stderr, "error at %s:%d: possible old-style config file entry\n",
infile, lineno);

View File

@@ -1,5 +1,26 @@
#ifndef __linux_ppdev_h__
#define __linux_ppdev_h__
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003, 2005 Theodore A. Roth
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef linux_ppdev_h
#define linux_ppdev_h
#define OBSOLETE__IOW _IOW
@@ -9,29 +30,28 @@
#include <stdlib.h>
#define PPISDATA PPWDATA
#define PPIGDATA PPRDATA
#define PPISCTRL PPWCONTROL
#define PPIGCTRL PPRCONTROL
#define PPISSTATUS PPWSTATUS
#define PPIGSTATUS PPRSTATUS
#define ppi_claim(pgm) \
if (ioctl(pgm->fd, PPCLAIM)) { \
#define ppi_claim(fd) \
if (ioctl(fd, PPCLAIM)) { \
fprintf(stderr, "%s: can't claim device \"%s\": %s\n\n", \
progname, port, strerror(errno)); \
close(pgm->fd); \
close(fd); \
exit(1); \
}
}
#define ppi_release(pgm) \
if (ioctl(pgm->fd, PPRELEASE)) { \
#define ppi_release(fd) \
if (ioctl(fd, PPRELEASE)) { \
fprintf(stderr, "%s: can't release device: %s\n\n", \
progname, strerror(errno)); \
exit(1); \
}
#define DO_PPI_READ(fd, reg, valp) \
(void)ioctl(fd, \
(reg) == PPIDATA? PPRDATA: ((reg) == PPICTRL? PPRCONTROL: PPRSTATUS), \
valp)
#define DO_PPI_WRITE(fd, reg, valp) \
(void)ioctl(fd, \
(reg) == PPIDATA? PPWDATA: ((reg) == PPICTRL? PPWCONTROL: PPWSTATUS), \
valp)
#endif /* __linux_ppdev_h__ */
#endif /* linux_ppdev_h */

View File

@@ -1,7 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
* 1998, 1999, 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 1990-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
* 1998, 1999, 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 1990-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2006 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,18 +29,24 @@
#include <errno.h>
#if defined(__FreeBSD__)
#include <dev/ppbus/ppi.h>
# include "freebsd_ppi.h"
#elif defined(__linux__)
#include "linux_ppdev.h"
# include "linux_ppdev.h"
#elif defined(__sun__) && defined(__svr4__) /* Solaris */
# include "solaris_ecpp.h"
#endif
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
#include "par.h"
#include "ppi.h"
#include "bitbang.h"
#define SLOW_TOGGLE 0
extern char * progname;
extern int do_cycles;
extern int verbose;
#if HAVE_PARPORT
struct ppipins_t {
int pin;
@@ -49,7 +55,7 @@ struct ppipins_t {
int inverted;
};
static struct ppipins_t pins[] = {
static struct ppipins_t ppipins[] = {
{ 1, PPICTRL, 0x01, 1 },
{ 2, PPIDATA, 0x01, 0 },
{ 3, PPIDATA, 0x02, 0 },
@@ -69,316 +75,136 @@ static struct ppipins_t pins[] = {
{ 17, PPICTRL, 0x08, 1 }
};
#define NPINS (sizeof(pins)/sizeof(struct ppipins_t))
#define NPINS (sizeof(ppipins)/sizeof(struct ppipins_t))
extern char * progname;
extern int do_cycles;
extern int verbose;
static int par_setpin (int fd, int pin, int value);
static int par_getpin (int fd, int pin);
static int par_pulsepin (int fd, int pin);
static int par_rdy_led (PROGRAMMER * pgm, int value);
static int par_err_led (PROGRAMMER * pgm, int value);
static int par_pgm_led (PROGRAMMER * pgm, int value);
static int par_vfy_led (PROGRAMMER * pgm, int value);
static int par_cmd (PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4]);
static int par_chip_erase (PROGRAMMER * pgm, AVRPART * p);
static int par_program_enable (PROGRAMMER * pgm, AVRPART * p);
static void par_powerup (PROGRAMMER * pgm);
static void par_powerdown (PROGRAMMER * pgm);
static int par_initialize (PROGRAMMER * pgm, AVRPART * p);
static void par_disable (PROGRAMMER * pgm);
static void par_enable (PROGRAMMER * pgm);
static int par_open (PROGRAMMER * pgm, char * port);
static void par_close (PROGRAMMER * pgm);
static int par_setpin(int fd, int pin, int value)
static int par_setpin(PROGRAMMER * pgm, int pin, int value)
{
int inverted;
inverted = pin & PIN_INVERSE;
pin &= PIN_MASK;
if (pin < 1 || pin > 17)
return -1;
pin--;
if (pins[pin].inverted)
if (ppipins[pin].inverted)
inverted = !inverted;
if (inverted)
value = !value;
if (value)
ppi_set(fd, pins[pin].reg, pins[pin].bit);
ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
else
ppi_clr(fd, pins[pin].reg, pins[pin].bit);
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
#if SLOW_TOGGLE
usleep(1000);
#endif
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
return 0;
}
static void par_setmany(PROGRAMMER * pgm, unsigned int pinset, int value)
{
int pin;
static int par_getpin(int fd, int pin)
for (pin = 1; pin <= 17; pin++) {
if (pinset & (1 << pin))
par_setpin(pgm, pin, value);
}
}
static int par_getpin(PROGRAMMER * pgm, int pin)
{
int value;
int inverted;
inverted = pin & PIN_INVERSE;
pin &= PIN_MASK;
if (pin < 1 || pin > 17)
return -1;
pin--;
value = ppi_get(fd, pins[pin].reg, pins[pin].bit);
value = ppi_get(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
if (value)
value = 1;
if (pins[pin].inverted)
if (ppipins[pin].inverted)
inverted = !inverted;
if (inverted)
value = !value;
return value;
}
static int par_pulsepin(int fd, int pin)
static int par_highpulsepin(PROGRAMMER * pgm, int pin)
{
int inverted;
inverted = pin & PIN_INVERSE;
pin &= PIN_MASK;
if (pin < 1 || pin > 17)
return -1;
pin--;
ppi_toggle(fd, pins[pin].reg, pins[pin].bit);
if (ppipins[pin].inverted)
inverted = !inverted;
#if SLOW_TOGGLE
usleep(1000);
#endif
if (inverted) {
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
ppi_toggle(fd, pins[pin].reg, pins[pin].bit);
ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
} else {
ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
#if SLOW_TOGGLE
usleep(1000);
#endif
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
}
return 0;
}
int par_getpinmask(int pin)
static char * pins_to_str(unsigned int pmask)
{
if (pin < 1 || pin > 17)
return -1;
return pins[pin-1].bit;
}
static char vccpins_buf[64];
static char * vccpins_str(unsigned int pmask)
{
unsigned int mask;
static char buf[64];
int pin;
char b2[8];
char * b;
b = vccpins_buf;
b[0] = 0;
for (pin = 2, mask = 1; mask < 0x80; mask = mask << 1, pin++) {
if (pmask & mask) {
buf[0] = 0;
for (pin = 1; pin <= 17; pin++) {
if (pmask & (1 << pin)) {
sprintf(b2, "%d", pin);
if (b[0] != 0)
strcat(b, ",");
strcat(b, b2);
if (buf[0] != 0)
strcat(buf, ",");
strcat(buf, b2);
}
}
return b;
return buf;
}
/*
* transmit and receive a byte of data to/from the AVR device
*/
static unsigned char par_txrx(PROGRAMMER * pgm, unsigned char byte)
{
int i;
unsigned char r, b, rbyte;
rbyte = 0;
for (i=7; i>=0; i--) {
/*
* Write and read one bit on SPI.
* Some notes on timing: Let T be the time it takes to do
* one par_setpin()-call resp. par clrpin()-call, then
* - SCK is high for 2T
* - SCK is low for 2T
* - MOSI setuptime is 1T
* - MOSI holdtime is 3T
* - SCK low to MISO read is 2T to 3T
* So we are within programming specs (expect for AT90S1200),
* if and only if T>t_CLCL (t_CLCL=clock period of target system).
*
* Due to the delay introduced by "IN" and "OUT"-commands,
* T is greater than 1us (more like 2us) on x86-architectures.
* So programming works safely down to 1MHz target clock.
*/
b = (byte >> i) & 0x01;
/* set the data input line as desired */
par_setpin(pgm->fd, pgm->pinno[PIN_AVR_MOSI], b);
par_setpin(pgm->fd, pgm->pinno[PIN_AVR_SCK], 1);
/*
* read the result bit (it is either valid from a previous falling
* edge or it is ignored in the current context)
*/
r = par_getpin(pgm->fd, pgm->pinno[PIN_AVR_MISO]);
par_setpin(pgm->fd, pgm->pinno[PIN_AVR_SCK], 0);
rbyte |= r << i;
}
return rbyte;
}
static int par_rdy_led(PROGRAMMER * pgm, int value)
{
par_setpin(pgm->fd, pgm->pinno[PIN_LED_RDY], !value);
return 0;
}
static int par_err_led(PROGRAMMER * pgm, int value)
{
par_setpin(pgm->fd, pgm->pinno[PIN_LED_ERR], !value);
return 0;
}
static int par_pgm_led(PROGRAMMER * pgm, int value)
{
par_setpin(pgm->fd, pgm->pinno[PIN_LED_PGM], !value);
return 0;
}
static int par_vfy_led(PROGRAMMER * pgm, int value)
{
par_setpin(pgm->fd, pgm->pinno[PIN_LED_VFY], !value);
return 0;
}
/*
* transmit an AVR device command and return the results; 'cmd' and
* 'res' must point to at least a 4 byte data buffer
*/
static int par_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4])
{
int i;
for (i=0; i<4; i++) {
res[i] = par_txrx(pgm, cmd[i]);
}
if(verbose >= 2)
{
fprintf(stderr, "par_cmd(): [ ");
for(i = 0; i < 4; i++)
fprintf(stderr, "%02X ", cmd[i]);
fprintf(stderr, "] [ ");
for(i = 0; i < 4; i++)
{
fprintf(stderr, "%02X ", res[i]);
}
fprintf(stderr, "]\n");
}
return 0;
}
/*
* issue the 'chip erase' command to the AVR device
*/
static int par_chip_erase(PROGRAMMER * pgm, AVRPART * p)
{
unsigned char cmd[4];
unsigned char res[4];
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
p->desc);
return -1;
}
pgm->pgm_led(pgm, ON);
memset(cmd, 0, sizeof(cmd));
avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd);
pgm->cmd(pgm, cmd, res);
usleep(p->chip_erase_delay);
pgm->initialize(pgm, p);
pgm->pgm_led(pgm, OFF);
return 0;
}
/*
* issue the 'program enable' command to the AVR device
*/
static int par_program_enable(PROGRAMMER * pgm, AVRPART * p)
{
unsigned char cmd[4];
unsigned char res[4];
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
fprintf(stderr, "program enable instruction not defined for part \"%s\"\n",
p->desc);
return -1;
}
memset(cmd, 0, sizeof(cmd));
avr_set_bits(p->op[AVR_OP_PGM_ENABLE], cmd);
pgm->cmd(pgm, cmd, res);
if (res[2] != cmd[1])
return -2;
return 0;
}
/*
* apply power to the AVR processor
*/
static void par_powerup(PROGRAMMER * pgm)
{
ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power up */
par_setmany(pgm, pgm->pinno[PPI_AVR_VCC], 1); /* power up */
usleep(100000);
}
@@ -388,66 +214,12 @@ static void par_powerup(PROGRAMMER * pgm)
*/
static void par_powerdown(PROGRAMMER * pgm)
{
ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power down */
par_setmany(pgm, pgm->pinno[PPI_AVR_VCC], 0); /* power down */
}
/*
* initialize the AVR device and prepare it to accept commands
*/
static int par_initialize(PROGRAMMER * pgm, AVRPART * p)
{
int rc;
int tries;
pgm->powerup(pgm);
usleep(20000);
par_setpin(pgm->fd, pgm->pinno[PIN_AVR_SCK], 0);
par_setpin(pgm->fd, pgm->pinno[PIN_AVR_RESET], 0);
usleep(20000);
par_pulsepin(pgm->fd, pgm->pinno[PIN_AVR_RESET]);
usleep(20000); /* 20 ms XXX should be a per-chip parameter */
/*
* Enable programming mode. If we are programming an AT90S1200, we
* can only issue the command and hope it worked. If we are using
* one of the other chips, the chip will echo 0x53 when issuing the
* third byte of the command. In this case, try up to 32 times in
* order to possibly get back into sync with the chip if we are out
* of sync.
*/
if (strcmp(p->desc, "AT90S1200")==0) {
pgm->program_enable(pgm, p);
}
else {
tries = 0;
do {
rc = pgm->program_enable(pgm, p);
if ((rc == 0)||(rc == -1))
break;
par_pulsepin(pgm->fd, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]);
tries++;
} while (tries < 65);
/*
* can't sync with the device, maybe it's not attached?
*/
if (rc) {
fprintf(stderr, "%s: AVR device not responding\n", progname);
return -1;
}
}
return 0;
}
static void par_disable(PROGRAMMER * pgm)
{
ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
par_setmany(pgm, pgm->pinno[PPI_AVR_BUFF], 1); /* turn off */
}
static void par_enable(PROGRAMMER * pgm)
@@ -463,20 +235,21 @@ static void par_enable(PROGRAMMER * pgm)
* and not via the buffer chip.
*/
par_setpin(pgm->fd, pgm->pinno[PIN_AVR_RESET], 0);
par_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
usleep(1);
/*
* enable the 74367 buffer, if connected; this signal is active low
*/
ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
par_setmany(pgm, pgm->pinno[PPI_AVR_BUFF], 0);
}
static int par_open(PROGRAMMER * pgm, char * port)
{
int rc;
bitbang_check_prerequisites(pgm);
pgm->fd = ppi_open(port);
if (pgm->fd < 0) {
fprintf(stderr, "%s: failed to open parallel port \"%s\"\n\n",
@@ -484,8 +257,6 @@ static int par_open(PROGRAMMER * pgm, char * port)
exit(1);
}
ppi_claim(pgm);
/*
* save pin values, so they can be restored when device is closed
*/
@@ -509,45 +280,74 @@ static int par_open(PROGRAMMER * pgm, char * port)
static void par_close(PROGRAMMER * pgm)
{
/*
* Restore pin values before closing,
* but ensure that buffers are turned off.
*/
pgm->ppidata |= pgm->pinno[PPI_AVR_BUFF];
ppi_setall(pgm->fd, PPIDATA, pgm->ppidata);
ppi_setall(pgm->fd, PPICTRL, pgm->ppictrl);
ppi_release(pgm);
par_setpin(pgm, pgm->pinno[PPI_AVR_BUFF], 1);
/*
* Handle exit specs.
*/
switch (pgm->exit_reset) {
case EXIT_RESET_ENABLED:
par_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
break;
case EXIT_RESET_DISABLED:
par_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 1);
break;
case EXIT_RESET_UNSPEC:
/* Leave it alone. */
break;
}
switch (pgm->exit_vcc) {
case EXIT_VCC_ENABLED:
par_setmany(pgm, pgm->pinno[PPI_AVR_VCC], 1);
break;
case EXIT_VCC_DISABLED:
par_setmany(pgm, pgm->pinno[PPI_AVR_VCC], 0);
break;
case EXIT_VCC_UNSPEC:
/* Leave it alone. */
break;
}
ppi_close(pgm->fd);
pgm->fd = -1;
}
static void par_display(PROGRAMMER * pgm, char * p)
{
char vccpins[64];
char buffpins[64];
if (pgm->pinno[PPI_AVR_VCC]) {
snprintf(vccpins, sizeof(vccpins), " = pins %s",
vccpins_str(pgm->pinno[PPI_AVR_VCC]));
snprintf(vccpins, sizeof(vccpins), "%s",
pins_to_str(pgm->pinno[PPI_AVR_VCC]));
}
else {
strcpy(vccpins, " (not used)");
}
if (pgm->pinno[PPI_AVR_BUFF]) {
snprintf(buffpins, sizeof(buffpins), " = pins %s",
vccpins_str(pgm->pinno[PPI_AVR_BUFF]));
snprintf(buffpins, sizeof(buffpins), "%s",
pins_to_str(pgm->pinno[PPI_AVR_BUFF]));
}
else {
strcpy(buffpins, " (not used)");
}
fprintf(stderr,
"%s VCC = 0x%02x%s\n"
"%s BUFF = 0x%02x%s\n"
"%s VCC = %s\n"
"%s BUFF = %s\n"
"%s RESET = %d\n"
"%s SCK = %d\n"
"%s MOSI = %d\n"
@@ -557,8 +357,8 @@ static void par_display(PROGRAMMER * pgm, char * p)
"%s PGM LED = %d\n"
"%s VFY LED = %d\n",
p, pgm->pinno[PPI_AVR_VCC], vccpins,
p, pgm->pinno[PPI_AVR_BUFF], buffpins,
p, vccpins,
p, buffpins,
p, pgm->pinno[PIN_AVR_RESET],
p, pgm->pinno[PIN_AVR_SCK],
p, pgm->pinno[PIN_AVR_MOSI],
@@ -570,25 +370,70 @@ static void par_display(PROGRAMMER * pgm, char * p)
}
/*
* parse the -E string
*/
static int par_parseexitspecs(PROGRAMMER * pgm, char *s)
{
char *cp;
while ((cp = strtok(s, ","))) {
if (strcmp(cp, "reset") == 0) {
pgm->exit_reset = EXIT_RESET_ENABLED;
}
else if (strcmp(cp, "noreset") == 0) {
pgm->exit_reset = EXIT_RESET_DISABLED;
}
else if (strcmp(cp, "vcc") == 0) {
pgm->exit_vcc = EXIT_VCC_ENABLED;
}
else if (strcmp(cp, "novcc") == 0) {
pgm->exit_vcc = EXIT_VCC_DISABLED;
}
else {
return -1;
}
s = 0; /* strtok() should be called with the actual string only once */
}
return 0;
}
void par_initpgm(PROGRAMMER * pgm)
{
strcpy(pgm->type, "PPI");
pgm->rdy_led = par_rdy_led;
pgm->err_led = par_err_led;
pgm->pgm_led = par_pgm_led;
pgm->vfy_led = par_vfy_led;
pgm->initialize = par_initialize;
pgm->exit_vcc = EXIT_VCC_UNSPEC;
pgm->exit_reset = EXIT_RESET_UNSPEC;
pgm->rdy_led = bitbang_rdy_led;
pgm->err_led = bitbang_err_led;
pgm->pgm_led = bitbang_pgm_led;
pgm->vfy_led = bitbang_vfy_led;
pgm->initialize = bitbang_initialize;
pgm->display = par_display;
pgm->enable = par_enable;
pgm->disable = par_disable;
pgm->powerup = par_powerup;
pgm->powerdown = par_powerdown;
pgm->program_enable = par_program_enable;
pgm->chip_erase = par_chip_erase;
pgm->cmd = par_cmd;
pgm->program_enable = bitbang_program_enable;
pgm->chip_erase = bitbang_chip_erase;
pgm->cmd = bitbang_cmd;
pgm->open = par_open;
pgm->close = par_close;
pgm->setpin = par_setpin;
pgm->getpin = par_getpin;
pgm->highpulsepin = par_highpulsepin;
pgm->parseexitspecs = par_parseexitspecs;
}
#else /* !HAVE_PARPORT */
void par_initpgm(PROGRAMMER * pgm)
{
fprintf(stderr,
"%s: parallel port access not available in this configuration\n",
progname);
}
#endif /* HAVE_PARPORT */

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,8 +24,6 @@
void par_initpgm (PROGRAMMER * pgm);
int par_getpinmask(int pin);
#endif

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -123,6 +123,7 @@ PROGRAMMER * pgm_new(void)
pgm->set_vtarget = NULL;
pgm->set_varef = NULL;
pgm->set_fosc = NULL;
pgm->perform_osccal = NULL;
return pgm;
}

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,15 +38,31 @@
extern LISTID programmers;
typedef enum {
EXIT_VCC_UNSPEC,
EXIT_VCC_ENABLED,
EXIT_VCC_DISABLED
} exit_vcc_t;
typedef enum {
EXIT_RESET_UNSPEC,
EXIT_RESET_ENABLED,
EXIT_RESET_DISABLED
} exit_reset_t;
typedef struct programmer_t {
LISTID id;
char desc[PGM_DESCLEN];
char type[PGM_TYPELEN];
char port[PGM_PORTLEN];
unsigned int pinno[N_PINS];
exit_vcc_t exit_vcc;
exit_reset_t exit_reset;
int ppidata;
int ppictrl;
int baudrate;
double bitclock; /* JTAG ICE clock period in microseconds */
int ispdelay; /* ISP clock delay */
int fd;
int page_size; /* page size if the programmer supports paged write/load */
int (*rdy_led) (struct programmer_t * pgm, int value);
@@ -80,8 +96,14 @@ typedef struct programmer_t {
int (*set_varef) (struct programmer_t * pgm, double v);
int (*set_fosc) (struct programmer_t * pgm, double v);
int (*set_sck_period) (struct programmer_t * pgm, double v);
int (*setpin) (struct programmer_t * pgm, int pin, int value);
int (*getpin) (struct programmer_t * pgm, int pin);
int (*highpulsepin) (struct programmer_t * pgm, int pin);
int (*parseexitspecs) (struct programmer_t * pgm, char *s);
int (*perform_osccal) (struct programmer_t * pgm);
char config_file[PATH_MAX]; /* config file where defined */
int lineno; /* config file line number */
char flag; /* for private use of the programmer */
} PROGRAMMER;
@@ -89,6 +111,7 @@ PROGRAMMER * pgm_new(void);
#if defined(WIN32NATIVE)
#include "ac_cfg.h"
#include <windows.h>
/* usleep replacements */
@@ -100,19 +123,11 @@ PROGRAMMER * pgm_new(void);
*/
void usleep(unsigned long us);
void gettimeofday(struct timeval*, void*z);
#define rindex strrchr
#if !defined(HAVE_GETTIMEOFDAY)
int gettimeofday(struct timeval *tv, struct timezone *tz);
#endif /* HAVE_GETTIMEOFDAY */
#endif /* __win32native_h */
#if !defined(ppi_claim)
# define ppi_claim(pgm)
#endif
#if !defined(ppi_release)
# define ppi_release(pgm)
#endif
#endif

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +35,8 @@ enum {
PIN_LED_VFY,
N_PINS
};
#define PIN_INVERSE 0x80 /* flag for inverted pin in serbb */
#define PIN_MASK 0x7f
#define LED_ON(fd,pin) ppi_setpin(fd,pin,0)
#define LED_OFF(fd,pin) ppi_setpin(fd,pin,1)

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,10 +19,13 @@
/* $Id$ */
#if defined(__FreeBSD__) || defined(__linux__)
#if !defined(WIN32NATIVE)
#include "ac_cfg.h"
#if HAVE_PARPORT
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,9 +34,11 @@
#include <errno.h>
#if defined(__FreeBSD__)
#include <dev/ppbus/ppi.h>
# include "freebsd_ppi.h"
#elif defined(__linux__)
#include "linux_ppdev.h"
# include "linux_ppdev.h"
#elif defined(__sun__) && defined(__svr4__) /* Solaris */
# include "solaris_ecpp.h"
#endif
#include "avr.h"
@@ -53,22 +58,15 @@ int ppi_shadow_access(int fd, int reg, unsigned char *v, unsigned char action)
{
static unsigned char shadow[3];
int shadow_num;
unsigned long set, get;
switch (reg) {
case PPIDATA:
set = PPISDATA;
get = PPIGDATA;
shadow_num = 0;
break;
case PPICTRL:
set = PPISCTRL;
get = PPIGCTRL;
shadow_num = 1;
break;
case PPISTATUS:
set = PPISSTATUS;
get = PPIGSTATUS;
shadow_num = 2;
break;
default:
@@ -83,12 +81,12 @@ int ppi_shadow_access(int fd, int reg, unsigned char *v, unsigned char action)
*v = shadow[shadow_num];
break;
case PPI_READ:
ioctl(fd, get, v);
DO_PPI_READ(fd, reg, v);
shadow[shadow_num]=*v;
break;
case PPI_WRITE:
shadow[shadow_num]=*v;
ioctl(fd, set, v);
DO_PPI_WRITE(fd, reg, v);
break;
}
return 0;
@@ -214,6 +212,8 @@ int ppi_open(char * port)
return -1;
}
ppi_claim (fd);
/*
* Initialize shadow registers
*/
@@ -228,79 +228,10 @@ int ppi_open(char * port)
void ppi_close(int fd)
{
ppi_release (fd);
close(fd);
}
#endif /* HAVE_PARPORT */
#elif defined(__POWERPC__) && defined(__APPLE__)
int ppi_shadow_access(int fd, int reg, unsigned char *v, unsigned char action)
{
return -1;
}
/*
* set the indicated bit of the specified register.
*/
int ppi_set(int fd, int reg, int bit)
{
return -1;
}
/*
* clear the indicated bit of the specified register.
*/
int ppi_clr(int fd, int reg, int bit)
{
return -1;
}
/*
* get the indicated bit of the specified register.
*/
int ppi_get(int fd, int reg, int bit)
{
return -1;
}
/*
* toggle the indicated bit of the specified register.
*/
int ppi_toggle(int fd, int reg, int bit)
{
return -1;
}
/*
* get all bits of the specified register.
*/
int ppi_getall(int fd, int reg)
{
return -1;
}
/*
* set all bits of the specified register to val.
*/
int ppi_setall(int fd, int reg, int val)
{
return -1;
}
int ppi_open(char * port)
{
return -1;
}
void ppi_close(int fd)
{
}
#endif
#endif /* !WIN32NATIVE */

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,7 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003, 2004 Eric B. Weddington <ericw@evcohs.com>
* Copyright (C) 2003, 2004, 2006
* Eric B. Weddington <eweddington@cso.atmel.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +30,7 @@ reg = register as defined in an enum in ppi.h. This must be converted
*/
#include "ac_cfg.h"
#if defined (WIN32NATIVE)
@@ -316,7 +317,8 @@ static void outb(unsigned char value, unsigned short port)
return;
}
void gettimeofday(struct timeval*tv, void*z){
#if !defined(HAVE_GETTIMEOFDAY)
int gettimeofday(struct timeval *tv, struct timezone *unused){
// i've found only ms resolution, avrdude expects us
SYSTEMTIME st;
@@ -324,7 +326,10 @@ void gettimeofday(struct timeval*tv, void*z){
tv->tv_sec=(long)(st.wSecond+st.wMinute*60+st.wHour*3600);
tv->tv_usec=(long)(st.wMilliseconds*1000);
return 0;
}
#endif /* HAVE_GETTIMEOFDAY */
// #define W32USLEEPDBG

247
avrdude/safemode.c Normal file
View File

@@ -0,0 +1,247 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* avrdude is Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This file: Copyright (C) 2005 Colin O'Flynn <coflynn@newae.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include "ac_cfg.h"
#include "avr.h"
#include "pgm.h"
#include "safemode.h"
/* This value from ac_cfg.h */
char * progname = PACKAGE_NAME;
/*
* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or
* "efuse") and verifies it. Will try up to tries amount of times
* before giving up
*/
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
AVRPART * p, int tries, int verbose)
{
AVRMEM * m;
unsigned char fuseread;
int returnvalue = -1;
m = avr_locate_mem(p, fusename);
if (m == NULL) {
return -1;
}
/* Keep trying to write then read back the fuse values */
while (tries > 0) {
avr_write_byte(pgm, p, m, 0, fuse);
avr_read_byte(pgm, p, m, 0, &fuseread);
/* Report information to user if needed */
if (verbose > 0) {
fprintf(stderr,
"%s: safemode: Wrote %s to %x, read as %x. %d attempts left\n",
progname, fusename, fuse, fuseread, tries-1);
}
/* If fuse wrote OK, no need to keep going */
if (fuse == fuseread) {
tries = 0;
returnvalue = 0;
}
tries--;
}
return returnvalue;
}
/*
* Reads the fuses three times, checking that all readings are the
* same. This will ensure that the before values aren't in error!
*/
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
unsigned char * efuse, unsigned char * fuse,
PROGRAMMER * pgm, AVRPART * p, int verbose)
{
unsigned char value;
unsigned char fusegood = 0;
unsigned char safemode_lfuse;
unsigned char safemode_hfuse;
unsigned char safemode_efuse;
unsigned char safemode_fuse;
AVRMEM * m;
safemode_lfuse = *lfuse;
safemode_hfuse = *hfuse;
safemode_efuse = *efuse;
safemode_fuse = *fuse;
/* Read fuse three times */
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
to generate a verify error */
m = avr_locate_mem(p, "fuse");
if (m != NULL) {
fusegood = 0; /* By default fuse is a failure */
avr_read_byte(pgm, p, m, 0, &safemode_fuse);
avr_read_byte(pgm, p, m, 0, &value);
if (value == safemode_fuse) {
avr_read_byte(pgm, p, m, 0, &value);
if (value == safemode_fuse){
fusegood = 1; /* Fuse read OK three times */
}
}
}
if (fusegood == 0) {
fprintf(stderr,
"%s: safemode: Verify error - unable to read fuse properly. "
"Programmer may not be reliable.\n", progname);
return -1;
}
else if ((fusegood == 1) && (verbose > 0)) {
printf("%s: safemode: fuse reads as %X\n", progname, safemode_fuse);
}
/* Read lfuse three times */
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
to generate a verify error */
m = avr_locate_mem(p, "lfuse");
if (m != NULL) {
fusegood = 0; /* By default fuse is a failure */
avr_read_byte(pgm, p, m, 0, &safemode_lfuse);
avr_read_byte(pgm, p, m, 0, &value);
if (value == safemode_lfuse) {
avr_read_byte(pgm, p, m, 0, &value);
if (value == safemode_lfuse){
fusegood = 1; /* Fuse read OK three times */
}
}
}
if (fusegood == 0) {
fprintf(stderr,
"%s: safemode: Verify error - unable to read lfuse properly. "
"Programmer may not be reliable.\n", progname);
return -1;
}
else if ((fusegood == 1) && (verbose > 0)) {
printf("%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse);
}
/* Read hfuse three times */
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
to generate a verify error */
m = avr_locate_mem(p, "hfuse");
if (m != NULL) {
fusegood = 0; /* By default fuse is a failure */
avr_read_byte(pgm, p, m, 0, &safemode_hfuse);
avr_read_byte(pgm, p, m, 0, &value);
if (value == safemode_hfuse) {
avr_read_byte(pgm, p, m, 0, &value);
if (value == safemode_hfuse){
fusegood = 1; /* Fuse read OK three times */
}
}
}
if (fusegood == 0) {
fprintf(stderr,
"%s: safemode: Verify error - unable to read hfuse properly. "
"Programmer may not be reliable.\n", progname);
return -2;
}
else if ((fusegood == 1) && (verbose > 0)){
printf("%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse);
}
/* Read efuse three times */
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
to generate a verify error */
m = avr_locate_mem(p, "efuse");
if (m != NULL) {
fusegood = 0; /* By default fuse is a failure */
avr_read_byte(pgm, p, m, 0, &safemode_efuse);
avr_read_byte(pgm, p, m, 0, &value);
if (value == safemode_efuse) {
avr_read_byte(pgm, p, m, 0, &value);
if (value == safemode_efuse){
fusegood = 1; /* Fuse read OK three times */
}
}
}
if (fusegood == 0) {
fprintf(stderr,
"%s: safemode: Verify error - unable to read efuse properly. "
"Programmer may not be reliable.\n", progname);
return -3;
}
else if ((fusegood == 1) && (verbose > 0)) {
printf("%s: safemode: efuse reads as %X\n", progname, safemode_efuse);
}
*lfuse = safemode_lfuse;
*hfuse = safemode_hfuse;
*efuse = safemode_efuse;
*fuse = safemode_fuse;
return 0;
}
/*
* This routine will store the current values pointed to by lfuse,
* hfuse, and efuse into an internal buffer in this routine when save
* is set to 1. When save is 0 (or not 1 really) it will copy the
* values from the internal buffer into the locations pointed to be
* lfuse, hfuse, and efuse. This allows you to change the fuse bits if
* needed from another routine (ie: have it so if user requests fuse
* bits are changed, the requested value is now verified
*/
int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse,
unsigned char * efuse, unsigned char * fuse)
{
static unsigned char safemode_lfuse = 0xff;
static unsigned char safemode_hfuse = 0xff;
static unsigned char safemode_efuse = 0xff;
static unsigned char safemode_fuse = 0xff;
switch (save) {
/* Save the fuses as safemode setting */
case 1:
safemode_lfuse = *lfuse;
safemode_hfuse = *hfuse;
safemode_efuse = *efuse;
safemode_fuse = *fuse;
break;
/* Read back the fuses */
default:
*lfuse = safemode_lfuse;
*hfuse = safemode_hfuse;
*efuse = safemode_efuse;
*fuse = safemode_fuse;
break;
}
return 0;
}

39
avrdude/safemode.h Normal file
View File

@@ -0,0 +1,39 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* avrdude is Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This file: Copyright (C) 2005 Colin O'Flynn <coflynn@newae.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __safemode_h__
#define __safemode_h__
/* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or "efuse") and verifies it. Will try up to tries
amount of times before giving up */
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm, AVRPART * p, int tries, int verbose);
/* Reads the fuses three times, checking that all readings are the same. This will ensure that the before values aren't in error! */
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse, PROGRAMMER * pgm, AVRPART * p, int verbose);
/* This routine will store the current values pointed to by lfuse, hfuse, and efuse into an internal buffer in this routine
when save is set to 1. When save is 0 (or not 1 really) it will copy the values from the internal buffer into the locations
pointed to be lfuse, hfuse, and efuse. This allows you to change the fuse bits if needed from another routine (ie: have it so
if user requests fuse bits are changed, the requested value is now verified */
int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse);
#endif //__safemode_h

View File

@@ -1,6 +1,7 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Theodore A. Roth <troth@openavr.org>
* Copyright (C) 2003-2004 Theodore A. Roth <troth@openavr.org>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,14 +34,21 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include "serial.h"
extern char *progname;
extern int verbose;
long serial_recv_timeout = 5000; /* ms */
struct baud_mapping {
long baud;
speed_t speed;
@@ -61,6 +69,9 @@ static struct baud_mapping baud_lookup_table [] = {
{ 0, 0 } /* Terminator. */
};
static struct termios original_termios;
static int saved_original_termios;
static speed_t serial_baud_lookup(long baud)
{
struct baud_mapping *map = baud_lookup_table;
@@ -71,63 +82,155 @@ static speed_t serial_baud_lookup(long baud)
map++;
}
fprintf(stderr, "%s: serial_baud_lookup(): unknown baud rate: %ld",
fprintf(stderr, "%s: serial_baud_lookup(): unknown baud rate: %ld\n",
progname, baud);
exit(1);
}
static int serial_setattr(int fd, long baud)
static int ser_setspeed(int fd, long baud)
{
int rc;
struct termios termios;
speed_t speed = serial_baud_lookup (baud);
if (!isatty(fd))
return -1;
return -ENOTTY;
/*
* initialize terminal modes
*/
rc = tcgetattr(fd, &termios);
if (rc < 0) {
fprintf(stderr, "%s: serial_setattr(): tcgetattr() failed, %s",
progname, strerror(errno));
fprintf(stderr, "%s: ser_setspeed(): tcgetattr() failed",
progname);
return -errno;
}
termios.c_iflag = 0;
/*
* copy termios for ser_close if we haven't already
*/
if (! saved_original_termios++) {
original_termios = termios;
}
termios.c_iflag = IGNBRK;
termios.c_oflag = 0;
termios.c_cflag = 0;
termios.c_cflag |= (CS8 | CREAD | CLOCAL);
termios.c_lflag = 0;
termios.c_cflag = (CS8 | CREAD | CLOCAL);
termios.c_cc[VMIN] = 1;
termios.c_cc[VTIME] = 0;
cfsetospeed(&termios, speed);
cfsetispeed(&termios, speed);
rc = tcsetattr(fd, TCSANOW, &termios);
rc = tcsetattr(fd, TCSANOW | TCSAFLUSH, &termios);
if (rc < 0) {
fprintf(stderr, "%s: serial_setattr(): tcsetattr() failed, %s",
progname, strerror(errno));
fprintf(stderr, "%s: ser_setspeed(): tcsetattr() failed",
progname);
return -errno;
}
/*
* Everything is now set up for a local line without modem control
* or flow control, so clear O_NONBLOCK again.
*/
rc = fcntl(fd, F_GETFL, 0);
if (rc != -1)
fcntl(fd, F_SETFL, rc & ~O_NONBLOCK);
return 0;
}
/*
* Given a port description of the form <host>:<port>, open a TCP
* connection to the specified destination, which is assumed to be a
* terminal/console server with serial parameters configured
* appropriately (e. g. 115200-8-N-1 for a STK500.)
*/
static int
net_open(const char *port)
{
char *hstr, *pstr, *end;
unsigned int pnum;
int fd;
struct sockaddr_in sockaddr;
struct hostent *hp;
int serial_open(char * port, int baud)
if ((hstr = strdup(port)) == NULL) {
fprintf(stderr, "%s: net_open(): Out of memory!\n",
progname);
exit(1);
}
if (((pstr = strchr(hstr, ':')) == NULL) || (pstr == hstr)) {
fprintf(stderr, "%s: net_open(): Mangled host:port string \"%s\"\n",
progname, hstr);
free(hstr);
exit(1);
}
/*
* Terminate the host section of the description.
*/
*pstr++ = '\0';
pnum = strtoul(pstr, &end, 10);
if ((*pstr == '\0') || (*end != '\0') || (pnum == 0) || (pnum > 65535)) {
fprintf(stderr, "%s: net_open(): Bad port number \"%s\"\n",
progname, pstr);
free(hstr);
exit(1);
}
if ((hp = gethostbyname(hstr)) == NULL) {
fprintf(stderr, "%s: net_open(): unknown host \"%s\"\n",
progname, hstr);
free(hstr);
exit(1);
}
free(hstr);
if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
fprintf(stderr, "%s: net_open(): Cannot open socket: %s\n",
progname, strerror(errno));
exit(1);
}
memset(&sockaddr, 0, sizeof(struct sockaddr_in));
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(pnum);
memcpy(&(sockaddr.sin_addr.s_addr), hp->h_addr, sizeof(struct in_addr));
if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) {
fprintf(stderr, "%s: net_open(): Connect failed: %s\n",
progname, strerror(errno));
exit(1);
}
return fd;
}
static int ser_open(char * port, long baud)
{
int rc;
int fd;
/*
* If the port is of the form "net:<host>:<port>", then
* handle it as a TCP connection to a terminal server.
*/
if (strncmp(port, "net:", strlen("net:")) == 0) {
return net_open(port + strlen("net:"));
}
/*
* open the serial port
*/
fd = open(port, O_RDWR | O_NOCTTY /*| O_NONBLOCK*/);
fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd < 0) {
fprintf(stderr, "%s: serial_open(): can't open device \"%s\": %s\n",
fprintf(stderr, "%s: ser_open(): can't open device \"%s\": %s\n",
progname, port, strerror(errno));
exit(1);
}
@@ -135,11 +238,11 @@ int serial_open(char * port, int baud)
/*
* set serial line attributes
*/
rc = serial_setattr(fd, baud);
rc = ser_setspeed(fd, baud);
if (rc) {
fprintf(stderr,
"%s: serial_open(): can't set attributes for device \"%s\"\n",
progname, port);
"%s: ser_open(): can't set attributes for device \"%s\": %s\n",
progname, port, strerror(-rc));
exit(1);
}
@@ -147,22 +250,32 @@ int serial_open(char * port, int baud)
}
void serial_close(int fd)
static void ser_close(int fd)
{
/* FIXME: Should really restore the terminal to original state here. */
/*
* restore original termios settings from ser_open
*/
if (saved_original_termios) {
int rc = tcsetattr(fd, TCSANOW | TCSADRAIN, &original_termios);
if (rc) {
fprintf(stderr,
"%s: ser_close(): can't reset attributes for device: %s\n",
progname, strerror(errno));
}
saved_original_termios = 0;
}
close(fd);
}
int serial_send(int fd, char * buf, size_t buflen)
static int ser_send(int fd, unsigned char * buf, size_t buflen)
{
struct timeval timeout;
struct timeval timeout, to2;
fd_set wfds;
int nfds;
int rc;
char * p = buf;
unsigned char * p = buf;
size_t len = buflen;
if (!len)
@@ -191,88 +304,94 @@ int serial_send(int fd, char * buf, size_t buflen)
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
to2 = timeout;
while (len) {
reselect:
FD_ZERO(&wfds);
FD_SET(fd, &wfds);
reselect:
nfds = select(fd+1, NULL, &wfds, NULL, &timeout);
nfds = select(fd+1, NULL, &wfds, NULL, &to2);
if (nfds == 0) {
fprintf(stderr,
"%s: serial_send(): programmer is not responding\n",
progname);
if (verbose >= 1)
fprintf(stderr,
"%s: ser_send(): programmer is not responding\n",
progname);
exit(1);
}
else if (nfds == -1) {
if (errno == EINTR) {
if (errno == EINTR || errno == EAGAIN) {
goto reselect;
}
else {
fprintf(stderr, "%s: serial_send(): select(): %s\n",
fprintf(stderr, "%s: ser_send(): select(): %s\n",
progname, strerror(errno));
exit(1);
}
}
rc = write(fd, p, 1);
rc = write(fd, p, (len > 1024) ? 1024 : len);
if (rc < 0) {
fprintf(stderr, "%s: serial_send(): write error: %s\n",
fprintf(stderr, "%s: ser_send(): write error: %s\n",
progname, strerror(errno));
exit(1);
}
p++;
len--;
p += rc;
len -= rc;
}
return 0;
}
int serial_recv(int fd, char * buf, size_t buflen)
static int ser_recv(int fd, unsigned char * buf, size_t buflen)
{
struct timeval timeout;
struct timeval timeout, to2;
fd_set rfds;
int nfds;
int rc;
char * p = buf;
unsigned char * p = buf;
size_t len = 0;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
timeout.tv_sec = serial_recv_timeout / 1000L;
timeout.tv_usec = (serial_recv_timeout % 1000L) * 1000;
to2 = timeout;
while (len < buflen) {
reselect:
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
reselect:
nfds = select(fd+1, &rfds, NULL, NULL, &timeout);
nfds = select(fd+1, &rfds, NULL, NULL, &to2);
if (nfds == 0) {
fprintf(stderr,
"%s: serial_recv(): programmer is not responding\n",
progname);
exit(1);
if (verbose > 1)
fprintf(stderr,
"%s: ser_recv(): programmer is not responding\n",
progname);
return -1;
}
else if (nfds == -1) {
if (errno == EINTR) {
if (errno == EINTR || errno == EAGAIN) {
fprintf(stderr,
"%s: ser_recv(): programmer is not responding,reselecting\n",
progname);
goto reselect;
}
else {
fprintf(stderr, "%s: serial_recv(): select(): %s\n",
fprintf(stderr, "%s: ser_recv(): select(): %s\n",
progname, strerror(errno));
exit(1);
}
}
rc = read(fd, p, 1);
rc = read(fd, p, (buflen - len > 1024) ? 1024 : buflen - len);
if (rc < 0) {
fprintf(stderr, "%s: serial_recv(): read error: %s\n",
fprintf(stderr, "%s: ser_recv(): read error: %s\n",
progname, strerror(errno));
exit(1);
}
p++;
len++;
p += rc;
len += rc;
}
p = buf;
@@ -301,7 +420,7 @@ int serial_recv(int fd, char * buf, size_t buflen)
}
int serial_drain(int fd, int display)
static int ser_drain(int fd, int display)
{
struct timeval timeout;
fd_set rfds;
@@ -334,7 +453,7 @@ int serial_drain(int fd, int display)
goto reselect;
}
else {
fprintf(stderr, "%s: serial_drain(): select(): %s\n",
fprintf(stderr, "%s: ser_drain(): select(): %s\n",
progname, strerror(errno));
exit(1);
}
@@ -342,7 +461,7 @@ int serial_drain(int fd, int display)
rc = read(fd, &buf, 1);
if (rc < 0) {
fprintf(stderr, "%s: serial_drain(): read error: %s\n",
fprintf(stderr, "%s: ser_drain(): read error: %s\n",
progname, strerror(errno));
exit(1);
}
@@ -354,4 +473,16 @@ int serial_drain(int fd, int display)
return 0;
}
struct serial_device serial_serdev =
{
.open = ser_open,
.setspeed = ser_setspeed,
.close = ser_close,
.send = ser_send,
.recv = ser_recv,
.drain = ser_drain,
};
struct serial_device *serdev = &serial_serdev;
#endif /* WIN32NATIVE */

View File

@@ -1,6 +1,7 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003, 2004 Martin J. Thomas <mthomas@rhrk.uni-kl.de>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,6 +34,8 @@
extern char *progname;
extern int verbose;
long serial_recv_timeout = 5000; /* ms */
#define W32SERBUFSIZE 1024
struct baud_mapping {
@@ -70,7 +73,7 @@ static DWORD serial_baud_lookup(long baud)
}
BOOL serial_w32SetTimeOut(HANDLE hComPort, DWORD timeout) // in ms
static BOOL serial_w32SetTimeOut(HANDLE hComPort, DWORD timeout) // in ms
{
COMMTIMEOUTS ctmo;
ZeroMemory (&ctmo, sizeof(COMMTIMEOUTS));
@@ -81,14 +84,49 @@ BOOL serial_w32SetTimeOut(HANDLE hComPort, DWORD timeout) // in ms
return SetCommTimeouts(hComPort, &ctmo);
}
int serial_open(char * port, long baud)
static int ser_setspeed(int fd, long baud)
{
DCB dcb;
HANDLE hComPort = (HANDLE)fd;
ZeroMemory (&dcb, sizeof(DCB));
dcb.DCBlength = sizeof(DCB);
dcb.BaudRate = serial_baud_lookup (baud);
dcb.fBinary = 1;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
if (!SetCommState(hComPort, &dcb))
return -1;
return 0;
}
static int ser_open(char * port, long baud)
{
LPVOID lpMsgBuf;
HANDLE hComPort=INVALID_HANDLE_VALUE;
/*
* If the port is of the form "net:<host>:<port>", then
* handle it as a TCP connection to a terminal server.
*
* This is curently not implemented for Win32.
*/
if (strncmp(port, "net:", strlen("net:")) == 0) {
fprintf(stderr,
"%s: ser_open(): network connects are currently not"
"implemented for Win32 environments\n",
progname);
exit(1);
}
/* if (hComPort!=INVALID_HANDLE_VALUE)
fprintf(stderr, "%s: serial_open(): \"%s\" is already open\n",
fprintf(stderr, "%s: ser_open(): \"%s\" is already open\n",
progname, port);
*/
@@ -106,7 +144,7 @@ int serial_open(char * port, long baud)
(LPTSTR) &lpMsgBuf,
0,
NULL);
fprintf(stderr, "%s: serial_open(): can't open device \"%s\": %s\n",
fprintf(stderr, "%s: ser_open(): can't open device \"%s\": %s\n",
progname, port, (char*)lpMsgBuf);
LocalFree( lpMsgBuf );
exit(1);
@@ -115,25 +153,16 @@ int serial_open(char * port, long baud)
if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
{
CloseHandle(hComPort);
fprintf(stderr, "%s: serial_open(): can't set buffers for \"%s\"\n",
fprintf(stderr, "%s: ser_open(): can't set buffers for \"%s\"\n",
progname, port);
exit(1);
}
ZeroMemory (&dcb, sizeof(DCB));
dcb.DCBlength = sizeof(DCB);
dcb.BaudRate = serial_baud_lookup (baud);
dcb.fBinary = 1;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
if (!SetCommState(hComPort, &dcb))
if (ser_setspeed((int)hComPort, baud) != 0)
{
CloseHandle(hComPort);
fprintf(stderr, "%s: serial_open(): can't set com-state for \"%s\"\n",
fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n",
progname, port);
exit(1);
}
@@ -141,7 +170,7 @@ int serial_open(char * port, long baud)
if (!serial_w32SetTimeOut(hComPort,0))
{
CloseHandle(hComPort);
fprintf(stderr, "%s: serial_open(): can't set initial timeout for \"%s\"\n",
fprintf(stderr, "%s: ser_open(): can't set initial timeout for \"%s\"\n",
progname, port);
exit(1);
}
@@ -150,7 +179,7 @@ int serial_open(char * port, long baud)
}
void serial_close(int fd)
static void ser_close(int fd)
{
HANDLE hComPort=(HANDLE)fd;
if (hComPort != INVALID_HANDLE_VALUE)
@@ -160,16 +189,17 @@ void serial_close(int fd)
}
int serial_send(int fd, char * buf, size_t buflen)
static int ser_send(int fd, char * buf, size_t buflen)
{
size_t len = buflen;
unsigned char c='\0';
DWORD written;
char * b = buf;
HANDLE hComPort=(HANDLE)fd;
if (hComPort == INVALID_HANDLE_VALUE) {
fprintf(stderr, "%s: serial_send(): port not open\n",
fprintf(stderr, "%s: ser_send(): port not open\n",
progname);
exit(1);
}
@@ -181,8 +211,8 @@ int serial_send(int fd, char * buf, size_t buflen)
{
fprintf(stderr, "%s: Send: ", progname);
while (buflen) {
c = *buf;
while (len) {
c = *b;
if (isprint(c)) {
fprintf(stderr, "%c ", c);
}
@@ -190,8 +220,8 @@ int serial_send(int fd, char * buf, size_t buflen)
fprintf(stderr, ". ");
}
fprintf(stderr, "[%02x] ", c);
buf++;
buflen--;
b++;
len--;
}
fprintf(stderr, "\n");
}
@@ -199,13 +229,13 @@ int serial_send(int fd, char * buf, size_t buflen)
serial_w32SetTimeOut(hComPort,500);
if (!WriteFile (hComPort, buf, buflen, &written, NULL)) {
fprintf(stderr, "%s: serial_send(): write error: %s\n",
fprintf(stderr, "%s: ser_send(): write error: %s\n",
progname, "sorry no info avail"); // TODO
exit(1);
}
if (written != buflen) {
fprintf(stderr, "%s: serial_send(): size/send mismatch\n",
fprintf(stderr, "%s: ser_send(): size/send mismatch\n",
progname);
exit(1);
}
@@ -214,7 +244,7 @@ int serial_send(int fd, char * buf, size_t buflen)
}
int serial_recv(int fd, char * buf, size_t buflen)
static int ser_recv(int fd, char * buf, size_t buflen)
{
unsigned char c;
char * p = buf;
@@ -224,12 +254,12 @@ int serial_recv(int fd, char * buf, size_t buflen)
HANDLE hComPort=(HANDLE)fd;
if (hComPort == INVALID_HANDLE_VALUE) {
fprintf(stderr, "%s: serial_read(): port not open\n",
fprintf(stderr, "%s: ser_read(): port not open\n",
progname);
exit(1);
}
serial_w32SetTimeOut(hComPort,5000);
serial_w32SetTimeOut(hComPort, serial_recv_timeout);
if (!ReadFile(hComPort, buf, buflen, &read, NULL)) {
LPVOID lpMsgBuf;
@@ -243,7 +273,7 @@ int serial_recv(int fd, char * buf, size_t buflen)
(LPTSTR) &lpMsgBuf,
0,
NULL );
fprintf(stderr, "%s: serial_recv(): read error: %s\n",
fprintf(stderr, "%s: ser_recv(): read error: %s\n",
progname, (char*)lpMsgBuf);
LocalFree( lpMsgBuf );
exit(1);
@@ -274,7 +304,7 @@ int serial_recv(int fd, char * buf, size_t buflen)
}
int serial_drain(int fd, int display)
static int ser_drain(int fd, int display)
{
// int rc;
unsigned char buf[10];
@@ -284,7 +314,7 @@ int serial_drain(int fd, int display)
HANDLE hComPort=(HANDLE)fd;
if (hComPort == INVALID_HANDLE_VALUE) {
fprintf(stderr, "%s: serial_drain(): port not open\n",
fprintf(stderr, "%s: ser_drain(): port not open\n",
progname);
exit(1);
}
@@ -309,7 +339,7 @@ int serial_drain(int fd, int display)
(LPTSTR) &lpMsgBuf,
0,
NULL );
fprintf(stderr, "%s: serial_drain(): read error: %s\n",
fprintf(stderr, "%s: ser_drain(): read error: %s\n",
progname, (char*)lpMsgBuf);
LocalFree( lpMsgBuf );
exit(1);
@@ -326,4 +356,16 @@ int serial_drain(int fd, int display)
return 0;
}
struct serial_device serial_serdev =
{
.open = ser_open,
.setspeed = ser_setspeed,
.close = ser_close,
.send = ser_send,
.recv = ser_recv,
.drain = ser_drain,
};
struct serial_device *serdev = &serial_serdev;
#endif /* WIN32NATIVE */

33
avrdude/serbb.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef serbb_h
#define serbb_h
void serbb_initpgm (PROGRAMMER * pgm);
int serbb_setpin(int fd, int pin, int value);
int serbb_getpin(int fd, int pin);
int serbb_highpulsepin(int fd, int pin);
#endif

310
avrdude/serbb_posix.c Normal file
View File

@@ -0,0 +1,310 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
/*
* Posix serial bitbanging interface for avrdude.
*/
#if !defined(WIN32NATIVE)
#include "ac_cfg.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <termios.h>
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
#include "bitbang.h"
#undef DEBUG
extern char *progname;
struct termios oldmode;
/*
serial port/pin mapping
1 cd <-
2 (rxd) <-
3 txd ->
4 dtr ->
5 GND
6 dsr <-
7 rts ->
8 cts <-
9 ri <-
*/
#define DB9PINS 9
static int serregbits[DB9PINS + 1] =
{ 0, TIOCM_CD, 0, 0, TIOCM_DTR, 0, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS, TIOCM_RI };
#ifdef DEBUG
static char *serpins[DB9PINS + 1] =
{ "NONE", "CD", "RXD", "TXD", "DTR", "GND", "DSR", "RTS", "CTS", "RI" };
#endif
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
{
unsigned int ctl;
int r;
if (pin & PIN_INVERSE)
{
value = !value;
pin &= PIN_MASK;
}
if ( pin < 1 || pin > DB9PINS )
return -1;
#ifdef DEBUG
printf("%s to %d\n",serpins[pin],value);
#endif
switch ( pin )
{
case 3: /* txd */
r = ioctl(pgm->fd, value ? TIOCSBRK : TIOCCBRK, 0);
if (r < 0) {
perror("ioctl(\"TIOCxBRK\")");
return -1;
}
return 0;
case 4: /* dtr */
case 7: /* rts */
r = ioctl(pgm->fd, TIOCMGET, &ctl);
if (r < 0) {
perror("ioctl(\"TIOCMGET\")");
return -1;
}
if ( value )
ctl |= serregbits[pin];
else
ctl &= ~(serregbits[pin]);
r = ioctl(pgm->fd, TIOCMSET, &ctl);
if (r < 0) {
perror("ioctl(\"TIOCMSET\")");
return -1;
}
return 0;
default: /* impossible */
return -1;
}
}
static int serbb_getpin(PROGRAMMER * pgm, int pin)
{
unsigned int ctl;
unsigned char invert;
int r;
if (pin & PIN_INVERSE)
{
invert = 1;
pin &= PIN_MASK;
} else
invert = 0;
if ( pin < 1 || pin > DB9PINS )
return(-1);
switch ( pin )
{
case 2: /* rxd, currently not implemented, FIXME */
return(-1);
case 1: /* cd */
case 6: /* dsr */
case 8: /* cts */
case 9: /* ri */
r = ioctl(pgm->fd, TIOCMGET, &ctl);
if (r < 0) {
perror("ioctl(\"TIOCMGET\")");
return -1;
}
if ( !invert )
{
#ifdef DEBUG
printf("%s is %d\n",serpins[pin],(ctl & serregbits[pin]) ? 1 : 0 );
#endif
return ( (ctl & serregbits[pin]) ? 1 : 0 );
}
else
{
#ifdef DEBUG
printf("%s is %d (~)\n",serpins[pin],(ctl & serregbits[pin]) ? 0 : 1 );
#endif
return (( ctl & serregbits[pin]) ? 0 : 1 );
}
default: /* impossible */
return(-1);
}
}
static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
{
if ( pin < 1 || pin > DB9PINS )
return -1;
serbb_setpin(pgm, pin, 1);
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
serbb_setpin(pgm, pin, 0);
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
return 0;
}
static void serbb_display(PROGRAMMER *pgm, char *p)
{
/* MAYBE */
}
static void serbb_enable(PROGRAMMER *pgm)
{
/* nothing */
}
static void serbb_disable(PROGRAMMER *pgm)
{
/* nothing */
}
static void serbb_powerup(PROGRAMMER *pgm)
{
/* nothing */
}
static void serbb_powerdown(PROGRAMMER *pgm)
{
/* nothing */
}
static int serbb_open(PROGRAMMER *pgm, char *port)
{
struct termios mode;
int flags;
int r;
bitbang_check_prerequisites(pgm);
/* adapted from uisp code */
pgm->fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (pgm->fd < 0) {
perror(port);
return(-1);
}
r = tcgetattr(pgm->fd, &mode);
if (r < 0) {
fprintf(stderr, "%s: ", port);
perror("tcgetattr");
return(-1);
}
oldmode = mode;
mode.c_iflag = IGNBRK | IGNPAR;
mode.c_oflag = 0;
mode.c_cflag = CLOCAL | CREAD | CS8 | B9600;
mode.c_cc [VMIN] = 1;
mode.c_cc [VTIME] = 0;
r = tcsetattr(pgm->fd, TCSANOW, &mode);
if (r < 0) {
fprintf(stderr, "%s: ", port);
perror("tcsetattr");
return(-1);
}
/* Clear O_NONBLOCK flag. */
flags = fcntl(pgm->fd, F_GETFL, 0);
if (flags == -1)
{
fprintf(stderr, "%s: Can not get flags: %s\n",
progname, strerror(errno));
return(-1);
}
flags &= ~O_NONBLOCK;
if (fcntl(pgm->fd, F_SETFL, flags) == -1)
{
fprintf(stderr, "%s: Can not clear nonblock flag: %s\n",
progname, strerror(errno));
return(-1);
}
return(0);
}
static void serbb_close(PROGRAMMER *pgm)
{
if (pgm->fd != -1)
{
(void)tcsetattr(pgm->fd, TCSANOW, &oldmode);
pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 1);
close(pgm->fd);
}
return;
}
void serbb_initpgm(PROGRAMMER *pgm)
{
strcpy(pgm->type, "SERBB");
pgm->rdy_led = bitbang_rdy_led;
pgm->err_led = bitbang_err_led;
pgm->pgm_led = bitbang_pgm_led;
pgm->vfy_led = bitbang_vfy_led;
pgm->initialize = bitbang_initialize;
pgm->display = serbb_display;
pgm->enable = serbb_enable;
pgm->disable = serbb_disable;
pgm->powerup = serbb_powerup;
pgm->powerdown = serbb_powerdown;
pgm->program_enable = bitbang_program_enable;
pgm->chip_erase = bitbang_chip_erase;
pgm->cmd = bitbang_cmd;
pgm->open = serbb_open;
pgm->close = serbb_close;
pgm->setpin = serbb_setpin;
pgm->getpin = serbb_getpin;
pgm->highpulsepin = serbb_highpulsepin;
}
#endif /* WIN32NATIVE */

373
avrdude/serbb_win32.c Normal file
View File

@@ -0,0 +1,373 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003, 2004 Martin J. Thomas <mthomas@rhrk.uni-kl.de>
* Copyright (C) 2005 Michael Holzt <kju-avr@fqdn.org>
* Copyright (C) 2005, 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
/*
* Win32 serial bitbanging interface for avrdude.
*/
#if defined(WIN32NATIVE)
#include "ac_cfg.h"
#include <windows.h>
#include <stdio.h>
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
#include "bitbang.h"
extern char *progname;
extern int verbose;
/* cached status lines */
static int dtr, rts, txd;
#define W32SERBUFSIZE 1024
/*
serial port/pin mapping
1 cd <-
2 (rxd) <-
3 txd ->
4 dtr ->
5 GND
6 dsr <-
7 rts ->
8 cts <-
9 ri <-
*/
#define DB9PINS 9
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
{
HANDLE hComPort = (HANDLE)pgm->fd;
LPVOID lpMsgBuf;
DWORD dwFunc;
const char *name;
if (pin & PIN_INVERSE)
{
value = !value;
pin &= PIN_MASK;
}
if (pin < 1 || pin > DB9PINS)
return -1;
switch (pin)
{
case 3: /* txd */
dwFunc = value? SETBREAK: CLRBREAK;
name = value? "SETBREAK": "CLRBREAK";
txd = value;
break;
case 4: /* dtr */
dwFunc = value? SETDTR: CLRDTR;
name = value? "SETDTR": "CLRDTR";
dtr = value;
break;
case 7: /* rts */
dwFunc = value? SETRTS: CLRRTS;
name = value? "SETRTS": "CLRRTS";
break;
default:
if (verbose)
fprintf(stderr,
"%s: serbb_setpin(): unknown pin %d\n",
progname, pin + 1);
return -1;
}
if (verbose > 4)
fprintf(stderr,
"%s: serbb_setpin(): EscapeCommFunction(%s)\n",
progname, name);
if (!EscapeCommFunction(hComPort, dwFunc))
{
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
fprintf(stderr,
"%s: serbb_setpin(): SetCommState() failed: %s\n",
progname, (char *)lpMsgBuf);
CloseHandle(hComPort);
LocalFree(lpMsgBuf);
exit(1);
}
return 0;
}
static int serbb_getpin(PROGRAMMER * pgm, int pin)
{
HANDLE hComPort = (HANDLE)pgm->fd;
LPVOID lpMsgBuf;
int invert, rv;
const char *name;
DWORD modemstate;
if (pin & PIN_INVERSE)
{
invert = 1;
pin &= PIN_MASK;
} else
invert = 0;
if (pin < 1 || pin > DB9PINS)
return -1;
if (pin == 1 /* cd */ || pin == 6 /* dsr */ || pin == 8 /* cts */)
{
if (!GetCommModemStatus(hComPort, &modemstate))
{
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
fprintf(stderr,
"%s: serbb_setpin(): GetCommModemStatus() failed: %s\n",
progname, (char *)lpMsgBuf);
CloseHandle(hComPort);
LocalFree(lpMsgBuf);
exit(1);
}
if (verbose > 4)
fprintf(stderr,
"%s: serbb_getpin(): GetCommState() => 0x%lx\n",
progname, modemstate);
switch (pin)
{
case 1:
modemstate &= MS_RLSD_ON;
break;
case 6:
modemstate &= MS_DSR_ON;
break;
case 8:
modemstate &= MS_CTS_ON;
break;
}
rv = modemstate != 0;
if (invert)
rv = !rv;
return rv;
}
switch (pin)
{
case 3: /* txd */
rv = txd;
name = "TXD";
break;
case 4: /* dtr */
rv = dtr;
name = "DTR";
break;
case 7: /* rts */
rv = rts;
name = "RTS";
break;
default:
if (verbose)
fprintf(stderr,
"%s: serbb_getpin(): unknown pin %d\n",
progname, pin + 1);
return -1;
}
if (verbose > 4)
fprintf(stderr,
"%s: serbb_getpin(): return cached state for %s\n",
progname, name);
if (invert)
rv = !rv;
return rv;
}
static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
{
if (pin < 1 || pin > 7)
return -1;
serbb_setpin(pgm, pin, 1);
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
serbb_setpin(pgm, pin, 0);
if (pgm->ispdelay > 1)
bitbang_delay(pgm->ispdelay);
return 0;
}
static void serbb_display(PROGRAMMER *pgm, char *p)
{
/* MAYBE */
}
static void serbb_enable(PROGRAMMER *pgm)
{
/* nothing */
}
static void serbb_disable(PROGRAMMER *pgm)
{
/* nothing */
}
static void serbb_powerup(PROGRAMMER *pgm)
{
/* nothing */
}
static void serbb_powerdown(PROGRAMMER *pgm)
{
/* nothing */
}
static int serbb_open(PROGRAMMER *pgm, char *port)
{
DCB dcb;
LPVOID lpMsgBuf;
HANDLE hComPort = INVALID_HANDLE_VALUE;
bitbang_check_prerequisites(pgm);
hComPort = CreateFile(port, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hComPort == INVALID_HANDLE_VALUE) {
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
fprintf(stderr, "%s: ser_open(): can't open device \"%s\": %s\n",
progname, port, (char*)lpMsgBuf);
LocalFree(lpMsgBuf);
return -1;
}
if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE))
{
CloseHandle(hComPort);
fprintf(stderr, "%s: ser_open(): can't set buffers for \"%s\"\n",
progname, port);
return -1;
}
ZeroMemory(&dcb, sizeof(DCB));
dcb.DCBlength = sizeof(DCB);
dcb.BaudRate = CBR_9600;
dcb.fBinary = 1;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
if (!SetCommState(hComPort, &dcb))
{
CloseHandle(hComPort);
fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n",
progname, port);
return -1;
}
if (verbose > 2)
fprintf(stderr,
"%s: ser_open(): opened comm port \"%s\", handle 0x%x\n",
progname, port, (int)hComPort);
pgm->fd = (int)hComPort;
dtr = rts = txd = 0;
return 0;
}
static void serbb_close(PROGRAMMER *pgm)
{
HANDLE hComPort=(HANDLE)pgm->fd;
if (hComPort != INVALID_HANDLE_VALUE)
{
pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 1);
CloseHandle (hComPort);
}
if (verbose > 2)
fprintf(stderr,
"%s: ser_close(): closed comm port handle 0x%x\n",
progname, (int)hComPort);
hComPort = INVALID_HANDLE_VALUE;
}
void serbb_initpgm(PROGRAMMER *pgm)
{
strcpy(pgm->type, "SERBB");
pgm->rdy_led = bitbang_rdy_led;
pgm->err_led = bitbang_err_led;
pgm->pgm_led = bitbang_pgm_led;
pgm->vfy_led = bitbang_vfy_led;
pgm->initialize = bitbang_initialize;
pgm->display = serbb_display;
pgm->enable = serbb_enable;
pgm->disable = serbb_disable;
pgm->powerup = serbb_powerup;
pgm->powerdown = serbb_powerdown;
pgm->program_enable = bitbang_program_enable;
pgm->chip_erase = bitbang_chip_erase;
pgm->cmd = bitbang_cmd;
pgm->open = serbb_open;
pgm->close = serbb_close;
pgm->setpin = serbb_setpin;
pgm->getpin = serbb_getpin;
pgm->highpulsepin = serbb_highpulsepin;
}
#endif /* WIN32NATIVE */

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003 Theodore A. Roth <troth@openavr.org>
* Copyright (C) 2003-2004 Theodore A. Roth <troth@openavr.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,11 +30,27 @@
#ifndef __serial_h__
#define __serial_h__
extern int serial_open(char * port, long baud);
extern void serial_close(int fd);
extern long serial_recv_timeout;
extern int serial_send(int fd, char * buf, size_t buflen);
extern int serial_recv(int fd, char * buf, size_t buflen);
extern int serial_drain(int fd, int display);
struct serial_device
{
int (*open)(char * port, long baud);
int (*setspeed)(int fd, long baud);
void (*close)(int fd);
int (*send)(int fd, unsigned char * buf, size_t buflen);
int (*recv)(int fd, unsigned char * buf, size_t buflen);
int (*drain)(int fd, int display);
};
extern struct serial_device *serdev;
extern struct serial_device serial_serdev, usb_serdev, usb_serdev_frame;
#define serial_open (serdev->open)
#define serial_setspeed (serdev->setspeed)
#define serial_close (serdev->close)
#define serial_send (serdev->send)
#define serial_recv (serdev->recv)
#define serial_drain (serdev->drain)
#endif /* __serial_h__ */

51
avrdude/solaris_ecpp.h Normal file
View File

@@ -0,0 +1,51 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2005 Joerg Wunsch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef solaris_ecpp_h
#define solaris_ecpp_h
#include <sys/ecppio.h>
#define ppi_claim(fd) \
do { \
struct ecpp_transfer_parms p; \
(void)ioctl(fd, ECPPIOC_GETPARMS, &p); \
p.mode = ECPP_DIAG_MODE; \
(void)ioctl(fd, ECPPIOC_SETPARMS, &p); \
} while(0);
#define ppi_release(fd)
#define DO_PPI_READ(fd, reg, valp) \
do { struct ecpp_regs r; \
if ((reg) == PPIDATA) { (void)ioctl(fd, ECPPIOC_GETDATA, valp); } \
else { (void)ioctl(fd, ECPPIOC_GETREGS, &r); \
*(valp) = ((reg) == PPICTRL)? r.dcr: r.dsr; } \
} while(0)
#define DO_PPI_WRITE(fd, reg, valp) \
do { struct ecpp_regs r; \
if ((reg) == PPIDATA) { (void)ioctl(fd, ECPPIOC_SETDATA, valp); } \
else { if ((reg) == PPICTRL) r.dcr = *(valp); else r.dsr = *(valp); \
(void)ioctl(fd, ECPPIOC_SETREGS, &r); } \
} while(0)
#endif /* solaris_ecpp_h */

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -55,15 +55,24 @@ static int stk500_is_page_empty(unsigned int address, int page_size,
const unsigned char *buf);
static int stk500_send(PROGRAMMER * pgm, char * buf, size_t len)
static int stk500_send(PROGRAMMER * pgm, unsigned char * buf, size_t len)
{
return serial_send(pgm->fd, buf, len);
}
static int stk500_recv(PROGRAMMER * pgm, char * buf, size_t len)
static int stk500_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len)
{
return serial_recv(pgm->fd, buf, len);
int rv;
rv = serial_recv(pgm->fd, buf, len);
if (rv < 0) {
fprintf(stderr,
"%s: stk500_recv(): programmer is not responding\n",
progname);
return -1;
}
return 0;
}
@@ -81,23 +90,35 @@ static int stk500_getsync(PROGRAMMER * pgm)
* get in sync */
buf[0] = Cmnd_STK_GET_SYNC;
buf[1] = Sync_CRC_EOP;
/*
* First send and drain a few times to get rid of line noise
*/
stk500_send(pgm, buf, 2);
stk500_recv(pgm, resp, 1);
stk500_drain(pgm, 0);
stk500_send(pgm, buf, 2);
stk500_drain(pgm, 0);
stk500_send(pgm, buf, 2);
if (stk500_recv(pgm, resp, 1) < 0)
return -1;
if (resp[0] != Resp_STK_INSYNC) {
fprintf(stderr,
"%s: stk500_getsync(): not in sync: resp=0x%02x\n",
progname, resp[0]);
stk500_drain(pgm, 0);
exit(1);
return -1;
}
stk500_recv(pgm, resp, 1);
if (stk500_recv(pgm, resp, 1) < 0)
return -1;
if (resp[0] != Resp_STK_OK) {
fprintf(stderr,
"%s: stk500_getsync(): can't communicate with device: "
"resp=0x%02x\n",
progname, resp[0]);
exit(1);
return -1;
}
return 0;
@@ -122,7 +143,8 @@ static int stk500_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
stk500_send(pgm, buf, 6);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] != Resp_STK_INSYNC) {
fprintf(stderr, "%s: stk500_cmd(): programmer is out of sync\n", progname);
exit(1);
@@ -131,9 +153,11 @@ static int stk500_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
res[0] = cmd[1];
res[1] = cmd[2];
res[2] = cmd[3];
stk500_recv(pgm, &res[3], 1);
if (stk500_recv(pgm, &res[3], 1) < 0)
exit(1);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] != Resp_STK_OK) {
fprintf(stderr, "%s: stk500_cmd(): protocol error\n", progname);
exit(1);
@@ -188,14 +212,16 @@ static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p)
buf[1] = Sync_CRC_EOP;
stk500_send(pgm, buf, 2);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
fprintf(stderr, "%s: stk500_program_enable(): can't get into sync\n",
progname);
return -1;
}
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return -1;
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
@@ -206,7 +232,8 @@ static int stk500_program_enable(PROGRAMMER * pgm, AVRPART * p)
return -1;
}
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_OK) {
return 0;
}
@@ -252,14 +279,16 @@ static int stk500_set_extended_parms(PROGRAMMER * pgm, int n,
buf[i] = Sync_CRC_EOP;
stk500_send(pgm, buf, i+1);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
fprintf(stderr, "%s: stk500_set_extended_parms(): can't get into sync\n",
progname);
return -1;
}
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return -1;
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
@@ -270,7 +299,8 @@ static int stk500_set_extended_parms(PROGRAMMER * pgm, int n,
return -1;
}
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_OK) {
return 0;
}
@@ -417,14 +447,16 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
buf[21] = Sync_CRC_EOP;
stk500_send(pgm, buf, 22);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
fprintf(stderr,
"%s: stk500_initialize(): programmer not in sync, resp=0x%02x\n",
progname, buf[0]);
if (tries > 33)
return -1;
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return -1;
goto retry;
return -1;
}
@@ -436,7 +468,8 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
return -1;
}
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] != Resp_STK_OK) {
fprintf(stderr,
"%s: stk500_initialize(): (b) protocol error, "
@@ -498,14 +531,16 @@ static void stk500_disable(PROGRAMMER * pgm)
buf[1] = Sync_CRC_EOP;
stk500_send(pgm, buf, 2);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
fprintf(stderr, "%s: stk500_disable(): can't get into sync\n",
progname);
return;
}
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return;
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
@@ -516,7 +551,8 @@ static void stk500_disable(PROGRAMMER * pgm)
return;
}
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_OK) {
return;
}
@@ -551,9 +587,8 @@ static int stk500_open(PROGRAMMER * pgm, char * port)
*/
stk500_drain(pgm, 0);
stk500_getsync(pgm);
stk500_drain(pgm, 0);
if (stk500_getsync(pgm) < 0)
return -1;
return 0;
}
@@ -581,14 +616,16 @@ static int stk500_loadaddr(PROGRAMMER * pgm, unsigned int addr)
stk500_send(pgm, buf, 4);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
fprintf(stderr, "%s: stk500_loadaddr(): can't get into sync\n",
progname);
return -1;
}
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return -1;
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
@@ -599,7 +636,8 @@ static int stk500_loadaddr(PROGRAMMER * pgm, unsigned int addr)
return -1;
}
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_OK) {
return 0;
}
@@ -616,13 +654,14 @@ static int stk500_loadaddr(PROGRAMMER * pgm, unsigned int addr)
static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes)
{
unsigned char buf[16];
unsigned char buf[page_size + 16];
int memtype;
unsigned int addr;
int a_div;
int block_size;
int tries;
unsigned int n;
unsigned int i;
int flash;
if (page_size == 0) {
@@ -688,25 +727,29 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
retry:
tries++;
stk500_loadaddr(pgm, addr/a_div);
buf[0] = Cmnd_STK_PROG_PAGE;
buf[1] = (block_size >> 8) & 0xff;
buf[2] = block_size & 0xff;
buf[3] = memtype;
stk500_send(pgm, buf, 4);
stk500_send(pgm, &m->buf[addr], block_size);
/* build command block and avoid multiple send commands as it leads to a crash
of the silabs usb serial driver on mac os x */
i = 0;
buf[i++] = Cmnd_STK_PROG_PAGE;
buf[i++] = (block_size >> 8) & 0xff;
buf[i++] = block_size & 0xff;
buf[i++] = memtype;
memcpy(&buf[i], &m->buf[addr], block_size);
i += block_size;
buf[i++] = Sync_CRC_EOP;
stk500_send( pgm, buf, i);
buf[0] = Sync_CRC_EOP;
stk500_send(pgm, buf, 1);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
fprintf(stderr, "\n%s: stk500_paged_write(): can't get into sync\n",
progname);
return -3;
}
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return -1;
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
@@ -717,7 +760,8 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -4;
}
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] != Resp_STK_OK) {
fprintf(stderr,
"\n%s: stk500_paged_write(): (a) protocol error, "
@@ -805,14 +849,16 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
buf[4] = Sync_CRC_EOP;
stk500_send(pgm, buf, 5);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
fprintf(stderr, "\n%s: stk500_paged_load(): can't get into sync\n",
progname);
return -3;
}
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return -1;
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
@@ -823,9 +869,11 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return -4;
}
stk500_recv(pgm, &m->buf[addr], block_size);
if (stk500_recv(pgm, &m->buf[addr], block_size) < 0)
exit(1);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] != Resp_STK_OK) {
fprintf(stderr,
"\n%s: stk500_paged_load(): (a) protocol error, "
@@ -984,14 +1032,16 @@ static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value)
stk500_send(pgm, buf, 3);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
fprintf(stderr, "\n%s: stk500_getparm(): can't get into sync\n",
progname);
return -1;
}
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return -1;
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
@@ -1002,10 +1052,12 @@ static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value)
return -2;
}
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
v = buf[0];
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_FAILED) {
fprintf(stderr,
"\n%s: stk500_getparm(): parameter 0x%02x failed\n",
@@ -1040,14 +1092,16 @@ static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value)
stk500_send(pgm, buf, 4);
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_NOSYNC) {
if (tries > 33) {
fprintf(stderr, "\n%s: stk500_setparm(): can't get into sync\n",
progname);
return -1;
}
stk500_getsync(pgm);
if (stk500_getsync(pgm) < 0)
return -1;
goto retry;
}
else if (buf[0] != Resp_STK_INSYNC) {
@@ -1058,12 +1112,14 @@ static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value)
return -2;
}
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_OK)
return 0;
parm = buf[0]; /* if not STK_OK, we've been echoed parm here */
stk500_recv(pgm, buf, 1);
if (stk500_recv(pgm, buf, 1) < 0)
exit(1);
if (buf[0] == Resp_STK_FAILED) {
fprintf(stderr,
"\n%s: stk500_setparm(): parameter 0x%02x failed\n",

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

72
avrdude/stk500generic.c Normal file
View File

@@ -0,0 +1,72 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
/*
* avrdude interface for Atmel STK500 programmer
*
* This is a wrapper around the STK500[v1] and STK500v2 programmers.
* Try to select the programmer type that actually responds, and
* divert to the actual programmer implementation if successful.
*/
#include "ac_cfg.h"
#include <stdio.h>
#include <string.h>
#include "pgm.h"
#include "stk500.h"
#include "stk500v2.h"
extern char *progname;
static int stk500generic_open(PROGRAMMER * pgm, char * port)
{
stk500_initpgm(pgm);
if (pgm->open(pgm, port) >= 0)
{
fprintf(stderr,
"%s: successfully opened stk500v1 device -- please use -c stk500v1\n",
progname);
return 0;
}
stk500v2_initpgm(pgm);
if (pgm->open(pgm, port) >= 0)
{
fprintf(stderr,
"%s: successfully opened stk500v2 device -- please use -c stk500v2\n",
progname);
return 0;
}
fprintf(stderr,
"%s: cannot open either stk500v1 or stk500v2 programmer\n",
progname);
return -1;
}
void stk500generic_initpgm(PROGRAMMER * pgm)
{
strcpy(pgm->type, "STK500GENERIC");
pgm->open = stk500generic_open;
}

29
avrdude/stk500generic.h Normal file
View File

@@ -0,0 +1,29 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef stk500generic_h__
#define stk500generic_h__
void stk500generic_initpgm (PROGRAMMER * pgm);
#endif

2317
avrdude/stk500v2.c Normal file

File diff suppressed because it is too large Load Diff

33
avrdude/stk500v2.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2002-2005 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2006 Joerg Wunsch <j@uriah.heep.sax.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef stk500v2_h__
#define stk500v2_h__
void stk500v2_initpgm (PROGRAMMER * pgm);
void stk500hvsp_initpgm (PROGRAMMER * pgm);
void stk500pp_initpgm (PROGRAMMER * pgm);
void stk500v2_jtagmkII_initpgm(PROGRAMMER * pgm);
#endif

134
avrdude/stk500v2_private.h Normal file
View File

@@ -0,0 +1,134 @@
//**** ATMEL AVR - A P P L I C A T I O N N O T E ************************
//*
//* Title: AVR068 - STK500 Communication Protocol
//* Filename: command.h
//* Version: 1.0
//* Last updated: 10.01.2005
//*
//* Support E-mail: avr@atmel.com
//*
//**************************************************************************
// *****************[ STK message constants ]***************************
#define MESSAGE_START 0x1B //= ESC = 27 decimal
#define TOKEN 0x0E
// *****************[ STK general command constants ]**************************
#define CMD_SIGN_ON 0x01
#define CMD_SET_PARAMETER 0x02
#define CMD_GET_PARAMETER 0x03
#define CMD_SET_DEVICE_PARAMETERS 0x04
#define CMD_OSCCAL 0x05
#define CMD_LOAD_ADDRESS 0x06
#define CMD_FIRMWARE_UPGRADE 0x07
// *****************[ STK ISP command constants ]******************************
#define CMD_ENTER_PROGMODE_ISP 0x10
#define CMD_LEAVE_PROGMODE_ISP 0x11
#define CMD_CHIP_ERASE_ISP 0x12
#define CMD_PROGRAM_FLASH_ISP 0x13
#define CMD_READ_FLASH_ISP 0x14
#define CMD_PROGRAM_EEPROM_ISP 0x15
#define CMD_READ_EEPROM_ISP 0x16
#define CMD_PROGRAM_FUSE_ISP 0x17
#define CMD_READ_FUSE_ISP 0x18
#define CMD_PROGRAM_LOCK_ISP 0x19
#define CMD_READ_LOCK_ISP 0x1A
#define CMD_READ_SIGNATURE_ISP 0x1B
#define CMD_READ_OSCCAL_ISP 0x1C
#define CMD_SPI_MULTI 0x1D
// *****************[ STK PP command constants ]*******************************
#define CMD_ENTER_PROGMODE_PP 0x20
#define CMD_LEAVE_PROGMODE_PP 0x21
#define CMD_CHIP_ERASE_PP 0x22
#define CMD_PROGRAM_FLASH_PP 0x23
#define CMD_READ_FLASH_PP 0x24
#define CMD_PROGRAM_EEPROM_PP 0x25
#define CMD_READ_EEPROM_PP 0x26
#define CMD_PROGRAM_FUSE_PP 0x27
#define CMD_READ_FUSE_PP 0x28
#define CMD_PROGRAM_LOCK_PP 0x29
#define CMD_READ_LOCK_PP 0x2A
#define CMD_READ_SIGNATURE_PP 0x2B
#define CMD_READ_OSCCAL_PP 0x2C
#define CMD_SET_CONTROL_STACK 0x2D
// *****************[ STK HVSP command constants ]*****************************
#define CMD_ENTER_PROGMODE_HVSP 0x30
#define CMD_LEAVE_PROGMODE_HVSP 0x31
#define CMD_CHIP_ERASE_HVSP 0x32
#define CMD_PROGRAM_FLASH_HVSP 0x33
#define CMD_READ_FLASH_HVSP 0x34
#define CMD_PROGRAM_EEPROM_HVSP 0x35
#define CMD_READ_EEPROM_HVSP 0x36
#define CMD_PROGRAM_FUSE_HVSP 0x37
#define CMD_READ_FUSE_HVSP 0x38
#define CMD_PROGRAM_LOCK_HVSP 0x39
#define CMD_READ_LOCK_HVSP 0x3A
#define CMD_READ_SIGNATURE_HVSP 0x3B
#define CMD_READ_OSCCAL_HVSP 0x3C
// *****************[ STK test command constants ]***************************
#define CMD_ENTER_TESTMODE 0x60
#define CMD_LEAVE_TESTMODE 0x61
#define CMD_CHIP_WRITE 0x62
#define CMD_PROGRAM_FLASH_PARTIAL 0x63
#define CMD_PROGRAM_EEPROM_PARTIAL 0x64
#define CMD_PROGRAM_SIGNATURE_ROW 0x65
#define CMD_READ_FLASH_MARGIN 0x66
#define CMD_READ_EEPROM_MARGIN 0x67
#define CMD_READ_SIGNATURE_ROW_MARGIN 0x68
#define CMD_PROGRAM_TEST_FUSE 0x69
#define CMD_READ_TEST_FUSE 0x6A
#define CMD_PROGRAM_HIDDEN_FUSE_LOW 0x6B
#define CMD_READ_HIDDEN_FUSE_LOW 0x6C
#define CMD_PROGRAM_HIDDEN_FUSE_HIGH 0x6D
#define CMD_READ_HIDDEN_FUSE_HIGH 0x6E
#define CMD_PROGRAM_HIDDEN_FUSE_EXT 0x6F
#define CMD_READ_HIDDEN_FUSE_EXT 0x70
// *****************[ STK status constants ]***************************
// Success
#define STATUS_CMD_OK 0x00
// Warnings
#define STATUS_CMD_TOUT 0x80
#define STATUS_RDY_BSY_TOUT 0x81
#define STATUS_SET_PARAM_MISSING 0x82
// Errors
#define STATUS_CMD_FAILED 0xC0
#define STATUS_CKSUM_ERROR 0xC1
#define STATUS_CMD_UNKNOWN 0xC9
// *****************[ STK parameter constants ]***************************
#define PARAM_BUILD_NUMBER_LOW 0x80
#define PARAM_BUILD_NUMBER_HIGH 0x81
#define PARAM_HW_VER 0x90
#define PARAM_SW_MAJOR 0x91
#define PARAM_SW_MINOR 0x92
#define PARAM_VTARGET 0x94
#define PARAM_VADJUST 0x95
#define PARAM_OSC_PSCALE 0x96
#define PARAM_OSC_CMATCH 0x97
#define PARAM_SCK_DURATION 0x98
#define PARAM_TOPCARD_DETECT 0x9A
#define PARAM_STATUS 0x9C
#define PARAM_DATA 0x9D
#define PARAM_RESET_POLARITY 0x9E
#define PARAM_CONTROLLER_INIT 0x9F
// *****************[ STK answer constants ]***************************
#define ANSWER_CKSUM_ERROR 0xB0

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2000, 2001, 2002, 2003 Brian S. Dean <bsd@bsdhome.com>
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,5 +26,6 @@
#include "pgm.h"
int terminal_mode(PROGRAMMER * pgm, struct avrpart * p);
char * terminal_get_input(const char *prompt);
#endif

View File

@@ -0,0 +1,254 @@
<?xml version="1.0" encoding='ISO-8859-1' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
* Copyright (c) 2006 Joerg Wunsch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
*
* $Id$
-->
<!--
* Extract high-voltage (parallel and serial) programming parameters
* out of the Atmel XML files, and convert them into avrdude.conf
* snippets.
*
* Run this file together with the respective AVR's XML file through
* an XSLT processor (xsltproc, saxon), and capture the output for
* inclusion into avrdude.conf.in.
-->
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="//*">
<xsl:if test='name() = "STK500_2"'>
<!--
* High-voltage parallel programming parameters.
-->
<xsl:for-each
select="*[starts-with(translate(name(),
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
'PP')]">
<xsl:if test="self::node()[name() = 'PPControlStack']"
> pp_controlstack =
<xsl:call-template name="format_cstack">
<xsl:with-param name="stack" select="." />
<xsl:with-param name="count" select="0" />
</xsl:call-template>;
</xsl:if> <!-- PPControlStack -->
<xsl:if test="self::node()[name() = 'PpEnterProgMode']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'stabDelay']"
> hventerstabdelay = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'progModeDelay']"
> progmodedelay = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'latchCycles']"
> latchcycles = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'toggleVtg']"
> togglevtg = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'powerOffDelay']"
> poweroffdelay = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'resetDelayMs']"
> resetdelayms = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'resetDelayUs']"
> resetdelayus = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- PpEnterProgMode -->
<xsl:if test="self::node()[name() = 'PpLeaveProgMode']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'stabDelay']"
> hvleavestabdelay = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- PpLeaveProgMode -->
<xsl:if test="self::node()[name() = 'PpChipErase']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'pulseWidth']"
> chiperasepulsewidth = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'pollTimeout']"
> chiperasepolltimeout = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- PpChipErase -->
<xsl:if test="self::node()[name() = 'PpProgramFuse']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'pulseWidth']"
> programfusepulsewidth = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'pollTimeout']"
> programfusepolltimeout = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- PpProgramFuse -->
<xsl:if test="self::node()[name() = 'PpProgramLock']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'pulseWidth']"
> programlockpulsewidth = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'pollTimeout']"
> programlockpolltimeout = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- PpProgramLock -->
</xsl:for-each> <!-- PP parameters -->
<!--
* High-voltage serial programming parameters.
-->
<xsl:for-each
select="*[starts-with(translate(name(),
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
'HVSP')]">
<xsl:if test="self::node()[name() = 'HvspControlStack']"
> hvsp_controlstack =
<xsl:call-template name="format_cstack">
<xsl:with-param name="stack" select="." />
<xsl:with-param name="count" select="0" />
</xsl:call-template>;
</xsl:if> <!-- HvspControlStack -->
<xsl:if test="self::node()[name() = 'HvspEnterProgMode']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'stabDelay']"
> hventerstabdelay = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'cmdexeDelay']"
> hvspcmdexedelay = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'synchCycles']"
> synchcycles = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'latchCycles']"
> latchcycles = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'toggleVtg']"
> togglevtg = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'powoffDelay']"
> poweroffdelay = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'resetDelay1']"
> resetdelayms = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'resetDelay2']"
> resetdelayus = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- HvspEnterProgMode -->
<xsl:if test="self::node()[name() = 'HvspLeaveProgMode']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'stabDelay']"
> hvleavestabdelay = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'resetDelay']"
> resetdelay = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- HvspLeaveProgMode -->
<xsl:if test="self::node()[name() = 'HvspChipErase']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'pollTimeout']"
> chiperasepolltimeout = <xsl:value-of select="." />;
</xsl:if>
<xsl:if test="self::node()[name() = 'eraseTime']"
> chiperasetime = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- HvspChipErase -->
<xsl:if test="self::node()[name() = 'HvspProgramFuse']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'pollTimeout']"
> programfusepolltimeout = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- HvspProgramFuse -->
<xsl:if test="self::node()[name() = 'HvspProgramLock']">
<xsl:for-each select="*">
<xsl:if test="self::node()[name() = 'pollTimeout']"
> programlockpolltimeout = <xsl:value-of select="." />;
</xsl:if>
</xsl:for-each>
</xsl:if> <!-- HvspProgramLock -->
</xsl:for-each> <!-- HVSP parameters -->
</xsl:if> <!-- STK500_2 parameters -->
</xsl:for-each> <!-- All nodes -->
</xsl:template>
<!--
* Format the control stack argument: replace space-separated
* list by a list separated with commas, followed by either
* a space or a newline, dependend on the current argument
* count.
* This template calls itself recursively, until the entire
* argument $stack has been processed.
-->
<xsl:template name="format_cstack">
<xsl:param name="stack" />
<xsl:choose>
<xsl:when test="string-length($stack) &lt;= 4">
<!-- Last element, print it, and leave template. -->
<xsl:value-of select="$stack" />
</xsl:when>
<xsl:otherwise>
<!--
* More arguments follow, print first value,
* followed by a comma, decide whether a space
* or a newline needs to be emitted, and recurse
* with the remaining part of $stack.
-->
<xsl:value-of select="substring($stack, 1, 4)" />
<xsl:choose>
<xsl:when test="$count mod 8 = 7">
<!-- comma, newline, 8 spaces indentation -->
<xsl:text>,
</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- comma, space -->
<xsl:text>, </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="format_cstack">
<xsl:with-param name="stack" select="substring($stack, 6)"
/>
<xsl:with-param name="count" select="$count + 1" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

454
avrdude/usb_libusb.c Normal file
View File

@@ -0,0 +1,454 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2005,2006 Joerg Wunsch
* Copyright (C) 2006 David Moore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
/*
* USB interface via libusb for avrdude.
*/
#include "ac_cfg.h"
#if defined(HAVE_LIBUSB)
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include <usb.h>
#include "serial.h"
#include "usbdevs.h"
extern char *progname;
extern int verbose;
static char usbbuf[USBDEV_MAX_XFER];
static int buflen = -1, bufptr;
static int usb_interface;
/*
* The "baud" parameter is meaningless for USB devices, so we reuse it
* to pass the desired USB device ID.
*/
static int usbdev_open(char * port, long baud)
{
char string[256];
char product[256];
struct usb_bus *bus;
struct usb_device *dev;
usb_dev_handle *udev;
char *serno, *cp2;
size_t x;
/*
* The syntax for usb devices is defined as:
*
* -P usb[:serialnumber]
*
* See if we've got a serial number passed here. The serial number
* might contain colons which we remove below, and we compare it
* right-to-left, so only the least significant nibbles need to be
* specified.
*/
if ((serno = strchr(port, ':')) != NULL)
{
/* first, drop all colons there if any */
cp2 = ++serno;
while ((cp2 = strchr(cp2, ':')) != NULL)
{
x = strlen(cp2) - 1;
memmove(cp2, cp2 + 1, x);
cp2[x] = '\0';
}
if (strlen(serno) > 12)
{
fprintf(stderr,
"%s: usbdev_open(): invalid serial number \"%s\"\n",
progname, serno);
exit(1);
}
}
usb_init();
usb_find_busses();
usb_find_devices();
for (bus = usb_get_busses(); bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
udev = usb_open(dev);
if (udev)
{
if (dev->descriptor.idVendor == USB_VENDOR_ATMEL &&
dev->descriptor.idProduct == (unsigned short)baud)
{
/* yeah, we found something */
if (usb_get_string_simple(udev,
dev->descriptor.iSerialNumber,
string, sizeof(string)) < 0)
{
fprintf(stderr,
"%s: usb_open(): cannot read serial number \"%s\"\n",
progname, usb_strerror());
/*
* On some systems, libusb appears to have
* problems sending control messages. Catch the
* benign case where the user did not request a
* particular serial number, so we could
* continue anyway.
*/
if (serno != NULL)
exit(1); /* no chance */
else
strcpy(string, "[unknown]");
}
if (usb_get_string_simple(udev,
dev->descriptor.iProduct,
product, sizeof(product)) < 0)
{
fprintf(stderr,
"%s: usb_open(): cannot read product name \"%s\"\n",
progname, usb_strerror());
strcpy(product, "[unnamed product]");
}
if (verbose)
fprintf(stderr,
"%s: usbdev_open(): Found %s, serno: %s\n",
progname, product, string);
if (serno != NULL)
{
/*
* See if the serial number requested by the
* user matches what we found, matching
* right-to-left.
*/
x = strlen(string) - strlen(serno);
if (strcasecmp(string + x, serno) != 0)
{
if (verbose > 2)
fprintf(stderr,
"%s: usbdev_open(): serial number doesn't match\n",
progname);
usb_close(udev);
continue;
}
}
if (dev->config == NULL)
{
fprintf(stderr,
"%s: usbdev_open(): USB device has no configuration\n",
progname);
goto trynext;
}
if (usb_set_configuration(udev, dev->config[0].bConfigurationValue))
{
fprintf(stderr,
"%s: usbdev_open(): error setting configuration %d: %s\n",
progname, dev->config[0].bConfigurationValue,
usb_strerror());
goto trynext;
}
usb_interface = dev->config[0].interface[0].altsetting[0].bInterfaceNumber;
if (usb_claim_interface(udev, usb_interface))
{
fprintf(stderr,
"%s: usbdev_open(): error claiming interface %d: %s\n",
progname, usb_interface, usb_strerror());
goto trynext;
}
return (int)udev;
}
trynext:
usb_close(udev);
}
}
}
fprintf(stderr, "%s: usbdev_open(): did not find any%s USB device \"%s\"\n",
progname, serno? " (matching)": "", port);
exit(1);
}
static int usbdev_setspeed(int fd, long baud)
{
return 0;
}
static void usbdev_close(int fd)
{
usb_dev_handle *udev = (usb_dev_handle *)fd;
(void)usb_release_interface(udev, usb_interface);
/*
* Without this reset, the AVRISP mkII seems to stall the second
* time we try to connect to it.
*/
usb_reset(udev);
usb_close(udev);
}
static int usbdev_send(int fd, unsigned char *bp, size_t mlen)
{
usb_dev_handle *udev = (usb_dev_handle *)fd;
size_t rv;
int i = mlen;
unsigned char * p = bp;
int tx_size;
/*
* Split the frame into multiple packets. It's important to make
* sure we finish with a short packet, or else the device won't know
* the frame is finished. For example, if we need to send 64 bytes,
* we must send a packet of length 64 followed by a packet of length
* 0.
*/
do {
tx_size = (mlen < USBDEV_MAX_XFER)? mlen: USBDEV_MAX_XFER;
rv = usb_bulk_write(udev, USBDEV_BULK_EP_WRITE, (char *)bp, tx_size, 5000);
if (rv != tx_size)
{
fprintf(stderr, "%s: usbdev_send(): wrote %d out of %d bytes, err = %s\n",
progname, rv, tx_size, usb_strerror());
return -1;
}
bp += tx_size;
mlen -= tx_size;
} while (tx_size == USBDEV_MAX_XFER);
if (verbose > 3)
{
fprintf(stderr, "%s: Sent: ", progname);
while (i) {
unsigned char c = *p;
if (isprint(c)) {
fprintf(stderr, "%c ", c);
}
else {
fprintf(stderr, ". ");
}
fprintf(stderr, "[%02x] ", c);
p++;
i--;
}
fprintf(stderr, "\n");
}
return 0;
}
/*
* As calls to usb_bulk_read() result in exactly one USB request, we
* have to buffer the read results ourselves, so the single-char read
* requests performed by the upper layers will be handled. In order
* to do this, we maintain a private buffer of what we've got so far,
* and transparently issue another USB read request if the buffer is
* empty and more data are requested.
*/
static int
usb_fill_buf(usb_dev_handle *udev)
{
int rv;
rv = usb_bulk_read(udev, USBDEV_BULK_EP_READ, usbbuf, USBDEV_MAX_XFER, 5000);
if (rv < 0)
{
if (verbose > 1)
fprintf(stderr, "%s: usb_fill_buf(): usb_bulk_read() error %s\n",
progname, usb_strerror());
return -1;
}
buflen = rv;
bufptr = 0;
return 0;
}
static int usbdev_recv(int fd, unsigned char *buf, size_t nbytes)
{
usb_dev_handle *udev = (usb_dev_handle *)fd;
int i, amnt;
unsigned char * p = buf;
for (i = 0; nbytes > 0;)
{
if (buflen <= bufptr)
{
if (usb_fill_buf(udev) < 0)
return -1;
}
amnt = buflen - bufptr > nbytes? nbytes: buflen - bufptr;
memcpy(buf + i, usbbuf + bufptr, amnt);
bufptr += amnt;
nbytes -= amnt;
i += amnt;
}
if (verbose > 3)
{
fprintf(stderr, "%s: Recv: ", progname);
while (i) {
unsigned char c = *p;
if (isprint(c)) {
fprintf(stderr, "%c ", c);
}
else {
fprintf(stderr, ". ");
}
fprintf(stderr, "[%02x] ", c);
p++;
i--;
}
fprintf(stderr, "\n");
}
return 0;
}
/*
* This version of recv keeps reading packets until we receive a short
* packet. Then, the entire frame is assembled and returned to the
* user. The length will be unknown in advance, so we return the
* length as the return value of this function, or -1 in case of an
* error.
*
* This is used for the AVRISP mkII device.
*/
static int usbdev_recv_frame(int fd, unsigned char *buf, size_t nbytes)
{
usb_dev_handle *udev = (usb_dev_handle *)fd;
int rv, n;
int i;
unsigned char * p = buf;
n = 0;
do
{
rv = usb_bulk_read(udev, USBDEV_BULK_EP_READ, usbbuf,
USBDEV_MAX_XFER, 10000);
if (rv < 0)
{
if (verbose > 1)
fprintf(stderr, "%s: usbdev_recv_frame(): usb_bulk_read(): %s\n",
progname, usb_strerror());
return -1;
}
if (rv <= nbytes)
{
memcpy (buf, usbbuf, rv);
buf += rv;
}
n += rv;
nbytes -= rv;
}
while (rv == USBDEV_MAX_XFER);
if (nbytes < 0)
return -1;
if (verbose > 3)
{
i = n;
fprintf(stderr, "%s: Recv: ", progname);
while (i) {
unsigned char c = *p;
if (isprint(c)) {
fprintf(stderr, "%c ", c);
}
else {
fprintf(stderr, ". ");
}
fprintf(stderr, "[%02x] ", c);
p++;
i--;
}
fprintf(stderr, "\n");
}
return n;
}
static int usbdev_drain(int fd, int display)
{
usb_dev_handle *udev = (usb_dev_handle *)fd;
int rv;
do {
rv = usb_bulk_read(udev, USBDEV_BULK_EP_READ, usbbuf, USBDEV_MAX_XFER, 100);
if (rv > 0 && verbose >= 4)
fprintf(stderr, "%s: usbdev_drain(): flushed %d characters\n",
progname, rv);
} while (rv > 0);
return 0;
}
/*
* Device descriptor for the JTAG ICE mkII.
*/
struct serial_device usb_serdev =
{
.open = usbdev_open,
.setspeed = usbdev_setspeed,
.close = usbdev_close,
.send = usbdev_send,
.recv = usbdev_recv,
.drain = usbdev_drain,
};
/*
* Device descriptor for the AVRISP mkII.
*/
struct serial_device usb_serdev_frame =
{
.open = usbdev_open,
.setspeed = usbdev_setspeed,
.close = usbdev_close,
.send = usbdev_send,
.recv = usbdev_recv_frame,
.drain = usbdev_drain,
};
#endif /* HAVE_LIBUSB */

444
avrdude/usbasp.c Normal file
View File

@@ -0,0 +1,444 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2006 Thomas Fischl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
/*
* Interface to the USBasp programmer.
*
* See http://www.fischl.de/usbasp/
*/
#include "ac_cfg.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include "avr.h"
#include "pgm.h"
#include "usbasp.h"
#ifdef HAVE_LIBUSB
#include <usb.h>
extern int verbose;
extern char * progname;
extern int do_cycles;
static usb_dev_handle *usbhandle;
/*
* wrapper for usb_control_msg call
*/
static int usbasp_transmit(unsigned char receive, unsigned char functionid,
unsigned char send[4], unsigned char * buffer, int buffersize)
{
int nbytes;
nbytes = usb_control_msg(usbhandle,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | (receive << 7),
functionid,
(send[1] << 8) | send[0],
(send[3] << 8) | send[2],
buffer, buffersize,
5000);
if(nbytes < 0){
fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
exit(1);
}
return nbytes;
}
/*
* Try to open USB device with given VID, PID, vendor and product name
* Parts of this function were taken from an example code by OBJECTIVE
* DEVELOPMENT Software GmbH (www.obdev.at) to meet conditions for
* shared VID/PID
*/
static int usbOpenDevice(usb_dev_handle **device, int vendor,
char *vendorName, int product, char *productName)
{
struct usb_bus *bus;
struct usb_device *dev;
usb_dev_handle *handle = NULL;
int errorCode = USB_ERROR_NOTFOUND;
static int didUsbInit = 0;
if(!didUsbInit){
didUsbInit = 1;
usb_init();
}
usb_find_busses();
usb_find_devices();
for(bus=usb_get_busses(); bus; bus=bus->next){
for(dev=bus->devices; dev; dev=dev->next){
if(dev->descriptor.idVendor == vendor &&
dev->descriptor.idProduct == product){
char string[256];
int len;
/* we need to open the device in order to query strings */
handle = usb_open(dev);
if(!handle){
errorCode = USB_ERROR_ACCESS;
fprintf(stderr,
"%s: Warning: cannot open USB device: %s\n",
progname, usb_strerror());
continue;
}
if(vendorName == NULL && productName == NULL){
/* name does not matter */
break;
}
/* now check whether the names match: */
len = usb_get_string_simple(handle, dev->descriptor.iManufacturer,
string, sizeof(string));
if(len < 0){
errorCode = USB_ERROR_IO;
fprintf(stderr,
"%s: Warning: cannot query manufacturer for device: %s\n",
progname, usb_strerror());
}else{
errorCode = USB_ERROR_NOTFOUND;
if (verbose > 1)
fprintf(stderr,
"%s: seen device from vendor ->%s<-\n",
progname, string);
if(strcmp(string, vendorName) == 0){
len = usb_get_string_simple(handle, dev->descriptor.iProduct,
string, sizeof(string));
if(len < 0){
errorCode = USB_ERROR_IO;
fprintf(stderr,
"%s: Warning: cannot query product for device: %s\n",
progname, usb_strerror());
}else{
errorCode = USB_ERROR_NOTFOUND;
if (verbose > 1)
fprintf(stderr,
"%s: seen product ->%s<-\n",
progname, string);
if(strcmp(string, productName) == 0)
break;
}
}
}
usb_close(handle);
handle = NULL;
}
}
if(handle)
break;
}
if(handle != NULL){
errorCode = 0;
*device = handle;
}
return errorCode;
}
static int usbasp_open(PROGRAMMER * pgm, char * port)
{
usb_init();
if (usbOpenDevice(&usbhandle, USBASP_SHARED_VID, "www.fischl.de",
USBASP_SHARED_PID, "USBasp") != 0) {
/* check if device with old VID/PID is available */
if (usbOpenDevice(&usbhandle, USBASP_OLD_VID, "www.fischl.de",
USBASP_OLD_PID, "USBasp") != 0) {
/* no USBasp found */
fprintf(stderr,
"%s: error: could not find USB device "
"\"USBasp\" with vid=0x%x pid=0x%x\n",
progname, USBASP_SHARED_VID, USBASP_SHARED_PID);
exit(1);
} else {
/* found USBasp with old IDs */
fprintf(stderr,
"%s: Warning: Found USB device \"USBasp\" with "
"old VID/PID! Please update firmware of USBasp!\n",
progname);
}
}
return 0;
}
static void usbasp_close(PROGRAMMER * pgm)
{
unsigned char temp[4];
memset(temp, 0, sizeof(temp));
usbasp_transmit(1, USBASP_FUNC_DISCONNECT, temp, temp, sizeof(temp));
usb_close(usbhandle);
}
static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
{
unsigned char temp[4];
memset(temp, 0, sizeof(temp));
usbasp_transmit(1, USBASP_FUNC_CONNECT, temp, temp, sizeof(temp));
usleep(100000);
pgm->program_enable(pgm, p);
return 0;
}
static void usbasp_disable(PROGRAMMER * pgm)
{
/* Do nothing. */
return;
}
static void usbasp_enable(PROGRAMMER * pgm)
{
/* Do nothing. */
return;
}
static void usbasp_display(PROGRAMMER * pgm, char * p)
{
return;
}
static int usbasp_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
unsigned char res[4])
{
int nbytes =
usbasp_transmit(1, USBASP_FUNC_TRANSMIT, cmd, res, sizeof(res));
if(nbytes != 4){
fprintf(stderr, "%s: error: wrong responds size\n",
progname);
return -1;
}
return 0;
}
static int usbasp_program_enable(PROGRAMMER * pgm, AVRPART * p)
{
unsigned char res[4];
unsigned char cmd[4];
memset(cmd, 0, sizeof(cmd));
memset(res, 0, sizeof(res));
cmd[0] = 0;
int nbytes =
usbasp_transmit(1, USBASP_FUNC_ENABLEPROG, cmd, res, sizeof(res));
if ((nbytes != 1) | (res[0] != 0)) {
fprintf(stderr, "%s: error: programm enable: target doesn't answer. %x \n",
progname, res[0]);
return -1;
}
return 0;
}
static int usbasp_chip_erase(PROGRAMMER * pgm, AVRPART * p)
{
unsigned char cmd[4];
unsigned char res[4];
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
p->desc);
return -1;
}
memset(cmd, 0, sizeof(cmd));
avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd);
pgm->cmd(pgm, cmd, res);
usleep(p->chip_erase_delay);
pgm->initialize(pgm, p);
return 0;
}
static int usbasp_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes)
{
int n;
unsigned char cmd[4];
int address = 0;
int wbytes = n_bytes;
int blocksize;
unsigned char * buffer = m->buf;
int function;
if (strcmp(m->desc, "flash") == 0) {
function = USBASP_FUNC_READFLASH;
} else if (strcmp(m->desc, "eeprom") == 0) {
function = USBASP_FUNC_READEEPROM;
} else {
return -2;
}
while (wbytes) {
if (wbytes > USBASP_READBLOCKSIZE) {
blocksize = USBASP_READBLOCKSIZE;
wbytes -= USBASP_READBLOCKSIZE;
} else {
blocksize = wbytes;
wbytes = 0;
}
cmd[0] = address & 0xFF;
cmd[1] = address >> 8;
n = usbasp_transmit(1, function, cmd, buffer, blocksize);
if (n != blocksize) {
fprintf(stderr, "%s: error: wrong reading bytes %x\n",
progname, n);
exit(1);
}
buffer += blocksize;
address += blocksize;
report_progress (address, n_bytes, NULL);
}
return n_bytes;
}
static int usbasp_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes)
{
int n;
unsigned char cmd[4];
int address = 0;
int wbytes = n_bytes;
int blocksize;
unsigned char * buffer = m->buf;
unsigned char blockflags = USBASP_BLOCKFLAG_FIRST;
int function;
if (strcmp(m->desc, "flash") == 0) {
function = USBASP_FUNC_WRITEFLASH;
} else if (strcmp(m->desc, "eeprom") == 0) {
function = USBASP_FUNC_WRITEEEPROM;
} else {
return -2;
}
while (wbytes) {
if (wbytes > USBASP_WRITEBLOCKSIZE) {
blocksize = USBASP_WRITEBLOCKSIZE;
wbytes -= USBASP_WRITEBLOCKSIZE;
} else {
blocksize = wbytes;
wbytes = 0;
blockflags |= USBASP_BLOCKFLAG_LAST;
}
cmd[0] = address & 0xFF;
cmd[1] = address >> 8;
cmd[2] = page_size & 0xFF;
cmd[3] = (blockflags & 0x0F) + ((page_size & 0xF00) >> 4); //TP: Mega128 fix
blockflags = 0;
n = usbasp_transmit(0, function, cmd, buffer, blocksize);
if (n != blocksize) {
fprintf(stderr, "%s: error: wrong count at writing %x\n",
progname, n);
exit(1);
}
buffer += blocksize;
address += blocksize;
report_progress (address, n_bytes, NULL);
}
return n_bytes;
}
void usbasp_initpgm(PROGRAMMER * pgm)
{
strcpy(pgm->type, "usbasp");
/*
* mandatory functions
*/
pgm->initialize = usbasp_initialize;
pgm->display = usbasp_display;
pgm->enable = usbasp_enable;
pgm->disable = usbasp_disable;
pgm->program_enable = usbasp_program_enable;
pgm->chip_erase = usbasp_chip_erase;
pgm->cmd = usbasp_cmd;
pgm->open = usbasp_open;
pgm->close = usbasp_close;
/*
* optional functions
*/
pgm->paged_write = usbasp_paged_write;
pgm->paged_load = usbasp_paged_load;
}
#else /* HAVE_LIBUSB */
extern char * progname;
static int usbasp_nousb_open (struct programmer_t *pgm, char * name)
{
fprintf(stderr, "%s: error: no usb support. please compile again with libusb installed.\n",
progname);
exit(1);
}
void usbasp_initpgm(PROGRAMMER * pgm)
{
strcpy(pgm->type, "usbasp");
pgm->open = usbasp_nousb_open;
}
#endif /* HAVE_LIBUSB */

55
avrdude/usbasp.h Normal file
View File

@@ -0,0 +1,55 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2006 Thomas Fischl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef usbasp_h
#define usbasp_h
#include "avrpart.h"
#define USBASP_SHARED_VID 0x16C0 /* VOTI */
#define USBASP_SHARED_PID 0x05DC /* Obdev's free shared PID */
#define USBASP_OLD_VID 0x03EB /* ATMEL */
#define USBASP_OLD_PID 0xC7B4 /* (unoffical) USBasp */
#define USBASP_FUNC_CONNECT 1
#define USBASP_FUNC_DISCONNECT 2
#define USBASP_FUNC_TRANSMIT 3
#define USBASP_FUNC_READFLASH 4
#define USBASP_FUNC_ENABLEPROG 5
#define USBASP_FUNC_WRITEFLASH 6
#define USBASP_FUNC_READEEPROM 7
#define USBASP_FUNC_WRITEEEPROM 8
#define USBASP_BLOCKFLAG_FIRST 1
#define USBASP_BLOCKFLAG_LAST 2
#define USBASP_READBLOCKSIZE 200
#define USBASP_WRITEBLOCKSIZE 200
#define USB_ERROR_NOTFOUND 1
#define USB_ERROR_ACCESS 2
#define USB_ERROR_IO 3
void usbasp_initpgm (PROGRAMMER * pgm);
#endif /* usbasp_h */

40
avrdude/usbdevs.h Normal file
View File

@@ -0,0 +1,40 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2006 Joerg Wunsch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
/*
* defines for the USB interface
*/
#ifndef usbdevs_h
#define usbdevs_h
#define USB_VENDOR_ATMEL 1003
#define USB_DEVICE_JTAGICEMKII 0x2103
#define USB_DEVICE_AVRISPMKII 0x2104
/*
* Should we query the endpoint number and max transfer size from USB?
* After all, the JTAG ICE mkII docs document these values.
*/
#define USBDEV_BULK_EP_WRITE 0x02
#define USBDEV_BULK_EP_READ 0x82
#define USBDEV_MAX_XFER 64
#endif /* usbdevs_h */

View File

@@ -0,0 +1,4 @@
.cvsignore
.deps
Makefile
Makefile.in