libftdi Archives

Subject: Re: FT2232H bug: wrong maxpacket at full speed

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 2 Nov 2009 10:10:08 +0100
Hello Dave,

On Monday, 2. November 2009 05:29:56 David Brownell wrote:
> When running an FT2232H at full speed, we saw a new failure mode that
> turned out to be a bug in libftdi.  Current git:
> 
> int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int
>  size) {
>     int offset = 0, ret = 1, i, num_of_chunks, chunk_remains;
>     int packet_size;
> 
>     // New hi-speed devices from FTDI use a packet size of 512 bytes
>     if (ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H)
>         packet_size = 512;
>     else
>         packet_size = 64;
> 
>     ....
> 
> So there's a clear and *INCORRECT* assumption that highspeed-capable
> devices are never going to run at full speed, where packet_size != 512
> but instead is the traditional 64 bytes (on these chips).
> 
> Failure mode:  two-byte "modem" status codes bubbling up in the middle
> of JTAG transactions.  Rude...
> 
> I have no patch for this; just reporting the bug.  It's clearly fixable
> on Linux, which is our priority (OpenOCD, for JTAG) by asking sysfs for
> the device's "speed" attribute (12 or 480 MHz), or (more awkwardly) the
> endpoint's wMaxPacketSize.  Other operating systems -- no comments.

Thanks for reporting this issue. Maybe there's a way to ask libusb
about the maximum packet size, I'll have to check that. Otherwise
we would need to go the sysfs route.

Does anyone know if it's a valid thing to do for a USB device
to switch to a lower speed during one "session"?

Cheers,
Thomas

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread