* avrftdi.c, avrftdi_private.h: added tx buffer size, and use smaller block sizes as larger sometimes hang

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1204 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Rene Liebscher 2013-09-03 20:33:52 +00:00
parent 8ed6920948
commit caa061e18c
3 changed files with 24 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2013-09-03 Rene Liebscher <R.Liebscher@gmx.de>
* avrftdi.c, avrftdi_private.h: added tx buffer size, and use
smaller block sizes as larger sometimes hang
2013-09-03 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2013-09-03 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* avrdude.h: Remove the erase cycle counter (options -y / -Y). * avrdude.h: Remove the erase cycle counter (options -y / -Y).

View File

@ -42,6 +42,13 @@
#include "avrftdi_tpi.h" #include "avrftdi_tpi.h"
#include "avrftdi_private.h" #include "avrftdi_private.h"
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifdef DO_NOT_BUILD_AVRFTDI #ifdef DO_NOT_BUILD_AVRFTDI
static int avrftdi_noftdi_open (struct programmer_t *pgm, char * name) static int avrftdi_noftdi_open (struct programmer_t *pgm, char * name)
@ -350,13 +357,16 @@ static inline unsigned char extract_data(PROGRAMMER * pgm, unsigned char *buf, i
static int avrftdi_transmit_bb(PROGRAMMER * pgm, unsigned char mode, const unsigned char *buf, static int avrftdi_transmit_bb(PROGRAMMER * pgm, unsigned char mode, const unsigned char *buf,
unsigned char *data, int buf_size) unsigned char *data, int buf_size)
{ {
size_t blocksize;
size_t remaining = buf_size; size_t remaining = buf_size;
size_t written = 0; size_t written = 0;
avrftdi_t* pdata = to_pdata(pgm); avrftdi_t* pdata = to_pdata(pgm);
size_t blocksize = pdata->rx_buffer_size/2; // we are reading 2 bytes per data byte
// more than this does not work with FT2232D // determine a maximum size of data block
blocksize = 12;//pdata->rx_buffer_size/2; // we are reading 2 bytes per data byte size_t max_size = MIN(pdata->ftdic->max_packet_size,pdata->tx_buffer_size);
// select block size so that resulting commands does not exceed max_size if possible
blocksize = MAX(1,(max_size-7)/((8*2*6)+(8*1*2)));
//fprintf(stderr,"blocksize %d \n",blocksize);
while(remaining) while(remaining)
{ {
@ -826,15 +836,18 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port)
case TYPE_2232C: case TYPE_2232C:
pdata->pin_limit = 12; pdata->pin_limit = 12;
pdata->rx_buffer_size = 384; pdata->rx_buffer_size = 384;
pdata->tx_buffer_size = 128;
break; break;
case TYPE_2232H: case TYPE_2232H:
pdata->pin_limit = 16; pdata->pin_limit = 16;
pdata->rx_buffer_size = 4096; pdata->rx_buffer_size = 4096;
pdata->tx_buffer_size = 4096;
break; break;
#ifdef HAVE_LIBFTDI_TYPE_232H #ifdef HAVE_LIBFTDI_TYPE_232H
case TYPE_232H: case TYPE_232H:
pdata->pin_limit = 16; pdata->pin_limit = 16;
pdata->rx_buffer_size = 1024; pdata->rx_buffer_size = 1024;
pdata->tx_buffer_size = 1024;
break; break;
#else #else
#warning No support for 232H, use a newer libftdi, version >= 0.20 #warning No support for 232H, use a newer libftdi, version >= 0.20
@ -842,12 +855,14 @@ static int avrftdi_open(PROGRAMMER * pgm, char *port)
case TYPE_4232H: case TYPE_4232H:
pdata->pin_limit = 8; pdata->pin_limit = 8;
pdata->rx_buffer_size = 2048; pdata->rx_buffer_size = 2048;
pdata->tx_buffer_size = 2048;
break; break;
default: default:
log_warn("Found unkown device %x. I will do my ", pdata->ftdic->type); log_warn("Found unkown device %x. I will do my ", pdata->ftdic->type);
log_warn("best to work with it, but no guarantees ...\n"); log_warn("best to work with it, but no guarantees ...\n");
pdata->pin_limit = 8; pdata->pin_limit = 8;
pdata->rx_buffer_size = pdata->ftdic->max_packet_size; pdata->rx_buffer_size = pdata->ftdic->max_packet_size;
pdata->tx_buffer_size = pdata->ftdic->max_packet_size;
break; break;
} }

View File

@ -78,6 +78,7 @@ typedef struct avrftdi_s {
int pin_limit; int pin_limit;
/* internal RX buffer of the device. needed for INOUT transfers */ /* internal RX buffer of the device. needed for INOUT transfers */
int rx_buffer_size; int rx_buffer_size;
int tx_buffer_size;
/* use bitbanging instead of mpsse spi */ /* use bitbanging instead of mpsse spi */
bool use_bitbanging; bool use_bitbanging;
} avrftdi_t; } avrftdi_t;