From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB25AC433F5 for ; Sat, 23 Oct 2021 23:30:17 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 666CA60F22 for ; Sat, 23 Oct 2021 23:30:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 666CA60F22 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 898628354C; Sun, 24 Oct 2021 01:29:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LQHqZXk3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7FDE38358D; Sun, 24 Oct 2021 01:27:48 +0200 (CEST) Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) (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 CB4EE8353B for ; Sun, 24 Oct 2021 01:27:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ot1-x330.google.com with SMTP id v2-20020a05683018c200b0054e3acddd91so6798080ote.8 for ; Sat, 23 Oct 2021 16:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b9O0fE/bg8Nvq0kFIPRFx+NByh/bK9v9nvTdlEJgvEc=; b=LQHqZXk3WO+42bZD0Q7lYX2bbZNcuXj9phE0PVgXQD6BFsQEfanp3NBdTsI3eOEmDG WhtOx0mDyistSBm0k79AGEzLHcWXYsHDiWQNShEQg9qWhKQkzDELupt6Y41JKaufEGJK W6Q9UDHHQEKfgB02hiVTrARHu/FvytkmdE/Cs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b9O0fE/bg8Nvq0kFIPRFx+NByh/bK9v9nvTdlEJgvEc=; b=kFjGc5bhKxTK/IVHnL0hy2tcc6UoNfq9lhaM9r+wieA/dUxIAxXSQu1gdXR06FKppk Q49k7T7DvNRi5yyxSaDS76NUDsBDAHgrur7XqHBkGns1ZpzKm+DCOCYFOlp6p+f7LJe6 yX9ulDsEJ9QU/g7b7SI0RSK4+Mfi2GGOHPWNHykjYBo6xksNJIqNN1XlRlJm1jYTdLuE eIXDsMTzYXtbIKV0/I7Z6SecGlgmx5yI+iiceL996mmYKRY92tt3pe2YaK/lTPZrPgFD ZXuOr97T3NdHPTfHZA8ktb6cPNag+gSZd/oBaJ0japUYXCYGIl+4u+HATgbfO9nz/2b9 j/QA== X-Gm-Message-State: AOAM530WBJ9Ug9hSKoTTyqVdyORfXj8xLVl08NT/HU8tnjZtqcf4onxb wFqf+wNfBBSja/rpT4T66s7RWB7ldkWQkQ== X-Google-Smtp-Source: ABdhPJzr2AHY/zhtKxUfjBc4+RzAG0ut8ug6BfPBLK1AnfCQgUc1WQuLJqPrJW/B72+gR99neK12hA== X-Received: by 2002:a9d:7985:: with SMTP id h5mr6664034otm.146.1635031631259; Sat, 23 Oct 2021 16:27:11 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id l24sm2253885oop.4.2021.10.23.16.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Oct 2021 16:27:10 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Michal Simek , Heinrich Schuchardt , Tom Rini , Ilias Apalodimas , Daniel Schwierzeck , Steffen Jaeckel , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Lukas Auer , Dennis Gilmore , Simon Glass Subject: [PATCH v2 24/41] bootstd: Add a bootdev command Date: Sat, 23 Oct 2021 17:26:18 -0600 Message-Id: <20211023172618.v2.24.Ic1c0b48869db2404f5d8c89518eb88156b8bc46a@changeid> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211023232635.9195-1-sjg@chromium.org> References: <20211023232635.9195-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.103.2 at phobos.denx.de X-Virus-Status: Clean Add a 'bootdev' command to handle listing and selection of bootdevs. Disable standard boot for a few boards which otherwise run out of space. Signed-off-by: Simon Glass --- (no changes since v1) MAINTAINERS | 1 + cmd/Kconfig | 8 ++ cmd/Makefile | 1 + cmd/bootdev.c | 120 +++++++++++++++++++++++++++++ configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/tbs2910_defconfig | 1 + 7 files changed, 133 insertions(+) create mode 100644 cmd/bootdev.c diff --git a/MAINTAINERS b/MAINTAINERS index cbb7a160a26..a95329286da 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -640,6 +640,7 @@ F: boot/bootdev*.c F: boot/bootflow.c F: boot/bootmeth*.c F: boot/bootstd.c +F: cmd/bootdev.c F: include/bootdev*.h F: include/bootflow.h F: include/bootmeth.h diff --git a/cmd/Kconfig b/cmd/Kconfig index 5b30b13e438..bb6b881660c 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -194,6 +194,14 @@ config CMD_BOOTM help Boot an application image from the memory. +config CMD_BOOTSTD + bool "bootdev" + depends on BOOTSTD + default y + help + Support working with standard boot, including listing available + bootdevs and showing information about a particular one. + config BOOTM_EFI bool "Support booting UEFI FIT images" depends on CMD_BOOTEFI && CMD_BOOTM && FIT diff --git a/cmd/Makefile b/cmd/Makefile index 891819ae0f6..a8fce22d6c6 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o obj-$(CONFIG_CMD_ADC) += adc.o obj-$(CONFIG_CMD_ARMFLASH) += armflash.o obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o +obj-$(CONFIG_CMD_BOOTSTD) += bootdev.o obj-$(CONFIG_CMD_SOURCE) += source.o obj-$(CONFIG_CMD_BCB) += bcb.o obj-$(CONFIG_CMD_BDI) += bdinfo.o diff --git a/cmd/bootdev.c b/cmd/bootdev.c new file mode 100644 index 00000000000..ecd797c0503 --- /dev/null +++ b/cmd/bootdev.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * 'bootdev' command + * + * Copyright 2021 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static int bootdev_check_state(struct bootstd_priv **stdp) +{ + struct bootstd_priv *std; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return ret; + if (!std->cur_bootdev) { + printf("Please use 'bootdev select' first\n"); + return -ENOENT; + } + *stdp = std; + + return 0; +} + +static int do_bootdev_list(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + bool probe; + + probe = argc >= 2 && !strcmp(argv[1], "-p"); + bootdev_list(probe); + + return 0; +} + +static int do_bootdev_select(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct bootstd_priv *std; + struct udevice *dev; + int ret; + + ret = bootstd_get_priv(&std); + if (ret) + return CMD_RET_FAILURE; + if (argc < 2) { + std->cur_bootdev = NULL; + return 0; + } + if (bootdev_find_by_any(argv[1], &dev)) + return CMD_RET_FAILURE; + + std->cur_bootdev = dev; + + return 0; +} + +static int do_bootdev_info(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct bootstd_priv *priv; + struct bootflow *bflow; + int ret, i, num_valid; + struct udevice *dev; + bool probe; + + probe = argc >= 2 && !strcmp(argv[1], "-p"); + + ret = bootdev_check_state(&priv); + if (ret) + return CMD_RET_FAILURE; + + dev = priv->cur_bootdev; + + /* Count the number of bootflows, including how many are valid*/ + num_valid = 0; + for (ret = bootdev_first_bootflow(dev, &bflow), i = 0; + !ret; + ret = bootdev_next_bootflow(&bflow), i++) + num_valid += bflow->state == BOOTFLOWST_READY; + + /* + * Prove the device, if requested, otherwise assume that there is no + * error + */ + ret = 0; + if (probe) + ret = device_probe(dev); + + printf("Name: %s\n", dev->name); + printf("Sequence: %d\n", dev_seq(dev)); + printf("Status: %s\n", ret ? simple_itoa(ret) : device_active(dev) ? + "Probed" : "OK"); + printf("Uclass: %s\n", dev_get_uclass_name(dev_get_parent(dev))); + printf("Bootflows: %d (%d valid)\n", i, num_valid); + + return 0; +} + +#ifdef CONFIG_SYS_LONGHELP +static char bootdev_help_text[] = + "list [-p] - list all available bootdevs (-p to probe)\n" + "bootdev select - select a bootdev by name | label | seq\n" + "bootdev info [-p] - show information about a bootdev (-p to probe)"; +#endif + +U_BOOT_CMD_WITH_SUBCMDS(bootdev, "Boot devices", bootdev_help_text, + U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootdev_list), + U_BOOT_SUBCMD_MKENT(select, 2, 1, do_bootdev_select), + U_BOOT_SUBCMD_MKENT(info, 2, 1, do_bootdev_info)); diff --git a/configs/amcore_defconfig b/configs/amcore_defconfig index 4befa7a62bd..822da8a81c6 100644 --- a/configs/amcore_defconfig +++ b/configs/amcore_defconfig @@ -7,6 +7,7 @@ CONFIG_SYS_MALLOC_LEN=0x100000 CONFIG_DEFAULT_DEVICE_TREE="amcore" CONFIG_TARGET_AMCORE=y CONFIG_SYS_LOAD_ADDR=0x20000 +# CONFIG_BOOTSTD is not set CONFIG_BOOTDELAY=1 CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set diff --git a/configs/rcar3_salvator-x_defconfig b/configs/rcar3_salvator-x_defconfig index 3b48ab2751b..c742f0304e3 100644 --- a/configs/rcar3_salvator-x_defconfig +++ b/configs/rcar3_salvator-x_defconfig @@ -11,6 +11,7 @@ CONFIG_RCAR_GEN3=y CONFIG_TARGET_SALVATOR_X=y CONFIG_SYS_LOAD_ADDR=0x58000000 CONFIG_FIT=y +# CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_USE_BOOTARGS=y CONFIG_DEFAULT_FDT_FILE="r8a77950-salvator-x.dtb" diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig index d393975a190..2f8eef41c55 100644 --- a/configs/tbs2910_defconfig +++ b/configs/tbs2910_defconfig @@ -14,6 +14,7 @@ CONFIG_DEFAULT_DEVICE_TREE="imx6q-tbs2910" CONFIG_PRE_CON_BUF_ADDR=0x7c000000 CONFIG_CMD_HDMIDETECT=y CONFIG_AHCI=y +# CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTCOMMAND=y -- 2.33.0.1079.g6e70778dc9-goog