Submitted by Doug Springer, based on work by

Wolfgang Moser, Ville Voipio, Hannes Weisbach
patch #7486: Patch to add FT2232C/D, FT2232H, FT4232H,
usbvid, usbpid, usbdev for USB support - Based on #7062
* avrftdi.c: New file.
* avrftdi.h: (Ditto.)
* configure.ac: Add check for libftdi.
* config_gram.y: Add AVRFTDI and per-programmer USB string
keywords.
* lexer.l: (Ditto.)
* avrdude.conf.in: Add avrftdi and 2232HIO programmers.
* pgm.h: Add USB parameters.
* Makefile.am: Add avrftdi.c and avrftdi.h.
* AUTHORS: Mention the new authors.
* avrdude.1: Document the changes.




git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@979 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2011-08-25 16:12:30 +00:00
parent d74d9e647e
commit 46c7bf38ec
13 changed files with 1332 additions and 7 deletions

View File

@ -16,6 +16,9 @@ Contributors:
David Hoerl <dhoerl@mac.com> David Hoerl <dhoerl@mac.com>
Michal Ludvig <mludvig@logix.net.nz> Michal Ludvig <mludvig@logix.net.nz>
Darell Tan <darell.tan@gmail.com> Darell Tan <darell.tan@gmail.com>
Wolfgang Moser
Ville Voipio
Hannes Weisbach
Doug Springer
For minor contributions, please see the ChangeLog files. For minor contributions, please see the ChangeLog files.

View File

@ -1,3 +1,22 @@
2011-08-25 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Submitted by Doug Springer, based on work by
Wolfgang Moser, Ville Voipio, Hannes Weisbach
patch #7486: Patch to add FT2232C/D, FT2232H, FT4232H,
usbvid, usbpid, usbdev for USB support - Based on #7062
* avrftdi.c: New file.
* avrftdi.h: (Ditto.)
* configure.ac: Add check for libftdi.
* config_gram.y: Add AVRFTDI and per-programmer USB string
keywords.
* lexer.l: (Ditto.)
* avrdude.conf.in: Add avrftdi and 2232HIO programmers.
* pgm.h: Add USB parameters.
* Makefile.am: Add avrftdi.c and avrftdi.h.
* AUTHORS: Mention the new authors.
* avrdude.1: Document the changes.
* doc/avrdude.texi: (Ditto.)
2011-08-23 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2011-08-23 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
bug #29585: Fix license bug #29585: Fix license

View File

@ -56,7 +56,7 @@ avrdude_CFLAGS = @ENABLE_WARNINGS@
libavrdude_a_CFLAGS = @ENABLE_WARNINGS@ libavrdude_a_CFLAGS = @ENABLE_WARNINGS@
avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB@ @LIBUSB_1_0@ @LIBHID@ -lm avrdude_LDADD = $(top_builddir)/$(noinst_LIBRARIES) @LIBUSB@ @LIBUSB_1_0@ @LIBFTDI@ @LIBHID@ -lm
bin_PROGRAMS = avrdude bin_PROGRAMS = avrdude
@ -87,6 +87,8 @@ libavrdude_a_SOURCES = \
avr910.c \ avr910.c \
avr910.h \ avr910.h \
avrdude.h \ avrdude.h \
avrftdi.c \
avrftdi.h \
avrpart.c \ avrpart.c \
avrpart.h \ avrpart.h \
bitbang.c \ bitbang.c \

1
NEWS
View File

@ -15,6 +15,7 @@ Current:
* New programmers supported: * New programmers supported:
- TPI programming through bitbang programmers (both, serial - TPI programming through bitbang programmers (both, serial
and parallel ones) and parallel ones)
- FT2232 (and relatives) based programmers (MPSSE bitbang mode)
* Bugfixes * Bugfixes

View File

