Re: [PATCH v2] usb: serial: Repair FTDI FT232R bricked eeprom

From: James Hilliard
Date: Thu Sep 10 2020 - 14:53:40 EST


On Thu, Sep 10, 2020 at 3:57 AM Hector Martin <hector@xxxxxxxxxxxxxx> wrote:
>
> On 10/09/2020 18.52, James Hilliard wrote:
> > So I'm having trouble coming up with a reliable way to fix this in userspace,
> > I've already got quite a few moving parts there as is and most of what I
> > come up with seems like it would not work reliably, at least for automatically
> > repairing the eeprom.
>
> I'm confused as to why this is hard to fix in userspace. You already
> said you have userspace code binding to the proper VID/PID, so your code
> won't find the bricked device. Then it's just a matter of having a udev
> rule run the unbricker when it detects the bad device (which should
> issue a USB reset when it's done reprogramming, making the device appear
> as the right VID/PID), thus effectively doing the same thing the kernel
> does. If this is embedded and not using udev, then substitute whatever
> equivalent you have. If you're polling for the device at runtime instead
> and don't have a device manager, just poll for the VID 0 device too and
> apply the fix.
Wouldn't you have to do a bunch of stuff like unbind the ftdi_sio driver before
you can issue usb control commands from userspace?

I haven't tested this yet but my assumption was that either a kernel driver
or libusb can issue usb control messages, but both can not be bound to
a device at the same time. I figured this wouldn't have come up when you
tested your python script since the script likely predated adding the brick PID
to the ftdi_sio Linux kernel driver.

Maybe it makes sense to add a sysfs interface for reading/writing eeprom values
without having to unbind the ftdi_sio driver.
>
> I can't think of a scenario where this would be difficult to fix in
> userspace...
>
> --
> Hector Martin (hector@xxxxxxxxxxxxxx)
> Public Key: https://mrcn.st/pub