Skip to content

Commit

Permalink
Limit transfer size only on Linux
Browse files Browse the repository at this point in the history
And it is limited in libusb and not necessarily linked to the
memory page size any longer.

https://sourceforge.net/p/dfu-util/tickets/102/

Signed-off-by: Tormod Volden <[email protected]>
  • Loading branch information
tormodvolden committed Jan 5, 2021
1 parent f56aaa0 commit 6c9fa24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_MEMCMP
AC_CHECK_FUNCS([getpagesize nanosleep err])
AC_CHECK_FUNCS([nanosleep err])

# Checks how to do large files
AC_SYS_LARGEFILE
Expand Down
13 changes: 5 additions & 8 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,16 +661,13 @@ int main(int argc, char **argv)
errx(EX_USAGE, "Transfer size must be specified");
}

#ifdef HAVE_GETPAGESIZE
/* autotools lie when cross-compiling for Windows using mingw32/64 */
#ifndef __MINGW32__
/* limitation of Linux usbdevio */
if ((int)transfer_size > getpagesize()) {
transfer_size = getpagesize();
#ifdef __linux__
/* limited to 4k in libusb Linux backend */
if ((int)transfer_size > 4096) {
transfer_size = 4096;
printf("Limited transfer size to %i\n", transfer_size);
}
#endif /* __MINGW32__ */
#endif /* HAVE_GETPAGESIZE */
#endif /* __linux__ */

if (transfer_size < dfu_root->bMaxPacketSize0) {
transfer_size = dfu_root->bMaxPacketSize0;
Expand Down

0 comments on commit 6c9fa24

Please sign in to comment.