The Cypress FX2 is a cheap and very versatile high speed interface for USB 2.0. The program fx2pipe makes it easy to use.
https://www.triplespark.net/elec/periph/USB-FX2/software/fx2pipe.html (https://www.triplespark.net/elec/periph/USB-FX2/software/fx2pipe.html)
The problem is that it was built for libusb-0.1 while nowadays libusb-1.0 is used. Therefore, it doesn't work on a modern OS.
mike@DX79SI /bulk/mike/downloads/fx2pipe-0.8/fx2pipe $ ./fx2pipe -i -0 -8 -ifclk=48o
Firmware config: 0x12 0xe3 0xe0 0x0c 0x12
IO loop running...
Downloading firmware [builtin]...
fx2pipe: wwusb.cc:129: WWUSBDevice::ErrorCode WWUSBDevice::_DoConnect(usb_device*): Assertion `dev_handle_to_dev(udh)==udev' failed.
Aborted
The culprit is in the file wwusb.cc:
// Totally evil and fragile extraction of file descriptor from
// guts of libusb. They don't install usbi.h, which is what we'd need
// to do this nicely.
//
// FIXME if everything breaks someday in the future, look here...
static inline int fd_from_usb_dev_handle(usb_dev_handle *udh)
{
return( *((int*)udh) );
}
// This function is from SSRP: Actually, we don't need it any more.
// Danger, big, fragile KLUDGE. The problem is that we want to be
// able to get from a usb_dev_handle back to a usb_device, and the
// right way to do this is buried in a non-installed include file.
static inline struct usb_device *dev_handle_to_dev(usb_dev_handle *udh)
{
struct usb_dev_handle_kludge {
int fd;
struct usb_bus *bus;
struct usb_device *device;
};
return(((struct usb_dev_handle_kludge *) udh)->device);
}
As seen from https://github.com/libusb/libusb/blob/master/libusb/libusbi.h (https://github.com/libusb/libusb/blob/master/libusb/libusbi.h) the internals of the device handle has changed considerably:
struct libusb_device {
/* lock protects refcnt, everything else is finalized at initialization
* time */
usbi_mutex_t lock;
int refcnt;
struct libusb_context *ctx;
struct libusb_device *parent_dev;
uint8_t bus_number;
uint8_t port_number;
uint8_t device_address;
enum libusb_speed speed;
struct list_head list;
unsigned long session_data;
struct libusb_device_descriptor device_descriptor;
int attached;
};
struct libusb_device_handle {
/* lock protects claimed_interfaces */
usbi_mutex_t lock;
unsigned long claimed_interfaces;
struct list_head list;
struct libusb_device *dev;
int auto_detach_kernel_driver;
};
The problem is that I do not see anything that corresponds to the file descriptor, unless it got renamed or is embedded into another struct. Anyone with libusb programming experience able to help out?
Well, that's how I did it (and posted in the other thread):
LD_LIBRARY_PATH=../libusb-0.1.12/.libs/ ./fx2pipe/fx2pipe -ifclk=48 -8 -n=300000000 -0
No 'make install', no patching :)