Plan 9 from Bell Labs’s /usr/web/sources/contrib/mospak/usb-serial-prolific-maxpkt/README

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


usb-serial-prolific-maxpkt: one write over 64 bytes stops a PL2303 port

sys/src/cmd/usb/serial/prolific.c sets the maximum packet size of
both bulk endpoints to 256:

    devctl(p->epin,  "maxpkt 256");
    devctl(p->epout, "maxpkt 256");

The PL2303 is a full-speed device, and a full-speed bulk endpoint
carries at most 64 bytes per packet (USB 2.0 section 5.8.3).  The
host controller driver cuts each write into packets of maxpkt
bytes, so a write of 65 bytes or more goes out as one packet the
chip cannot take.  That write is lost, and so is every later one
until the device is unplugged.

The fix removes plseteps.  The endpoints keep the packet size from
their descriptors, which openep in lib/dev.c already sets; silabs.c
works the same way.

Apply
    cd /
    ape/patch -p0 < /path/to/usb-serial-prolific-maxpkt/usb-serial-prolific-maxpkt.diff

Rebuild
    cd /sys/src/cmd/usb && mk install

    usbd links the serial driver from lib/usbdev.a and is part of
    the kernel (bootdir), so rebuild and install the kernel as well
    if usbd starts usb/serial for any device.

Verification
    Join the adapter's TX and RX.  usbd has no Prolific entry in
    usbdb, so start the driver by hand:

    usb/serial
    grep bulk /dev/usb/ctl		# maxpkt of the PL2303 endpoints
    echo b9600 >/dev/eiaUN/eiaUctl
    cat /dev/eiaUN/eiaU &
    echo <a line of 70 characters> >/dev/eiaUN/eiaU
    echo short >/dev/eiaUN/eiaU

    Before: maxpkt 256, and neither line comes back.
    After: maxpkt 64, and both do.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.