From patchwork Wed Jun 10 16:36:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kovalivskyi X-Patchwork-Id: 1307083 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=TBnSyrBe; 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 49ht2H5yWcz9sRR for ; Thu, 11 Jun 2020 02:37:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BCFEA81C54; Wed, 10 Jun 2020 18:37:22 +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="TBnSyrBe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A4E9B819F4; Wed, 10 Jun 2020 18:37:19 +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 15646818F8 for ; Wed, 10 Jun 2020 18:37:13 +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 z9so3272443ljh.13 for ; Wed, 10 Jun 2020 09:37:13 -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=APQuXdqlLcaEir80S+V8w9nj5p1Y33nKbcX1m5+o3wY=; b=TBnSyrBel1m9P5/c/QvOc1g1CT2nSgw4lAuaqORa4SM6nPaK+U9Z0dEjfyP9VkcFhW LfwKrzuAi3YTnaEYObjnmwgKlOuvyYAEN5Rixv/WH2Ql87tJpCtD6/aY1ALJVlFT1boq KZaVH7ylN4IYrMqWq2Y+IG1I9Lx4HdJB1BRqsoxYe86UHoEpo8Fz42GBrdF4dojZnzkK AlEGR6dXA9Pvgh6HJfxPBOyCu64aeipf7opQmUXjB3jB3sn/EottJF+oiS1LU9dsi/kT ePYPbzdNQ/UG0qwowgzOSEQ3iJ+u+w1W2HWwz/5Mqj88nh6jC2VSTb2nbvSCRjb9bRRY iGXQ== 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=APQuXdqlLcaEir80S+V8w9nj5p1Y33nKbcX1m5+o3wY=; b=iBFeHWwPG7UBhGYiE5yoyeZvA1fyY+y08jlKxaoT2vCQ0i+I8J/mowXBva6SYY4DU5 d9wLydgHZkLMUbFA3WD0VUQfBmyYUrMxPjhiqrzQ3n2iesbv4Kjtbx8CjFYLfoXyJ6qV Yka+E7oMwhxH00wY7/Xl+w3dQeIxRN8pASc6y6f1tx+aBGJ0qYLSbbEZ/yu7UtOgaWXu YY2BJTKMUMHP1dgbpP3qiSPxxE+I0p94OAgXHcyWFZyeHwnp0mAatnDy82lOL7jrrLnz CmM4ZCPJTiG7ZPr4GGSKkznQTWZAcPDJmqvD1NnWNISwyxKIBUdvnT2vYsqr6zwU6RCL /M2w== X-Gm-Message-State: AOAM5313AwxZzTLgAkCU4ktC/2rQyCZJiXDsWSCzf1wFTZaP7MqXXsZT OZD0nASXAfrtFLw2c9Do0eKdDOKYyOw= X-Google-Smtp-Source: ABdhPJyDXMXULP4R3k5gTa7USA/cFGBDfFP9MjSb1RsbHonepEGXtSZbx6Dr7XK7ZpbNtTIgAz2Hcw== X-Received: by 2002:a2e:b6d1:: with SMTP id m17mr2184467ljo.328.1591807032104; Wed, 10 Jun 2020 09:37:12 -0700 (PDT) Received: from user-HP-ZBook-14u-G4.synapse.com ([159.224.5.60]) by smtp.googlemail.com with ESMTPSA id f74sm43639lfd.68.2020.06.10.09.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 09:37: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 v3 3/3] fastboot: Add default fastboot_set_reboot_flag implementation Date: Wed, 10 Jun 2020 19:36:47 +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/Makefile | 1 + drivers/fastboot/fb_bcb_impl.c | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 drivers/fastboot/fb_bcb_impl.c 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/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; +}