From 595e619093db9345a3807341d4877cf0459e149b Mon Sep 17 00:00:00 2001 From: Mikaela Szekely Date: Mon, 23 Sep 2019 14:36:04 -0600 Subject: [PATCH] firmware: fix ZLPs for USB0 EP0 This fixes 64-byte-aligned USB0 commands, which were broken due to a Linux spec violation. See https://github.com/greatscottgadgets/greatfet/issues/283 for more details. --- firmware/platform/lpc43xx/drivers/usb/usb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/firmware/platform/lpc43xx/drivers/usb/usb.c b/firmware/platform/lpc43xx/drivers/usb/usb.c index 29c322d..08eee8a 100644 --- a/firmware/platform/lpc43xx/drivers/usb/usb.c +++ b/firmware/platform/lpc43xx/drivers/usb/usb.c @@ -840,6 +840,11 @@ void usb_endpoint_init_without_descriptor( { bool zero_length_terminate = (transfer_type == USB_TRANSFER_TYPE_CONTROL) && !manual_zlps; + // IN EP0 needs non-automatic-ZLPs to work around a Linux spec violation. + if (endpoint->address == 0) { + zero_length_terminate = false; + } + usb_endpoint_flush(endpoint); // TODO: There are more capabilities to adjust based on the endpoint