mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-17 02:54:17 +00:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70246d5b09 | ||
|
|
cd07291aae | ||
|
|
ede97a0ed2 | ||
|
|
caec621eaa | ||
|
|
c23519f392 | ||
|
|
4cbcbe84ec | ||
|
|
fddb673ee8 | ||
|
|
b561874f07 | ||
|
|
5e68193a6c | ||
|
|
d9866f6219 | ||
|
|
645961163d | ||
|
|
e9750a7712 | ||
|
|
0b197a6c6f | ||
|
|
70fdf3082e | ||
|
|
e58b699f41 | ||
|
|
6b379d8842 | ||
|
|
6fa8db276f | ||
|
|
7f7974ce25 | ||
|
|
f0c7b52223 | ||
|
|
0935636c7b | ||
|
|
1b38485a23 | ||
|
|
fa935481aa | ||
|
|
5ea6e54f96 | ||
|
|
92010244dc | ||
|
|
85e827043d | ||
|
|
25d844791c | ||
|
|
3ef11e335a | ||
|
|
58233bbed4 | ||
|
|
ad9238b29e | ||
|
|
5ce121ab1c | ||
|
|
5105a871be | ||
|
|
496ab3fd81 | ||
|
|
a1c528dbe2 | ||
|
|
50b587155d | ||
|
|
d1342a1984 | ||
|
|
f9331bc6b4 | ||
|
|
08e0114447 | ||
|
|
0f12718ab6 | ||
|
|
1b3d1fb776 |
@@ -1,3 +1,185 @@
|
||||
2006-01-23 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* configure.in: Bump version.
|
||||
|
||||
2006-01-17 Colin O'Flynn <coflynn@newae.com>
|
||||
* main.c: Fixed a typo in safemode variable names, fixed bug 15113
|
||||
* avrdude.conf.in : Added BS2 and pagel to M162, Patch 4766
|
||||
* main.c, stk500v2.c: Added patch 4804 from eolson@mit.edu
|
||||
Which stops sck from being writtend needlessly
|
||||
|
||||
2006-01-13 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
Contributed by David Moore: 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.)
|
||||
|
||||
2006-01-12 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* avrdude.conf.in: Add EEPROM page instructions for the
|
||||
ATmega169 so it will work for STK500v2.
|
||||
|
||||
2005-12-16 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* avrdude.conf.in: Added support for ATtiny24/44/84.
|
||||
|
||||
2005-12-05 Colin O'Flynn <coflynn@newae.com>
|
||||
|
||||
* avrdude.conf.in: Added m162 support for stk500v2
|
||||
|
||||
2005-12-01 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* avrdude.conf.in: fix the number of significant bits for
|
||||
the efuse memory in ATmega48/88/168; the datasheet is a bit
|
||||
off here as well.
|
||||
|
||||
2005-11-29 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* avrdude.1: update for JTAG ICE mkI support.
|
||||
* doc/avrdude.texi: (Ditto.)
|
||||
|
||||
2005-11-29 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
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.
|
||||
|
||||
2005-11-29 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
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.
|
||||
|
||||
2005-11-28 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* jtagmkI.c: Improve the communication startup with the ICE.
|
||||
|
||||
2005-11-28 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* configure.ac: enable parport access on x86_64 Linux and
|
||||
FreeBSD systems.
|
||||
|
||||
2005-11-27 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* avrdude.conf.in: add the "calibration" space to ATmega16.
|
||||
|
||||
2005-11-25 Colin O'Flynn <coflynn@newae.com>
|
||||
|
||||
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
|
||||
|
||||
2005-11-24 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
Add basic support for the Atmel JTAG ICE mkI:
|
||||
* config_gram.y: add mkI support to config sytax.
|
||||
* lexer.l: (Ditto.)
|
||||
* avrdude.conf.in: add sample programmer entries.
|
||||
* jtagmkI.c: New file
|
||||
* jtagmkI.h: New file
|
||||
* jtagmkI_private.h: New file
|
||||
* Makefile.am: include new files in build.
|
||||
|
||||
2005-11-24 Colin O'Flynn <coflynn@newae.com>
|
||||
|
||||
Fix bug 14681 - Serial Communication Fails on -vvvv with Windows
|
||||
* ser_win32.c: Patched with Brian Dean's patch
|
||||
|
||||
2005-11-05 Colin O'Flynn <coflynn@newae.com>
|
||||
|
||||
Patch #4532 by Manfred Bartz
|
||||
* avrdude.conf.in: added support for ATMega168 (also added support
|
||||
for the stk500v2 protocol which was not in the patch).
|
||||
|
||||
2005-11-03 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
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.
|
||||
|
||||
2005-11-02 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* config.h: change YYSTYPE to be a single word, to work around
|
||||
a bug in Solaris' yacc.
|
||||
* lexer.l: remove incompatibilities with Solaris' default lex,
|
||||
bump resource limits for lex.
|
||||
|
||||
2005-11-01 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
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.
|
||||
|
||||
2005-10-20 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* butterfly.c: fix yet another sign extension bug.
|
||||
|
||||
2005-10-14 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* avrdude.conf.in (ATmega8515): fix size of calibration
|
||||
memory.
|
||||
|
||||
2005-10-09 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* avrdude.conf.in: add support for ATmega640/1280/1281.
|
||||
* avrdude.1: document the above.
|
||||
* doc/avrdude.texi: (Ditto.)
|
||||
|
||||
2005-09-27 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* doc/avrdude.texi: 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.
|
||||
|
||||
2005-09-26 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* jtagmkII.c (jtagmkII_paged_write): default the page size early so the
|
||||
buffer will be allocated correctly.
|
||||
* usb_libusb.c: fix libusb handling; now it works with libusb-win32 as
|
||||
well.
|
||||
|
||||
2005-09-21 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
|
||||
* main.c(do_op): use mem->desc in place of upd->memtype to
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#
|
||||
|
||||
EXTRA_DIST = \
|
||||
ChangeLog \
|
||||
ChangeLog-2001 \
|
||||
ChangeLog-2002 \
|
||||
ChangeLog-2003 \
|
||||
@@ -69,6 +70,10 @@ avrdude_SOURCES = \
|
||||
crc16.h \
|
||||
fileio.c \
|
||||
fileio.h \
|
||||
freebsd_ppi.h \
|
||||
jtagmkI.c \
|
||||
jtagmkI.h \
|
||||
jtagmkI_private.h \
|
||||
jtagmkII.c \
|
||||
jtagmkII.h \
|
||||
jtagmkII_private.h \
|
||||
@@ -92,6 +97,7 @@ avrdude_SOURCES = \
|
||||
serbb_win32.c \
|
||||
ser_posix.c \
|
||||
ser_win32.c \
|
||||
solaris_ecpp.h \
|
||||
stk500.c \
|
||||
stk500.h \
|
||||
stk500_private.h \
|
||||
@@ -100,6 +106,7 @@ avrdude_SOURCES = \
|
||||
stk500v2_private.h \
|
||||
term.c \
|
||||
term.h \
|
||||
usbdevs.h \
|
||||
usb_libusb.c
|
||||
|
||||
man_MANS = avrdude.1
|
||||
@@ -108,6 +115,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}"
|
||||
|
||||
13
avrdude/NEWS
13
avrdude/NEWS
@@ -5,8 +5,19 @@ Approximate change log for AVRDUDE by version.
|
||||
(For more detailed changes, see the ChangeLog file.)
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Current:
|
||||
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:
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.\"
|
||||
.\" $Id$
|
||||
.\"
|
||||
.Dd DATE September 18, 2005
|
||||
.Dd DATE November 29, 2005
|
||||
.Os
|
||||
.Dt AVRDUDE 1
|
||||
.Sh NAME
|
||||
@@ -55,7 +55,8 @@ is a program for downloading code and data to Atmel AVR
|
||||
microcontrollers.
|
||||
.Nm Avrdude
|
||||
supports Atmel's STK500 programmer,
|
||||
Atmel's JTAG ICE mkII,
|
||||
Atmel's AVRISP and AVRISP mkII devices,
|
||||
Atmel's JTAG ICE (both mkI and mkII),
|
||||
programmers complying to AppNote AVR910 and AVR109 (including the Butterfly),
|
||||
as well as a simple hard-wired
|
||||
programmer connected directly to a
|
||||
@@ -104,7 +105,7 @@ 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 mkII is supported as well to up- or download memory
|
||||
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).
|
||||
.Pp
|
||||
Input files can be provided, and output files can be written in
|
||||
@@ -169,6 +170,8 @@ pwm3 AT90PWM3
|
||||
8535 AT90S8535
|
||||
m103 ATmega103
|
||||
m128 ATmega128
|
||||
m1280 ATmega1280
|
||||
m1281 ATmega1281
|
||||
m16 ATmega16
|
||||
m161 ATmega161
|
||||
m162 ATmega162
|
||||
@@ -181,6 +184,7 @@ m329 ATmega329
|
||||
m3290 ATmega3290
|
||||
m48 ATmega48
|
||||
m64 ATmega64
|
||||
m640 ATmega640
|
||||
m644 ATmega644
|
||||
m649 ATmega649
|
||||
m6490 ATmega6490
|
||||
@@ -349,6 +353,9 @@ 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.
|
||||
.It Fl q
|
||||
Disable (or quell) output of the progress bar while reading or writing
|
||||
to the device. Specify it a second time for even quieter operation.
|
||||
@@ -640,14 +647,19 @@ This man page by
|
||||
Please report bugs via
|
||||
.Dl "http://savannah.nongnu.org/bugs/?group=avrdude" .
|
||||
.Pp
|
||||
The JTAGICE mkII programmer currently cannot write to the flash ROM
|
||||
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.
|
||||
.Pp
|
||||
The device IDs used by AVR910 and AVR109 do not match, so the
|
||||
avr109 (aka. butterfly) programmer might report
|
||||
.Dl "selected device is not supported by programmer" .
|
||||
Use the -F option to force
|
||||
.Nm
|
||||
to contiue anway.
|
||||
to contiue anyway.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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.
|
||||
|
||||
@@ -40,35 +40,6 @@ extern char * progname;
|
||||
extern int do_cycles;
|
||||
extern int verbose;
|
||||
|
||||
static int bitbang_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||
{
|
||||
if ( pgm->flag )
|
||||
serbb_setpin(pgm->fd,pin,value);
|
||||
else
|
||||
par_setpin(pgm->fd,pin,value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int bitbang_getpin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
if ( pgm->flag )
|
||||
return serbb_getpin(pgm->fd,pin);
|
||||
else
|
||||
return par_getpin(pgm->fd,pin);
|
||||
}
|
||||
|
||||
|
||||
static int bitbang_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
if ( pgm->flag )
|
||||
return serbb_highpulsepin(pgm->fd,pin);
|
||||
else
|
||||
return par_highpulsepin(pgm->fd,pin);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* transmit and receive a byte of data to/from the AVR device
|
||||
*/
|
||||
@@ -82,7 +53,7 @@ static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte)
|
||||
/*
|
||||
* Write and read one bit on SPI.
|
||||
* Some notes on timing: Let T be the time it takes to do
|
||||
* one bitbang_setpin()-call resp. par clrpin()-call, then
|
||||
* one pgm->setpin()-call resp. par clrpin()-call, then
|
||||
* - SCK is high for 2T
|
||||
* - SCK is low for 2T
|
||||
* - MOSI setuptime is 1T
|
||||
@@ -99,17 +70,17 @@ static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte)
|
||||
b = (byte >> i) & 0x01;
|
||||
|
||||
/* set the data input line as desired */
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_MOSI], b);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_MOSI], b);
|
||||
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_SCK], 1);
|
||||
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 = bitbang_getpin(pgm, pgm->pinno[PIN_AVR_MISO]);
|
||||
r = pgm->getpin(pgm, pgm->pinno[PIN_AVR_MISO]);
|
||||
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||
|
||||
rbyte |= r << i;
|
||||
}
|
||||
@@ -120,25 +91,25 @@ static unsigned char bitbang_txrx(PROGRAMMER * pgm, unsigned char byte)
|
||||
|
||||
int bitbang_rdy_led(PROGRAMMER * pgm, int value)
|
||||
{
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_LED_RDY], !value);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_LED_RDY], !value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bitbang_err_led(PROGRAMMER * pgm, int value)
|
||||
{
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_LED_ERR], !value);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_LED_ERR], !value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bitbang_pgm_led(PROGRAMMER * pgm, int value)
|
||||
{
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_LED_PGM], !value);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_LED_PGM], !value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bitbang_vfy_led(PROGRAMMER * pgm, int value)
|
||||
{
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_LED_VFY], !value);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_LED_VFY], !value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -236,11 +207,11 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||
pgm->powerup(pgm);
|
||||
usleep(20000);
|
||||
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||
bitbang_setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_SCK], 0);
|
||||
pgm->setpin(pgm, pgm->pinno[PIN_AVR_RESET], 0);
|
||||
usleep(20000);
|
||||
|
||||
bitbang_highpulsepin(pgm, pgm->pinno[PIN_AVR_RESET]);
|
||||
pgm->highpulsepin(pgm, pgm->pinno[PIN_AVR_RESET]);
|
||||
|
||||
usleep(20000); /* 20 ms XXX should be a per-chip parameter */
|
||||
|
||||
@@ -261,7 +232,7 @@ int bitbang_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||
rc = pgm->program_enable(pgm, p);
|
||||
if ((rc == 0)||(rc == -1))
|
||||
break;
|
||||
bitbang_highpulsepin(pgm, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]);
|
||||
pgm->highpulsepin(pgm, pgm->pinno[p->retry_pulse/*PIN_AVR_SCK*/]);
|
||||
tries++;
|
||||
} while (tries < 65);
|
||||
|
||||
|
||||
@@ -297,9 +297,9 @@ static int butterfly_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "avr910.h"
|
||||
#include "butterfly.h"
|
||||
#include "avr.h"
|
||||
#include "jtagmkI.h"
|
||||
#include "jtagmkII.h"
|
||||
|
||||
#if defined(WIN32NATIVE)
|
||||
@@ -90,6 +91,7 @@ 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_LOADPAGE
|
||||
%token K_MAX_WRITE_DELAY
|
||||
@@ -358,6 +360,12 @@ prog_parm :
|
||||
}
|
||||
} |
|
||||
|
||||
K_TYPE TKN_EQUAL K_JTAG_MKI {
|
||||
{
|
||||
jtagmkI_initpgm(current_prog);
|
||||
}
|
||||
} |
|
||||
|
||||
K_TYPE TKN_EQUAL K_JTAG_MKII {
|
||||
{
|
||||
jtagmkII_initpgm(current_prog);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT(avrdude, 5.0cvs, avrdude-dev@nongnu.org)
|
||||
AC_INIT(avrdude, 5.1, 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
|
||||
@@ -93,6 +93,18 @@ AC_ARG_ENABLE(
|
||||
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@'
|
||||
@@ -104,14 +116,14 @@ DIST_SUBDIRS_AC='windows'
|
||||
fi
|
||||
|
||||
AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR)
|
||||
AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC)
|
||||
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"
|
||||
;;
|
||||
@@ -119,7 +131,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"
|
||||
;;
|
||||
@@ -127,6 +139,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"
|
||||
@@ -137,14 +153,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*)
|
||||
@@ -168,9 +199,17 @@ fi
|
||||
AC_CONFIG_FILES([
|
||||
windows/Makefile
|
||||
avrdude.spec
|
||||
avrdude.conf
|
||||
Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
# 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
|
||||
|
||||
@@ -28,7 +28,7 @@ This file documents the avrdude program.
|
||||
|
||||
For avrdude version @value{VERSION}, @value{UPDATED}.
|
||||
|
||||
Copyright @copyright{} 2003,2005 Brian Dean
|
||||
Copyright @copyright{} 2003, 2005 Brian Dean
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
@@ -59,9 +59,9 @@ 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,2005 Brian S. Dean
|
||||
@sp 2
|
||||
@@ -94,6 +94,12 @@ 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
|
||||
@end ifinfo
|
||||
|
||||
@menu
|
||||
@@ -129,8 +135,9 @@ 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 six basic programmer types: Atmel's STK500,
|
||||
Atmel's JTAG ICE mkII, appnote
|
||||
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), appnote
|
||||
avr910, appnote avr109 (including the AVR Butterfly),
|
||||
serial bit-bang adapters,
|
||||
and the PPI (parallel port interface). PPI represents a class
|
||||
@@ -166,7 +173,7 @@ 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.
|
||||
(This protocol can also be run on top of USB.)
|
||||
(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.
|
||||
|
||||
@@ -223,9 +230,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
|
||||
@@ -285,6 +292,12 @@ ATmega103
|
||||
@itemx m128
|
||||
ATmega128
|
||||
|
||||
@itemx m1280
|
||||
ATmega1280
|
||||
|
||||
@itemx m1281
|
||||
ATmega1281
|
||||
|
||||
@itemx m16
|
||||
ATmega16
|
||||
|
||||
@@ -321,6 +334,9 @@ ATmega48
|
||||
@itemx m64
|
||||
ATmega64
|
||||
|
||||
@itemx m640
|
||||
ATmega640
|
||||
|
||||
@itemx m644
|
||||
ATmega644
|
||||
|
||||
@@ -415,7 +431,16 @@ Atmel Low Cost Serial Programmer
|
||||
Atmel AppNote AVR911 AVROSP (an alias for avr109)
|
||||
|
||||
@itemx avrisp
|
||||
Atmel AVR ISP
|
||||
Atmel AVR ISP (an alias for stk500)
|
||||
|
||||
@itemx avrispv2
|
||||
Atmel AVR ISP, running a version 2.x firmware (an alias for stk500v2)
|
||||
|
||||
@itemx avrispmkII
|
||||
Atmel AVR ISP mkII (alias for stk500v2)
|
||||
|
||||
@itemx avrispmk2
|
||||
Atmel AVR ISP mkII (alias for stk500v2)
|
||||
|
||||
@itemx bascom
|
||||
Bascom SAMPLE programming cable
|
||||
@@ -429,6 +454,13 @@ Atmel Butterfly Development Board
|
||||
@itemx dt006
|
||||
Dontronics DT006
|
||||
|
||||
@item jtagmkI
|
||||
@itemx jtag1
|
||||
Atmel JTAG ICE mkI, running at 115200 Bd
|
||||
|
||||
@itemx jtag1slow
|
||||
Atmel JTAG ICE mkI, running at 19200 Bd
|
||||
|
||||
@item jtagmkII
|
||||
@itemx jtag2slow
|
||||
Atmel JTAG ICE mkII (default speed 19200 Bd)
|
||||
@@ -458,7 +490,7 @@ STK200
|
||||
Atmel STK500
|
||||
|
||||
@itemx stk500v2
|
||||
Atmel STK500, running a verrsion 2.x firmware
|
||||
Atmel STK500, running a version 2.x firmware
|
||||
|
||||
@end table
|
||||
|
||||
@@ -554,6 +586,11 @@ 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.
|
||||
|
||||
@item -q
|
||||
Disable (or quell) output of the progress bar while reading or writing
|
||||
@@ -699,7 +736,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
|
||||
|
||||
@@ -735,7 +772,7 @@ avrdude done. Thank you.
|
||||
|
||||
%
|
||||
@end cartouche
|
||||
@end example
|
||||
@end smallexample
|
||||
|
||||
@page
|
||||
@noindent
|
||||
@@ -743,7 +780,7 @@ 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
|
||||
|
||||
@@ -764,7 +801,7 @@ avrdude done. Thank you.
|
||||
|
||||
%
|
||||
@end cartouche
|
||||
@end example
|
||||
@end smallexample
|
||||
|
||||
@page
|
||||
@noindent
|
||||
@@ -772,7 +809,7 @@ 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 -U flash:w:diag.hex \
|
||||
@@ -813,14 +850,14 @@ 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:
|
||||
|
||||
@example
|
||||
@smallexample
|
||||
@cartouche
|
||||
|
||||
% avrdude -c jtag2 -p m649 -P usb:1c:37 -t
|
||||
@@ -836,8 +873,27 @@ avrdude: Device signature = 0x1e9603
|
||||
avrdude done. Thank you.
|
||||
|
||||
@end cartouche
|
||||
@end example
|
||||
@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
|
||||
@@ -958,7 +1014,7 @@ Display the current target supply voltage and JTAG bit clock rate/period.
|
||||
@noindent
|
||||
Display part parameters, modify eeprom cells, perform a chip erase:
|
||||
|
||||
@example
|
||||
@smallexample
|
||||
@cartouche
|
||||
% avrdude -p m128 -c stk500 -t
|
||||
|
||||
@@ -1010,7 +1066,7 @@ avrdude> dump eeprom 0 16
|
||||
|
||||
avrdude>
|
||||
@end cartouche
|
||||
@end example
|
||||
@end smallexample
|
||||
|
||||
|
||||
@noindent
|
||||
@@ -1020,7 +1076,7 @@ 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 -u -c stk500 -t
|
||||
|
||||
@@ -1050,7 +1106,7 @@ avrdude> w lfuse 0 0x2f
|
||||
|
||||
avrdude>
|
||||
@end cartouche
|
||||
@end example
|
||||
@end smallexample
|
||||
|
||||
|
||||
@c
|
||||
@@ -1119,7 +1175,7 @@ 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
|
||||
@@ -1135,7 +1191,7 @@ programmer
|
||||
pgmled = <num> ; # pin number
|
||||
vfyled = <num> ; # pin number
|
||||
;
|
||||
@end example
|
||||
@end smallexample
|
||||
|
||||
|
||||
@c
|
||||
@@ -1144,7 +1200,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
|
||||
@@ -1177,7 +1233,7 @@ part
|
||||
writepage = <instruction format> ;
|
||||
;
|
||||
;
|
||||
@end example
|
||||
@end smallexample
|
||||
|
||||
@menu
|
||||
* Instruction Format::
|
||||
@@ -1226,7 +1282,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";
|
||||
@@ -1234,7 +1290,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
|
||||
|
||||
|
||||
|
||||
@@ -1750,6 +1806,7 @@ line driven and for writing the batch files.
|
||||
|
||||
@noindent
|
||||
In general, please report any bugs encountered via
|
||||
@*
|
||||
@url{http://savannah.nongnu.org/bugs/?group=avrdude}.
|
||||
|
||||
|
||||
@@ -1791,16 +1848,6 @@ 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: I cannot modify the fuse bits on my AVR!
|
||||
|
||||
Solution: You probably forgot to specify the -u option, which allows you to modify fuse bits.
|
||||
This is done to prevent corrupt data from changing the fuse bits without you knowing about it, and
|
||||
currently also prevents the user from changing the fuse bits by accident. This patch was added in
|
||||
response to a number of occasions when an AVR had stopped responding because the fuse bits got changed
|
||||
by an error caused by the programmer. Programmer of course meaning both the physical device, and the
|
||||
person sitting at the keyboard.
|
||||
|
||||
@item
|
||||
Problem: AVRDUDE says my device is not supported when using the AVR109 boot loader
|
||||
|
||||
@@ -1815,11 +1862,21 @@ Use the -F option to force AVRDUDE to continue anyway.
|
||||
|
||||
@item
|
||||
Problem: Updating the flash ROM from terminal mode does not work with the
|
||||
JTAG ICE mkII.
|
||||
JTAG ICEs.
|
||||
|
||||
Solution: None at this time. Currently, the JTAG ICE mkII code cannot
|
||||
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.
|
||||
|
||||
|
||||
@end itemize
|
||||
|
||||
40
avrdude/freebsd_ppi.h
Normal file
40
avrdude/freebsd_ppi.h
Normal 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
1392
avrdude/jtagmkI.c
Normal file
File diff suppressed because it is too large
Load Diff
28
avrdude/jtagmkI.h
Normal file
28
avrdude/jtagmkI.h
Normal 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* avrdude - A Downloader/Uploader for AVR device programmers
|
||||
* Copyright (C) 2005 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
* Copyright (C) 2005,2006 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
*
|
||||
* Derived from stk500 code which is:
|
||||
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "pgm.h"
|
||||
#include "jtagmkII_private.h"
|
||||
#include "serial.h"
|
||||
#include "usbdevs.h"
|
||||
|
||||
|
||||
extern int verbose;
|
||||
@@ -1044,26 +1045,34 @@ static void jtagmkII_enable(PROGRAMMER * pgm)
|
||||
|
||||
static int jtagmkII_open(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
long baud;
|
||||
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkII_open()\n", progname);
|
||||
|
||||
#if defined(HAVE_LIBUSB)
|
||||
/*
|
||||
* If the port name starts with "usb", divert the serial routines
|
||||
* to the USB ones.
|
||||
*/
|
||||
if (strncmp(port, "usb", 3) == 0)
|
||||
serdev = &usb_serdev;
|
||||
#endif
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
/*
|
||||
* The JTAG ICE mkII always starts with a baud rate of 19200 Bd upon
|
||||
* attaching. If the config file or command-line parameters specify
|
||||
* a higher baud rate, we switch to it later on, after establishing
|
||||
* the connection with the ICE.
|
||||
*/
|
||||
pgm->fd = serial_open(port, 19200);
|
||||
baud = 19200;
|
||||
|
||||
#if defined(HAVE_LIBUSB)
|
||||
/*
|
||||
* If the port name starts with "usb", divert the serial routines
|
||||
* to the USB ones. The serial_open() function for USB overrides
|
||||
* the meaning of the "baud" parameter to be the USB device ID to
|
||||
* search for.
|
||||
*/
|
||||
if (strncmp(port, "usb", 3) == 0) {
|
||||
serdev = &usb_serdev;
|
||||
baud = USB_DEVICE_JTAGICEMKII;
|
||||
}
|
||||
#endif
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
pgm->fd = serial_open(port, baud);
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
@@ -1165,6 +1174,8 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||
if (jtagmkII_program_enable(pgm) < 0)
|
||||
return -1;
|
||||
|
||||
if (page_size == 0) page_size = 256;
|
||||
|
||||
if ((cmd = malloc(page_size + 10)) == NULL) {
|
||||
fprintf(stderr, "%s: jtagmkII_paged_write(): Out of memory\n",
|
||||
progname);
|
||||
@@ -1182,8 +1193,6 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||
page_size = eeprom_pagesize;
|
||||
}
|
||||
|
||||
if (page_size == 0) page_size = 256;
|
||||
|
||||
serial_recv_timeout = 100;
|
||||
for (addr = 0; addr < n_bytes; addr += page_size) {
|
||||
report_progress(addr, n_bytes,NULL);
|
||||
|
||||
169
avrdude/jtagmkI_private.h
Normal file
169
avrdude/jtagmkI_private.h
Normal 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 */
|
||||
};
|
||||
@@ -46,17 +46,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 +69,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,21 +104,19 @@ 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; }
|
||||
@@ -138,6 +141,7 @@ 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; }
|
||||
max_write_delay { yylval=NULL; return K_MAX_WRITE_DELAY; }
|
||||
memory { yylval=NULL; return K_MEMORY; }
|
||||
@@ -216,7 +220,7 @@ yes { yylval=new_token(K_YES); return K_YES; }
|
||||
"~" { 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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -101,7 +101,7 @@ void usage(void)
|
||||
"Options:\n"
|
||||
" -p <partno> Required. Specify AVR device.\n"
|
||||
" -b <baudrate> Override RS-232 baud rate.\n"
|
||||
" -B <bitclock> Specify JTAG bit clock period (us).\n"
|
||||
" -B <bitclock> Specify JTAG/STK500v2 bit clock period (us).\n"
|
||||
" -C <config-file> Specify location of configuration file.\n"
|
||||
" -c <programmer> Specify programmer type.\n"
|
||||
" -D Disable auto erase for flash memory\n"
|
||||
@@ -129,39 +129,6 @@ void usage(void)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* parse the -E string
|
||||
*/
|
||||
int getexitspecs(char *s, int *set, int *clr)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
while ((cp = strtok(s, ","))) {
|
||||
if (strcmp(cp, "reset") == 0) {
|
||||
*clr |= par_getpinmask(pgm->pinno[PIN_AVR_RESET]);
|
||||
}
|
||||
else if (strcmp(cp, "noreset") == 0) {
|
||||
*set |= par_getpinmask(pgm->pinno[PIN_AVR_RESET]);
|
||||
}
|
||||
else if (strcmp(cp, "vcc") == 0) {
|
||||
if (pgm->pinno[PPI_AVR_VCC])
|
||||
*set |= pgm->pinno[PPI_AVR_VCC];
|
||||
}
|
||||
else if (strcmp(cp, "novcc") == 0) {
|
||||
if (pgm->pinno[PPI_AVR_VCC])
|
||||
*clr |= pgm->pinno[PPI_AVR_VCC];
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
s = 0; /* strtok() should be called with the actual string only once */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int read_config(char * file)
|
||||
{
|
||||
FILE * f;
|
||||
@@ -742,11 +709,11 @@ int main(int argc, char * argv [])
|
||||
char * homedir;
|
||||
#endif
|
||||
|
||||
progname = rindex(argv[0],'/');
|
||||
progname = strrchr(argv[0],'/');
|
||||
|
||||
#if defined (WIN32NATIVE)
|
||||
/* take care of backslash as dir sep in W32 */
|
||||
if (!progname) progname = rindex(argv[0],'\\');
|
||||
if (!progname) progname = strrchr(argv[0],'\\');
|
||||
#endif /* WIN32NATIVE */
|
||||
|
||||
if (progname)
|
||||
@@ -1106,14 +1073,13 @@ int main(int argc, char * argv [])
|
||||
|
||||
|
||||
if (exitspecs != NULL) {
|
||||
if (strcmp(pgm->type, "PPI") != 0) {
|
||||
if (pgm->getexitspecs == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: -E option is only valid with \"PPI\" "
|
||||
"programmer types\n",
|
||||
"%s: WARNING: -E option not supported by this programmer type\n",
|
||||
progname);
|
||||
exitspecs = NULL;
|
||||
}
|
||||
else if (getexitspecs(exitspecs, &ppisetbits, &ppiclrbits) < 0) {
|
||||
else if (pgm->getexitspecs(pgm, exitspecs, &ppisetbits, &ppiclrbits) < 0) {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
@@ -1163,6 +1129,7 @@ int main(int argc, char * argv [])
|
||||
if (verbose) {
|
||||
fprintf(stderr, "%sSetting bit clk period: %.1f\n", progbuf, bitclock);
|
||||
}
|
||||
|
||||
pgm->bitclock = bitclock * 1e-6;
|
||||
}
|
||||
|
||||
@@ -1420,7 +1387,7 @@ int main(int argc, char * argv [])
|
||||
|
||||
/* Try reading back fuses, make sure they are reliable to read back */
|
||||
if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse,
|
||||
&safemodeafter_efuse, &safemode_fuse, pgm, p, verbose) != 0) {
|
||||
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 0) {
|
||||
/* Uh-oh.. try once more to read back fuses */
|
||||
if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse,
|
||||
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p, verbose) != 0) {
|
||||
|
||||
105
avrdude/par.c
105
avrdude/par.c
@@ -29,9 +29,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"
|
||||
@@ -40,6 +42,12 @@
|
||||
#include "ppi.h"
|
||||
#include "bitbang.h"
|
||||
|
||||
extern char * progname;
|
||||
extern int do_cycles;
|
||||
extern int verbose;
|
||||
|
||||
#if HAVE_PARPORT
|
||||
|
||||
#define SLOW_TOGGLE 0
|
||||
|
||||
struct ppipins_t {
|
||||
@@ -71,12 +79,7 @@ struct ppipins_t ppipins[] = {
|
||||
|
||||
#define NPINS (sizeof(ppipins)/sizeof(struct ppipins_t))
|
||||
|
||||
|
||||
extern char * progname;
|
||||
extern int do_cycles;
|
||||
extern int verbose;
|
||||
|
||||
int par_setpin(int fd, int pin, int value)
|
||||
static int par_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||
{
|
||||
|
||||
pin &= PIN_MASK;
|
||||
@@ -90,9 +93,9 @@ int par_setpin(int fd, int pin, int value)
|
||||
value = !value;
|
||||
|
||||
if (value)
|
||||
ppi_set(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
else
|
||||
ppi_clr(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
@@ -102,7 +105,7 @@ int par_setpin(int fd, int pin, int value)
|
||||
}
|
||||
|
||||
|
||||
int par_getpin(int fd, int pin)
|
||||
static int par_getpin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
int value;
|
||||
|
||||
@@ -113,7 +116,7 @@ int par_getpin(int fd, int pin)
|
||||
|
||||
pin--;
|
||||
|
||||
value = ppi_get(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
value = ppi_get(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
|
||||
if (value)
|
||||
value = 1;
|
||||
@@ -125,7 +128,7 @@ int par_getpin(int fd, int pin)
|
||||
}
|
||||
|
||||
|
||||
int par_highpulsepin(int fd, int pin)
|
||||
static int par_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
|
||||
if (pin < 1 || pin > 17)
|
||||
@@ -133,11 +136,11 @@ int par_highpulsepin(int fd, int pin)
|
||||
|
||||
pin--;
|
||||
|
||||
ppi_set(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
ppi_set(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
#endif
|
||||
ppi_clr(fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
ppi_clr(pgm->fd, ppipins[pin].reg, ppipins[pin].bit);
|
||||
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
@@ -158,7 +161,7 @@ int par_getpinmask(int pin)
|
||||
|
||||
|
||||
char vccpins_buf[64];
|
||||
char * vccpins_str(unsigned int pmask)
|
||||
static char * vccpins_str(unsigned int pmask)
|
||||
{
|
||||
unsigned int mask;
|
||||
int pin;
|
||||
@@ -183,7 +186,7 @@ char * vccpins_str(unsigned int pmask)
|
||||
/*
|
||||
* apply power to the AVR processor
|
||||
*/
|
||||
void par_powerup(PROGRAMMER * pgm)
|
||||
static void par_powerup(PROGRAMMER * pgm)
|
||||
{
|
||||
ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power up */
|
||||
usleep(100000);
|
||||
@@ -193,17 +196,17 @@ void par_powerup(PROGRAMMER * pgm)
|
||||
/*
|
||||
* remove power from the AVR processor
|
||||
*/
|
||||
void par_powerdown(PROGRAMMER * pgm)
|
||||
static void par_powerdown(PROGRAMMER * pgm)
|
||||
{
|
||||
ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_VCC]); /* power down */
|
||||
}
|
||||
|
||||
void par_disable(PROGRAMMER * pgm)
|
||||
static void par_disable(PROGRAMMER * pgm)
|
||||
{
|
||||
ppi_set(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
|
||||
}
|
||||
|
||||
void par_enable(PROGRAMMER * pgm)
|
||||
static void par_enable(PROGRAMMER * pgm)
|
||||
{
|
||||
/*
|
||||
* Prepare to start talking to the connected device - pull reset low
|
||||
@@ -216,7 +219,7 @@ 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);
|
||||
|
||||
/*
|
||||
@@ -225,7 +228,7 @@ void par_enable(PROGRAMMER * pgm)
|
||||
ppi_clr(pgm->fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
|
||||
}
|
||||
|
||||
int par_open(PROGRAMMER * pgm, char * port)
|
||||
static int par_open(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@@ -236,8 +239,6 @@ int par_open(PROGRAMMER * pgm, char * port)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ppi_claim(pgm);
|
||||
|
||||
/*
|
||||
* save pin values, so they can be restored when device is closed
|
||||
*/
|
||||
@@ -259,7 +260,7 @@ int par_open(PROGRAMMER * pgm, char * port)
|
||||
}
|
||||
|
||||
|
||||
void par_close(PROGRAMMER * pgm)
|
||||
static void par_close(PROGRAMMER * pgm)
|
||||
{
|
||||
/*
|
||||
* Restore pin values before closing,
|
||||
@@ -269,13 +270,11 @@ void par_close(PROGRAMMER * pgm)
|
||||
ppi_setall(pgm->fd, PPIDATA, pgm->ppidata);
|
||||
ppi_setall(pgm->fd, PPICTRL, pgm->ppictrl);
|
||||
|
||||
ppi_release(pgm);
|
||||
|
||||
ppi_close(pgm->fd);
|
||||
pgm->fd = -1;
|
||||
}
|
||||
|
||||
void par_display(PROGRAMMER * pgm, char * p)
|
||||
static void par_display(PROGRAMMER * pgm, char * p)
|
||||
{
|
||||
char vccpins[64];
|
||||
char buffpins[64];
|
||||
@@ -320,6 +319,38 @@ void par_display(PROGRAMMER * pgm, char * p)
|
||||
p, pgm->pinno[PIN_LED_VFY]);
|
||||
}
|
||||
|
||||
/*
|
||||
* parse the -E string
|
||||
*/
|
||||
static int par_getexitspecs(PROGRAMMER * pgm, char *s, int *set, int *clr)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
while ((cp = strtok(s, ","))) {
|
||||
if (strcmp(cp, "reset") == 0) {
|
||||
*clr |= par_getpinmask(pgm->pinno[PIN_AVR_RESET]);
|
||||
}
|
||||
else if (strcmp(cp, "noreset") == 0) {
|
||||
*set |= par_getpinmask(pgm->pinno[PIN_AVR_RESET]);
|
||||
}
|
||||
else if (strcmp(cp, "vcc") == 0) {
|
||||
if (pgm->pinno[PPI_AVR_VCC])
|
||||
*set |= pgm->pinno[PPI_AVR_VCC];
|
||||
}
|
||||
else if (strcmp(cp, "novcc") == 0) {
|
||||
if (pgm->pinno[PPI_AVR_VCC])
|
||||
*clr |= pgm->pinno[PPI_AVR_VCC];
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
s = 0; /* strtok() should be called with the actual string only once */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void par_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
@@ -340,7 +371,19 @@ void par_initpgm(PROGRAMMER * pgm)
|
||||
pgm->cmd = bitbang_cmd;
|
||||
pgm->open = par_open;
|
||||
pgm->close = par_close;
|
||||
|
||||
/* this is a parallel port bitbang device */
|
||||
pgm->flag = 0;
|
||||
pgm->setpin = par_setpin;
|
||||
pgm->getpin = par_getpin;
|
||||
pgm->highpulsepin = par_highpulsepin;
|
||||
pgm->getexitspecs = par_getexitspecs;
|
||||
}
|
||||
|
||||
#else /* !HAVE_PARPORT */
|
||||
|
||||
void par_initpgm(PROGRAMMER * pgm)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: parallel port access not available in this configuration\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
#endif /* HAVE_PARPORT */
|
||||
|
||||
@@ -24,11 +24,6 @@
|
||||
|
||||
void par_initpgm (PROGRAMMER * pgm);
|
||||
|
||||
int par_getpinmask(int pin);
|
||||
int par_setpin(int fd, int pin, int value);
|
||||
int par_getpin(int fd, int pin);
|
||||
int par_highpulsepin(int fd, int pin);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ 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 (*getexitspecs) (struct programmer_t * pgm, char *s, int *set, int *clr);
|
||||
char config_file[PATH_MAX]; /* config file where defined */
|
||||
int lineno; /* config file line number */
|
||||
char flag; /* for private use of the programmer */
|
||||
@@ -104,17 +108,7 @@ void usleep(unsigned long us);
|
||||
|
||||
void gettimeofday(struct timeval*, void*z);
|
||||
|
||||
#define rindex strrchr
|
||||
|
||||
#endif /* __win32native_h */
|
||||
|
||||
|
||||
#if !defined(ppi_claim)
|
||||
# define ppi_claim(pgm)
|
||||
#endif
|
||||
|
||||
#if !defined(ppi_release)
|
||||
# define ppi_release(pgm)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -179,6 +179,7 @@ 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;
|
||||
|
||||
@@ -195,8 +196,8 @@ static int ser_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);
|
||||
}
|
||||
@@ -204,8 +205,8 @@ static int ser_send(int fd, char * buf, size_t buflen)
|
||||
fprintf(stderr, ". ");
|
||||
}
|
||||
fprintf(stderr, "[%02x] ", c);
|
||||
buf++;
|
||||
buflen--;
|
||||
b++;
|
||||
len--;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
@@ -58,15 +58,15 @@ struct termios oldmode;
|
||||
7 cts <-
|
||||
*/
|
||||
|
||||
int serregbits[] =
|
||||
static int serregbits[] =
|
||||
{ TIOCM_CD, 0, 0, TIOCM_DTR, TIOCM_DSR, TIOCM_RTS, TIOCM_CTS };
|
||||
|
||||
#ifdef DEBUG
|
||||
char *serpins[7] =
|
||||
static char *serpins[7] =
|
||||
{ "CD", "RXD", "TXD ~RESET", "DTR MOSI", "DSR", "RTS SCK", "CTS MISO" };
|
||||
#endif
|
||||
|
||||
void serbb_setpin(int fd, int pin, int value)
|
||||
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||
{
|
||||
unsigned int ctl;
|
||||
|
||||
@@ -77,7 +77,7 @@ void serbb_setpin(int fd, int pin, int value)
|
||||
}
|
||||
|
||||
if ( pin < 1 || pin > 7 )
|
||||
return;
|
||||
return -1;
|
||||
|
||||
pin--;
|
||||
|
||||
@@ -88,24 +88,24 @@ void serbb_setpin(int fd, int pin, int value)
|
||||
switch ( pin )
|
||||
{
|
||||
case 2: /* txd */
|
||||
ioctl(fd, value ? TIOCSBRK : TIOCCBRK, 0);
|
||||
return;
|
||||
ioctl(pgm->fd, value ? TIOCSBRK : TIOCCBRK, 0);
|
||||
return 0;
|
||||
|
||||
case 3: /* dtr, rts */
|
||||
case 5: ioctl(fd, TIOCMGET, &ctl);
|
||||
case 5: ioctl(pgm->fd, TIOCMGET, &ctl);
|
||||
if ( value )
|
||||
ctl |= serregbits[pin];
|
||||
else
|
||||
ctl &= ~(serregbits[pin]);
|
||||
ioctl(fd, TIOCMSET, &ctl);
|
||||
return;
|
||||
ioctl(pgm->fd, TIOCMSET, &ctl);
|
||||
return 0;
|
||||
|
||||
default: /* impossible */
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int serbb_getpin(int fd, int pin)
|
||||
static int serbb_getpin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
unsigned int ctl;
|
||||
unsigned char invert;
|
||||
@@ -131,7 +131,7 @@ int serbb_getpin(int fd, int pin)
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6: ioctl(fd, TIOCMGET, &ctl);
|
||||
case 6: ioctl(pgm->fd, TIOCMGET, &ctl);
|
||||
if ( !invert )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@@ -152,16 +152,16 @@ int serbb_getpin(int fd, int pin)
|
||||
}
|
||||
}
|
||||
|
||||
int serbb_highpulsepin(int fd, int pin)
|
||||
static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
if (pin < 1 || pin > 7)
|
||||
return -1;
|
||||
|
||||
serbb_setpin(fd, pin, 1);
|
||||
serbb_setpin(pgm, pin, 1);
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
#endif
|
||||
serbb_setpin(fd, pin, 0);
|
||||
serbb_setpin(pgm, pin, 0);
|
||||
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
@@ -172,32 +172,32 @@ int serbb_highpulsepin(int fd, int pin)
|
||||
|
||||
|
||||
|
||||
void serbb_display(PROGRAMMER *pgm, char *p)
|
||||
static void serbb_display(PROGRAMMER *pgm, char *p)
|
||||
{
|
||||
/* MAYBE */
|
||||
}
|
||||
|
||||
void serbb_enable(PROGRAMMER *pgm)
|
||||
static void serbb_enable(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_disable(PROGRAMMER *pgm)
|
||||
static void serbb_disable(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_powerup(PROGRAMMER *pgm)
|
||||
static void serbb_powerup(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_powerdown(PROGRAMMER *pgm)
|
||||
static void serbb_powerdown(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
static int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
{
|
||||
struct termios mode;
|
||||
int flags;
|
||||
@@ -206,41 +206,40 @@ int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
|
||||
pgm->fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
|
||||
if ( pgm->fd > 0 )
|
||||
{
|
||||
tcgetattr(pgm->fd, &mode);
|
||||
oldmode = mode;
|
||||
if (pgm->fd < 0)
|
||||
return(-1);
|
||||
|
||||
cfmakeraw(&mode);
|
||||
mode.c_iflag &= ~(INPCK | IXOFF | IXON);
|
||||
mode.c_cflag &= ~(HUPCL | CSTOPB | CRTSCTS);
|
||||
mode.c_cflag |= (CLOCAL | CREAD);
|
||||
mode.c_cc [VMIN] = 1;
|
||||
mode.c_cc [VTIME] = 0;
|
||||
tcgetattr(pgm->fd, &mode);
|
||||
oldmode = mode;
|
||||
|
||||
tcsetattr(pgm->fd, TCSANOW, &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;
|
||||
|
||||
/* Clear O_NONBLOCK flag. */
|
||||
flags = fcntl(pgm->fd, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
tcsetattr(pgm->fd, TCSANOW, &mode);
|
||||
|
||||
/* Clear O_NONBLOCK flag. */
|
||||
flags = fcntl(pgm->fd, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
fprintf(stderr, "%s: Can not get flags\n", progname);
|
||||
return(-1);
|
||||
}
|
||||
flags &= ~O_NONBLOCK;
|
||||
if (fcntl(pgm->fd, F_SETFL, flags) == -1)
|
||||
flags &= ~O_NONBLOCK;
|
||||
if (fcntl(pgm->fd, F_SETFL, flags) == -1)
|
||||
{
|
||||
fprintf(stderr, "%s: Can not clear nonblock flag\n", progname);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void serbb_close(PROGRAMMER *pgm)
|
||||
static void serbb_close(PROGRAMMER *pgm)
|
||||
{
|
||||
tcsetattr(pgm->fd, TCSADRAIN, &oldmode);
|
||||
tcsetattr(pgm->fd, TCSANOW, &oldmode);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,9 +262,9 @@ void serbb_initpgm(PROGRAMMER *pgm)
|
||||
pgm->cmd = bitbang_cmd;
|
||||
pgm->open = serbb_open;
|
||||
pgm->close = serbb_close;
|
||||
|
||||
/* this is a serial port bitbang device */
|
||||
pgm->flag = 1;
|
||||
pgm->setpin = serbb_setpin;
|
||||
pgm->getpin = serbb_getpin;
|
||||
pgm->highpulsepin = serbb_highpulsepin;
|
||||
}
|
||||
|
||||
#endif /* WIN32NATIVE */
|
||||
|
||||
@@ -59,9 +59,9 @@ static int dtr, rts, txd;
|
||||
Negative pin # means negated value.
|
||||
*/
|
||||
|
||||
void serbb_setpin(int fd, int pin, int value)
|
||||
static int serbb_setpin(PROGRAMMER * pgm, int pin, int value)
|
||||
{
|
||||
HANDLE hComPort = (HANDLE)fd;
|
||||
HANDLE hComPort = (HANDLE)pgm->fd;
|
||||
LPVOID lpMsgBuf;
|
||||
DWORD dwFunc;
|
||||
const char *name;
|
||||
@@ -73,7 +73,7 @@ void serbb_setpin(int fd, int pin, int value)
|
||||
}
|
||||
|
||||
if (pin < 1 || pin > 7)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
pin--;
|
||||
|
||||
@@ -101,7 +101,7 @@ void serbb_setpin(int fd, int pin, int value)
|
||||
fprintf(stderr,
|
||||
"%s: serbb_setpin(): unknown pin %d\n",
|
||||
progname, pin + 1);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
if (verbose > 4)
|
||||
fprintf(stderr,
|
||||
@@ -126,12 +126,12 @@ void serbb_setpin(int fd, int pin, int value)
|
||||
LocalFree(lpMsgBuf);
|
||||
exit(1);
|
||||
}
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int serbb_getpin(int fd, int pin)
|
||||
static int serbb_getpin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
HANDLE hComPort = (HANDLE)fd;
|
||||
HANDLE hComPort = (HANDLE)pgm->fd;
|
||||
LPVOID lpMsgBuf;
|
||||
int invert, rv;
|
||||
const char *name;
|
||||
@@ -224,16 +224,16 @@ int serbb_getpin(int fd, int pin)
|
||||
return rv;
|
||||
}
|
||||
|
||||
int serbb_highpulsepin(int fd, int pin)
|
||||
static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
|
||||
{
|
||||
if (pin < 1 || pin > 7)
|
||||
return -1;
|
||||
|
||||
serbb_setpin(fd, pin, 1);
|
||||
serbb_setpin(pgm, pin, 1);
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
#endif
|
||||
serbb_setpin(fd, pin, 0);
|
||||
serbb_setpin(pgm, pin, 0);
|
||||
|
||||
#if SLOW_TOGGLE
|
||||
usleep(1000);
|
||||
@@ -243,32 +243,32 @@ int serbb_highpulsepin(int fd, int pin)
|
||||
}
|
||||
|
||||
|
||||
void serbb_display(PROGRAMMER *pgm, char *p)
|
||||
static void serbb_display(PROGRAMMER *pgm, char *p)
|
||||
{
|
||||
/* MAYBE */
|
||||
}
|
||||
|
||||
void serbb_enable(PROGRAMMER *pgm)
|
||||
static void serbb_enable(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_disable(PROGRAMMER *pgm)
|
||||
static void serbb_disable(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_powerup(PROGRAMMER *pgm)
|
||||
static void serbb_powerup(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
void serbb_powerdown(PROGRAMMER *pgm)
|
||||
static void serbb_powerdown(PROGRAMMER *pgm)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
static int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
{
|
||||
DCB dcb;
|
||||
LPVOID lpMsgBuf;
|
||||
@@ -332,7 +332,7 @@ int serbb_open(PROGRAMMER *pgm, char *port)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void serbb_close(PROGRAMMER *pgm)
|
||||
static void serbb_close(PROGRAMMER *pgm)
|
||||
{
|
||||
HANDLE hComPort=(HANDLE)pgm->fd;
|
||||
if (hComPort != INVALID_HANDLE_VALUE)
|
||||
@@ -364,9 +364,9 @@ void serbb_initpgm(PROGRAMMER *pgm)
|
||||
pgm->cmd = bitbang_cmd;
|
||||
pgm->open = serbb_open;
|
||||
pgm->close = serbb_close;
|
||||
|
||||
/* this is a serial port bitbang device */
|
||||
pgm->flag = 1;
|
||||
pgm->setpin = serbb_setpin;
|
||||
pgm->getpin = serbb_getpin;
|
||||
pgm->highpulsepin = serbb_highpulsepin;
|
||||
}
|
||||
|
||||
#endif /* WIN32NATIVE */
|
||||
|
||||
@@ -44,7 +44,7 @@ struct serial_device
|
||||
};
|
||||
|
||||
extern struct serial_device *serdev;
|
||||
extern struct serial_device serial_serdev, usb_serdev;
|
||||
extern struct serial_device serial_serdev, usb_serdev, usb_serdev_frame;
|
||||
|
||||
#define serial_open (serdev->open)
|
||||
#define serial_setspeed (serdev->setspeed)
|
||||
|
||||
51
avrdude/solaris_ecpp.h
Normal file
51
avrdude/solaris_ecpp.h
Normal 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 */
|
||||
@@ -2,6 +2,7 @@
|
||||
* avrdude - A Downloader/Uploader for AVR device programmers
|
||||
* Copyright (C) 2005 Erik Walthinsen
|
||||
* Copyright (C) 2002-2004 Brian S. Dean <bsd@bsdhome.com>
|
||||
* 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
|
||||
@@ -24,6 +25,10 @@
|
||||
/*
|
||||
* avrdude interface for Atmel STK500V2 programmer
|
||||
*
|
||||
* As the AVRISP mkII device is basically an STK500v2 one that can
|
||||
* only talk across USB, and that misses any kind of framing protocol,
|
||||
* this is handled here as well.
|
||||
*
|
||||
* Note: most commands use the "universal command" feature of the
|
||||
* programmer in a "pass through" mode, exceptions are "program
|
||||
* enable", "paged read", and "paged write".
|
||||
@@ -45,6 +50,7 @@
|
||||
#include "stk500_private.h" // temp until all code converted
|
||||
#include "stk500v2_private.h"
|
||||
#include "serial.h"
|
||||
#include "usbdevs.h"
|
||||
|
||||
#define STK500V2_XTAL 7372800U
|
||||
|
||||
@@ -66,6 +72,7 @@ extern char * progname;
|
||||
extern int do_cycles;
|
||||
|
||||
static unsigned char command_sequence = 1;
|
||||
static int is_mk2; /* Is the device an AVRISP mkII? */
|
||||
|
||||
|
||||
static int stk500v2_getparm(PROGRAMMER * pgm, unsigned char parm, unsigned char * value);
|
||||
@@ -74,12 +81,26 @@ static void stk500v2_print_parms1(PROGRAMMER * pgm, char * p);
|
||||
static int stk500v2_is_page_empty(unsigned int address, int page_size,
|
||||
const unsigned char *buf);
|
||||
|
||||
static int stk500v2_set_sck_period_mk2(PROGRAMMER * pgm, double v);
|
||||
|
||||
static int stk500v2_send_mk2(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
||||
{
|
||||
if (serial_send(pgm->fd, data, len) != 0) {
|
||||
fprintf(stderr,"%s: stk500_send_mk2(): failed to send command to serial port\n",progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stk500v2_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
||||
{
|
||||
unsigned char buf[275 + 6]; // max MESSAGE_BODY of 275 bytes, 6 bytes overhead
|
||||
int i;
|
||||
|
||||
if (is_mk2)
|
||||
return stk500v2_send_mk2(pgm, data, len);
|
||||
|
||||
buf[0] = MESSAGE_START;
|
||||
buf[1] = command_sequence;
|
||||
buf[2] = len / 256;
|
||||
@@ -110,6 +131,19 @@ static int stk500v2_drain(PROGRAMMER * pgm, int display)
|
||||
return serial_drain(pgm->fd, display);
|
||||
}
|
||||
|
||||
static int stk500v2_recv_mk2(PROGRAMMER * pgm, unsigned char msg[],
|
||||
size_t maxsize)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = serial_recv(pgm->fd, msg, maxsize);
|
||||
if (rv < 0) {
|
||||
fprintf(stderr, "%s: stk500v2_recv_mk2: error in USB receive\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int stk500v2_recv(PROGRAMMER * pgm, unsigned char msg[], size_t maxsize) {
|
||||
enum states { sINIT, sSTART, sSEQNUM, sSIZE1, sSIZE2, sTOKEN, sDATA, sCSUM, sDONE } state = sSTART;
|
||||
@@ -122,6 +156,9 @@ static int stk500v2_recv(PROGRAMMER * pgm, unsigned char msg[], size_t maxsize)
|
||||
struct timeval tv;
|
||||
double tstart, tnow;
|
||||
|
||||
if (is_mk2)
|
||||
return stk500v2_recv_mk2(pgm, msg, maxsize);
|
||||
|
||||
DEBUG("STK500V2: stk500v2_recv(): ");
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
@@ -437,13 +474,30 @@ static void stk500v2_enable(PROGRAMMER * pgm)
|
||||
|
||||
static int stk500v2_open(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
long baud = 115200;
|
||||
|
||||
DEBUG("STK500V2: stk500v2_open()\n");
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
if (pgm->baudrate)
|
||||
pgm->fd = serial_open(port, pgm->baudrate);
|
||||
else
|
||||
pgm->fd = serial_open(port, 115200);
|
||||
baud = pgm->baudrate;
|
||||
|
||||
#if defined(HAVE_LIBUSB)
|
||||
/*
|
||||
* If the port name starts with "usb", divert the serial routines
|
||||
* to the USB ones. The serial_open() function for USB overrides
|
||||
* the meaning of the "baud" parameter to be the USB device ID to
|
||||
* search for.
|
||||
*/
|
||||
if (strncmp(port, "usb", 3) == 0) {
|
||||
serdev = &usb_serdev_frame;
|
||||
baud = USB_DEVICE_AVRISPMKII;
|
||||
is_mk2 = 1;
|
||||
pgm->set_sck_period = stk500v2_set_sck_period_mk2;
|
||||
}
|
||||
#endif
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
pgm->fd = serial_open(port, baud);
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
@@ -454,6 +508,11 @@ static int stk500v2_open(PROGRAMMER * pgm, char * port)
|
||||
|
||||
stk500v2_drain(pgm, 0);
|
||||
|
||||
if (pgm->bitclock != 0.0) {
|
||||
if (pgm->set_sck_period(pgm, pgm->bitclock) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -797,6 +856,44 @@ static int stk500v2_set_fosc(PROGRAMMER * pgm, double v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The list of SCK frequencies supported by the AVRISP mkII, as listed
|
||||
* in AVR069 */
|
||||
double avrispmkIIfreqs[] = {
|
||||
8000000, 4000000, 2000000, 1000000, 500000, 250000, 125000,
|
||||
96386, 89888, 84211, 79208, 74767, 70797, 67227, 64000,
|
||||
61069, 58395, 55945, 51613, 49690, 47905, 46243, 43244,
|
||||
41885, 39409, 38278, 36200, 34335, 32654, 31129, 29740,
|
||||
28470, 27304, 25724, 24768, 23461, 22285, 21221, 20254,
|
||||
19371, 18562, 17583, 16914, 16097, 15356, 14520, 13914,
|
||||
13224, 12599, 12031, 11511, 10944, 10431, 9963, 9468,
|
||||
9081, 8612, 8239, 7851, 7498, 7137, 6809, 6478, 6178,
|
||||
5879, 5607, 5359, 5093, 4870, 4633, 4418, 4209, 4019,
|
||||
3823, 3645, 3474, 3310, 3161, 3011, 2869, 2734, 2611,
|
||||
2484, 2369, 2257, 2152, 2052, 1956, 1866, 1779, 1695,
|
||||
1615, 1539, 1468, 1398, 1333, 1271, 1212, 1155, 1101,
|
||||
1049, 1000, 953, 909, 866, 826, 787, 750, 715, 682,
|
||||
650, 619, 590, 563, 536, 511, 487, 465, 443, 422,
|
||||
402, 384, 366, 349, 332, 317, 302, 288, 274, 261,
|
||||
249, 238, 226, 216, 206, 196, 187, 178, 170, 162,
|
||||
154, 147, 140, 134, 128, 122, 116, 111, 105, 100,
|
||||
95.4, 90.9, 86.6, 82.6, 78.7, 75.0, 71.5, 68.2,
|
||||
65.0, 61.9, 59.0, 56.3, 53.6, 51.1
|
||||
};
|
||||
|
||||
static int stk500v2_set_sck_period_mk2(PROGRAMMER * pgm, double v)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(avrispmkIIfreqs); i++) {
|
||||
if (1 / avrispmkIIfreqs[i] >= v)
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Using p = %.2f us for SCK (param = %d)\n",
|
||||
1000000 / avrispmkIIfreqs[i], i);
|
||||
|
||||
return stk500v2_setparm(pgm, PARAM_SCK_DURATION, i);
|
||||
}
|
||||
|
||||
/* This code assumes that each count of the SCK duration parameter
|
||||
represents 8/f, where f is the clock frequency of the STK500V2 master
|
||||
@@ -848,8 +945,7 @@ static int stk500v2_getparm(PROGRAMMER * pgm, unsigned char parm, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value)
|
||||
static int stk500v2_setparm_real(PROGRAMMER * pgm, unsigned char parm, unsigned char value)
|
||||
{
|
||||
unsigned char buf[32];
|
||||
|
||||
@@ -866,6 +962,23 @@ static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value)
|
||||
{
|
||||
unsigned char current_value;
|
||||
int res;
|
||||
|
||||
res = stk500v2_getparm(pgm, parm, ¤t_value);
|
||||
if (res < 0)
|
||||
fprintf(stderr, "%s: Unable to get parameter 0x%02x\n", progname, parm);
|
||||
|
||||
// don't issue a write if the correct value is already set.
|
||||
if (value == current_value) {
|
||||
fprintf(stderr, "%s: Skipping paramter write; parameter value already set.\n", progname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return stk500v2_setparm_real(pgm, parm, value);
|
||||
}
|
||||
|
||||
static void stk500v2_display(PROGRAMMER * pgm, char * p)
|
||||
{
|
||||
@@ -938,7 +1051,11 @@ static void stk500v2_print_parms1(PROGRAMMER * pgm, char * p)
|
||||
unit = "Hz";
|
||||
fprintf(stderr, "%.3f %s\n", f, unit);
|
||||
}
|
||||
fprintf(stderr, "%sSCK period : %.1f us\n", p,
|
||||
if (is_mk2)
|
||||
fprintf(stderr, "%sSCK period : %.2f us\n", p,
|
||||
(float) 1000000 / avrispmkIIfreqs[sck_duration]);
|
||||
else
|
||||
fprintf(stderr, "%sSCK period : %.1f us\n", p,
|
||||
sck_duration * 8.0e6 / STK500V2_XTAL + 0.05);
|
||||
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* avrdude - A Downloader/Uploader for AVR device programmers
|
||||
* Copyright (C) 2005 Joerg Wunsch
|
||||
* 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
|
||||
@@ -38,25 +39,24 @@
|
||||
#include <usb.h>
|
||||
|
||||
#include "serial.h"
|
||||
#include "usbdevs.h"
|
||||
|
||||
extern char *progname;
|
||||
extern int verbose;
|
||||
|
||||
#define USB_VENDOR_ATMEL 1003
|
||||
#define USB_DEVICE_JTAGICEMKII 0x2103
|
||||
/*
|
||||
* Should we query the endpoint number and max transfer size from USB?
|
||||
* After all, the JTAG ICE mkII docs document these values.
|
||||
*/
|
||||
#define JTAGICE_BULK_EP 2
|
||||
#define JTAGICE_MAX_XFER 64
|
||||
|
||||
static char usbbuf[JTAGICE_MAX_XFER];
|
||||
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;
|
||||
@@ -99,7 +99,7 @@ static int usbdev_open(char * port, long baud)
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
|
||||
for (bus = usb_busses; bus; bus = bus->next)
|
||||
for (bus = usb_get_busses(); bus; bus = bus->next)
|
||||
{
|
||||
for (dev = bus->devices; dev; dev = dev->next)
|
||||
{
|
||||
@@ -107,7 +107,7 @@ static int usbdev_open(char * port, long baud)
|
||||
if (udev)
|
||||
{
|
||||
if (dev->descriptor.idVendor == USB_VENDOR_ATMEL &&
|
||||
dev->descriptor.idProduct == USB_DEVICE_JTAGICEMKII)
|
||||
dev->descriptor.idProduct == (unsigned short)baud)
|
||||
{
|
||||
/* yeah, we found something */
|
||||
if (usb_get_string_simple(udev,
|
||||
@@ -130,10 +130,20 @@ static int usbdev_open(char * port, long baud)
|
||||
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: usb_open(): Found JTAG ICE, serno: %s\n",
|
||||
progname, string);
|
||||
"%s: usbdev_open(): Found %s, serno: %s\n",
|
||||
progname, product, string);
|
||||
if (serno != NULL)
|
||||
{
|
||||
/*
|
||||
@@ -153,8 +163,35 @@ static int usbdev_open(char * port, long baud)
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -174,6 +211,14 @@ 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);
|
||||
}
|
||||
|
||||
@@ -181,8 +226,51 @@ static void usbdev_close(int fd)
|
||||
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;
|
||||
|
||||
return usb_bulk_write(udev, JTAGICE_BULK_EP, (char *)bp, mlen, 5000) != mlen;
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -198,7 +286,7 @@ usb_fill_buf(usb_dev_handle *udev)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = usb_bulk_read(udev, JTAGICE_BULK_EP, usbbuf, JTAGICE_MAX_XFER, 5000);
|
||||
rv = usb_bulk_read(udev, USBDEV_BULK_EP_READ, usbbuf, USBDEV_MAX_XFER, 5000);
|
||||
if (rv < 0)
|
||||
{
|
||||
if (verbose > 1)
|
||||
@@ -256,6 +344,71 @@ static int usbdev_recv(int fd, unsigned char *buf, size_t nbytes)
|
||||
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)
|
||||
{
|
||||
@@ -263,7 +416,7 @@ static int usbdev_drain(int fd, int display)
|
||||
int rv;
|
||||
|
||||
do {
|
||||
rv = usb_bulk_read(udev, JTAGICE_BULK_EP, usbbuf, JTAGICE_MAX_XFER, 100);
|
||||
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);
|
||||
@@ -272,6 +425,9 @@ static int usbdev_drain(int fd, int display)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Device descriptor for the JTAG ICE mkII.
|
||||
*/
|
||||
struct serial_device usb_serdev =
|
||||
{
|
||||
.open = usbdev_open,
|
||||
@@ -282,4 +438,17 @@ struct serial_device usb_serdev =
|
||||
.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 */
|
||||
|
||||
40
avrdude/usbdevs.h
Normal file
40
avrdude/usbdevs.h
Normal 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 */
|
||||
Reference in New Issue
Block a user