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 A906AC433EF for ; Sat, 23 Oct 2021 23:26:55 +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 A027960527 for ; Sat, 23 Oct 2021 23:26:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A027960527 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 C060883460; Sun, 24 Oct 2021 01:26:51 +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="FaM2GPu1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E7FD28291E; Sun, 24 Oct 2021 01:26:48 +0200 (CEST) Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) (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 B102782BC7 for ; Sun, 24 Oct 2021 01:26:42 +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-oi1-x229.google.com with SMTP id r6so10049937oiw.2 for ; Sat, 23 Oct 2021 16:26:42 -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:mime-version :content-transfer-encoding; bh=21evNqvWagXB5untRtuvDJtNq1n+UBpqq81k0vk2HGU=; b=FaM2GPu1NrcvlT78VPkp2OhiodcI5rCbqieeOsxrKunIVrJPRfZERuMuoR4TkxLPsT FpqVNC8MdQNzXgIXXfUT7o/lXDPDSwQSj/Wm85bgGULg06BiZMhOLlYSSAk46eU7p9AQ 0/wf9nt8iuPPgIwCLuQj49KIamSBx0L/cb3gU= 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:mime-version :content-transfer-encoding; bh=21evNqvWagXB5untRtuvDJtNq1n+UBpqq81k0vk2HGU=; b=H6UTTVjmMx4e9hTDstqKAQrIYmfrzkKceqxPyNjmV4XjB+AP3+Ufs8Yr4nlqy6seX8 UpiQj94U6IKk33vZkFTrVmypsfNvCj+12z2AXWffHx9mpjmbfydywxMTh/XP5wnfJIu8 CmOaB+H8tIpABwKiVsHitQlvjupmqt7nHAndZzToVKDkpSAfAjPSb9HVGxOGpOgPHmVX y3rPJXf197XqWdghnirs+O2Cj/2heMJ2lMokdCUNMsnuAu6Y6wr9lk5oQ+mnAOADv3cx ZnDp+NJxfQ36JHd+sJ5NzrYjF9dpfJJh/La4jnS8F28PPzaIvMHuFx8HM9o84hP+vHSb r88A== X-Gm-Message-State: AOAM5322nbuzE3JmVDgUlqxJ2irsPouxfO9xPEqgUaf7bLO2wKo7VvQ0 CgARnogVEFLMLC3eCxMXhx8VmyqVjhvDcQ== X-Google-Smtp-Source: ABdhPJymyPoqDVvpt9VZjenhV+yAiVUWI1JRucIjr2kUdGBlaofoasHFwTzWgW+ui/HH+Q3WdgFvYg== X-Received: by 2002:a05:6808:259:: with SMTP id m25mr6171932oie.97.1635031600601; Sat, 23 Oct 2021 16:26:40 -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.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Oct 2021 16:26:40 -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 , Jaehoon Chung , Marek Vasut , Masahiro Yamada , Pavel Herrmann , Peng Fan , Stephen Warren , Stephen Warren Subject: [PATCH v2 00/41] Initial implementation of standard boot Date: Sat, 23 Oct 2021 17:25:54 -0600 Message-Id: <20211023232635.9195-1-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting. It introduces the following concepts: - bootdev - a device which can hold a distro - bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot) - bootflow - a description of how to boot (owned by the distro) This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot. With this we can boot on a Raspberry Pi 3 with just one command: bootflow scan -lb which means to scan, listing (-l) each bootflow and trying to boot each one (-b). The final patch shows this. With a standard way to identify boot devices, booting become easier. It also should be possible to support U-Boot scripts, for backwards compatibility only. This series relies on the PXE clean-up series, posted here: https://patchwork.ozlabs.org/project/uboot/list/?series=267078 For documentation, see the 'doc' patch. For version 2, a new naming scheme is used as above: - bootdev is used instead of bootdevice, because 'device' is overused, is everywhere in U-Boot, can be confused with udevice - bootmeth - because 'method' is too vanilla, appears 1300 times in U-Boot Also in version 2, drivers are introduced for the boot methods, to make it more extensible. Booting a custom OS is simply a matter of creating a bootmeth for it and implementing the read_file() and boot() methods. The design is described in these two documents: https://drive.google.com/file/d/1ggW0KJpUOR__vBkj3l61L2dav4ZkNC12/view?usp=sharing https://drive.google.com/file/d/1kTrflO9vvGlKp-ZH_jlgb9TY3WYG6FF9/view?usp=sharing The series is available at u-boot-dm/bme-working Sample log on rpi_3_32b: U-Boot 2021.10-rc2-00043-gccd453aa918-dirty (Aug 28 2021 - 13:58:46 -0600) DRAM: 992 MiB RPI 3 Model B (0xa22082) MMC: mmc@7e202000: 0, sdhci@7e300000: 1 Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... In: serial Out: vidconsole Err: vidconsole Net: No ethernet found. starting USB... Bus usb@7e980000: USB DWC2 scanning bus usb@7e980000 for devices... usb_kbd usb_kbd: Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0 Scanning for bootflows in all bootmethods Seq Type State Uclass Part Name Filename --- ----------- ------ -------- ---- ------------------------ ---------------- Scanning bootmethod 'mmc@7e202000.bootmethod': 0 efi-loader loaded mmc 1 mmc@7e202000.bootmethod.p efi/boot/bootarm.efi ** Booting bootflow 'mmc@7e202000.bootmethod.part_1' Scanning disk mmc@7e202000.blk... ** Unrecognized filesystem type ** Card did not respond to voltage select! : -110 Scanning disk sdhci@7e300000.blk... Disk sdhci@7e300000.blk not ready Found 4 disks No EFI system partition Booting /efi\boot Waiting for Ethernet connection... done. Fedora (5.11.12-300.fc34.armv7hl) 34 (Workstation Edition) UEFI Firmware Settings Use the ▲ and ▼ keys to change the selection. Press 'e' to edit the selected item, or 'c' for a command prompt. Press Escape to return to the previous menu. The selected entry will be started automatically in 0s. Changes in v2: - Free the memory buffer, to avoid running out of memory - Unmap the file - Reorder struct sandbox_mmc_priv Simon Glass (41): lib: Add a way to find the postiion of a trailing number Makefile: Allow LTO to be disabled for a build test/py: Allow passing input to a program sandbox: Support unmapping a file sandbox: mmc: Support a backing file mmc: Allow for children other than the block device mbr: Correct verification check disk: part_dos: Fix a NULL pointer error common: Allow a smaller console-recording pre-reloc dm: core: Add tests for stringlist functions dm: core: Fix handling of uclass pre_unbind method dm: core: Fix up string-function documentation dm: core: Add a way to obtain a string list dm: core: Allow finding children / uclasses by partial name dm: core: Add a way to count the devices in a uclass sandbox: Enable HEXDUMP for sandbox_flattree test/py: Relax the naming rules for unit tests test/py: Raise a ValueError if a command fails bootstd: Add the concept of a bootflow bootstd: Add the bootstd uclass and core implementation bootstd: Add the bootdev uclass bootstd: Add the bootmeth uclass and helpers bootstd: Add support for bootflows bootstd: Add a bootdev command bootstd: Add a bootflow ommand bootstd: Add a bootmeth command bootstd: Add an implementation of distro boot bootstd: mmc: Add a bootdev driver bootstd: ethernet: Add a bootdev driver bootstd: Add an implementation of distro PXE boot bootstd: Add an implementation of EFI boot bootstd: Add a system bootdev for strange boot methods bootstd: Add an implementation of EFI bootmgr bootstd: Add a sandbox bootmeth driver bootstd: usb: Add a bootdev driver test: fastboot: Avoid using mmc1 test: dm: Restart USB before assuming it is stopped bootstd: Add tests for bootstd including all uclasses bootstd: Add setup for the bootflow tests bootstd: doc: Add documentation RFC: Switch rpi over to use bootstd MAINTAINERS | 21 + Makefile | 18 +- arch/arm/config.mk | 4 +- arch/arm/include/asm/global_data.h | 2 +- arch/sandbox/cpu/os.c | 10 + arch/sandbox/dts/test.dts | 19 + boot/Kconfig | 77 ++- boot/Makefile | 14 + boot/bootdev-uclass.c | 439 ++++++++++++++ boot/bootflow.c | 576 ++++++++++++++++++ boot/bootmeth-uclass.c | 59 ++ boot/bootmeth_distro.c | 217 +++++++ boot/bootmeth_efi.c | 263 ++++++++ boot/bootmeth_efi_mgr.c | 84 +++ boot/bootmeth_pxe.c | 183 ++++++ boot/bootmeth_sandbox.c | 67 +++ boot/bootstd-uclass.c | 176 ++++++ boot/system_bootdev.c | 64 ++ cmd/Kconfig | 15 + cmd/Makefile | 1 + cmd/bootdev.c | 120 ++++ cmd/bootflow.c | 386 ++++++++++++ cmd/bootmeth.c | 158 +++++ cmd/mbr.c | 8 +- common/Kconfig | 10 + common/console.c | 4 +- common/usb_storage.c | 12 + configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/sandbox_defconfig | 3 +- configs/sandbox_flattree_defconfig | 4 +- configs/tbs2910_defconfig | 1 + disk/part_dos.c | 10 +- doc/build/gcc.rst | 17 + doc/develop/bootstd.rst | 600 +++++++++++++++++++ doc/develop/distro.rst | 3 + doc/develop/index.rst | 1 + doc/device-tree-bindings/bootdev.txt | 26 + doc/device-tree-bindings/bootmeth.txt | 31 + doc/device-tree-bindings/bootstd.txt | 36 ++ doc/device-tree-bindings/mmc/sandbox,mmc.txt | 18 + doc/usage/bootdev.rst | 135 +++++ doc/usage/bootflow.rst | 427 +++++++++++++ doc/usage/bootmeth.rst | 106 ++++ doc/usage/index.rst | 3 + drivers/core/device-remove.c | 9 +- drivers/core/device.c | 13 +- drivers/core/of_access.c | 3 +- drivers/core/ofnode.c | 26 + drivers/core/read.c | 6 + drivers/core/uclass.c | 29 +- drivers/mmc/Makefile | 5 + drivers/mmc/mmc-uclass.c | 27 +- drivers/mmc/mmc_bootdev.c | 62 ++ drivers/mmc/sandbox_mmc.c | 60 +- drivers/usb/host/Makefile | 4 + drivers/usb/host/usb_bootdev.c | 61 ++ include/bootdev.h | 258 ++++++++ include/bootflow.h | 304 ++++++++++ include/bootmeth.h | 156 +++++ include/bootstd.h | 80 +++ include/configs/rpi.h | 41 +- include/distro.h | 24 + include/dm/device.h | 12 + include/dm/ofnode.h | 24 +- include/dm/read.h | 28 + include/dm/uclass-id.h | 3 + include/dm/uclass-internal.h | 14 +- include/dm/uclass.h | 17 + include/mmc.h | 12 +- include/os.h | 9 + include/test/suites.h | 2 + include/vsprintf.h | 18 + lib/strto.c | 14 +- net/Kconfig | 9 + net/Makefile | 1 + net/eth-uclass.c | 8 + net/eth_bootdev.c | 101 ++++ test/Makefile | 1 + test/boot/Makefile | 5 + test/boot/bootdev.c | 200 +++++++ test/boot/bootflow.c | 398 ++++++++++++ test/boot/bootmeth.c | 90 +++ test/boot/bootstd_common.c | 35 ++ test/boot/bootstd_common.h | 27 + test/cmd_ut.c | 7 + test/dm/blk.c | 6 + test/dm/fastboot.c | 4 +- test/dm/ofnode.c | 96 +++ test/py/conftest.py | 2 +- test/py/multiplexed_log.py | 10 +- test/py/tests/bootstd/mmc1.img.xz | Bin 0 -> 4448 bytes test/py/tests/test_ut.py | 103 ++++ test/py/u_boot_utils.py | 5 +- 94 files changed, 6765 insertions(+), 94 deletions(-) create mode 100644 boot/bootdev-uclass.c create mode 100644 boot/bootflow.c create mode 100644 boot/bootmeth-uclass.c create mode 100644 boot/bootmeth_distro.c create mode 100644 boot/bootmeth_efi.c create mode 100644 boot/bootmeth_efi_mgr.c create mode 100644 boot/bootmeth_pxe.c create mode 100644 boot/bootmeth_sandbox.c create mode 100644 boot/bootstd-uclass.c create mode 100644 boot/system_bootdev.c create mode 100644 cmd/bootdev.c create mode 100644 cmd/bootflow.c create mode 100644 cmd/bootmeth.c create mode 100644 doc/develop/bootstd.rst create mode 100644 doc/device-tree-bindings/bootdev.txt create mode 100644 doc/device-tree-bindings/bootmeth.txt create mode 100644 doc/device-tree-bindings/bootstd.txt create mode 100644 doc/device-tree-bindings/mmc/sandbox,mmc.txt create mode 100644 doc/usage/bootdev.rst create mode 100644 doc/usage/bootflow.rst create mode 100644 doc/usage/bootmeth.rst create mode 100644 drivers/mmc/mmc_bootdev.c create mode 100644 drivers/usb/host/usb_bootdev.c create mode 100644 include/bootdev.h create mode 100644 include/bootflow.h create mode 100644 include/bootmeth.h create mode 100644 include/bootstd.h create mode 100644 include/distro.h create mode 100644 net/eth_bootdev.c create mode 100644 test/boot/Makefile create mode 100644 test/boot/bootdev.c create mode 100644 test/boot/bootflow.c create mode 100644 test/boot/bootmeth.c create mode 100644 test/boot/bootstd_common.c create mode 100644 test/boot/bootstd_common.h create mode 100644 test/py/tests/bootstd/mmc1.img.xz -- 2.33.0.1079.g6e70778dc9-goog