Configuring CBUSX_CLK24

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Configuring CBUSX_CLK24

Yegor Yefremov
I'm configuring FTX ftdi.CBUS_FUNCTION_0 to ftdi.CBUSX_CLK24 in Linux
(ARM machine). After this ttyUSB0 gets disconnected, I can either
rebind it or reload the FTDI drive. Everything as expected. The
problem is, that I get 24MHz output only if I really reboot my ARM
machine.

How can I activate 24MHz without rebooting?

My code snippet for programming 24MHz:

if ftdi.set_eeprom_value(context, ftdi.CBUS_FUNCTION_0, ftdi.CBUSX_CLK24) != 0:
    print("Failed to set CBUS_FUNCTION_0")
    return False

# prepare EEPROM buffer for writing
if ftdi.eeprom_build(context) < 0:
    print("Failed to build EEPROM")
    return False

# finally write EEPROM
if ftdi.write_eeprom(context) != 0:
    print("Failed to write EEPROM")
    return False

# close FTDI device
if ftdi.usb_close(context) != 0:
    print("Failed to close FTDI device")
    return False

Regards,
Yegor

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

Re: Configuring CBUSX_CLK24

Thomas Jarosch
Hi Yegor,

On Tuesday, 18 April 2017 11:47:50 CEST Yegor Yefremov wrote:

> I'm configuring FTX ftdi.CBUS_FUNCTION_0 to ftdi.CBUSX_CLK24 in Linux
> (ARM machine). After this ttyUSB0 gets disconnected, I can either
> rebind it or reload the FTDI drive. Everything as expected. The
> problem is, that I get 24MHz output only if I really reboot my ARM
> machine.
>
> How can I activate 24MHz without rebooting?
>
> My code snippet for programming 24MHz:
>
> if ftdi.set_eeprom_value(context, ftdi.CBUS_FUNCTION_0, ftdi.CBUSX_CLK24) !=
> 0: print("Failed to set CBUS_FUNCTION_0")
>     return False
>
> # prepare EEPROM buffer for writing
> if ftdi.eeprom_build(context) < 0:
>     print("Failed to build EEPROM")
>     return False
>
> # finally write EEPROM
> if ftdi.write_eeprom(context) != 0:
>     print("Failed to write EEPROM")
>     return False
>
> # close FTDI device
> if ftdi.usb_close(context) != 0:
>     print("Failed to close FTDI device")
>     return False

do you really need to reboot the host
or does re-plugging the device also help?

Did you try to call ftdi_usb_reset() after flashing?

Thought ftdi_usb_open() calls that internally anyway.

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
|

Re: Configuring CBUSX_CLK24

Yegor Yefremov
Hi Thomas,

On Thu, Apr 20, 2017 at 6:17 PM, Thomas Jarosch
<[hidden email]> wrote:

> Hi Yegor,
>
> On Tuesday, 18 April 2017 11:47:50 CEST Yegor Yefremov wrote:
>> I'm configuring FTX ftdi.CBUS_FUNCTION_0 to ftdi.CBUSX_CLK24 in Linux
>> (ARM machine). After this ttyUSB0 gets disconnected, I can either
>> rebind it or reload the FTDI drive. Everything as expected. The
>> problem is, that I get 24MHz output only if I really reboot my ARM
>> machine.
>>
>> How can I activate 24MHz without rebooting?
>>
>> My code snippet for programming 24MHz:
>>
>> if ftdi.set_eeprom_value(context, ftdi.CBUS_FUNCTION_0, ftdi.CBUSX_CLK24) !=
>> 0: print("Failed to set CBUS_FUNCTION_0")
>>     return False
>>
>> # prepare EEPROM buffer for writing
>> if ftdi.eeprom_build(context) < 0:
>>     print("Failed to build EEPROM")
>>     return False
>>
>> # finally write EEPROM
>> if ftdi.write_eeprom(context) != 0:
>>     print("Failed to write EEPROM")
>>     return False
>>
>> # close FTDI device
>> if ftdi.usb_close(context) != 0:
>>     print("Failed to close FTDI device")
>>     return False
>
> do you really need to reboot the host
> or does re-plugging the device also help?

Re-plugging is not possible as FTDI chip is soldered, i.e. part of the
whole device.

> Did you try to call ftdi_usb_reset() after flashing?

Yes.

          # prepare EEPROM buffer for writing
          if ftdi.eeprom_build(context) < 0:
             print("Failed to build EEPROM")
              return False

          # finally write EEPROM
          if ftdi.write_eeprom(context) != 0:
              print("Failed to write EEPROM")
              return False

          # reset FTDI device
          if ftdi.usb_reset(context) != 0:
              print("Failed to reset FTDI device")
              return False

          # close FTDI device
          if ftdi.usb_close(context) != 0:
              print("Failed to close FTDI device")
              return False

> Thought ftdi_usb_open() calls that internally anyway.

Original FTDI API has two functions:

FT_ResetDevice and FT_CyclePort. The latter is suitable for my case:

"The effect of this function is the same as disconnecting then
reconnecting the device from USB. Possible use of this function is
situations where a fatal error has occurred and it is difficult, or
not possible, to recover without unplugging and replugging the USB
cable. This function can also be used after reprogramming the EEPROM
to force the FTDI device to read the new EEPROM contents which would
otherwise require a physical disconnect-reconnect."

Though this routine is marked as "Windows (2000 and later) ".

Any idea?

Yegor

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

Re: Configuring CBUSX_CLK24

Thomas Jarosch
Hello Yegor,

On Friday, 21 April 2017 09:42:27 CEST Yegor Yefremov wrote:
>           # reset FTDI device
>           if ftdi.usb_reset(context) != 0:
>               print("Failed to reset FTDI device")
>               return False

sorry, missed that part yesterday.

>           # close FTDI device
>           if ftdi.usb_close(context) != 0:
>               print("Failed to close FTDI device")
>               return False
>
> > Thought ftdi_usb_open() calls that internally anyway.
>
> Original FTDI API has two functions:
>
> FT_ResetDevice and FT_CyclePort. The latter is suitable for my case:
>
> "The effect of this function is the same as disconnecting then
> reconnecting the device from USB. Possible use of this function is
> situations where a fatal error has occurred and it is difficult, or
> not possible, to recover without unplugging and replugging the USB
> cable. This function can also be used after reprogramming the EEPROM
> to force the FTDI device to read the new EEPROM contents which would
> otherwise require a physical disconnect-reconnect."
>
> Though this routine is marked as "Windows (2000 and later) ".
>
> Any idea?

may be this helps:

https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line

Source for the short program:
http://marc.info/?l=linux-usb&m=121459435621262&w=2

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
|

Re: Configuring CBUSX_CLK24

Yegor Yefremov
On Fri, Apr 21, 2017 at 9:49 AM, Thomas Jarosch
<[hidden email]> wrote:

> Hello Yegor,
>
> On Friday, 21 April 2017 09:42:27 CEST Yegor Yefremov wrote:
>>           # reset FTDI device
>>           if ftdi.usb_reset(context) != 0:
>>               print("Failed to reset FTDI device")
>>               return False
>
> sorry, missed that part yesterday.
>
>>           # close FTDI device
>>           if ftdi.usb_close(context) != 0:
>>               print("Failed to close FTDI device")
>>               return False
>>
>> > Thought ftdi_usb_open() calls that internally anyway.
>>
>> Original FTDI API has two functions:
>>
>> FT_ResetDevice and FT_CyclePort. The latter is suitable for my case:
>>
>> "The effect of this function is the same as disconnecting then
>> reconnecting the device from USB. Possible use of this function is
>> situations where a fatal error has occurred and it is difficult, or
>> not possible, to recover without unplugging and replugging the USB
>> cable. This function can also be used after reprogramming the EEPROM
>> to force the FTDI device to read the new EEPROM contents which would
>> otherwise require a physical disconnect-reconnect."
>>
>> Though this routine is marked as "Windows (2000 and later) ".
>>
>> Any idea?
>
> may be this helps:
>
> https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line
>
> Source for the short program:
> http://marc.info/?l=linux-usb&m=121459435621262&w=2

It works. Thanks.

Yegor

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