@ -148,11 +148,16 @@ option might be required to achieve a stable ISP communication.
For ATxmega devices, the AVR Dragon is supported in PDI mode, provided it For ATxmega devices, the AVR Dragon is supported in PDI mode, provided it
has a firmware version of at least 6.11 (decimal). has a firmware version of at least 6.11 (decimal).
.Pp .Pp
The USBasp ISP and USBtinyISP adapters are also supported, provided The avrftdi, USBasp ISP and USBtinyISP adapters are also supported, provided
.Nm avrdude .Nm avrdude
has been compiled with libusb support. has been compiled with libusb support.
They both feature simple firmware-only USB implementations, running on USBasp ISP and USBtinyISP both feature simple firmware-only USB implementations,
an ATmega8 (or ATmega88), or ATtiny2313, respectively. running on an ATmega8 (or ATmega88), or ATtiny2313, respectively. If libftdi has
has been compiled in
.Nm avrdude ,
the avrftdi device adds support for many programmers using FTDI's 2232C/D/H
and 4232H parts running in MPSSE mode, which hard-codes (in the chip)
SCK to bit 1, MOSI to bit 2, and MISO to bit 3. Reset is usually bit 4.
.Pp .Pp
Input files can be provided, and output files can be written in Input files can be provided, and output files can be written in
different file formats, such as raw binary files containing the data different file formats, such as raw binary files containing the data
@ -1041,3 +1046,9 @@ This also applies to the STK500 and STK600 in parallel programming mode.
The USBasp and USBtinyISP drivers do not offer any option to distinguish multiple The USBasp and USBtinyISP drivers do not offer any option to distinguish multiple
devices connected simultaneously, so effectively only a single device devices connected simultaneously, so effectively only a single device
is supported. is supported.
.Pp
The avrftdi driver allows to select specific devices using any combination of vid,pid
serial number (usbsn) vendor description (usbvendoror part description (usbproduct)
as seen with lsusb or whatever tool used to view USB device information. Multiple
devices can be on the bus at the same time. For the H parts, which have multiple MPSSE
interfaces, the interface can also be selected. It defaults to interface 'A'.

View File

@ -32,6 +32,14 @@
# rdyled = <num> ; # pin number # rdyled = <num> ; # pin number
# pgmled = <num> ; # pin number # pgmled = <num> ; # pin number
# vfyled = <num> ; # pin number # vfyled = <num> ; # pin number
# usbvid = <hexnum>; # USB VID (Vendor ID)
# usbpid = <hexnum>; # USB PID (Product ID)
# usbdev = <interface>; # USB interface or other device info
# usbvendor = <vendorname>; # USB Vendor Name
# usbproduct = <productname>; # USB Product Name
# usbsn = <serialno>; # USB Serial Number
#
# To invert a bit, use = ~ <num>, the spaces are important.
# ; # ;
# #
# part # part
@ -319,6 +327,73 @@ programmer
desc = "Arduino"; desc = "Arduino";
type = arduino; type = arduino;
; ;
# this will interface with the chips on these programmers:
#
# http://real.kiev.ua/old/avreal/en/adapters
# http://www.amontec.com/jtagkey.shtml, jtagkey-tiny.shtml
# http://www.olimex.com/dev/arm-usb-ocd.html, arm-usb-tiny.html
# http://www.ethernut.de/en/hardware/turtelizer/index.html
# http://elk.informatik.fh-augsburg.de/hhweb/doc/openocd/usbjtag/usbjtag.html
# http://dangerousprototypes.com/docs/FT2232_breakout_board
# http://www.ftdichip.com/Products/Modules/DLPModules.htm,DLP-2232*,DLP-USB1232H
# http://flashrom.org/FT2232SPI_Programmer
#
# The drivers will look for a specific device and use the first one found.
# If you have mulitple devices, then look for unique information (like SN)
# And fill that in here.
programmer
id = "avrftdi";
desc = "FT2232D based generic programmer";
type = avrftdi;
usbvid = 0x0403;
usbpid = 0x6010;
usbvendor = "";
usbproduct = "";
usbdev = "A";
usbsn = "";
#ISP-signals - lower ACBUS-Nibble (default)
reset = 4;
sck = 1;
mosi = 2;
miso = 3;
#LED SIGNALs - higher ACBUS-Nibble
# errled = 5;
# rdyled = 6;
# pgmled = 7;
# vfyled = 8;
#Buffer Signal - ADBUS - Nibble
# buff = 9;
;
# This is an implementation of the above with a buffer IC (74AC244) and
# 4 LEDs directly attached, active low. The buff and reset pins are
# understood (by avrdude) to be active low, so there's no
# need to invert the bits.
programmer
id = "2232HIO";
desc = "FT2232H based generic programmer";
type = avrftdi;
usbvid = 0x0403;
# Note: This PID is reserved for generic H devices and
# should be programmed into the EEPROM
# usbpid = 0x8A48;
usbpid = 0x6010;
usbdev = "A";
usbvendor = "";
usbproduct = "";
usbsn = "";
#ISP-signals
reset = 4;
sck = 1;
mosi = 2;
miso = 3;
buff = 5;
#LED SIGNALs
errled = ~ 12;
rdyled = ~ 15;
pgmled = ~ 14;
vfyled = ~ 13;
;
programmer programmer
id = "avrisp"; id = "avrisp";

1079
avrftdi.c Normal file

File diff suppressed because it is too large Load Diff

56
avrftdi.h Normal file
View File

@ -0,0 +1,56 @@
/*
* avrftdi - extension for avrdude, Wolfgang Moser, Ville Voipio
* Copyright (C) 2011 Hannes Weisbach, Doug Springer
*
* 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 avrftdi_h
#define avrfdti_h
#ifdef __cplusplus
extern "C" {
#endif
#define SCK 0x01
#define SDO 0x02
#define SDI 0x04
#define RX 0x20
#define TX 0x11
#define TRX (RX | TX)
#define TYPE_C_D 0x500
#define TYPE_H 0x700
#define TYPE_4H 0x800
#define E(x) if ((x)) { fprintf(stdout, "%s:%d %s() %s: %s (%d)\n\t%s\n", __FILE__, __LINE__, __FUNCTION__, \
#x, strerror(errno), errno, ftdi_get_error_string(&ftdic)); return -1; }
#define E_VOID(x) if ((x)) { fprintf(stdout, "%s:%d %s() %s: %s (%d)\n\t%s\n", __FILE__, __LINE__, __FUNCTION__, \
#x, strerror(errno), errno, ftdi_get_error_string(&ftdic)); }
void avrftdi_initpgm (PROGRAMMER * pgm);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -48,6 +48,7 @@
#include "avr.h" #include "avr.h"
#include "jtagmkI.h" #include "jtagmkI.h"
#include "jtagmkII.h" #include "jtagmkII.h"
#include "avrftdi.h"
#if defined(WIN32NATIVE) #if defined(WIN32NATIVE)
#define strtok_r( _s, _sep, _lasts ) \ #define strtok_r( _s, _sep, _lasts ) \
@ -82,6 +83,7 @@ static int parse_cmdbits(OPCODE * op);
%token K_PAGED %token K_PAGED
%token K_ARDUINO %token K_ARDUINO
%token K_AVRFTDI
%token K_BAUDRATE %token K_BAUDRATE
%token K_BS2 %token K_BS2
%token K_BUFF %token K_BUFF
@ -149,7 +151,13 @@ static int parse_cmdbits(OPCODE * op);
%token K_STK600PP %token K_STK600PP
%token K_AVR910 %token K_AVR910
%token K_USBASP %token K_USBASP
%token K_USBDEV
%token K_USBSN
%token K_USBTINY %token K_USBTINY
%token K_USBPID
%token K_USBPRODUCT
%token K_USBVENDOR
%token K_USBVID
%token K_BUTTERFLY %token K_BUTTERFLY
%token K_TYPE %token K_TYPE
%token K_VCC %token K_VCC
@ -432,6 +440,12 @@ prog_parm :
} }
} | } |
K_TYPE TKN_EQUAL K_AVRFTDI {
{
avrftdi_initpgm(current_prog);
}
} |
K_TYPE TKN_EQUAL K_BUSPIRATE { K_TYPE TKN_EQUAL K_BUSPIRATE {
{ {
buspirate_initpgm(current_prog); buspirate_initpgm(current_prog);
@ -590,7 +604,49 @@ prog_parm :
} }
} }
} | } |
K_USBDEV TKN_EQUAL TKN_STRING {
{
strncpy(current_prog->usbdev, $3->value.string, PGM_USBSTRINGLEN);
current_prog->usbdev[PGM_USBSTRINGLEN-1] = 0;
free_token($3);
}
} |
K_USBVID TKN_EQUAL TKN_NUMBER {
{
current_prog->usbvid = $3->value.number;
}
} |
K_USBPID TKN_EQUAL TKN_NUMBER {
{
current_prog->usbpid = $3->value.number;
}
} |
K_USBSN TKN_EQUAL TKN_STRING {
{
strncpy(current_prog->usbsn, $3->value.string, PGM_USBSTRINGLEN);
current_prog->usbsn[PGM_USBSTRINGLEN-1] = 0;
free_token($3);
}
} |
K_USBVENDOR TKN_EQUAL TKN_STRING {
{
strncpy(current_prog->usbvendor, $3->value.string, PGM_USBSTRINGLEN);
current_prog->usbvendor[PGM_USBSTRINGLEN-1] = 0;
free_token($3);
}
} |
K_USBPRODUCT TKN_EQUAL TKN_STRING {
{
strncpy(current_prog->usbproduct, $3->value.string, PGM_USBSTRINGLEN);
current_prog->usbproduct[PGM_USBSTRINGLEN-1] = 0;
free_token($3);
}
} |
K_BAUDRATE TKN_EQUAL TKN_NUMBER { K_BAUDRATE TKN_EQUAL TKN_NUMBER {
{ {
current_prog->baudrate = $3->value.number; current_prog->baudrate = $3->value.number;

View File

@ -83,7 +83,14 @@ if test x$have_libusb_1_0 = xyes; then
AC_CHECK_HEADERS([libusb.h]) AC_CHECK_HEADERS([libusb.h])
fi fi
AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0) AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0)
AH_TEMPLATE([HAVE_LIBFTDI],
[Define if FTDI support is enabled via libftdi])
AC_CHECK_LIB([ftdi], [ftdi_init], [have_libftdi=yes])
if test x$have_libftdi = xyes; then
LIBFTDI="-lftdi"
AC_DEFINE([HAVE_LIBFTDI])
fi
AC_SUBST(LIBFTDI, $LIBFTDI)
# Checks for header files. # Checks for header files.
AC_CHECK_HEADERS([limits.h stdlib.h string.h]) AC_CHECK_HEADERS([limits.h stdlib.h string.h])
AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h]) AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h])

View File

@ -169,9 +169,14 @@ emulated on top of USB is likely to not work at all, or to work
abysmally slow. abysmally slow.
The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC. The STK500, JTAG ICE, avr910, and avr109/butterfly use the serial port to communicate with the PC.
The STK600, JTAG ICE mkII, AVRISP mkII, USBasp, and USBtinyISP The STK600, JTAG ICE mkII, AVRISP mkII, USBasp, avrftdi (and derivitives), and USBtinyISP
programmers communicate through the USB, using @code{libusb} as a programmers communicate through the USB, using @code{libusb} as a
platform abstraction layer. platform abstraction layer.
The avrftdi adds support for the FT2232C/D, FT2232H, and FT4232H devices. These all use
the MPSSE mode, which has a specific pin mapping. Bit 1 (the lsb of the byte in the config
file) is SCK. Bit 2 is MOSI, and Bit 3 is MISO. Bit 4 usually reset. The 2232C/D parts
are only supported on interface A, but the H parts can be either A or B (specified by the
usbdev config parameter).
The STK500, STK600, JTAG ICE, and avr910 contain on-board logic to control the programming of the target The STK500, STK600, JTAG ICE, and avr910 contain on-board logic to control the programming of the target
device. device.
The avr109 bootloader implements a protocol similar to avr910, but is The avr109 bootloader implements a protocol similar to avr910, but is

View File

@ -120,6 +120,7 @@ allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; }
arduino { yylval=NULL; return K_ARDUINO; } arduino { yylval=NULL; return K_ARDUINO; }
avr910 { yylval=NULL; return K_AVR910; } avr910 { yylval=NULL; return K_AVR910; }
avr910_devcode { yylval=NULL; return K_AVR910_DEVCODE; } avr910_devcode { yylval=NULL; return K_AVR910_DEVCODE; }
avrftdi { yylval=NULL; return K_AVRFTDI; }
usbasp { yylval=NULL; return K_USBASP; } usbasp { yylval=NULL; return K_USBASP; }
usbtiny { yylval=NULL; return K_USBTINY; } usbtiny { yylval=NULL; return K_USBTINY; }
bank_size { yylval=NULL; return K_PAGE_SIZE; } bank_size { yylval=NULL; return K_PAGE_SIZE; }
@ -197,6 +198,12 @@ stk600 { yylval=NULL; return K_STK600; }
stk600hvsp { yylval=NULL; return K_STK600HVSP; } stk600hvsp { yylval=NULL; return K_STK600HVSP; }
stk600pp { yylval=NULL; return K_STK600PP; } stk600pp { yylval=NULL; return K_STK600PP; }
type { yylval=NULL; return K_TYPE; } type { yylval=NULL; return K_TYPE; }
usbdev { yylval=NULL; return K_USBDEV; }
usbpid { yylval=NULL; return K_USBPID; }
usbproduct { yylval=NULL; return K_USBPRODUCT; }
usbsn { yylval=NULL; return K_USBSN; }
usbvendor { yylval=NULL; return K_USBVENDOR; }
usbvid { yylval=NULL; return K_USBVID; }
vcc { yylval=NULL; return K_VCC; } vcc { yylval=NULL; return K_VCC; }
vfyled { yylval=NULL; return K_VFYLED; } vfyled { yylval=NULL; return K_VFYLED; }

4
pgm.h
View File

@ -36,6 +36,7 @@
#define PGM_DESCLEN 80 #define PGM_DESCLEN 80
#define PGM_PORTLEN PATH_MAX #define PGM_PORTLEN PATH_MAX
#define PGM_TYPELEN 32 #define PGM_TYPELEN 32
#define PGM_USBSTRINGLEN 256
typedef enum { typedef enum {
EXIT_VCC_UNSPEC, EXIT_VCC_UNSPEC,
@ -60,6 +61,9 @@ typedef struct programmer_t {
int ppidata; int ppidata;
int ppictrl; int ppictrl;
int baudrate; int baudrate;
int usbvid, usbpid;
char usbdev[PGM_USBSTRINGLEN], usbsn[PGM_USBSTRINGLEN];
char usbvendor[PGM_USBSTRINGLEN], usbproduct[PGM_USBSTRINGLEN];
double bitclock; /* JTAG ICE clock period in microseconds */ double bitclock; /* JTAG ICE clock period in microseconds */
int ispdelay; /* ISP clock delay */ int ispdelay; /* ISP clock delay */
union filedescriptor fd; union filedescriptor fd;