usb-serial-acm: serial ports for CDC ACM devices
usb/serial drives FTDI, Prolific and Silicon Labs chips and the EHCI
debug port. CDC ACM devices (USB CDC 1.2, PSTN 1.2) are not
recognised, so microcontroller boards, USB modems and most firmware
serial consoles get no /dev/eiaU port.
The patch adds sys/src/cmd/usb/serial/acm.c, one port per ACM control
interface, and two usbdb lines so usbd starts the driver. Line
settings, DTR/RTS and break go to the device as PSTN 1.2 defines
them; serial state notifications set the c and e values in eiaUctl
and count line errors. The file is acm.c because usb/ether already
puts a cdc.$O in lib/usbdev.a, the library both programs share.
usb/serial now programs the line and raises DTR and RTS on the
first open of eiaU or eiaUctl, and drops them on the last close, as
uart(3) does. Before, a data-only open sent no line settings, and a
PL2303 passes no data until it gets them. Open also holds the
device lock while it sets the line, as uart(3) does; before, it
could send control requests during a write. This applies to every
chip; FTDI ports have not been tested with the change.
usbd gives a device to one driver only, the first usbdb entry that
matches one of its interfaces. disk comes first, so a board that
also has a mass storage interface (a DAPLink board) keeps its drive
and gets no serial port. This and the other limits are listed in
usb(4) BUGS.
Apply
cd /
ape/patch -p0 < /path/to/usb-serial-acm/usb-serial-acm.diff
Rebuild
cd /sys/src/cmd/usb && mk install
cd /sys/src/9/pc && mk 'CONF=pcf'
9fat:
cp 9pcf /n/9fat/9pcf
fshalt
usbd links every usb driver from lib/usbdev.a, so build all of
/sys/src/cmd/usb; its mkfile builds lib first and usbd last.
usbd is part of the kernel (bootdir in /sys/src/9/pc/pcf), so the
driver takes effect only with the new kernel. Restart the
machine after fshalt: fshalt -r reloads the kernel under /n/boot,
not the one on 9fat. On a cpu server use CONF=pccpuf.
Verification
Plug the device in:
ls /dev/eiaU* # one directory per ACM port
cat /dev/eiaUN/eiaUctl # d1 and r1 while it is open
Tested
386 terminal (pcf kernel), nRF52840 Dongle running Zephyr's
CDC ACM: line settings, DTR/RTS, reads and writes.
|