From ea4e59d27f681cd7d606f1f6c5a40e88d4b1f65f Mon Sep 17 00:00:00 2001 From: Roman Leonov Date: Thu, 28 Nov 2024 11:57:38 +0100 Subject: [PATCH 1/3] refactor(usbd_control): Updated the buffer name for deeper debug --- src/device/usbd_control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index 80a2a2cc15..d964a75d0d 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -174,7 +174,7 @@ bool usbd_control_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, if (_ctrl_xfer.request.bmRequestType_bit.direction == TUSB_DIR_OUT) { TU_VERIFY(_ctrl_xfer.buffer); memcpy(_ctrl_xfer.buffer, _ctrl_epbuf.buf, xferred_bytes); - TU_LOG_MEM(CFG_TUD_LOG_LEVEL, _usbd_ctrl_buf, xferred_bytes, 2); + TU_LOG_MEM(CFG_TUD_LOG_LEVEL, _ctrl_xfer.buffer, xferred_bytes, 2); } _ctrl_xfer.total_xferred += (uint16_t) xferred_bytes; From eb9539b5b3fb1ccc8ec8f8c5ad5bc288ec7a29c1 Mon Sep 17 00:00:00 2001 From: Roman Leonov Date: Thu, 28 Nov 2024 11:58:20 +0100 Subject: [PATCH 2/3] fix(dcd_dwc2): Reset allocated_epin_count on bus reset and close all ep --- src/portable/synopsys/dwc2/dcd_dwc2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c index b6e7fae2ca..58d9a0f0ed 100644 --- a/src/portable/synopsys/dwc2/dcd_dwc2.c +++ b/src/portable/synopsys/dwc2/dcd_dwc2.c @@ -543,7 +543,7 @@ void dcd_edpt_close_all(uint8_t rhport) { dwc2_regs_t* dwc2 = DWC2_REG(rhport); uint8_t const ep_count = _dwc2_controller[rhport].ep_count; - _dcd_data.allocated_epin_count = 1; + _dcd_data.allocated_epin_count = 0; // Disable non-control interrupt dwc2->daintmsk = (1 << DAINTMSK_OEPM_Pos) | (1 << DAINTMSK_IEPM_Pos); @@ -654,7 +654,7 @@ static void handle_bus_reset(uint8_t rhport) { tu_memclr(xfer_status, sizeof(xfer_status)); _dcd_data.sof_en = false; - _dcd_data.allocated_epin_count = 1; + _dcd_data.allocated_epin_count = 0; // 1. NAK for all OUT endpoints for (uint8_t n = 0; n < ep_count; n++) { From 681b920ab2a59097b52e650c99e38213d38c47f4 Mon Sep 17 00:00:00 2001 From: Roman Leonov Date: Thu, 28 Nov 2024 12:59:13 +0100 Subject: [PATCH 3/3] fix(dcd_dwc2): Correct usage of dwc2_controller --- src/portable/synopsys/dwc2/dcd_dwc2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c index 58d9a0f0ed..29d36f6943 100644 --- a/src/portable/synopsys/dwc2/dcd_dwc2.c +++ b/src/portable/synopsys/dwc2/dcd_dwc2.c @@ -195,8 +195,8 @@ static bool dfifo_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t packet_size) { } } else { // Check IN endpoints concurrently active limit - if(_dwc2_controller->ep_in_count) { - TU_ASSERT(_dcd_data.allocated_epin_count < _dwc2_controller->ep_in_count); + if(dwc2_controller->ep_in_count) { + TU_ASSERT(_dcd_data.allocated_epin_count < dwc2_controller->ep_in_count); _dcd_data.allocated_epin_count++; }