David Brownell | 2 Nov 05:29 2009
Picon

FT2232H bug: wrong maxpacket at full speed

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.

- Dave

(Continue reading)

Thomas Jarosch | 2 Nov 10:10 2009

Re: FT2232H bug: wrong maxpacket at full speed

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.
(Continue reading)

Thomas Jarosch | 2 Nov 10:13 2009

Re: Patch: EEPROM location Read and Write function

Hello Oleg,

On Monday, 26. October 2009 17:53:40 Signalyzer ( www.signalyzer.com ) 
wrote:
> Thank you for your most prompt response on my message. I sincerely
> appreciate your support on this topic.
> 
> Please let me know if you like to resubmit patch with corrected
>  indentations?

We should be able to fix this while applying ;)

> This patch will definitely help me to integrate Signalyzer H support
> into OpenOCD and other projects that rely the libftdi.

Ok. My colleague who wanted to take care of the patches turned sick
on his first day of vacation and still is :( I'll try to apply
the patches during the week.

Cheers,
Thomas

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

Thimo E. | 2 Nov 10:14 2009
Picon

Re: FT2232H bug: wrong maxpacket at full speed

Dear all,

please refer to my post some months ago:

http://developer.intra2net.com/mailarchive/html/libftdi/2009/msg00178.html

There are some other bugs with FT2232H which are still not fixed upstream.

Comments are highly appreciated.

Best regards
  Thimo

Thomas Jarosch schrieb:
> 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
(Continue reading)

Thomas Jarosch | 2 Nov 10:34 2009

Re: FT2232H bug: wrong maxpacket at full speed

Hello Thimo,

On Monday, 2. November 2009 10:14:28 Thimo E. wrote:
> please refer to my post some months ago:
> 
> http://developer.intra2net.com/mailarchive/html/libftdi/2009/msg00178.htm
> l
> 
> There are some other bugs with FT2232H which are still not fixed
>  upstream.
> 
> Comments are highly appreciated.

Thanks for reminding me! The first two patches look sane.
I'll take care of it this week. Guess we'll have a new
release soon once we've sorted out issue 3).

Cheers,
Thomas

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

David Brownell | 2 Nov 10:54 2009
Picon

Re: FT2232H bug: wrong maxpacket at full speed

On Monday 02 November 2009, Thimo E. wrote:
> Dear all,
> 
> please refer to my post some months ago:
> 
> http://developer.intra2net.com/mailarchive/html/libftdi/2009/msg00178.html
> 
> There are some other bugs with FT2232H which are still not fixed upstream.

I thought I remembered seeing an email in the list
archives that had some not-yet-fixed bugs.  I think
that was likely the one.

I don't yet have an FT2232H device, but after seeing
this issue crop up ... I'm quite certain we'll be
seeing OpenOCD v0.3.x users tripping over that bug.

http://developer.intra2net.com/mailarchive/html/libftdi/2009/msg00292.html

looked interesting too (very recent post).

> Comments are highly appreciated.

No comments for now on your patch, beyond "looks plausiable".

But I see your issue #3 is the same one I noted.  This is part
of why it's a good idea to avoid complex emails ... if you'd
posted your open issue separately, I suspect the more obvious
stuff would have gotten responses!  ;)

(Continue reading)

David Brownell | 2 Nov 10:58 2009
Picon

Re: FT2232H bug: wrong maxpacket at full speed

On Monday 02 November 2009, Thomas Jarosch wrote:

> 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.

I don't know about portable options ... but <usb.h> in Linux
does at least show the config descriptor hanging out in the
usb_device data structure, which means you could parse it.

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

Such a thing isn't valid.  It would be a new session.  Plus
there'd be the issue of how to ask for such behavior....

- Dave

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

Thomas Jarosch | 3 Nov 18:01 2009

Patches applied

Hello,

I guess I've applied all outstanding patches to libftdi's git tree.
Please ping me if I might have missed one/yours.

Now we just need a fix for the

"FT2232H bug: wrong maxpacket at full speed" 

issue ;)

Cheers,
Thomas

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

Howard Coven | 5 Nov 01:14 2009
Picon

writing to FT245R

i'm trying to use the libftdi to write to a FT245R chip using the standard protocol.

here is the main part of my code

///////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "ftdi.h"

int main(void)
{
        struct ftdi_context ftdic;

// all declarations, intializization  , etc..

 if (ftdi_init(&ftdic) < 0)
    {
        fprintf(stderr, "ftdi_init failed\n");
        return EXIT_FAILURE;
    }

    if ((ret = ftdi_usb_open(&ftdic, 0x0403, 0x6001)) < 0)
    {
        fprintf(stderr, "unable to open ftdi device: %d (%s)\n", ret, ftdi_get_error_string(&ftdic));
        return EXIT_FAILURE;
    }
if ((ret = ftdi_write_data(&ftdic, outBuff, 34))<0)
    {
        printf("write failed ! \n\r");
    }   
        else printf("#ofBytesWritten: %d\n\r",ret);

/////////////////////////////////////////////////////////////

I don't get any errors, but the ftdi_write_data function does not seem to
be having any results writing to the device.
I do seem to be able to connect & read from the device,
so i'm not sure what is wrong.

notice i'm merely including the ftdi files ,(  #include "ftdi.h" )
as i have put them in the same directory as my main.
do i have to first install the libftdi for it to work correctly.
i'm running Ubuntu 9.04
linux 2.6.28-16-generic

thanks!
Howard

Bing brings you maps, menus, and reviews organized in one place. Try it now.

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


Alex Harford | 5 Nov 01:20 2009
Picon

Re: writing to FT245R

On Wed, Nov 4, 2009 at 5:14 PM, Howard Coven <hcoven <at> hotmail.com> wrote:
>
> I don't get any errors, but the ftdi_write_data function does not seem to
> be having any results writing to the device.
> I do seem to be able to connect & read from the device,
> so i'm not sure what is wrong.

I think I have encountered the same bug.  Try calling the write
function twice.  I know it isn't correct, but it might help in
debugging.  I haven't traced the root cause yet.

Alex

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


Gmane