ftdi_convert_baudrate bug ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ftdi_convert_baudrate bug ?

Pierre Molinaro
Hi,

I use libftdi 1-1.1 (last release) with interface B of an Olimex ARM-USB-OCD JTAG. All is working fine, but change baud rate. ftdi_set_baudrate () does not fail, it returns 0, but has no effect on baud rate.

I have found this message in libftdi archives :
        http://developer.intra2net.com/mailarchive/html/libftdi/2013/msg00207.html

It suggested the following change in ftdi_convert_baudrate () function:
------
if (ftdi->type == TYPE_2232H ||
        ftdi->type == TYPE_4232H ||
        ftdi->type == TYPE_232H )
    {
        *index = (unsigned short)(encoded_divisor >> 8);
    }
    else
    {
        *index = (unsigned short)(encoded_divisor >> 16);
    }
    *index &= 0xFF00;
    *index |= ftdi->index;
------
Applying this change works fine for me. Is this change can be done in future releases ?

Best regards,
Pierre Molinaro


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ftdi_convert_baudrate bug ?

Thomas Jarosch
Hi Pierre,

On Sunday, 4. May 2014 18:51:45 Pierre Molinaro wrote:

> I use libftdi 1-1.1 (last release) with interface B of an Olimex
> ARM-USB-OCD JTAG. All is working fine, but change baud rate.
> ftdi_set_baudrate () does not fail, it returns 0, but has no effect on
> baud rate.
>
> I have found this message in libftdi archives :
> http://developer.intra2net.com/mailarchive/html/libftdi/2013/msg00207.htm
> l
>
> It suggested the following change in ftdi_convert_baudrate () function:
> ------
> if (ftdi->type == TYPE_2232H ||
>         ftdi->type == TYPE_4232H ||
>         ftdi->type == TYPE_232H )
>     {
>         *index = (unsigned short)(encoded_divisor >> 8);
>     }
>     else
>     {
>         *index = (unsigned short)(encoded_divisor >> 16);
>     }
>     *index &= 0xFF00;
>     *index |= ftdi->index;

hmm, I prefer not touching this in a too generic way
since I don't have AM type chips around to test it.

What chip is used on your ARM-USB-OCD JTAG interface? FT2232C?
May be we can narrow down what's happening.

Does this code change work for you:

$ git diff
diff --git a/src/ftdi.c b/src/ftdi.c
index b6caf6c..3e2ebfd 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -1200,7 +1200,7 @@ static int ftdi_convert_baudrate(int baudrate, struct ftdi_context *ftdi,
     }
     // Split into "value" and "index" values
     *value = (unsigned short)(encoded_divisor & 0xFFFF);
-    if (ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H || ftdi->type == TYPE_232H)
+    if (ftdi->type == TYPE_2232C || ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H || ftdi->type == TYPE_232H)
     {
         *index = (unsigned short)(encoded_divisor >> 8);
         *index &= 0xFF00;


?

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ftdi_convert_baudrate bug ?

Pierre Molinaro
Hi Thomas,

The Olimex ARM-USB-OCD JTAG documentation says it is an FT2232L chip, but libftdi recognizes it as a FT2232C (printing ftdi->type displays 2).

The patch runs fine for me.

Cheers,

Pierre

Le 16 mai 2014 à 17:19, Thomas Jarosch a écrit :

> Hi Pierre,
>
> On Sunday, 4. May 2014 18:51:45 Pierre Molinaro wrote:
>> I use libftdi 1-1.1 (last release) with interface B of an Olimex
>> ARM-USB-OCD JTAG. All is working fine, but change baud rate.
>> ftdi_set_baudrate () does not fail, it returns 0, but has no effect on
>> baud rate.
>>
>> I have found this message in libftdi archives :
>> http://developer.intra2net.com/mailarchive/html/libftdi/2013/msg00207.htm
>> l
>>
>> It suggested the following change in ftdi_convert_baudrate () function:
>> ------
>> if (ftdi->type == TYPE_2232H ||
>>        ftdi->type == TYPE_4232H ||
>>        ftdi->type == TYPE_232H )
>>    {
>>        *index = (unsigned short)(encoded_divisor >> 8);
>>    }
>>    else
>>    {
>>        *index = (unsigned short)(encoded_divisor >> 16);
>>    }
>>    *index &= 0xFF00;
>>    *index |= ftdi->index;
>
> hmm, I prefer not touching this in a too generic way
> since I don't have AM type chips around to test it.
>
> What chip is used on your ARM-USB-OCD JTAG interface? FT2232C?
> May be we can narrow down what's happening.
>
> Does this code change work for you:
>
> $ git diff
> diff --git a/src/ftdi.c b/src/ftdi.c
> index b6caf6c..3e2ebfd 100644
> --- a/src/ftdi.c
> +++ b/src/ftdi.c
> @@ -1200,7 +1200,7 @@ static int ftdi_convert_baudrate(int baudrate, struct ftdi_context *ftdi,
>     }
>     // Split into "value" and "index" values
>     *value = (unsigned short)(encoded_divisor & 0xFFFF);
> -    if (ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H || ftdi->type == TYPE_232H)
> +    if (ftdi->type == TYPE_2232C || ftdi->type == TYPE_2232H || ftdi->type == TYPE_4232H || ftdi->type == TYPE_232H)
>     {
>         *index = (unsigned short)(encoded_divisor >> 8);
>         *index &= 0xFF00;
>
>
> ?
>
> Cheers,
> Thomas
>


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]

Loading...