From patchwork Thu Mar 5 11:29:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: afirago X-Patchwork-Id: 446678 X-Patchwork-Delegate: l.majewski@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id C961E140140 for ; Thu, 5 Mar 2015 22:29:39 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 436004B60B; Thu, 5 Mar 2015 12:29:34 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RaI7V09pRhu2; Thu, 5 Mar 2015 12:29:34 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9001C4B5D2; Thu, 5 Mar 2015 12:29:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AE6024B5D2 for ; Thu, 5 Mar 2015 12:29:29 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iQR0LbVjKEdi for ; Thu, 5 Mar 2015 12:29:29 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from relay1.mentorg.com (relay1.mentorg.com [192.94.38.131]) by theia.denx.de (Postfix) with ESMTP id 1D14C4B5CD for ; Thu, 5 Mar 2015 12:29:25 +0100 (CET) Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-04.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YTTxw-0003aG-HB from Alexey_Firago@mentor.com ; Thu, 05 Mar 2015 03:29:21 -0800 Received: from [137.202.142.56] (137.202.0.76) by SVR-IES-FEM-04.mgc.mentorg.com (137.202.0.110) with Microsoft SMTP Server id 14.3.224.2; Thu, 5 Mar 2015 11:29:19 +0000 Message-ID: <54F83E15.3050702@mentor.com> Date: Thu, 5 Mar 2015 14:29:25 +0300 From: Alexey Firago User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Lukasz Majewski References: <1424873447-22426-1-git-send-email-alexey_firago@mentor.com> <20150226112230.78fe4b1e@amdc2363> <54F81EA5.9080800@mentor.com> <20150305110447.00b09c2a@amdc2363> In-Reply-To: <20150305110447.00b09c2a@amdc2363> X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: Steve Rae , U-Boot Mailing List , Marek Vasut , Rob Herring Subject: Re: [U-Boot] [PATCH v3] fastboot: add support for reboot-bootloader command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Lukasz, Here is how I've tested "v3 fastboot: add support for reboot-bootloader command" patch: * Applied it to master ( 7ae8350f67eea861280a4cbd2d067777a0e87153) * Board to test - Nitrogen6q * Applied attached "0001-test-nitrogen6x-fastboot-add-reboot-bootloader-suppo.patch" with the board specific flags handling functions and envs * On "fastboot reboot-bootloader" command, nitrogen6x specific fb_set_reboot_flag() is called, setting bit in the SNVS_LPGPR register (as in Freescale's releases) * On reboot board checks this bit in board's misc_init_r() and sets "fastboot_flag" env accordingly * bootscript handles "fastboot_flag" Let me know if I've missed something. Regards, Alexey On 05.03.2015 13:04, Lukasz Majewski wrote: > Hi Alexey, > >> Hi Lukasz, >> >> Hmm, I don't see it applied to u-boot-dfu now. Do I need to add >> something ? > If possible, please look into the current status of fastboot support in > u-boot mainline (since we are at -rc3). > > Since I'm not (yet) a fastboot user, please support me with testing. > > Best regards, > Lukasz > >> Thanks, >> Alexey >> >> On 26.02.2015 13:22, Lukasz Majewski wrote: >>> Hi Alexey, >>> >>>> 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 >>>> --- >>>> >>>> Changes in v3: >>>> - return -ENOSYS from default fb_set_reboot_flag() >>>> >>>> Changes in v2: >>>> - return error in default fb_set_reboot_flag() >>>> >>>> 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..a000c25 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 -ENOSYS; >>>> +} >>>> + >>>> 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"); >>>> } >>> Applied to u-boot-dfu. >>> >>> Thanks for patch! >>> > > From 260bfb6fa20c977982797af696f44fe174e28115 Mon Sep 17 00:00:00 2001 From: Alexey Firago Date: Thu, 5 Mar 2015 13:59:34 +0300 Subject: [PATCH] test: nitrogen6x: fastboot: add reboot-bootloader support Signed-off-by: Alexey Firago --- board/boundary/nitrogen6x/nitrogen6x.c | 37 ++++++++++++++++++++++++++++++++++ include/configs/nitrogen6x.h | 11 +++++++--- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c index e8ea256..cc5417c 100644 --- a/board/boundary/nitrogen6x/nitrogen6x.c +++ b/board/boundary/nitrogen6x/nitrogen6x.c @@ -1009,6 +1009,36 @@ static const struct boot_mode board_boot_modes[] = { }; #endif +#ifdef CONFIG_CMD_FASTBOOT +#define SNVS_LPGPR 0x68 +#define ANDROID_FASTBOOT_FLAG (1 << 8) + +int fb_set_reboot_flag(void) +{ + u32 reg; + reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR); + reg |= ANDROID_FASTBOOT_FLAG; + writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR); + return 0; +} + +static int fb_check_and_clean_flag(void) +{ + int flag_set = 0; + u32 reg; + + reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR); + flag_set = !!(reg & ANDROID_FASTBOOT_FLAG); + + /* clean it in case looping infinite here.... */ + if (flag_set) { + reg &= ~ANDROID_FASTBOOT_FLAG; + writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR); + } + return flag_set; +} +#endif + int misc_init_r(void) { #ifdef CONFIG_PREBOOT @@ -1018,5 +1048,12 @@ int misc_init_r(void) #ifdef CONFIG_CMD_BMODE add_board_boot_modes(board_boot_modes); #endif + +#ifdef CONFIG_CMD_FASTBOOT + if (fb_check_and_clean_flag()) + setenv("fastboot_flag", "1"); + else + setenv("fastboot_flag", "0"); +#endif return 0; } diff --git a/include/configs/nitrogen6x.h b/include/configs/nitrogen6x.h index 6d379ed..c2d726b 100644 --- a/include/configs/nitrogen6x.h +++ b/include/configs/nitrogen6x.h @@ -268,10 +268,15 @@ "bootdevs=" CONFIG_DRIVE_TYPES "\0" \ "umsdevs=" CONFIG_UMSDEVS "\0" \ "console=ttymxc1\0" \ + "fastboot_flag=0\0" \ "clearenv=if sf probe || sf probe || sf probe 1 ; then " \ "sf erase 0xc0000 0x2000 && " \ "echo restored environment to factory default ; fi\0" \ - "bootcmd=for dtype in ${bootdevs}" \ + "bootcmd="\ + "if test '1' -eq $fastboot_flag; then " \ + "echo 'Entering fastboot'; fastboot; " \ + "fi; " \ + "for dtype in ${bootdevs}" \ "; do " \ "if itest.s \"xusb\" == \"x${dtype}\" ; then " \ "usb start ;" \ @@ -411,8 +416,8 @@ #define CONFIG_USB_GADGET_VBUS_DRAW 2 /* Netchip IDs */ -#define CONFIG_G_DNL_VENDOR_NUM 0x0525 -#define CONFIG_G_DNL_PRODUCT_NUM 0xa4a5 +#define CONFIG_G_DNL_VENDOR_NUM 0x18d1 +#define CONFIG_G_DNL_PRODUCT_NUM 0xd02 #define CONFIG_G_DNL_MANUFACTURER "Boundary" #define CONFIG_CMD_FASTBOOT -- 1.9.1