Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for selection by usb bus:device address #22

Closed
wants to merge 3 commits into from

Conversation

iomode
Copy link

@iomode iomode commented May 20, 2020

This patch implements support for device selection (--bus-dev-addr) by usb bus and device address*. (mentioned in #11)

This is done by using ftdi_usb_open_bus_addr(...) from libftdi 1.4.
Currently, ftx-prog uses legacy libftdi 0.20 released in 2012.
I have updated the references to libftdi 1.X (1.4/2017) and no lib related code changes were necessary (except including <unistd.h>).
libftdi 1.4 is available from Ubuntu/Debian since 2017 so I think upgrading the lib dependency is acceptable.

** For those who want to use this in a production tool:
The usb devices number changes after each reconnect so --bus-dev-addr does not support a physical port selection.
However, the kernel device file path is persistent over reconnects so this workaround script can be used:

#!/bin/bash
BUSADDR=$(cat /sys/bus/usb/devices/3-14.5.5/busnum) # The kernel driver file is persistent
DEVADDR=$(cat /sys/bus/usb/devices/3-14.5.5/devnum)
./ftx_prog --bus-dev-addr "$BUSADDR" "$DEVADDR"

@iomode
Copy link
Author

iomode commented May 21, 2020

Unfortunately, I have to revoke my pull request because I did not test it properly.
The libftdi upgrade triggers the bug mentioned in #16 which means eeprom writing stops working.

I investigated this further and figured out that libftdi 1.0 introduced an offset check which is not applicable for the FT-X series (It is a bug still present in libftdi 1.4).

Based on this information I further looked at the libftdi API and realized that the ftdi_write_eeprom_location(...) function seems to be more or less deprecated.

libftdi does no have some very nice functions for eeprom handling including reading/writing/erasing/modifying data just based on the ftdi context.
I guess that 80% of the ftx-prog functionality becomes deprecated/duplicated if you upgrade to libftdi 1.X (just the argument parser is useful).

A good example for the new API usage can be found in the example tool:
https://github.com/wjakob/libftdi/blob/master/examples/eeprom.c
It has only read/erase/factory reset functionality implemented but it is a good example how simplified the new API is.

For those who want to use an up to date manufacturing tool you can have a look at:
https://github.com/wjakob/libftdi/tree/master/ftdi_eeprom
It allows you to program FTDI devices based on a configuration file and basically implements the same functionality as ftx-prog (including bus:device address based selection).

I know that this project is now in a passive maintenance mode but if someone wants to proceed development it would be highly recommended to switch to the new libftdi API.
Otherwise the tool will become unusable if some package maintainers decide to remove libftdi 0.20 from the repositories.

@iomode iomode closed this May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant