public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1] fastboot: add support for reboot-bootloader command
@ 2015-02-24 11:34 Alexey Firago
  2015-02-24 16:15 ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Firago @ 2015-02-24 11:34 UTC (permalink / raw)
  To: u-boot

The "fastboot reboot-bootloader" command is defined to
re-enter into fastboot mode after rebooting into
bootloader. This command is usually used after updating
bootloader via fastboot.

This commit implements only a generic side of the
command - setting of the reset flag and then resetting.
Setting of the reset flag is implemented using __weak
fb_set_reboot_flag() function. The actual setting and
checking of the reset flag should be implemented by
a boot script and/or board/SoC specific code.

Signed-off-by: Alexey Firago <alexey_firago@mentor.com>

---

 drivers/usb/gadget/f_fastboot.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 310175a..9d898cc 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -122,6 +122,7 @@ static struct usb_gadget_strings *fastboot_strings[] = {
 };
 
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
+static int strcmp_l1(const char *s1, const char *s2);
 
 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
 {
@@ -317,8 +318,20 @@ static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
 	do_reset(NULL, 0, 0, NULL);
 }
 
+int __weak fb_set_reboot_flag(void)
+{
+	return 0;
+}
+
 static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
 {
+	char *cmd = req->buf;
+	if (!strcmp_l1("reboot-bootloader", cmd)) {
+		if (fb_set_reboot_flag()) {
+			fastboot_tx_write_str("FAILCannot set reboot flag");
+			return;
+		}
+	}
 	fastboot_func->in_req->complete = compl_do_reset;
 	fastboot_tx_write_str("OKAY");
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v1] fastboot: add support for reboot-bootloader command
  2015-02-24 11:34 [U-Boot] [PATCH v1] fastboot: add support for reboot-bootloader command Alexey Firago
@ 2015-02-24 16:15 ` Rob Herring
  2015-02-24 17:55   ` Alexey Firago
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2015-02-24 16:15 UTC (permalink / raw)
  To: u-boot

On Tue, Feb 24, 2015 at 5:34 AM, Alexey Firago <alexey_firago@mentor.com> wrote:
> The "fastboot reboot-bootloader" command is defined to
> re-enter into fastboot mode after rebooting into
> bootloader. This command is usually used after updating
> bootloader via fastboot.
>
> This commit implements only a generic side of the
> command - setting of the reset flag and then resetting.
> Setting of the reset flag is implemented using __weak
> fb_set_reboot_flag() function. The actual setting and
> checking of the reset flag should be implemented by
> a boot script and/or board/SoC specific code.
>
> Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
>
> ---
>
>  drivers/usb/gadget/f_fastboot.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
> index 310175a..9d898cc 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -122,6 +122,7 @@ static struct usb_gadget_strings *fastboot_strings[] = {
>  };
>
>  static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
> +static int strcmp_l1(const char *s1, const char *s2);
>
>  static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
>  {
> @@ -317,8 +318,20 @@ static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
>         do_reset(NULL, 0, 0, NULL);
>  }
>
> +int __weak fb_set_reboot_flag(void)
> +{
> +       return 0;

Perhaps the default implementation is not too important, but it does
not cause a reboot into fastboot mode so it should probably return an
error instead.

Rob

> +}
> +
>  static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
>  {
> +       char *cmd = req->buf;
> +       if (!strcmp_l1("reboot-bootloader", cmd)) {
> +               if (fb_set_reboot_flag()) {
> +                       fastboot_tx_write_str("FAILCannot set reboot flag");
> +                       return;
> +               }
> +       }
>         fastboot_func->in_req->complete = compl_do_reset;
>         fastboot_tx_write_str("OKAY");
>  }
> --
> 1.9.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v1] fastboot: add support for reboot-bootloader command
  2015-02-24 16:15 ` Rob Herring
@ 2015-02-24 17:55   ` Alexey Firago
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Firago @ 2015-02-24 17:55 UTC (permalink / raw)
  To: u-boot


On 24.02.2015 19:15, Rob Herring wrote:
> On Tue, Feb 24, 2015 at 5:34 AM, Alexey Firago <alexey_firago@mentor.com> wrote:
>> The "fastboot reboot-bootloader" command is defined to
>> re-enter into fastboot mode after rebooting into
>> bootloader. This command is usually used after updating
>> bootloader via fastboot.
>>
>> This commit implements only a generic side of the
>> command - setting of the reset flag and then resetting.
>> Setting of the reset flag is implemented using __weak
>> fb_set_reboot_flag() function. The actual setting and
>> checking of the reset flag should be implemented by
>> a boot script and/or board/SoC specific code.
>>
>> Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
>>
>> ---
>>
>>   drivers/usb/gadget/f_fastboot.c | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
>> index 310175a..9d898cc 100644
>> --- a/drivers/usb/gadget/f_fastboot.c
>> +++ b/drivers/usb/gadget/f_fastboot.c
>> @@ -122,6 +122,7 @@ static struct usb_gadget_strings *fastboot_strings[] = {
>>   };
>>
>>   static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
>> +static int strcmp_l1(const char *s1, const char *s2);
>>
>>   static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
>>   {
>> @@ -317,8 +318,20 @@ static void compl_do_reset(struct usb_ep *ep, struct usb_request *req)
>>          do_reset(NULL, 0, 0, NULL);
>>   }
>>
>> +int __weak fb_set_reboot_flag(void)
>> +{
>> +       return 0;
> Perhaps the default implementation is not too important, but it does
> not cause a reboot into fastboot mode so it should probably return an
> error instead.
>
> Rob
Sounds reasonable. Resending.

Alexey

>
>> +}
>> +
>>   static void cb_reboot(struct usb_ep *ep, struct usb_request *req)
>>   {
>> +       char *cmd = req->buf;
>> +       if (!strcmp_l1("reboot-bootloader", cmd)) {
>> +               if (fb_set_reboot_flag()) {
>> +                       fastboot_tx_write_str("FAILCannot set reboot flag");
>> +                       return;
>> +               }
>> +       }
>>          fastboot_func->in_req->complete = compl_do_reset;
>>          fastboot_tx_write_str("OKAY");
>>   }
>> --
>> 1.9.1
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot at lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-24 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-24 11:34 [U-Boot] [PATCH v1] fastboot: add support for reboot-bootloader command Alexey Firago
2015-02-24 16:15 ` Rob Herring
2015-02-24 17:55   ` Alexey Firago

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox