avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avrdude-dev] [bug #38831] [PATCH] Fix avrftdi onchip-buffer overrun


From: Hermann Kraus
Subject: Re: [avrdude-dev] [bug #38831] [PATCH] Fix avrftdi onchip-buffer overrun
Date: Fri, 26 Apr 2013 18:21:35 +0200
User-agent: Opera Mail/12.10 (Linux)

On Fri, 26 Apr 2013 13:09:11 +0200, Hannes Weisbach <address@hidden> wrote:
this is not an issue, because the FIFO is only of importance in UART mode. avrftdi uses the MPSSE mode, in which packet sizes are handled by the USB spec and subsystem of the operating system, specifically libusb.

I have seen the same problem as in #38659 while trying to verify or read an atmega16.
I got the same
avrftdi.c:536 avrftdi_transmit() ftdi_write_data(pdata->ftdic, buf, buf_size + 4) != buf_size + 4: Connection timed out (110)
error messages. Reading an mega8 worked however. I tracked it down to the different "buf_size" values (512 vs. 256). It stops working as soon as buf_size is bigger than 380. Together with the 4 bytes protocol overhead I get exactly the fifo size of 384 bytes.

Everything you write about not caring about packet sizes you wrote is correct. But libusb only handles splitting the data into packets that match the USB endpoint size, but it know nothing about buffers internal to the chip. I'm not sure if write-only access would work (I guess it works, as programming the flash does work), but writing + reading data back definitely doesn't work.

You send an 512 byte OUT request which produces 512 bytes of data. However there is no IN request to read the data. So after processing 384 bytes the FT2232 stall its endpoint till the results are read, while on the other hand the host waits for the full 512 bytes to be sent before it issues an IN request. This creates a dead-lock condition. The USB timeout expires and the transaction is aborted.

There are three solutions to this problem:
a) Issue an asynchronous IN request before the OUT request.
b) Issue an asynchronous OUT request and immediately afterwards an IN request.
c) Split data in packets that fit into the FIFO buffer of the FT2232.

Solution c) looked like the easiest one to implement so I chose it.

Regards,
Hermann



reply via email to

[Prev in Thread] Current Thread [Next in Thread]