diff options
author | Haoran Wang <elven.wang@nxp.com> | 2017-10-31 00:48:45 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-10-31 00:48:45 +0000 |
commit | ba4e70ab4ecbd02c5806359af58da0de3133ab1e (patch) | |
tree | 4ef5383f838808d43221181e47c32357b7ec4ef9 | |
parent | c12d1d24fe46e781f6415902c4c6ff96b169d07e (diff) | |
parent | 894d37a2a16db54467cc3257a511cfdd4679d39a (diff) | |
download | uboot-imx-ba4e70ab4ecbd02c5806359af58da0de3133ab1e.tar.gz |
[iot] fastboot:Add 'get_staged' command support
am: 894d37a2a1
Change-Id: Ia01f73b8526cb3365313c51a8a8952a42bf98abb
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index c4dab3878d..ddd9cc9d39 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -2756,6 +2756,15 @@ static int fastboot_set_alt(struct usb_function *f, ret = -EINVAL; goto err; } +#ifdef CONFIG_ANDROID_THINGS_SUPPORT + /* + * fastboot host end implement to get data in one bulk package so need + * large buffer for the "fastboot upload" and "fastboot get_staged". + */ + if (f_fb->in_req->buf) + free(f_fb->in_req->buf); + f_fb->in_req->buf = memalign(CONFIG_SYS_CACHELINE_SIZE, EP_BUFFER_SIZE * 32); +#endif f_fb->in_req->complete = fastboot_complete; ret = usb_ep_queue(f_fb->out_ep, f_fb->out_req, 0); @@ -3281,6 +3290,25 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req) usb_ep_queue(ep, req, 0); } +static void cb_upload(struct usb_ep *ep, struct usb_request *req) +{ + char response[FASTBOOT_RESPONSE_LEN]; + + if (!download_bytes || download_bytes > (EP_BUFFER_SIZE * 32)) { + sprintf(response, "FAIL"); + fastboot_tx_write_str(response); + return; + } + + printf("Will upload %d bytes.\n", download_bytes); + snprintf(response, FASTBOOT_RESPONSE_LEN, "DATA%08x", download_bytes); + fastboot_tx_write_str(response); + + fastboot_tx_write((const char *)(interface.transfer_buffer), download_bytes); + + snprintf(response,FASTBOOT_RESPONSE_LEN, "OKAY"); + fastboot_tx_write_str(response); +} static void cb_download(struct usb_ep *ep, struct usb_request *req) { char *cmd = req->buf; @@ -3640,6 +3668,9 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { .cmd = "getvar:", .cb = cb_getvar, }, { + .cmd = "upload", + .cb = cb_upload, + }, { .cmd = "download:", .cb = cb_download, }, { |