Skip to content

Commit 73b8d16

Browse files
committed
Revert "A fix for the SerialUSB buffer overflow bug."
This reverts commit ee2d18e.
1 parent ee2d18e commit 73b8d16

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

cores/arduino/USB/USBCore.cpp

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,32 +120,12 @@ uint32_t USBD_Send(uint32_t ep, const void* d, uint32_t len)
120120
int r = len;
121121
const uint8_t* data = (const uint8_t*)d;
122122

123-
if (!_usbConfiguration)
124-
{
125-
TRACE_CORE(printf("pb conf\n\r");)
123+
if (!_usbConfiguration)
124+
{
125+
TRACE_CORE(printf("pb conf\n\r");)
126126
return -1;
127-
}
128-
129-
size_t i = 0;
130-
// Ensure the chunk size is aligned 4
131-
size_t chunkSize = UDD_IN_CACHE_SIZE -(UDD_IN_CACHE_SIZE % 4);
132-
133-
// Send the full chunks
134-
for (i = 0; i < (len / chunkSize); i++)
135-
{
136-
UDD_Send(ep, data + (i*chunkSize), chunkSize);
137-
138-
/* Clear the transfer complete flag */
139-
udd_clear_IN_transf_cplt(ep);
140-
/* Set the bank as ready */
141-
udd_IN_transfer_allowed(ep);
142-
143-
/* Wait for transfer to complete */
144-
while (!udd_is_IN_transf_cplt(ep)); // need fire exit.
145-
}
146-
147-
// Send the remainder
148-
UDD_Send(ep, data + (i * chunkSize), len % chunkSize);
127+
}
128+
UDD_Send(ep, data, len);
149129

150130
/* Clear the transfer complete flag */
151131
udd_clear_IN_transf_cplt(ep);

cores/arduino/USB/samd21_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ extern "C"{
3434
//#define TRACE_DEVICE(x) x
3535
#define TRACE_DEVICE(x)
3636

37-
__attribute__((__aligned__(4))) /*__attribute__((__section__(".bss_hram0")))*/ uint8_t udd_ep_out_cache_buffer[4][UDD_OUT_CACHE_SIZE];
38-
__attribute__((__aligned__(4))) /*__attribute__((__section__(".bss_hram0")))*/ uint8_t udd_ep_in_cache_buffer[4][UDD_IN_CACHE_SIZE];
37+
__attribute__((__aligned__(4))) /*__attribute__((__section__(".bss_hram0")))*/ uint8_t udd_ep_out_cache_buffer[4][64];
38+
__attribute__((__aligned__(4))) /*__attribute__((__section__(".bss_hram0")))*/ uint8_t udd_ep_in_cache_buffer[4][128];
3939

4040
/**
4141
* USB SRAM data containing pipe descriptor table

cores/arduino/USB/samd21_device.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ extern "C" {
2626
#define EP0 0
2727
#define EPX_SIZE 64// 64 for Full Speed, EPT size max is 1024
2828

29-
#define UDD_OUT_CACHE_SIZE 64
30-
#define UDD_IN_CACHE_SIZE 128
31-
3229
// Force device low speed mode
3330
#define udd_force_low_speed() USB->DEVICE.CTRLB.reg &= ~USB_DEVICE_CTRLB_SPDCONF_Msk; USB->DEVICE.CTRLB.reg |= USB_DEVICE_CTRLB_SPDCONF_1_Val
3431
// Force full speed mode

0 commit comments

Comments
 (0)