Skip to contentSkip to conversation

question about "drivers/usb/gadget/f_fastboot.c"

U-Boot Steve Rae 1 participant 1 message Jan 27, 2016

lore
Share & tools
lore

Steve Rae

author
#0 lore raw

Please explain the following logic in "drivers/usb/gadget/f_fastboot.c":

422) static unsigned int rx_bytes_expected(unsigned int maxpacket)
423) {

424)      int rx_remain = download_size - download_bytes;
425)      int rem = 0;
426)      if (rx_remain < 0)

427) return 0;
428) if (rx_remain > EP_BUFFER_SIZE)
429) return EP_BUFFER_SIZE;
430) if (rx_remain < maxpacket) {
431) rx_remain = maxpacket;
432) } else if (rx_remain % maxpacket != 0) {
433) rem = rx_remain % maxpacket;
434) rx_remain = rx_remain + (maxpacket - rem);
435) }
436) return rx_remain;
437) }

In my case,
- rx_remain is 616
- maxpacket is 512
therefore, it hits line 434, where rx_remain is adjusted to 1024

But then the fastboot download phase just sits and waits forever, because the host can only send 616 bytes, and we are waiting for 1024 bytes!

I don't understand why we are expecting MORE bytes than the host can send during the download phase.... And I don't understand the need to align to a multiple of "maxpacket" during the download phase....

BTW, if I delete lines 430 through 435, then it works properly!

Thanks, Steve