Skip to content

Commit e3b7ed9

Browse files
committed
use dummy for all ZLP for ip3511, fix lpc55 build with DEBUG=1
1 parent 35e1a27 commit e3b7ed9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

hw/bsp/lpc55/family.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SRC_C += \
4343
$(MCU_DIR)/drivers/fsl_power.c \
4444
$(MCU_DIR)/drivers/fsl_reset.c \
4545
$(SDK_DIR)/drivers/lpc_gpio/fsl_gpio.c \
46+
$(SDK_DIR)/drivers/common/fsl_common_arm.c \
4647
$(SDK_DIR)/drivers/flexcomm/fsl_flexcomm.c \
4748
$(SDK_DIR)/drivers/flexcomm/fsl_usart.c \
4849
lib/sct_neopixel/sct_neopixel.c

src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ typedef struct
178178
// For example: LPC55s69 port1 Highspeed must be USB_RAM (0x40100000)
179179
// Use CFG_TUSB_MEM_SECTION to place it accordingly.
180180
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(256) static dcd_data_t _dcd;
181-
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(256) static volatile uint8_t dummy[8] = { 0 }; // a fix for EP0 OUT ZLPs overwriting the buffer
181+
182+
// Dummy buffer to fix ZLPs overwriting the buffer (probably an USB/DMA controller bug)
183+
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(64) static uint8_t dummy[8];
182184

183185
//--------------------------------------------------------------------+
184186
// Multiple Controllers
@@ -405,10 +407,14 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t to
405407
tu_memclr(&_dcd.dma[ep_id], sizeof(xfer_dma_t));
406408
_dcd.dma[ep_id].total_bytes = total_bytes;
407409

408-
if (!buffer && !ep_id) // for EP0 OUT ZLPs to prevent overwrites to buffer
410+
if (!buffer)
409411
{
412+
// Although having no data, ZLPs can cause buffer overwritten to zeroes.
413+
// Probably due to USB/DMA controller side effect/bug.
414+
// Assigned buffer offset to (valid) dummy to prevent overwriting to DATABUFSTART
410415
buffer = (uint8_t*)(uint32_t)dummy;
411416
}
417+
412418
prepare_ep_xfer(rhport, ep_id, get_buf_offset(buffer), total_bytes);
413419

414420
return true;

0 commit comments

Comments
 (0)