Line stick: Microsoft OS 2.0 descriptors, so Windows binds WinUSB itself

The stick is now USB 2.1 with a BOS descriptor whose Microsoft OS 2.0
platform capability names vendor request 0x4D (LP_REQ_MS_OS_20). Windows
reads the descriptor set with it (device, IN, wIndex 7). The set gives
both interfaces the compatible ID WINUSB and a DeviceInterfaceGUID:
- the line interface gets D-Modem's {0463C853-BB62-4057-9E76-D14B0E3ACAFD},
  the GUID its dmodem-usb.inf uses;
- the reset interface gets the Pico SDK's, so picotool works too.

dmodemd --usb (libusb) and picotool then work on Windows with no INF and
no Zadig.

Checked: the line firmware builds (SDK 2.3.1, TinyUSB 0.21.0), the BOS and
descriptor set parse as expected from the built ELF, host tests and
check_docs pass. Not yet tried on a real Windows host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014mJrc5ZMECC5SzurFsvyAn
This commit is contained in:
Claude committed 2026-10-22 14:44:21 +00:00
1 parent 996421f216
commit 71f76c5e9e
5 files changed
+68 -4

No files matched your search

+3 -1
View File
@@ -14,6 +14,8 @@ running on whatever the stick is plugged into:
- **Linux:** `dmodemd` drives it through libusb, as it drives Smart
Link's SmartUSB56 today (§6). The modem appears as a pty.
- **Windows:** `dmodemd` drives it through libusb on WinUSB, which
Windows binds by itself (Microsoft OS 2.0 descriptors: no INF).
- **Android:** dmodem-android gets a real telephone line beside SIP
(§6.2).
@@ -36,7 +38,7 @@ side.
| L4 | Hook control fast enough for **pulse dialling** (D-Modem times the pulses) and hook flash |
| L5 | **Ring detection** and **caller ID** (the line heard while on hook) |
| L6 | Isolation from the line: ≥ 1500 Vrms, the DAA's capacitive barrier; line surge protection and a telecom fuse |
| L7 | Driverless on Linux and Android: a vendor-class USB interface for libusb (no kernel driver) |
| L7 | Driverless on Linux, Android and Windows: a vendor-class USB interface for libusb (no kernel driver; WinUSB by Microsoft OS 2.0 descriptors) |
| L8 | Firmware update over the same USB-C cable (UF2) |
| L9 | A stick about **82 mm** long (a disposable lighter), RJ11 at one end, USB-C at the other |
| L10 | Every part normally stocked and buyable at qty 1 |
+9
View File
@@ -170,6 +170,14 @@ ST7554, which `dmodemd/usb_line.cpp` drives), so that driver is the model.
- USB `1209:0002` (a pid.codes *test* PID until a real one is assigned),
product "pico-serial Line". No kernel driver claims it: open it with
libusb.
- **Windows** binds WinUSB to both interfaces by itself (no INF, no
Zadig): the stick is USB 2.1 with a BOS descriptor whose Microsoft OS 2.0
platform capability names vendor request `0x4D`. Windows reads the
descriptor set with it (`bmRequestType` `0xC0`, `wIndex` 7). The set gives
each interface the compatible ID `WINUSB` and a `DeviceInterfaceGUID`:
`{0463C853-BB62-4057-9E76-D14B0E3ACAFD}` for the line (D-Modem's, as its
`dmodem-usb.inf` gives it), the Pico SDK's
`{bc7398c1-73cd-4cb7-98b8-913a8fca7bf6}` for the reset interface.
- Interface 0: class `0xFF`, subclass `0x4C`, protocol `0x01`, "pico-serial
Line". (Interface 1 is Raspberry Pi's reset interface, for `picotool`.)
- **Alternate setting 0** has no endpoints. **Alternate setting 1** has:
@@ -221,6 +229,7 @@ bad value stalls.
| `0x21` | DAA_WRITE | OUT | `register << 8 \| value` | a register; register 5 keeps OHE set (the hook stays the pin's) and its ONHM bit sets the monitor |
| `0x30` | RESET | OUT | 0 | the DAA reset and brought up again, on hook (~150 ms) |
| `0x31` | REBOOT_UF2 | OUT | 0 | into the RP2040's UF2 loader, 50 ms after the status stage |
| `0x4D` | MS_OS_20 | IN | 0 | (device, `wIndex` 7) the Microsoft OS 2.0 descriptor set, for Windows |
**Pulse dialling** is the host's: it sends `SET_HOOK` 0 and 1 for each
break and make, as `dmodemd` does with the SmartUSB56's hook GPIO. Each
+1
View File
@@ -227,6 +227,7 @@ softmodem front end. The host's driver sees one vendor interface with an
isochronous pair for the line's samples and an interrupt endpoint for
events, shaped like Smart Link's SmartUSB56 so D-Modem's driver for that is
the model; the protocol is in [PROTOCOL.md](PROTOCOL.md#line-stick-pico-serial-line).
Microsoft OS 2.0 descriptors bind WinUSB to it on Windows, with no INF.
- **Bring-up:** MCLK is the USB PLL's 48 MHz on GPIO21 (no fractional
divider: a clean clock). The Si3056 is reset with M0 = M1 = 0 (serial mode
+1
View File
@@ -33,6 +33,7 @@ enum {
LP_REQ_DAA_WRITE = 0x21, // OUT: wValue = register << 8 | value
LP_REQ_RESET = 0x30, // OUT: the DAA reset and brought up again, on hook
LP_REQ_REBOOT_UF2 = 0x31, // OUT: into the RP2040's UF2 loader
LP_REQ_MS_OS_20 = 0x4D, // IN, wIndex 7: the Microsoft OS 2.0 descriptor set (Windows)
};
// State bits (lp_info_t.state, lp_status_t.state, lp_event_t.state)
+54 -3
View File
@@ -6,8 +6,9 @@
// Link SmartUSB56's (D-Modem's dmodemd drives that one): alternate setting 0
// with no endpoints, alternate setting 1 with an isochronous OUT and IN pair
// for the samples and an interrupt IN for events; plus Raspberry Pi's reset
// interface (picotool). The protocol: firmware/PROTOCOL.md "Line stick",
// line_proto.h.
// interface (picotool). Microsoft OS 2.0 descriptors bind WinUSB to both
// interfaces on Windows, with no INF. The protocol: firmware/PROTOCOL.md
// "Line stick", line_proto.h.
#include <string.h>
#include "tusb.h"
#include "device/usbd_pvt.h"
@@ -33,7 +34,7 @@ enum { STR_LANG, STR_MANUFACTURER, STR_PRODUCT, STR_SERIAL, STR_LINE, STR_RESET
static const tusb_desc_device_t desc_device = {
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200,
.bcdUSB = 0x0210, // 2.1: the BOS descriptor (Microsoft OS 2.0) is there
.bDeviceClass = 0, // each interface says
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
@@ -75,6 +76,50 @@ const uint8_t *tud_descriptor_device_cb(void) { return (const uint8_t *)&desc_de
// TinyUSB, on GET_DESCRIPTOR(CONFIGURATION): the one configuration (index is always 0).
const uint8_t *tud_descriptor_configuration_cb(uint8_t index) { (void)index; return desc_config; }
// Microsoft OS 2.0: the BOS descriptor names the descriptor set and the
// vendor request Windows reads it with (LP_REQ_MS_OS_20, wIndex 7). The set
// binds WinUSB to each interface: the line one with D-Modem's interface GUID
// (as its dmodem-usb.inf gives), the reset one as the Pico SDK does.
#define MS_OS_20_INDEX 7
#define LINE_MS_OS_20_LEN (0x08 + 0x14 + 0x80)
#define MS_OS_20_LEN (0x0A + LINE_MS_OS_20_LEN + RPI_RESET_MS_OS_20_DESC_LEN)
#define BOS_LEN (TUD_BOS_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN)
#define W16(c) (c), 0
static const uint8_t desc_bos[] = {
TUD_BOS_DESCRIPTOR(BOS_LEN, 1),
TUD_BOS_MS_OS_20_DESCRIPTOR(MS_OS_20_LEN, LP_REQ_MS_OS_20),
};
TU_VERIFY_STATIC(sizeof desc_bos == BOS_LEN, "BOS descriptor length");
static const uint8_t desc_ms_os_20[] = {
// set header: length, type, Windows version (8.1), total length
U16_TO_U8S_LE(0x000A), U16_TO_U8S_LE(MS_OS_20_SET_HEADER_DESCRIPTOR), U32_TO_U8S_LE(0x06030000),
U16_TO_U8S_LE(MS_OS_20_LEN),
// the line interface: function subset header (length, type, first interface, reserved, subset length)
U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), ITF_LINE, 0,
U16_TO_U8S_LE(LINE_MS_OS_20_LEN),
// compatible ID WINUSB, no sub-compatible ID
U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
// registry property DeviceInterfaceGUID (REG_SZ, UTF-16): D-Modem's
U16_TO_U8S_LE(0x0080), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), U16_TO_U8S_LE(0x0001), U16_TO_U8S_LE(0x0028),
W16('D'), W16('e'), W16('v'), W16('i'), W16('c'), W16('e'), W16('I'), W16('n'), W16('t'), W16('e'),
W16('r'), W16('f'), W16('a'), W16('c'), W16('e'), W16('G'), W16('U'), W16('I'), W16('D'), W16(0),
U16_TO_U8S_LE(0x004E),
// {0463C853-BB62-4057-9E76-D14B0E3ACAFD}
W16('{'), W16('0'), W16('4'), W16('6'), W16('3'), W16('C'), W16('8'), W16('5'), W16('3'), W16('-'),
W16('B'), W16('B'), W16('6'), W16('2'), W16('-'), W16('4'), W16('0'), W16('5'), W16('7'), W16('-'),
W16('9'), W16('E'), W16('7'), W16('6'), W16('-'), W16('D'), W16('1'), W16('4'), W16('B'), W16('0'),
W16('E'), W16('3'), W16('A'), W16('C'), W16('A'), W16('F'), W16('D'), W16('}'), W16(0),
// the reset interface (picotool), the SDK's
RPI_RESET_MS_OS_20_DESCRIPTOR(ITF_RESET),
};
TU_VERIFY_STATIC(sizeof desc_ms_os_20 == MS_OS_20_LEN, "MS OS 2.0 descriptor set length");
// TinyUSB, on GET_DESCRIPTOR(BOS): the BOS descriptor above.
const uint8_t *tud_descriptor_bos_cb(void) { return desc_bos; }
static uint16_t desc_str[33];
// TinyUSB, on GET_DESCRIPTOR(STRING): string `index` as a USB string
@@ -228,9 +273,15 @@ static bool ld_control_xfer_cb(uint8_t rhport, uint8_t stage, const tusb_control
// TinyUSB hands vendor requests to the device (not an interface) here: the
// same requests, as the SmartUSB56's driver sends them.
// Windows' request for the Microsoft OS 2.0 descriptor set comes here too.
bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, const tusb_control_request_t *r) {
if (r->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE) return ld_control_xfer_cb(rhport, stage, r);
if (r->bmRequestType_bit.recipient != TUSB_REQ_RCPT_DEVICE) return false;
if (r->bRequest == LP_REQ_MS_OS_20 && r->wIndex == MS_OS_20_INDEX &&
r->bmRequestType_bit.direction == TUSB_DIR_IN) {
if (stage != CONTROL_STAGE_SETUP) return true;
return tud_control_xfer(rhport, r, (void *)(uintptr_t)desc_ms_os_20, sizeof desc_ms_os_20);
}
return vendor_request(rhport, stage, r);
}