public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Steve Rae <srae@broadcom.com>
To: u-boot@lists.denx.de
Subject: [U-Boot]  question about "drivers/usb/gadget/f_fastboot.c"
Date: Wed, 27 Jan 2016 11:49:13 -0800	[thread overview]
Message-ID: <56A91F39.7010500@broadcom.com> (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

                 reply	other threads:[~2016-01-27 19:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56A91F39.7010500@broadcom.com \
    --to=srae@broadcom.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox