summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-01-08 01:21:03 +0700
committerhathach <[email protected]>2021-01-08 01:21:03 +0700
commit60620dca4286fc9ce9ddf4c2f2e6a39c062a5056 (patch)
treefb2b3b62a16df26449107352153947afadd6968c /src
parent9f0b401f802fa553bd7fc84e76299702d8568b4c (diff)
walkround for samd21 setup_packet overflow
increase setup packet size from 8 to 12, since USB DMA controller is suspected to overflow the buffer with 2 extra bytes
Diffstat (limited to 'src')
-rw-r--r--src/portable/microchip/samd/dcd_samd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/portable/microchip/samd/dcd_samd.c b/src/portable/microchip/samd/dcd_samd.c
index f1dca88a5..35fac23a8 100644
--- a/src/portable/microchip/samd/dcd_samd.c
+++ b/src/portable/microchip/samd/dcd_samd.c
@@ -37,14 +37,20 @@
/* MACRO TYPEDEF CONSTANT ENUM
*------------------------------------------------------------------*/
static TU_ATTR_ALIGNED(4) UsbDeviceDescBank sram_registers[8][2];
-static TU_ATTR_ALIGNED(4) uint8_t _setup_packet[8];
+
+// Setup packet is only 8 bytes in length. However under certain scenario,
+// SAMD21 USB DMA controller is "suspected" to overwrite/overflow the setup_packet with 2 extra bytes.
+// Which corrupt other variable and cause issue such as
+// https://github.com/adafruit/circuitpython/issues/3912 (on macOS)
+// Therefore we increase it to 12 bytes as walk-around until figuring out the root cause
+static TU_ATTR_ALIGNED(4) uint8_t _setup_packet[8+4];
// ready for receiving SETUP packet
static inline void prepare_setup(void)
{
// Only make sure the EP0 OUT buffer is ready
sram_registers[0][0].ADDR.reg = (uint32_t) _setup_packet;
- sram_registers[0][0].PCKSIZE.bit.MULTI_PACKET_SIZE = sizeof(_setup_packet);
+ sram_registers[0][0].PCKSIZE.bit.MULTI_PACKET_SIZE = sizeof(tusb_control_request_t);
sram_registers[0][0].PCKSIZE.bit.BYTE_COUNT = 0;
}