From patchwork Thu Jun 4 07:55:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1303350 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=ZkirgVPo; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cylf5Vb7z9sSc for ; Thu, 4 Jun 2020 17:56:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF0DC81E60; Thu, 4 Jun 2020 09:56:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.b="ZkirgVPo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 478A981E5D; Thu, 4 Jun 2020 09:56:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D99A081E50 for ; Thu, 4 Jun 2020 09:56:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lj1-x241.google.com with SMTP id c11so6096112ljn.2 for ; Thu, 04 Jun 2020 00:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=nHrxKdKPAti+dbk/Zle6qeTkA4P4Qwi/KWWHgj0v1+w=; b=ZkirgVPotPz7Uly0UlfyP5ch8Qi4yyiajfQKmP70kszXJVpsJX3yIuO/UtuHIEwCBK 1k262e58D3GDMmxUtYlN74v3Infr5gOll9a8/uVbQUwk+uvVO+uDD0fhEZDm6gvrEdO8 KFrrplfGVxayAsH+Q7ZdTzc4LxjdM9aWbChM9qwrvY+m5QYzKVBYgC2ea9rDg0crzsQX Dje2IhwV9rnqhGJmujG0+pYumStyhjlw3/i8tD3iz0BBSY8NTmx7CI5/RZOzMQywDORc dCOHi6iRtuwAkuBXlz/iWSbDNgxcd4ajZaKoXIOQAYIhcCH/7t/AEVfVedmRzuk096Wh 3TOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=nHrxKdKPAti+dbk/Zle6qeTkA4P4Qwi/KWWHgj0v1+w=; b=HKPaAA9r3njHGBHMsmydhnqbuSy7NfuFV8CrsdFVbTmb1k3FzZ3m8viqLMSaO5gR/I P/Za+9BJeFavrO7fX/0IN+V2Ojm9/wQ3FPTs8KtTJTMz/CPqNfFvw3MPIbhSN1kb4Q2V p8JOkiSTdQjSMwOloxl5ioBd15aV4NWe0hmqjyVClV6C5Wt+Et53+/f4TcYDB+3+FBVB J4DgJoaH4YWPDbv2q5cg/HtMwKSYfjj8jNs6z7vNWS0yFrjhRdTmSjZOM1yW+mhFp6if MvXilzEr2Bx9xYdkjIcBw+B8QjBctzrYIJjmINvoBiR7BftxnWnLo9KYmsrTsyUQpKb9 4rWg== X-Gm-Message-State: AOAM532LrbQju3wB9qRR1QM44UCUiA1stRGmYWC56mHS7aGR0nqNO/tU Xty4yyW9BOjSpDEed6M3kRmoUDgHhT0= X-Google-Smtp-Source: ABdhPJyh+tiLw2rFLzG4rb/zoTibFmOEoT1hrcJ3pNawB0PJ4TsKG+G/5RDuhrbdanBGukdink20aA== X-Received: by 2002:a05:651c:3d0:: with SMTP id f16mr1471670ljp.7.1591257374687; Thu, 04 Jun 2020 00:56:14 -0700 (PDT) Received: from localhost.localdomain ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id w17sm1250391ljj.108.2020.06.04.00.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 00:56:14 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk Subject: [PATCH v2 1/2] fastboot: add support for 'reboot fastboot' command Date: Thu, 4 Jun 2020 10:55:48 +0300 Message-Id: <2b4819f8fa0e8d22630ae7782be8e07766f1eb0a.1591256843.git.roman.kovalivskyi@globallogic.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean From: Roman Stratiienko Android 10 adds support for dynamic partitions and in order to support this userspace fastboot must be used[1]. New tool fastbootd is included into recovery. Userspace fastboot works from recovery and is launched if: 1) - Dynamic partitioning is enabled 2) - Boot control block has 'boot-fastboot' value into command field The bootloader is expected to load and boot into the recovery image upon seeing boot-fastboot in the BCB command. Recovery then parses the BCB message and switches to fastbootd mode[2]. Please note that boot script is expected to handle 'boot-fastboot' command in BCB and load into recovery mode. Bootloader must support 'reboot fastboot' command which should reboot device into userspace fastboot to accomodate those changes[3]. Another command that bootloader must support[3] is 'reboot recovery'. This command should simply reboot device into recovery mode. [1] - https://source.android.com/devices/bootloader/fastbootd [2] - https://source.android.com/devices/bootloader/fastbootd#unified_fastboot_and_recovery [3] - https://source.android.com/devices/bootloader/fastbootd#modifications_to_the_bootloader Signed-off-by: Roman Kovalivskyi Signed-off-by: Roman Stratiienko Change-Id: I9d2bdc9a6f6f31ea98572fe155e1cc8341e9af76 --- arch/arm/mach-meson/board-common.c | 6 ++++- arch/arm/mach-rockchip/board.c | 6 ++++- board/amazon/kc1/kc1.c | 6 ++++- board/lg/sniper/sniper.c | 6 ++++- board/ti/am57xx/board.c | 6 ++++- board/ti/dra7xx/evm.c | 6 ++++- drivers/fastboot/fb_command.c | 40 +++++++++++++++++++++++++++++- drivers/fastboot/fb_common.c | 5 +++- drivers/usb/gadget/f_fastboot.c | 2 ++ include/fastboot.h | 13 +++++++++- net/fastboot.c | 2 ++ 11 files changed, 89 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-meson/board-common.c b/arch/arm/mach-meson/board-common.c index 19e5bfd3660c..ffa0ccf003cf 100644 --- a/arch/arm/mach-meson/board-common.c +++ b/arch/arm/mach-meson/board-common.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -153,8 +154,11 @@ int board_late_init(void) #if CONFIG_IS_ENABLED(FASTBOOT) static unsigned int reboot_reason = REBOOT_REASON_NORMAL; -int fastboot_set_reboot_flag() +int fastboot_set_reboot_flag(int reason) { + if (reason != FASTBOOT_REBOOT_BOOTLOADER) + return -ENOTSUPP; + reboot_reason = REBOOT_REASON_BOOTLOADER; printf("Using reboot reason: 0x%x\n", reboot_reason); diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 430c0cbf41e4..ca9f63bce72c 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -152,8 +153,11 @@ int board_usb_init(int index, enum usb_init_type init) #endif /* CONFIG_USB_GADGET */ #if CONFIG_IS_ENABLED(FASTBOOT) -int fastboot_set_reboot_flag(void) +int fastboot_set_reboot_flag(int reason) { + if (reason != FASTBOOT_REBOOT_BOOTLOADER) + return -ENOTSUPP; + printf("Setting reboot to fastboot flag ...\n"); /* Set boot mode to fastboot */ writel(BOOT_FASTBOOT, CONFIG_ROCKCHIP_BOOT_MODE_REG); diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c index fb1828ff44da..d61a0db7cb62 100644 --- a/board/amazon/kc1/kc1.c +++ b/board/amazon/kc1/kc1.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -163,8 +164,11 @@ void get_board_serial(struct tag_serialnr *serialnr) omap_die_id_get_board_serial(serialnr); } -int fastboot_set_reboot_flag(void) +int fastboot_set_reboot_flag(int reason) { + if (reason != FASTBOOT_REBOOT_BOOTLOADER) + return -ENOTSUPP; + return omap_reboot_mode_store("b"); } diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c index 2825eccc035a..cbbe56597e71 100644 --- a/board/lg/sniper/sniper.c +++ b/board/lg/sniper/sniper.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -175,8 +176,11 @@ void reset_misc(void) omap_reboot_mode_store(reboot_mode); } -int fastboot_set_reboot_flag(void) +int fastboot_set_reboot_flag(int reason) { + if (reason != FASTBOOT_REBOOT_BOOTLOADER) + return -ENOTSUPP; + return omap_reboot_mode_store("b"); } diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c index 8720eb87a55d..28c7e890448c 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -1169,8 +1170,11 @@ int board_fit_config_name_match(const char *name) #endif #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE) -int fastboot_set_reboot_flag(void) +int fastboot_set_reboot_flag(int reason) { + if (reason != FASTBOOT_REBOOT_BOOTLOADER) + return -ENOTSUPP; + printf("Setting reboot to fastboot flag ...\n"); env_set("dofastboot", "1"); env_save(); diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c index acf7ff169170..aa53a5e8b7e6 100644 --- a/board/ti/dra7xx/evm.c +++ b/board/ti/dra7xx/evm.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -1050,8 +1051,11 @@ int board_fit_config_name_match(const char *name) #endif #if CONFIG_IS_ENABLED(FASTBOOT) && !CONFIG_IS_ENABLED(ENV_IS_NOWHERE) -int fastboot_set_reboot_flag(void) +int fastboot_set_reboot_flag(int reason) { + if (reason != FASTBOOT_REBOOT_BOOTLOADER) + return -ENOTSUPP; + printf("Setting reboot to fastboot flag ...\n"); env_set("dofastboot", "1"); env_save(); diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 49f6a61c3745..f385aa8e0542 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -37,6 +37,8 @@ static void flash(char *, char *); static void erase(char *, char *); #endif static void reboot_bootloader(char *, char *); +static void reboot_fastbootd(char *, char *); +static void reboot_recovery(char *, char *); #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) static void oem_format(char *, char *); #endif @@ -79,6 +81,14 @@ static const struct { .command = "reboot-bootloader", .dispatch = reboot_bootloader }, + [FASTBOOT_COMMAND_REBOOT_FASTBOOTD] = { + .command = "reboot-fastboot", + .dispatch = reboot_fastbootd + }, + [FASTBOOT_COMMAND_REBOOT_RECOVERY] = { + .command = "reboot-recovery", + .dispatch = reboot_recovery + }, [FASTBOOT_COMMAND_SET_ACTIVE] = { .command = "set_active", .dispatch = okay @@ -307,12 +317,40 @@ static void erase(char *cmd_parameter, char *response) */ static void reboot_bootloader(char *cmd_parameter, char *response) { - if (fastboot_set_reboot_flag()) + if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_BOOTLOADER)) fastboot_fail("Cannot set reboot flag", response); else fastboot_okay(NULL, response); } +/** + * reboot_fastbootd() - Sets reboot fastboot flag. + * + * @cmd_parameter: Pointer to command parameter + * @response: Pointer to fastboot response buffer + */ +static void reboot_fastbootd(char *cmd_parameter, char *response) +{ + if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_FASTBOOTD)) + fastboot_fail("Cannot set fastboot flag", response); + else + fastboot_okay(NULL, response); +} + +/** + * reboot_recovery() - Sets reboot recovery flag. + * + * @cmd_parameter: Pointer to command parameter + * @response: Pointer to fastboot response buffer + */ +static void reboot_recovery(char *cmd_parameter, char *response) +{ + if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_RECOVERY)) + fastboot_fail("Cannot set recovery flag", response); + else + fastboot_okay(NULL, response); +} + #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) /** * oem_format() - Execute the OEM format command diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c index c3735a44af74..012a6288c187 100644 --- a/drivers/fastboot/fb_common.c +++ b/drivers/fastboot/fb_common.c @@ -88,8 +88,11 @@ void fastboot_okay(const char *reason, char *response) * which sets whatever flag your board specific Android bootloader flow * requires in order to re-enter the bootloader. */ -int __weak fastboot_set_reboot_flag(void) +int __weak fastboot_set_reboot_flag(int reason) { + if (reason != FASTBOOT_REBOOT_BOOTLOADER) + return -ENOTSUPP; + return -ENOSYS; } diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 384c0f6f6e27..30f7a52087fc 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -455,6 +455,8 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) case FASTBOOT_COMMAND_REBOOT: case FASTBOOT_COMMAND_REBOOT_BOOTLOADER: + case FASTBOOT_COMMAND_REBOOT_FASTBOOTD: + case FASTBOOT_COMMAND_REBOOT_RECOVERY: fastboot_func->in_req->complete = compl_do_reset; break; } diff --git a/include/fastboot.h b/include/fastboot.h index 1933b1d98e3b..1830d859afb6 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -32,6 +32,8 @@ enum { FASTBOOT_COMMAND_CONTINUE, FASTBOOT_COMMAND_REBOOT, FASTBOOT_COMMAND_REBOOT_BOOTLOADER, + FASTBOOT_COMMAND_REBOOT_FASTBOOTD, + FASTBOOT_COMMAND_REBOOT_RECOVERY, FASTBOOT_COMMAND_SET_ACTIVE, #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT) FASTBOOT_COMMAND_OEM_FORMAT, @@ -40,6 +42,15 @@ enum { FASTBOOT_COMMAND_COUNT }; +/** + * Reboot reasons + */ +enum { + FASTBOOT_REBOOT_BOOTLOADER, + FASTBOOT_REBOOT_FASTBOOTD, + FASTBOOT_REBOOT_RECOVERY +}; + /** * fastboot_response() - Writes a response of the form "$tag$reason". * @@ -77,7 +88,7 @@ void fastboot_okay(const char *reason, char *response); * which sets whatever flag your board specific Android bootloader flow * requires in order to re-enter the bootloader. */ -int fastboot_set_reboot_flag(void); +int fastboot_set_reboot_flag(int reason); /** * fastboot_set_progress_callback() - set progress callback diff --git a/net/fastboot.c b/net/fastboot.c index 0c57fb9947df..7e7a601b9fe6 100644 --- a/net/fastboot.c +++ b/net/fastboot.c @@ -227,6 +227,8 @@ static void fastboot_send(struct fastboot_header header, char *fastboot_data, case FASTBOOT_COMMAND_REBOOT: case FASTBOOT_COMMAND_REBOOT_BOOTLOADER: + case FASTBOOT_COMMAND_REBOOT_FASTBOOTD: + case FASTBOOT_COMMAND_REBOOT_RECOVERY: do_reset(NULL, 0, 0, NULL); break; } From patchwork Thu Jun 4 07:55:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1303351 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.a=rsa-sha256 header.s=google header.b=Sksqjx/f; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cylr522Dz9sSc for ; Thu, 4 Jun 2020 17:56:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A4C0B81E5A; Thu, 4 Jun 2020 09:56:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=globallogic.com header.i=@globallogic.com header.b="Sksqjx/f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3287781E64; Thu, 4 Jun 2020 09:56:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E742081E58 for ; Thu, 4 Jun 2020 09:56:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=globallogic.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=roman.kovalivskyi@globallogic.com Received: by mail-lj1-x243.google.com with SMTP id z9so6039044ljh.13 for ; Thu, 04 Jun 2020 00:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=globallogic.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=+Q+d6914xL21nNRXZa37r4pJdTTnyGrSku9o75+WSuc=; b=Sksqjx/frO5T/khhEc8XsbL5tzKK8+fVzQqbRa5+ykSaVa2E/9SX3hwvE1fyQt9URr 9Lk1FzBdF27u3MQgjUbsQkXCUoWCilc6p7u3wxAEcWqp1eSwRSqOA7QgnkKeRM5s/Daf jntjreWHdmQb2yQ9zeOgducuziiqbVXqnFk+Bb+U2/Qh5WSf+h4kxnsGiVzWq1UGNT5w 7fh8wWEdS5bIY5WEdxWyjyfSYOmNHAUAICrHRAk6fi/HKGXqJ4qx/RmcN/Wmi/QUr2MC 7nXj1WVOervpfkIWSSVF03Oa8ghWUuLUCFyQk1JEtZSopJ41ce1Ny+V6xmMF2UjpQ74X bZEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=+Q+d6914xL21nNRXZa37r4pJdTTnyGrSku9o75+WSuc=; b=Bze/QYxTM1qST2BqvH0Q9iwYGXdp6FHaJbdFFwmUxIewxfvtE7ebRfm/Q+GqONWxxl eyp8AhbxFWCaW1Y0PqJFDArhvQaEcO1AEUludbH9JQWE5wviVPP07SqajEjsbyvSH+tn LajfpsYALMfJ2V+yjanMH6EBVwautr164YxO0WhOUrla96WyO/PwNED2RERRy5nL2nry E6UJtS5HwgWMw4kz0o5z3HkfExU8GZbqPRWWu6Em0dGY02tKtse8fuIRtWTOOvMA8vg4 jIhGZ7IrFIztwHrBhv3TFZivQ4tphXG2rRwjzE/O6uARRnihvM5OawFpNbvE2D4BqV9l 0Afw== X-Gm-Message-State: AOAM530E0usN2QlDj6kVS+MgaJhui2v8FeC3EuiGUYV/e5Upz9oDnCp0 Rp/ADHMxxBd5cpt3rmFSXGJdgyRKQ1E= X-Google-Smtp-Source: ABdhPJwCPfZQOIG3bkkG+7rbRekYWzTV5tUMEfIGnjLv9PbCfqvkV6G6u5IFdYnTjsYiHyQZnqj46Q== X-Received: by 2002:a2e:8e97:: with SMTP id z23mr1431379ljk.399.1591257378029; Thu, 04 Jun 2020 00:56:18 -0700 (PDT) Received: from localhost.localdomain ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id w17sm1250391ljj.108.2020.06.04.00.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 00:56:17 -0700 (PDT) From: Roman Kovalivskyi To: u-boot@lists.denx.de Cc: Roman Stratiienko , Joe Hershberger , Roman Kovalivskyi , Simon Glass , Marek Vasut , Lukasz Majewski , Eugeniu Rosca , Alex Kiernan , Sam Protsenko , Neil Armstrong , Philipp Tomsich , Kever Yang , Paul Kocialkowski , Lokesh Vutla , Jagan Teki , Miquel Raynal , Boris Brezillon , Tom Rini , Igor Opaniuk Subject: [PATCH v2 2/2] fastboot: add default fastboot_set_reboot_flag implementation Date: Thu, 4 Jun 2020 10:55:49 +0300 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Default implementation of fastboot_set_reboot_flag function that depends on "bcb" commands could be used in general case if there are no need to make any platform-specific implementation, otherwise it could be disabled via Kconfig option FASTBOOT_USE_BCB_SET_REBOOT_FLAG. Please note that FASTBOOT_USE_BCB_SET_REBOOT_FLAG is mutually exclusive with some platforms which already have their own implementation of this function. Signed-off-by: Roman Kovalivskyi --- drivers/fastboot/Kconfig | 9 +++++++++ drivers/fastboot/fb_common.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index d4436dfc9173..bcb43bc5d556 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -165,6 +165,15 @@ config FASTBOOT_CMD_OEM_FORMAT relies on the env variable partitions to contain the list of partitions as required by the gpt command. +config FASTBOOT_USE_BCB_SET_REBOOT_FLAG + bool "Enable default fastboot_set_reboot_flag implementation" + depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && !TARGET_KC1 && \ + !TARGET_SNIPER && !TARGET_AM57XX_EVM && !TARGET_DRA7XX_EVM + default 1 + help + Add default implementation of fastboot_set_reboot_flag that uses + "bcb" commands. + endif # FASTBOOT endmenu diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c index 012a6288c187..77fe22e88f3d 100644 --- a/drivers/fastboot/fb_common.c +++ b/drivers/fastboot/fb_common.c @@ -88,6 +88,41 @@ void fastboot_okay(const char *reason, char *response) * which sets whatever flag your board specific Android bootloader flow * requires in order to re-enter the bootloader. */ +#if CONFIG_IS_ENABLED(FASTBOOT_USE_BCB_SET_REBOOT_FLAG) +int fastboot_set_reboot_flag(int reason) +{ + char cmd[32]; + + snprintf(cmd, sizeof(cmd), "bcb load %d misc", + CONFIG_FASTBOOT_FLASH_MMC_DEV); + + if (run_command(cmd, 0)) + return -ENODEV; + + switch (reason) { + case FASTBOOT_REBOOT_BOOTLOADER: + snprintf(cmd, sizeof(cmd), + "bcb set command bootonce-bootloader"); + break; + case FASTBOOT_REBOOT_FASTBOOTD: + snprintf(cmd, sizeof(cmd), "bcb set command boot-fastboot"); + break; + case FASTBOOT_REBOOT_RECOVERY: + snprintf(cmd, sizeof(cmd), "bcb set command boot-recovery"); + break; + default: + return -EINVAL; + } + + if (run_command(cmd, 0)) + return -ENOEXEC; + + if (run_command("bcb store", 0)) + return -EIO; + + return 0; +} +#else int __weak fastboot_set_reboot_flag(int reason) { if (reason != FASTBOOT_REBOOT_BOOTLOADER) @@ -95,6 +130,7 @@ int __weak fastboot_set_reboot_flag(int reason) return -ENOSYS; } +#endif /** * fastboot_get_progress_callback() - Return progress callback