We can't set readbuffer_chunksize larger than MAX_BULK_BUFFER_LENGTH,
which is defined in libusb-1.0, on Linux. Otherwise, each USB read
request will be divided into multiple (to be exactly, 4) URBs. The
last 3 URBs of these 4 URBs will usually result in abnormal reaps
because we usually request small number of data. The abnormal reaps
will concatenate empty ftdi packets to other packet on Linux kernel
older than 2.6.32. libftdi cannot parse such combined packet. This
will cause issue for UrJTAG when using libftdi-1.0 with libusb-1.0. I
have committed this patch on the libftdi-1.0 git tree.
Jie
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [email protected]
Index: src/ftdi.c
===================================================================
--- src/ftdi.c (revision 3932)
+++ src/ftdi.c (working copy)
@@ -1621,6 +1621,14 @@ int ftdi_read_data_set_chunksize(struct
// Invalidate all remaining data
ftdi->readbuffer_offset = 0;
ftdi->readbuffer_remaining = 0;
+#ifdef __linux__
+ /* We can't set readbuffer_chunksize larger than MAX_BULK_BUFFER_LENGTH,
+ which is defined in libusb-1.0. Otherwise, each USB read request will
+ be divided into multiple URBs. This will cause issues on Linux kernel
+ older than 2.6.32. */
+ if (chunksize > 16384)
+ chunksize = 16384;
+#endif
if ((new_buf = (unsigned char *)realloc(ftdi->readbuffer, chunksize)) == NULL)
ftdi_error_return(-1, "out of memory for readbuffer");