From patchwork Tue Jun 23 00:27:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1314808 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=aWhMoCjm; 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 49rRww1k00z9sSf for ; Tue, 23 Jun 2020 10:29:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3664281E7E; Tue, 23 Jun 2020 02:28:34 +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="aWhMoCjm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 58C2481E53; Tue, 23 Jun 2020 02:28:23 +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-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) (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 4059E81E53 for ; Tue, 23 Jun 2020 02:28: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-lf1-x143.google.com with SMTP id d7so10672321lfi.12 for ; Mon, 22 Jun 2020 17:28: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=ZGvkWJcxYtyoogS8Rra7BEW8feGSWj9rcDEHqSVMWhk=; b=aWhMoCjmGSC7IVwyINJzU1VWGBngGr2KYyRCyZio8TirDNGjFA9jhUQ5ggDYDuzltl y04yEyP2GlknBo7HG17e70VBsWg2Fgr7egRoZQ1xnOap1buAYzhLMV+/J7oLsx1HeG6r 284DpRNBo6z36e/mfAspW1PBfG1JXAcX7+kasLd5LhVWqNpFgTLhLH4IapPKMDlMeO2b j5Oo7ZhRHdZTwpaR7KETSEmzqYh715ze2HN3LgrShuaQ95SPiJ1S7G6GNWxqCVuSJbZZ 7L85IkGztBxmyjF1gC+ktV7TKjq7OFG3r3up0s4wTbIAy+vdN3g7QaTc0MrF7oTVhDNi X/Gg== 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=ZGvkWJcxYtyoogS8Rra7BEW8feGSWj9rcDEHqSVMWhk=; b=tch+Y+R8xBk7J7qqLtVPLYIXL23wZhLzN3+8CaqAbJy17jLc00A7ePdOhUM06e4Jtw wp2eVu3Bp3EFVT0ZV5HrC+h1yvu4pnq+f2GWx3XJCctouw5sEaQFvHxvopS4TmLwN+0h ANUOiAxUSLfycSCtl/dU12ozkPvD6u/KM5TicUKTQnf6ScA1e9Z2SMPbHC/moRGoD0gC gtWEBw3fxghQnnt8bqSPN6tHaCk7D4uuHgd110Y6LVfr1yVgk1bIRJyRkEeJwm8MtbGz vxK3hPyJSeinrIefq0ci2ndTVFjD6zNjQHHY94Zy2e4bnFVedXU9JQdxAMcvaBvBjc4z MrEQ== X-Gm-Message-State: AOAM533eYwh7G/to1AlgFr2XEZEaRhaNOlk87jC81ZwWzaN97Gr5ykmE Z8Z/Vu/KndaUCZGU5n51+ImM7E9njr/skA== X-Google-Smtp-Source: ABdhPJwMUlMTZzTWYxUrM4Z9Hz1vbQby+ON9sSggYyfiKjs6u6mocCvzjly69rjZ8Va5cTyagaAYTg== X-Received: by 2002:a19:993:: with SMTP id 141mr11075205lfj.166.1592872089469; Mon, 22 Jun 2020 17:28:09 -0700 (PDT) Received: from localhost.localdomain ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id o6sm144233ljh.42.2020.06.22.17.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 17:28:09 -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 , Aleksandr Bulyshchenko Subject: [PATCH v4 1/3] fastboot: Extend fastboot_set_reboot_flag with reboot reason Date: Tue, 23 Jun 2020 03:27:53 +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 Extend fastboot_set_reboot_flag arguments with reboot reason so that it could handle different reboot cases in future. Signed-off-by: Roman Kovalivskyi Reviewed-by: Roman Stratiienko --- 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 | 2 +- drivers/fastboot/fb_common.c | 2 +- include/fastboot.h | 10 +++++++++- 9 files changed, 41 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-meson/board-common.c b/arch/arm/mach-meson/board-common.c index 19e5bfd3660c..a1f08bb98c6f 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(enum fastboot_reboot_reason reason) { + if (reason != FASTBOOT_REBOOT_REASON_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..ba4da72b3910 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(enum fastboot_reboot_reason reason) { + if (reason != FASTBOOT_REBOOT_REASON_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..445980f16e62 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(enum fastboot_reboot_reason reason) { + if (reason != FASTBOOT_REBOOT_REASON_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..99b832fe601b 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(enum fastboot_reboot_reason reason) { + if (reason != FASTBOOT_REBOOT_REASON_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..49afd3bc927b 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(enum fastboot_reboot_reason reason) { + if (reason != FASTBOOT_REBOOT_REASON_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..3bc40c721146 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(enum fastboot_reboot_reason reason) { + if (reason != FASTBOOT_REBOOT_REASON_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..8ce5d32fb2ba 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -307,7 +307,7 @@ 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_REASON_BOOTLOADER)) fastboot_fail("Cannot set reboot flag", response); else fastboot_okay(NULL, response); diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c index c3735a44af74..736ce1cd024f 100644 --- a/drivers/fastboot/fb_common.c +++ b/drivers/fastboot/fb_common.c @@ -88,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 __weak fastboot_set_reboot_flag(void) +int __weak fastboot_set_reboot_flag(enum fastboot_reboot_reason reason) { return -ENOSYS; } diff --git a/include/fastboot.h b/include/fastboot.h index 1933b1d98e3b..14f4c68868d8 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -40,6 +40,14 @@ enum { FASTBOOT_COMMAND_COUNT }; +/** + * Reboot reasons + */ +enum fastboot_reboot_reason { + FASTBOOT_REBOOT_REASON_BOOTLOADER, + FASTBOOT_REBOOT_REASONS_COUNT +}; + /** * fastboot_response() - Writes a response of the form "$tag$reason". * @@ -77,7 +85,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(enum fastboot_reboot_reason reason); /** * fastboot_set_progress_callback() - set progress callback From patchwork Tue Jun 23 00:27:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1314807 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=85.214.62.61; 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=JunIjkW3; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49rRwW0HxBz9sSf for ; Tue, 23 Jun 2020 10:28:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3665E81E5D; Tue, 23 Jun 2020 02:28:30 +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="JunIjkW3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 240E681E20; Tue, 23 Jun 2020 02:28:16 +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-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) (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 E248481E20 for ; Tue, 23 Jun 2020 02:28:12 +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-lf1-x144.google.com with SMTP id c11so10671889lfh.8 for ; Mon, 22 Jun 2020 17:28:12 -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=nulLhq7WdpDHE0iUimuF7Ousb5MPU5uJUkny9fNNisc=; b=JunIjkW33JwFPPluxSdrcnTeJfUXYlehHKlIu+MvoQ1kJtoMqHtv1BYKpZAZ+pBEIk LTwlW8zK02S2Hq466y+mVV9P4QHR4BAan9VOCW52fxuJbHXalQ05q7Xxey4X4TK6kVPI 0rQLnLIgBRNfT4DxBLAVIfwqzKWjWXOJg5vyJtCavGDqhazYxW0iRbEfEqMBSYOCV/KV CXWjofKQBn3CWG9dvo4F52HAVoEJScMLzwMedigOXLDxnvuFHDBhBfFifQjd55OlCpHj trs9EbBpdqou6LufA4vnvebMSyIW/TJYykWNpjUuCJux8Z2gkeqP3/wi8CYK3ge7T6L9 mSDw== 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=nulLhq7WdpDHE0iUimuF7Ousb5MPU5uJUkny9fNNisc=; b=B5O2+YmhxZO6nIFTjci3RgnB3w68I/VuCfH0txMjm4nvHRx9UFylGlUy0hOdW4VJ40 BcJhAjytfhg6QrstbVRt6oEBR14TP3BZZQ1bDcwcxXabySnltP5AbOsBgktxxQYYQjRU vPg/siQO+hBbjymIL+r1A/i1EBhAnun6IuHHxJxEy2PwM22rq2G/jycnUw1qFhYr9Qwx f7bnZezeywfsojAeFfaITfsTLt3h2qRiwn1C/f+ETsTkogxMBprJA59vn6b0Ypx57j9x YBVnNNK0LfbBdk6Jc9xnVt1hlaSETorMgf46Jcag9fb+PvJWTR/4qQVjJpkGctq9lOrl WgOw== X-Gm-Message-State: AOAM531J1kWyhkJlwYJtx02jh2TS5KVMXabDBBm0fHb/f0+EDxUlO9W7 ltufT2lZmIUDzZ1T/US21sXg9FBbXWLlEA== X-Google-Smtp-Source: ABdhPJw1fu3t3Hd9YIGMXtoQtFQ5YUc1Bb/gZ7r7tmv3STnBYCaGKlZSlj7hX8OeQQI3icQcfhk4fQ== X-Received: by 2002:a19:691c:: with SMTP id e28mr11290954lfc.131.1592872091916; Mon, 22 Jun 2020 17:28:11 -0700 (PDT) Received: from localhost.localdomain ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id o6sm144233ljh.42.2020.06.22.17.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 17:28:11 -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 , Aleksandr Bulyshchenko Subject: [PATCH v4 2/3] fastboot: Add support for 'reboot fastboot' command Date: Tue, 23 Jun 2020 03:27:54 +0300 Message-Id: <867ccae1d22fc46c0af79fc503fe9ca09780e308.1592871839.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 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 --- drivers/fastboot/fb_command.c | 38 +++++++++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 2 ++ include/fastboot.h | 4 ++++ net/fastboot.c | 2 ++ 4 files changed, 46 insertions(+) diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 8ce5d32fb2ba..d3c578672dc6 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 @@ -313,6 +323,34 @@ static void reboot_bootloader(char *cmd_parameter, char *response) 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_REASON_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_REASON_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/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 14f4c68868d8..b86b508e69fd 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, @@ -45,6 +47,8 @@ enum { */ enum fastboot_reboot_reason { FASTBOOT_REBOOT_REASON_BOOTLOADER, + FASTBOOT_REBOOT_REASON_FASTBOOTD, + FASTBOOT_REBOOT_REASON_RECOVERY, FASTBOOT_REBOOT_REASONS_COUNT }; 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 Tue Jun 23 00:27:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1314809 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=WVi5bh08; 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 49rRxT5mSpz9sSf for ; Tue, 23 Jun 2020 10:29:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D7B081E51; Tue, 23 Jun 2020 02:28:43 +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="WVi5bh08"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDB8481E5B; Tue, 23 Jun 2020 02:28:41 +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-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) (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 3F6E681E5F for ; Tue, 23 Jun 2020 02:28:25 +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-x244.google.com with SMTP id 9so21387970ljv.5 for ; Mon, 22 Jun 2020 17:28:25 -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=TFADCu/mGkPNG36VkMgx4O4eQnOwyLsekvztW0Mhg+g=; b=WVi5bh08QKA5HYN/5R93Z4MAq+etm9Z/tc/Ixtox132LQNg4qYiZnFmXP0FpHWaUdE nge3fiJqvPH6Nv+xVl8+OSxiBb5OAYxqV7MhhaAlmKYqapEOG0l0QR8eJ15g/pod9A1d wc/qpcpjJqzyyEGl7hb2Ehvms29V8to7//DsATyMpv5CJMLqbmmOGwhAg/2nTO44HSF3 3HU1M0WVbkfTNLWHzIwDjC2J5lHPZxqexcjNKDkmRHoBFjuq3gj2S7EJAS40rQN5I79d ep39Rk5ZU1/lmKByLYLCVaqlzzeQ+gMqfAtctHi2iRHqdnOElh0CHv6tcpMEp6B4WGaV 7xUA== 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=TFADCu/mGkPNG36VkMgx4O4eQnOwyLsekvztW0Mhg+g=; b=WP+aIFkAFrjdULf+ze6AO2+YSZWxX6iOtEH8TX/W6UBcs5B0pi8A0OME5dd4IjSjQP nIDJtkehTrdtdUEO/EQ2GIOEMvhF895Tgt5b8aoS807CjWd5wR9i9kHsLRJ4soBCoWqp dBcIVfKxFQpl19nVLaEZGGtWeoh7YcVSw7FpXz1RpmY0VWBFNHeRNC3A7X0TcX5IOkRG xqeU2OCBlpKXjRz9JqaiWbXbZKEBK+VHCu+ssqZK+gt3MpD14acxn00IF4ZtyOkQmmeH mf8/VUTcjPwT91J58vSuY2d3tNdbDVf//vLAgQ4yb8p8ISL8uctAH7hNewPYbc/p6CQ2 +5pQ== X-Gm-Message-State: AOAM531Vo6FLq22v2y8qxrNS0amdjCDfeaNKUPZiaZV4weDNknRwXjT+ jBnbzc67h7pqBMK9Phbln0K+8wqiT5ac4w== X-Google-Smtp-Source: ABdhPJzKxt1wmB4Ff2fBzK3ZReTgsWqlQMQ1gc51tv9e2/OBu2XmKVnlBJW1YuXFO3XeYRIXH2Y7DQ== X-Received: by 2002:a2e:858c:: with SMTP id b12mr9309389lji.275.1592872095355; Mon, 22 Jun 2020 17:28:15 -0700 (PDT) Received: from localhost.localdomain ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id o6sm144233ljh.42.2020.06.22.17.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 17:28: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 , Aleksandr Bulyshchenko Subject: [PATCH v4 3/3] fastboot: Add default fastboot_set_reboot_flag implementation Date: Tue, 23 Jun 2020 03:27:55 +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 Reviewed-by: Roman Stratiienko --- drivers/fastboot/Kconfig | 12 +++++++++ drivers/fastboot/Makefile | 1 + drivers/fastboot/fb_bcb_impl.c | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 drivers/fastboot/fb_bcb_impl.c diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index d4436dfc9173..4352ba67a713 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -165,6 +165,18 @@ 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 "Use BCB by fastboot to set boot reason" + depends on CMD_BCB && !ARCH_MESON && !ARCH_ROCKCHIP && !TARGET_KC1 && \ + !TARGET_SNIPER && !TARGET_AM57XX_EVM && !TARGET_DRA7XX_EVM + default y + help + Fastboot could implement setting of reboot reason in a generic fashion + via BCB commands. BCB commands are able to write reboot reason into + command field of boot control block. In general case it is sufficient + implementation if your platform supports BCB commands and doesn't + require any specific reboot reason handling. + endif # FASTBOOT endmenu diff --git a/drivers/fastboot/Makefile b/drivers/fastboot/Makefile index 048af5aa8234..2b2c390fe4de 100644 --- a/drivers/fastboot/Makefile +++ b/drivers/fastboot/Makefile @@ -5,3 +5,4 @@ obj-y += fb_getvar.o obj-y += fb_command.o obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o +obj-$(CONFIG_FASTBOOT_USE_BCB_SET_REBOOT_FLAG) += fb_bcb_impl.o diff --git a/drivers/fastboot/fb_bcb_impl.c b/drivers/fastboot/fb_bcb_impl.c new file mode 100644 index 000000000000..a5ae94e2e357 --- /dev/null +++ b/drivers/fastboot/fb_bcb_impl.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020 GlobalLogic. + * Roman Kovalivskyi + */ + +#include +#include + +/** + * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader + * + * Set flag which indicates that we should reboot into the bootloader + * following the reboot that fastboot executes after this function. + * + * This function should be overridden in your board file with one + * which sets whatever flag your board specific Android bootloader flow + * requires in order to re-enter the bootloader. + */ +int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason) +{ + static const char * const boot_cmds[] = { + "bootonce-bootloader", + "boot-fastboot", + "boot-recovery" + }; + + char cmd[32]; + + if (reason >= FASTBOOT_REBOOT_REASONS_COUNT) + return -EINVAL; + + snprintf(cmd, sizeof(cmd), "bcb load %d misc", + CONFIG_FASTBOOT_FLASH_MMC_DEV); + + if (run_command(cmd, 0)) + return -ENODEV; + + snprintf(cmd, sizeof(cmd), "bcb set command %s", boot_cmds[reason]); + + if (run_command(cmd, 0)) + return -ENOEXEC; + + if (run_command("bcb store", 0)) + return -EIO; + + return 0; +}