From 112b7fec537b85121e9ba530070d2e1642bc556b Mon Sep 17 00:00:00 2001 From: Michael Loukeris Date: Wed, 14 Oct 2026 01:51:34 +0300 Subject: [PATCH] LPC11Uxx USB: fix OUT endpoint stall and endpoint count A finished OUT transfer left the endpoint stalled until the next receive started. Back-to-back OUT packets then failed on the host. Leave the endpoint inactive so it NAKs. USB_MAX_ENDPOINTS was 5, which counts EP0. The LPC11Uxx has four endpoints besides EP0. A fifth one wrote past epn_buffer and the endpoint list. --- os/hal/ports/LPC/LLD/USB/hal_usb_lld.c | 4 ---- os/hal/ports/LPC/LLD/USB/hal_usb_lld.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/os/hal/ports/LPC/LLD/USB/hal_usb_lld.c b/os/hal/ports/LPC/LLD/USB/hal_usb_lld.c index aeb38a4736..18177dad04 100644 --- a/os/hal/ports/LPC/LLD/USB/hal_usb_lld.c +++ b/os/hal/ports/LPC/LLD/USB/hal_usb_lld.c @@ -161,10 +161,6 @@ static size_t usb_packet_receive(USBDriver *usbp, usbep_t ep) { // ReSetup for recieve USB_EPLIST->entry[4 * ep] |= EPLIST_ENTRY_NBYTES(epcp->out_maxsize) | EPLIST_ADDR(usbp->epn_buffer[ep * 2]) | EPLIST_ENTRY_ACTIVE; - } else { - if (ep != 0) { - USB_EPLIST->entry[4 * ep] |= EPLIST_ENTRY_STALL; - } } return n; diff --git a/os/hal/ports/LPC/LLD/USB/hal_usb_lld.h b/os/hal/ports/LPC/LLD/USB/hal_usb_lld.h index 4cc3ee7792..978689db83 100644 --- a/os/hal/ports/LPC/LLD/USB/hal_usb_lld.h +++ b/os/hal/ports/LPC/LLD/USB/hal_usb_lld.h @@ -34,7 +34,7 @@ /** * @brief Maximum endpoint address. */ -#define USB_MAX_ENDPOINTS 5 +#define USB_MAX_ENDPOINTS 4 /** * @brief Status stage handling method.