summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2022-10-24 18:43:21 +0700
committerhathach <[email protected]>2022-10-24 18:43:21 +0700
commite3b7ed9ae966be1cb41165343ef30c6523ed5771 (patch)
tree17ebbf666c515f4d369bec14d2bfc87994e9566b /src
parent35e1a27c950c4b25106c074d0b66220d099e54a7 (diff)
use dummy for all ZLP for ip3511, fix lpc55 build with DEBUG=1
Diffstat (limited to 'src')
-rw-r--r--src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
index 7825d287f..9b490c48c 100644
--- a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+++ b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
@@ -178,7 +178,9 @@ typedef struct
// For example: LPC55s69 port1 Highspeed must be USB_RAM (0x40100000)
// Use CFG_TUSB_MEM_SECTION to place it accordingly.
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(256) static dcd_data_t _dcd;
-CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(256) static volatile uint8_t dummy[8] = { 0 }; // a fix for EP0 OUT ZLPs overwriting the buffer
+
+// Dummy buffer to fix ZLPs overwriting the buffer (probably an USB/DMA controller bug)
+CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(64) static uint8_t dummy[8];
//--------------------------------------------------------------------+
// Multiple Controllers
@@ -405,10 +407,14 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t to
tu_memclr(&_dcd.dma[ep_id], sizeof(xfer_dma_t));
_dcd.dma[ep_id].total_bytes = total_bytes;
- if (!buffer && !ep_id) // for EP0 OUT ZLPs to prevent overwrites to buffer
+ if (!buffer)
{
+ // Although having no data, ZLPs can cause buffer overwritten to zeroes.
+ // Probably due to USB/DMA controller side effect/bug.
+ // Assigned buffer offset to (valid) dummy to prevent overwriting to DATABUFSTART
buffer = (uint8_t*)(uint32_t)dummy;
}
+
prepare_ep_xfer(rhport, ep_id, get_buf_offset(buffer), total_bytes);
return true;