From 63b4e02fede271f6f17c81494484286a83d98369 Mon Sep 17 00:00:00 2001 From: martinzw <38779698+martinzw@users.noreply.github.com> Date: Mon, 22 Apr 2019 10:18:11 +0200 Subject: [PATCH 1/2] Update uotghs_host.c If you try to read longer messages (>256 bytes) from USB device from host side, the buffer rolls over overwriting the buffer. For DUE/SAM can handle pipes with 1024 bytes, a uint16_t should be used. --- system/libsam/source/uotghs_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libsam/source/uotghs_host.c b/system/libsam/source/uotghs_host.c index e7fe572d..0c37d3fa 100644 --- a/system/libsam/source/uotghs_host.c +++ b/system/libsam/source/uotghs_host.c @@ -360,7 +360,7 @@ void UHD_Pipe_Free(uint32_t ul_pipe) uint32_t UHD_Pipe_Read(uint32_t ul_pipe, uint32_t ul_size, uint8_t* data) { uint8_t *ptr_ep_data = 0; - uint8_t nb_byte_received = 0; + uint16_t nb_byte_received = 0; //otherwise roll over when reading pipe >256 Bytes uint32_t ul_nb_trans = 0; // Get information to read data From 7a44418fcfa96d5614936aefa9b691abc5cd6bbe Mon Sep 17 00:00:00 2001 From: martinzw <38779698+martinzw@users.noreply.github.com> Date: Tue, 23 Apr 2019 17:43:33 +0200 Subject: [PATCH 2/2] Update uotghs_host.c --- system/libsam/source/uotghs_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libsam/source/uotghs_host.c b/system/libsam/source/uotghs_host.c index 0c37d3fa..8c5ee35c 100644 --- a/system/libsam/source/uotghs_host.c +++ b/system/libsam/source/uotghs_host.c @@ -360,7 +360,7 @@ void UHD_Pipe_Free(uint32_t ul_pipe) uint32_t UHD_Pipe_Read(uint32_t ul_pipe, uint32_t ul_size, uint8_t* data) { uint8_t *ptr_ep_data = 0; - uint16_t nb_byte_received = 0; //otherwise roll over when reading pipe >256 Bytes + uint16_t nb_byte_received = 0; //counts bytes received from pipe (max. 1024 on SAM3x8E) uint32_t ul_nb_trans = 0; // Get information to read data