From 34a13723d86cdf4f75182d751149445f24bfa07f Mon Sep 17 00:00:00 2001 From: Stoyan Shopov Date: Tue, 2 Jun 2020 21:27:13 +0300 Subject: [PATCH] Decrease the control USB pipe size on f103 blackmagic probes to 8 bytes Rationale: In USB device mode, the f103 chip provides 512 bytes of memory for USB traffic. In the 'master' branch of the blackmagic probe, the control endpoint pipe size is set to 64 bytes, effectively consuming a quarter (1 'in' endpoint, 1 'out' endpoint == 2 endpoints, 2 /* endpoints */ x 64 /* bytes per endpoint */ == 128 bytes out of 512 /* bytes of precious usb packet memory */). The USB standard, for full speed devices, does allow a control endpoint size of 8 bytes. I am not too aware of all the details of the USB standard, but the USB standard seems to allow fragmented transactions on the control USB pipe (endpoint 0), which libopencm3 apparently supports: libopencm3/lib/usb/usb_control.c:usb_control_send_chunk() I am using this change (from 64, to 8 bytes) on a windows 10 machine, on an stlink hardware ('PROBE_HOST=stlink'). It works on my machine. This change can potentially provide other USB endpoints in the blackmagic firmware with more memory --- src/platforms/common/cdcacm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/common/cdcacm.c b/src/platforms/common/cdcacm.c index a063d31a..f3df8fc9 100644 --- a/src/platforms/common/cdcacm.c +++ b/src/platforms/common/cdcacm.c @@ -58,7 +58,7 @@ static const struct usb_device_descriptor dev = { .bDeviceClass = 0xEF, /* Miscellaneous Device */ .bDeviceSubClass = 2, /* Common Class */ .bDeviceProtocol = 1, /* Interface Association */ - .bMaxPacketSize0 = 64, + .bMaxPacketSize0 = 8, .idVendor = 0x1D50, .idProduct = 0x6018, .bcdDevice = 0x0100,