From: "Hector Martin \"marcan\"" <hector@marcansoft.com>
To: James Hilliard <james.hilliard1@gmail.com>,
Oliver Neukum <oneukum@suse.de>
Cc: linux-usb@vger.kernel.org, Johan Hovold <johan@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Russ Dill <Russ.Dill@gmail.com>
Subject: Re: [PATCH v2] usb: serial: Repair FTDI FT232R bricked eeprom
Date: Thu, 10 Sep 2020 12:46:57 +0900 [thread overview]
Message-ID: <36F0CEB4-DE2E-41DA-9569-4706B00FCF7D@marcansoft.com> (raw)
In-Reply-To: <CADvTj4oznyY=sfbmtmdcYMgkYriV_Ujk=+0Fz--XumNa8ZvD=A@mail.gmail.com>
On September 10, 2020 12:40:59 PM GMT+09:00, James Hilliard <james.hilliard1@gmail.com> wrote:
>On Wed, Sep 9, 2020 at 9:02 PM Oliver Neukum <oneukum@suse.de> wrote:
>>
>> Am Mittwoch, den 09.09.2020, 13:34 -0600 schrieb James Hilliard:
>> > This patch detects and reverses the effects of the malicious FTDI
>> > Windows driver version 2.12.00(FTDIgate).
>>
>> Hi,
>>
>> this raises questions.
>> Should we do this unconditionally without asking?
>Well I think since we can reliably detect devices that have been
>bricked by the malicious windows driver it's fine. I was careful to
>ensure that this will bail out and not try to change anything unless
>all
>conditions match this specific brick attack.
>> Does this belong into kernel space?
>This seemed to be by far the simplest option for embedded systems
>that need to automatically detect and repair the bricked eeproms.
>
>People seem to have plugged a bunch of counterfeit FTDI Arduino's
>that normally attach to an embedded Linux host into windows for
>some reason for a kiosk platform of mine which messed up the
>userspace detection/mappings. This seemed like the best way to
>avoid this being a support issue requiring manual unbricking
>prochedures.
If you need to update the kernel on this platform anyway to use this feature, why not just introduce a userspace script to fix the bricked units instead?
Needing this autofixed seems like somewhat of a niche use case better served by a script on platforms where it might be a problem, rather than upstream kernel code.
>>
>> > +static int ftdi_repair_brick(struct usb_serial_port *port)
>> > +{
>> > + struct ftdi_private *priv = usb_get_serial_port_data(port);
>> > + int orig_latency;
>> > + int rv;
>> > + u16 *eeprom_data;
>> > + u16 checksum;
>> > + int eeprom_size;
>> > + int result;
>> > +
>> > + switch (priv->chip_type) {
>> > + case FT232RL:
>> > + eeprom_size = 0x40;
>> > + break;
>> > + default:
>> > + /* Unsupported for brick repair */
>> > + return 0;
>> > + }
>> > +
>> > + /* Latency timer needs to be 0x77 to unlock EEPROM
>programming */
>> > + if (priv->latency != 0x77) {
>> > + orig_latency = priv->latency;
>> > + priv->latency = 0x77;
>> > + rv = write_latency_timer(port);
>> > + priv->latency = orig_latency;
>> > + if (rv < 0)
>> > + return -EIO;
>> > + }
>>
>> Do you really want to change this without returning to the original?
>> @@ -2255,6 +2364,12 @@ static int ftdi_sio_port_probe(struct
>usb_serial_port *port)
>> ftdi_set_max_packet_size(port);
>> if (read_latency_timer(port) < 0)
>> priv->latency = 16;
>> + vendor_id =
>le16_to_cpu(port->serial->dev->descriptor.idVendor);
>> + product_id =
>le16_to_cpu(port->serial->dev->descriptor.idProduct);
>> + if (vendor_id == FTDI_VID &&
>> + product_id == FTDI_BRICK_PID &&
>> + priv->chip_type == FT232RL)
>> + ftdi_repair_brick(port);
>> write_latency_timer(port);
>It should get restored here.
>> create_sysfs_attrs(port);
>>
>>
>> Regards
>> Oliver
>>
--
Hector Martin "marcan" (hector@marcansoft.com)
Public key: https://mrcn.st/pub
next prev parent reply other threads:[~2020-09-10 3:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 19:34 [PATCH v2] usb: serial: Repair FTDI FT232R bricked eeprom James Hilliard
2020-09-10 3:02 ` Oliver Neukum
2020-09-10 3:17 ` Hector Martin "marcan"
2020-09-10 3:46 ` James Hilliard
2020-09-10 3:49 ` Hector Martin "marcan"
2020-09-10 4:39 ` James Hilliard
2020-09-10 3:40 ` James Hilliard
2020-09-10 3:46 ` Hector Martin "marcan" [this message]
2020-09-10 4:07 ` James Hilliard
2020-09-10 5:33 ` Lars Melin
2020-09-10 6:48 ` James Hilliard
2020-09-10 8:01 ` James Hilliard
2020-09-10 8:08 ` Johan Hovold
2020-09-10 8:17 ` James Hilliard
2020-09-10 8:55 ` Greg Kroah-Hartman
2020-09-10 9:52 ` James Hilliard
2020-09-10 9:57 ` Hector Martin
2020-09-10 18:51 ` James Hilliard
2020-09-10 19:54 ` Hector Martin
2020-09-11 6:09 ` Greg Kroah-Hartman
2020-09-10 5:49 ` Greg Kroah-Hartman
2020-09-10 6:45 ` James Hilliard
2020-09-10 8:10 ` Hector Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=36F0CEB4-DE2E-41DA-9569-4706B00FCF7D@marcansoft.com \
--to=hector@marcansoft.com \
--cc=Russ.Dill@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.hilliard1@gmail.com \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).