libftdi Archives

Subject: Re: Configuring CBUSX_CLK24

From: Yegor Yefremov <yegorslists@xxxxxxxxxxxxxx>
To: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Cc: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 21 Apr 2017 09:42:27 +0200
Hi Thomas,

On Thu, Apr 20, 2017 at 6:17 PM, Thomas Jarosch
<thomas.jarosch@xxxxxxxxxxxxx> 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 libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread