GithubHelp home page GithubHelp logo

richardeoin / ftx-prog Goto Github PK

View Code? Open in Web Editor NEW
120.0 17.0 46.0 97 KB

A Linux command-line alternative to the FTDI FTProg utility for FTDI's FT-X series

License: GNU General Public License v2.0

C 99.12% Makefile 0.88%

ftx-prog's Introduction

ftx-prog is a Linux command-line alternative to the FTProg utility for FTDI's FT-X series of USB interfaces.

Installation

Install some prerequisites

sudo apt-get install build-essential gcc make libftdi-dev

then download, unzip, open a terminal in the unzipped directory and

make

Don't forget to plug in your FT-X device!

Usage

sudo ./ftx_prog

This should give you full details on all the possible options.

Display Current Settings

sudo ./ftx_prog --dump

CBUS Pins

sudo ./ftx_prog --cbus [cbus pin number] [function]

Sets up configurable CBUS pins with a particular function. Have a look at --help to see all the possible functions, and §7.12 of this application note to see what they all do. Don't forget that the pin numbers are zero based, so --cbus 0 corresponds to the CBUS0 pin.

The most commonly used are:

  • RxLED (pulses low when data is being sent from the host to the USB device)
  • TxLED (pulses low when data is being sent from the USB device to the host)
  • TxRxLED (pulses low when data is being sent either way)
  • SLEEP (goes low when the interface is in USB suspend mode)

Inverting RS232 Signals

FT230X and FT231X only

sudo ./ftx_prog --invert [rs232 pin]

This will invert the polarity of this pin on the chip. So if it was Active High it'll become Active Low and vice versa. You can use --dump to see if the pin is in its default state or not.

The possible pins are:

  • txd The interface's data output pin
  • rxd The interface's data input pin
  • rts Request to Send output pin
  • cts Clear to Send input pin
  • dtr Data Terminal Ready output pin
  • dsr Data Set Ready input pin
  • dcd Data Carrier Detect input pin
  • ri Ring Indicator input pin

Taking RI low (or high when polarity is inverted) for > 20ms will resume the USB host controller from suspend if remote wakeup has been enabled using --remote-wakeup on.

I2C

FT200XD and FT201X only

Note: The functionality of these options is completely untested

sudo ./ftx_prog --i2c-slave-address <number>

Sets the slave address of the FT-X on the I2C bus. For instance, --i2c-slave-address 0x22 will restore the slave address to its default value.

sudo ./ftx_prog --i2c-schmitt [on|off]

The I2C pins have schmitt triggers which can be turned on or off.

sudo ./ftx_prog --i2c-device-id <number>

Sets the I2C device ID.

SPI / FT1248

FT220X and FT221X only

Note: The functionality of these options is completely untested

sudo ./ftx_prog --ft1248-cpol [high|low]

The clock on the SPI / FT1248 bus can either be active high (Like SPI Mode 1) or active low (Like SPI Mode 3).

sudo ./ftx_prog --ft1248-bord [msb|lsb]

The bit order on the SPI / FT1248 bus can be either msb first or lsb first.

sudo ./ftx_prog --ft1248-flow-control [on|off]

Turns on flow control when SS_n is inactive.

RS485

Note: The functionality of these options is completely untested

sudo ./ftx_prog --rs485-echo-supp [on|off]

Used to enable echo supression if the interface is being used in a RS-485 system.

Misc

sudo ./ftx_prog --load-vcp [on|off]

Controls if the Virtual COM Port (VCP) drivers are loaded.

sudo ./ftx_prog --remote-wakeup [on|off]

Allows the interface to be woken up by something other than USB.

Use sudo ./ftx_prog --help to see details of all the command line options.

There are other configuration options that have not yet been implemented in the user interface. Support for the user configurable area in the EEPROM is also a possibility.

Workarounds for FT-X devices

All

Due to an error in the Silicon Revisions A, B and C of the FT-X series:

The device is put into suspend mode during a transfer of certain data patterns most notable with binary zeros. This can halt the data transfer in certain circumstances and will require the device to be reenumerated to recover. NB. It is the presence of this data pattern on the USB bus regardless of whether the data is intended for the [FT-X] or other devices (e.g. a broadcast) on the bus that forces the suspend state.

This can be fixed by connecting any CBUS pin to ground on the PCB and then configuring it as KeepAwake#. If you were to choose CBUS0 then sudo ./ftx_prog --cbus 0 Keep_Awake will do the configuration.

FT230X and FT231X

In Silicon Revisons A and B of the FT230X and FT231X:

An incorrect value for the VCP driver was programmed into the MTP on some production runs.

This means the Virtual COM Port (VCP) drivers are disabled, preventing the device from appearing as a COM Port on windows. Note: This is untested and may not be true!

To enable the VCP drivers, use sudo ./ftx_prog --load-vcp true.

License

GPL v2

Contributing

Bug reports and pull requests welcome!

This project is passively maintained, so there may be no changes for a long time. PRs are more likely to get merged if they are well explained, well commented and match the style of the surrounding code.

Credits

Modified for the FT-X series by Richard Meadows 2012

Based upon ft232r_prog, Version 1.23, by Mark Lord. Copyright 2010-2012.

ftx-prog's People

Contributors

bradjc avatar dave2 avatar johnmamish avatar lnanek avatar lordblick avatar martin-kaiser avatar richardeoin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ftx-prog's Issues

--self-powered on is setting the remote wakeup option, not the self powered option

When we use the --self-powered option with on and off values, it seems to be setting the remote wakeup value in the EEPROM, not the self powered option. We've verified this using the Windows FT_Prog tool and the Linux D2XX EEPROM read sample code.

Logs:
root@lnanek-MacBookPro:/home/lnanek/Downloads/source/ftx-prog# sudo ./ftx_prog --max-bus-power 500 --self-powered off --cbus 0 VBUS_Sense

ftx_prog: version 0.1
Modified for the FT-X series by Richard Meadows

Based upon:
ft232r_prog: version 1.23, by Mark Lord.
Battery Charge Detect (BCD) Enabled = False
Force Power Enable Signal on CBUS = False
Deactivate Sleep in Battery Charge Mode = False
External Oscillator Enabled = False
External Oscillator Feedback Resistor Enabled = False
CBUS pin allocated to VBUS Sense Mode = False
Load Virtual COM Port (VCP) Drivers = True
Vendor ID (VID) = 0x0403
Product ID (PID) = 0x6015
USB Version = USB16.0
Remote Wakeup by something other than USB = True
Self Powered = False
Serial Number = DA015EW7

I2C

I2C Slave Address = 0 
I2C Device ID = 0 
I2C Schmitt Triggers Disabled = False

CBUS

CBUS0 = VBUS_Sense
CBUS1 = RxLED
CBUS2 = TxLED
CBUS3 = SLEEP
CBUS4 = Tristate
CBUS5 = Tristate
CBUS6 = Tristate

No change from existing eeprom contents.
root@lnanek-MacBookPro:/home/lnanek/Downloads/source/ftx-prog#
root@lnanek-MacBookPro:/home/lnanek/Downloads/source/ftx-prog# ../../libftd2xx-x86_64-1.3.6/release/examples/EEPROM/read/read
Library version = 0x10306
Opening port 0
FT_Open succeeded. Handle is 0x254d6d0
FT_GetDeviceInfo succeeded. Device is type 9.
FT_EE_Read succeeded.

Signature1 = 0
Signature2 = -1
Version = 0
VendorId = 0x0403
ProductId = 0x6015
Manufacturer =
ManufacturerId =
Description =
SerialNumber =
MaxPower = 500
PnP = 1
SelfPowered = 0
RemoteWakeup = 0
Returning 0
root@lnanek-MacBookPro:/home/lnanek/Downloads/source/ftx-prog#
root@lnanek-MacBookPro:/home/lnanek/Downloads/source/ftx-prog# sudo ./ftx_prog --max-bus-power 500 --self-powered on --cbus 0 VBUS_Sense

ftx_prog: version 0.1
Modified for the FT-X series by Richard Meadows

Based upon:
ft232r_prog: version 1.23, by Mark Lord.
Battery Charge Detect (BCD) Enabled = False
Force Power Enable Signal on CBUS = False
Deactivate Sleep in Battery Charge Mode = False
External Oscillator Enabled = False
External Oscillator Feedback Resistor Enabled = False
CBUS pin allocated to VBUS Sense Mode = False
Load Virtual COM Port (VCP) Drivers = True
Vendor ID (VID) = 0x0403
Product ID (PID) = 0x6015
USB Version = USB16.0
Remote Wakeup by something other than USB = True
Serial Number = DA015EW7

I2C

I2C Slave Address = 0 
I2C Device ID = 0 
I2C Schmitt Triggers Disabled = False

CBUS

CBUS0 = VBUS_Sense
CBUS1 = RxLED
CBUS2 = TxLED
CBUS3 = SLEEP
CBUS4 = Tristate
CBUS5 = Tristate
CBUS6 = Tristate

Rewriting eeprom with new contents.
root@lnanek-MacBookPro:/home/lnanek/Downloads/source/ftx-prog#
root@lnanek-MacBookPro:/home/lnanek/Downloads/source/ftx-prog# ../../libftd2xx-x86_64-1.3.6/release/examples/EEPROM/read/read
Library version = 0x10306
Opening port 0
FT_Open succeeded. Handle is 0x1c676d0
FT_GetDeviceInfo succeeded. Device is type 9.
FT_EE_Read succeeded.

Signature1 = 0
Signature2 = -1
Version = 0
VendorId = 0x0403
ProductId = 0x6015
Manufacturer =
ManufacturerId =
Description =
SerialNumber =
MaxPower = 500
PnP = 1
SelfPowered = 0
RemoteWakeup = 1
Returning 0

Reading outputs invalid USB String descriptors, writing corrupts them.

I am trying to configure FT230XS (0403:6015) chips with ftx-prog to get rid of the annoying need for FT Prog, however using ftx-prog corrupts the device eeprom.

Steps to reproduce:

  • connect FT-X
  • ftx_prog --dump will output
[...]
        CBUS Schmitt Trigger = 0

        Manufacturer = 
F
        Product = $F
        Serial Number = D
[...]

Which is invalid.

  • Compare: Read EEPROM contents with FT Prog -> See USB String Descriptors

Writing (tested --save/--restore and --cbus) will write corrupted String Descriptors.

How to set address?

I'm getting the following error when using sudo ./ftx_prog --dump:

ftx_prog: version 0.3
Modified for the FT-X series by Richard Meadows

Based upon:
ft232r_prog: version 1.23, by Mark Lord.
ftdi_usb_open() failed for 0403:6015: device not found

when the listed devices I have from lsusb are:

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

How do I define the correct address (that should be 0403:6001)?

FT4232H

anyone tried with FT4232H?

FT232H has 10 CBUS

It looks like it's hardcoded to 7 here.

I haven't even gotten my ft232h yet so I'm not going to try changing values personally, but thought I'd leave a note.

The cbus's that can be set to GPIO are (0-indexed) 5/6/8/9 I think.

Is FT232R supported?

Greetings,

Apologies in advance for a newbie question. Does this work for all FT devices?

I tried commands such as the following with a couple of FTDI devices:

sudo ./ftx_prog --old-vid 0x0403 --old-pid 0x6001 --ignore-crc-error --new-pid 0x1066

sudo ./ftx_prog --old-vid 0x0403 --old-pid 0x6001 --ignore-crc-error --manufacturer Testing123

The one device is a DeLock serial to USB converter, chip unknown. The other is an optical sensor that has, I believe, an RS232R inside it. I'm not 100% sure about the chip. Neither change is persisted.

If I read correctly the manufacturer string is stored only if there is an external EEPROM, however the pid changes should have been persisted.

No way to select a specific FT-X device if no serial number is present.

The serial number is currently the only way to specify the device to program.
There is no way to select a specific device from a device node (e.g. /dev/ttyUSBx) or USB Bus/Device Number.
For an automated production/test system i would really like to ensure programming the right device.

Option --restore appears to do nothing

When using --save, I can generate a file with the contents of the EEPROM, but using --restore on a new command line, with the created file as argument, does nothing. The old contents appear and the EEPROM is not modified at all. It is not possible to write a new FTDI chip using this method.

ftx_Prog on tumbleweed

Hi, Im using Linux Tumbleweed and whrn I tried to make , got this error:
"Can't find -lftdi"
In Tumbleweed I got the libftdi1, but I guess is searching in different folder, how can I fix this?

How do I use this ftx-prog to update the eeprom information on 2 different FT231X ICs populated on a PCBA

Greetings,

I would like to use this ftx-prog tool to update my dbus driving current value of 2pcs FT231X.
However, I only could see one device when I used this tool. And there are indeed two devices listed in lsusb.

Is there any way to let me use this tool to set the dbus driving current value on both ICs in Linux like use the bus# and dev# to indicate which device I would like to program?
Thanks in advance.

FT200DX I2C Detection | Help Request

Dear Developer,

I apologize for opening an issue for a help request, but I need your assistance and believe you can help.

I connected a BME280 I2C breakout to the CJMCU-200 with the FX200DX chip to read the environmental sensor via USB.

image002

I successfully installed the driver and can read some data, but I do not see the I2C address 0x22 appearing.

image001 (1)

How can I confirm or check that the BME280 sensor is recognized at a specific address?

image

I am using a Raspberry Pi 5 with Bookworm OS.

Thank you in advance.

Best regards,
Paul

No way to erase a bad device and no way to get past an invalid CRC

It seems the latest FT_PROG on the FT2232H uses a different CRC to this program.
ftx_prog always reports the CRC wrong.
Currently ftx_prog quits if the CRC is wrong, preventing you from making any changes.

Also if you change the PID, then FT_PROG (wierdly) sometimes fails to see devices - methinks if the CRC is wrong, which it usually is. So there is no way to re-program the device. ftx_prog to the rescue....

Hence ftx_prog is a useful way to restore a bricked device.

The attached diff solves these issues and adds two functions:
--erase-eeprom
--ignore-crc-error
jm0.2.diff.txt

Invalid access to checksum protected area below 0x80

ftx_prog --old-serial-number DN00X61S --product ThumbDV

said:

Rewriting eeprom with new contents.
ftdi_write_eeprom_location() failed: Invalid access to checksum protected area  below 0x80

https://github.com/richardeoin/ftx-prog/blob/master/ftx_prog.c

says:

	for (i = 0; i < len/2; i++) {
		if (ftdi_write_eeprom_location(&ftdi, i,
eeprom[i*2] | (eeprom[(i*2)+1] << 8))) {

Note that variable i starts as 0 and it passes i in the second argument to ftdi_write_eeprom_location, but that argument is not allowed to be less than 0x80 according to:

http://developer.intra2net.com/git/?p=libftdi;a=blob_plain;f=src/ftdi.c;hb=HEAD

which says:

int ftdi_write_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr,
                               unsigned short eeprom_val)
{
    int chip_type_location;
    unsigned short chip_type;

    if (ftdi == NULL || ftdi->usb_dev == NULL)
        ftdi_error_return(-2, "USB device unavailable");

    if (eeprom_addr <0x80)
        ftdi_error_return(-2, "Invalid access to checksum protected area  below 0x80");

That occurred with a ThumbDV device that has a FTDI chip. If you want more info on ThumbDV, see:

http://nwdigitalradio.com/thumbdv-and-dv3000-resource-page/

USB-RS485-WE-1800-BT device not found.

Hi everyone, I have this USB to RS-485 converter (USB-RS485-WE-1800-BT) but when I try to dump its config I have the following output.

❯ sudo ftx_prog --dump

ftx_prog: version 0.3
Modified for the FT-X series by Richard Meadows

Based upon:
ft232r_prog: version 1.23, by Mark Lord.
ftdi_usb_open() failed for 0403:6015: device not found

And ... indeed for sure it won't be found becaus as I can see in the lsusb output ... there is no such a device!

❯ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 5986:2130 Acer, Inc Integrated Camera
Bus 003 Device 002: ID 0bda:b023 Realtek Semiconductor Corp. RTL8822BE Bluetooth 4.2 Adapter
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 004: ID 145f:02c9 Trust Trust Keyboard
Bus 001 Device 003: ID 062a:4102 MosArt Semiconductor Corp. Wireless Mouse
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

So is this converter supported by ftx-prog? I just can see the --rs485-echo-supp argument ... so apparently ftx-prog is compliant with rs485 converters, but is this maybe the only one thing I can do with my converter? Enabling/desabling the echo?

Thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.