From 050b9dde68751940b13dd8f631bf7164b6cadaf5 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 16 Jan 2020 23:20:48 +0100 Subject: HACK: Solve weird problem with lost OUT transfer on ping-pong endpoint This adds an unconditional endpoint reset procedure to every SET_FEATURE(UnHalt). It doesn't really make sense that this is required, *particularly* as we *MUST NOT* set bEndpoint->bank to 0 here. Without this patch, I'm observing the following problem: Every first OUT transfer after a SET_INTERFACE + UNHALT on a bulk endpoint is lost. "lost" means that it completes successfully on the host, can be seen completing successfully with an ACK on a USB bus analyzer, but still doesn't show up in the firmware. No Endpoint Interrupt is generated. This can be reproduced by calling libusb_set_interface_alt_setting() from the host and then submitting a single OUT transfer. Change-Id: I18ed530e617baddf76e8f9829512443ce2a76e0d --- firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c index 1ebab5b..e6edda6 100644 --- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c +++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c @@ -1672,6 +1672,10 @@ uint8_t USBD_HAL_Halt(uint8_t bEndpoint, uint8_t ctl) UDP->UDP_RST_EP |= 1 << bEndpoint; UDP->UDP_RST_EP &= ~(1 << bEndpoint); } + + /* This fixes a weird bug with regard to ping-pong OUT endpoints */ + UDP->UDP_RST_EP |= 1 << bEndpoint; + UDP->UDP_RST_EP &= ~(1 << bEndpoint); } /* Return Halt status */ -- cgit v1.2.3