Skip to content

bootstd: Allow migration from distro_bootcmd scripts

Simon Glass u-boot 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest70 patches 9 repliesIn review
  2. v270 of 71 patches 16 repliesSuperseded
  3. v171 patches 5 repliesSuperseded

Changes in v3 from the cover letter

- Rebase to -master

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/70dm: core: Correct ordering of uclasses IDsinclude/dm/uclass-id.h+2 -21 reply
2/70dm: core: Support sorting devices with dm treecmd/dm.c doc/usage/cmd/dm.rst drivers/core/dump.c +2 more+114 -120 replies
3/70dm: test: Correct assertion in dm_test_part()test/dm/part.c+4 -80 replies
4/70lib: Add a function to split a string into substringsinclude/vsprintf.h lib/strto.c test/str_ut.c+147 -00 replies
5/70bootstd: Remove special-case code for boot_targetsboot/bootdev-uclass.c boot/bootstd-uclass.c include/bootstd.h+32 -310 replies
6/70bootstd: Simplify locating existing bootdevsboot/bootdev-uclass.c+5 -110 replies
7/70test: Fix the help for the ut commandtest/cmd_ut.c+1 -10 replies
8/70test: Drop duplicate restore of DM statetest/test-main.c+0 -40 replies
9/70sandbox: mmc: Start off with a zeroed filedrivers/mmc/sandbox_mmc.c+1 -10 replies
10/70vbe: Avoid a build failure when bloblist is not enabledcmd/vbe.c+5 -20 replies
11/70vbe: sandbox: Drop VBE node in chosenarch/sandbox/dts/sandbox.dtsi+0 -130 replies
12/70dm: part: Update test to use mmc2test/dm/part.c+6 -68 replies
13/70dm: test: Correct ordering of DM setuptest/boot/bootflow.c test/test-main.c+14 -70 replies
14/70ide: Drop non-DM code for BLKdrivers/block/ide.c+1 -410 replies
15/70dm: mmc: Use bootdev_setup_sibling_blk()boot/bootdev-uclass.c drivers/mmc/mmc-uclass.c include/bootdev.h+35 -140 replies
16/70bootstd: Add a default method to get bootflowsboot/bootdev-uclass.c drivers/mmc/mmc_bootdev.c drivers/usb/host/usb_bootdev.c +1 more+29 -520 replies
17/70sandbox: Allow ethernet to be disabled at runtimearch/sandbox/cpu/state.c arch/sandbox/include/asm/state.h arch/sandbox/include/asm/test.h +2 more+62 -00 replies
18/70sandbox: Allow ethernet bootdevs to be disabled for testsinclude/net.h include/test/test.h net/eth-uclass.c +1 more+48 -20 replies
19/70sandbox: Enable the Ethernet bootdevconfigs/sandbox_defconfig configs/sandbox_flattree_defconfig+0 -20 replies
20/70lib: Support printing an error stringlib/vsprintf.c+12 -00 replies
21/70event: Correct duplicate log message in event_notify()common/event.c+1 -10 replies
22/70efi: Improve logging in efi_disklib/efi_loader/efi_disk.c+21 -90 replies
23/70bootstd: Add the concept of a bootdev hunterboot/bootdev-uclass.c cmd/bootdev.c include/bootdev.h +2 more+176 -30 replies
24/70bootstd: Support running bootdev huntersboot/bootdev-uclass.c cmd/bootdev.c include/bootdev.h +1 more+84 -10 replies
25/70dm: usb: Mark the device name as alloced when bindingdrivers/usb/host/usb-uclass.c+2 -00 replies
26/70test: Add a generic function to skip delaysinclude/test/test.h+16 -00 replies
27/70bootstd: Add a USB hunterdrivers/usb/host/usb_bootdev.c test/boot/bootdev.c+33 -50 replies
28/70bootstd: Add an MMC hunterdrivers/mmc/mmc_bootdev.c test/boot/bootdev.c+16 -60 replies
29/70net: Add a function to run dhcpcmd/net.c include/net.h+50 -00 replies
30/70bootstd: Add a hunter for ethernetnet/eth_bootdev.c test/boot/bootdev.c+52 -290 replies
31/70part: Add a function to find the first bootable partitiondisk/part.c include/part.h test/boot/bootflow.c +3 more+49 -70 replies
32/70bootstd: Only scan bootable partitionsboot/bootdev-uclass.c include/bootflow.h test/boot/bootdev.c +1 more+50 -30 replies
33/70scsi: Correct allocation of block-device namedrivers/scsi/scsi.c+8 -20 replies
34/70scsi: Remove all children of SCSI devices before rescanningdrivers/scsi/scsi.c+13 -20 replies
35/70bootstd: Add a SCSI bootdevdrivers/scsi/Makefile drivers/scsi/scsi.c drivers/scsi/scsi_bootdev.c +1 more+86 -80 replies
36/70bootstd: Add an IDE bootdevconfigs/sandbox_flattree_defconfig drivers/block/ide.c test/boot/bootdev.c+62 -60 replies
37/70bootstd: Add an NVMe bootdevdrivers/nvme/nvme-uclass.c drivers/nvme/nvme.c test/boot/bootdev.c+68 -60 replies
38/70virtio: Avoid repeating a long expressiondrivers/virtio/virtio-uclass.c+5 -50 replies
39/70virtio: Fix returning -ENODEVdrivers/virtio/virtio-uclass.c+1 -10 replies
40/70virtio: Avoid strange behaviour on removaldrivers/virtio/virtio_sandbox.c test/dm/virtio_device.c+3 -130 replies
41/70virtio: Add a block devicearch/sandbox/dts/test.dts drivers/virtio/virtio_sandbox.c+8 -10 replies
42/70bootstd: Add a virtio bootdevdrivers/virtio/virtio-uclass.c test/boot/bootdev.c+57 -50 replies
43/70ata: Don't try to use non-existent portsdrivers/ata/ahci.c+6 -00 replies
44/70bootstd: Rename bootdev checkersboot/bootflow.c boot/bootmeth_distro.c boot/bootmeth_efi.c +5 more+15 -150 replies
45/70bootstd: Allow reading an EFI file from the networkboot/bootmeth_efi.c+109 -80 replies
46/70bootstd: Include the device tree in the bootflowboot/bootflow.c cmd/bootflow.c include/bootflow.h +1 more+14 -00 replies
47/70bootstd: Support reading the device tree with EFIboot/bootmeth_efi.c+99 -60 replies
48/70bootstd: Set the distro_bootpart env var with scriptsboot/bootmeth_script.c include/bootflow.h+6 -00 replies
49/70bootstd: Update docs on bootmeth_try_file() for sandboxinclude/bootflow.h include/bootmeth.h+2 -20 replies
50/70bootstd: Move label parsing into its own functionboot/bootdev-uclass.c+36 -120 replies
51/70bootstd: Add a new bootmeth method to set the bootflowboot/bootmeth-uclass.c include/bootmeth.h+44 -00 replies
52/70sandbox: Allow SPI flash bootdevs to be disabled for testsarch/sandbox/cpu/state.c arch/sandbox/include/asm/state.h arch/sandbox/include/asm/test.h +2 more+49 -00 replies
53/70bootstd: Add a SPI flash bootdevboot/bootdev-uclass.c boot/bootflow.c configs/sandbox_defconfig +7 more+144 -100 replies
54/70bootstd: Support reading a script from network or SPI flashboot/bootmeth_script.c+80 -130 replies
55/70bootstd: Treat DHCP and PXE as bootdev labelsboot/bootdev-uclass.c boot/bootmeth_efi.c boot/bootmeth_pxe.c +7 more+81 -340 replies
56/70bootstd: Use hunters when scanning for bootflowscmd/bootflow.c include/bootflow.h+20 -60 replies
57/70bootstd: Allow hunting for bootdevs of a given priorityboot/bootdev-uclass.c include/bootdev.h test/boot/bootdev.c+61 -00 replies
58/70bootstd: Add a new pre-scan priority for bootdevsboot/bootdev-uclass.c doc/develop/bootstd.rst drivers/block/ide.c +9 more+84 -440 replies
59/70bootstd: Allow hunting for a bootdev by labelboot/bootdev-uclass.c include/bootdev.h include/bootflow.h +3 more+195 -50 replies
60/70bootstd: Allow iterating to the next label in a listboot/bootdev-uclass.c include/bootdev.h include/bootflow.h +1 more+123 -30 replies
61/70bootstd: Allow iterating to the next bootdev priortiyboot/bootdev-uclass.c include/bootdev.h include/bootflow.h +1 more+165 -00 replies
62/70extension: Refactor to allow non-command usagecmd/extension_board.c+14 -40 replies
63/70bootstd: Add a hunter for the extension featurecmd/extension_board.c test/boot/bootdev.c test/boot/bootflow.c +1 more+63 -240 replies
64/70bootstd: Switch bootdev scanning to use labelsboot/bootdev-uclass.c boot/bootflow.c include/bootdev.h +3 more+147 -1520 replies
65/70bootstd: Allow scanning a single bootdev labelboot/bootdev-uclass.c boot/bootflow.c cmd/bootflow.c +4 more+166 -760 replies
66/70bootstd: Drop the old bootflow_scan_first()boot/bootflow.c cmd/bootflow.c include/bootflow.h +2 more+19 -450 replies
67/70bootstd: Record the bootdevs used during scanningboot/bootflow.c include/bootflow.h test/boot/bootdev.c+63 -430 replies
68/70bootstd: Add a little more logging of bootflowsboot/bootdev-uclass.c boot/bootflow.c+5 -00 replies
69/70bootstd: Update documentation for new featuresdoc/develop/bootstd.rst doc/develop/driver-model/nvme.rst doc/usage/cmd/bootdev.rst +1 more+216 -700 replies
70/70rockchip: Convert rockpro64-rk3399 to use standard bootinclude/configs/rk3399_common.h include/configs/rockchip-common.h+3 -40 replies

Reviews trailers per patch

2 of 70 patches have a Reviewed-by or Acked-by.

PatchKever YangRamon Fried
1/70
2/70
3/70
4/70
5/70
6/70
7/70
8/70
9/70
10/70
11/70
12/70
13/70
14/70
15/70
16/70
17/70
18/70
19/70
20/70
21/70
22/70
23/70
24/70
25/70
26/70
27/70
28/70
29/70R-b
30/70
31/70
32/70
33/70
34/70
35/70
36/70
37/70
38/70
39/70
40/70
41/70
42/70
43/70
44/70
45/70
46/70
47/70
48/70
49/70
50/70
51/70
52/70
53/70
54/70
55/70
56/70
57/70
58/70
59/70
60/70
61/70
62/70
63/70
64/70
65/70
66/70
67/70
68/70
69/70
70/70R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/70] bootstd: Allow migration from distro_bootcmd scripts

So far, standard boot does not replicate all the of the functionality of the distro_bootcmd scripts. In particular it lacks some bootdevs and some of the bootmeths are incomplete.

Also there is currently no internal mechanism to enumerate buses in order to discover bootdevs, e.g. with USB.

This series addresses these shortcomings:

- Adds the concept of a 'bootdev hunter' to enumerate buses, etc. in an effort to find bootdevs of a certain priority
- Adds bootdevs for SCSI, IDE, NVMe, virtio, SPI flash
- Handles PXE and DHCP properly
- Supports reading the device tree with EFI and reading scripts from the network

It also tidies up label processing, so it is possible to use:

bootflow scan mmc2

to scan just one MMC device (with BOOTSTD_FULL).

As before this implementation still relies on CONFIG_CMDLINE being enabled, mostly for the network stack. Further work would be required to disentangle that.

Quite a few tests are added but there are some gaps:

- SPI flash bootdev
- EFI FDT loading

Note that SATA works via SCSI (CONFIG_SCSI_AHCI) and does not use driver model. Only pogo_v4 seems to be affected. Probably all thats is needed is to call bootdev_setup_sibling_blk() in the Marvell SATA driver.

Also, while it would be possible to init MMC in a bootdev hunter, there is no point since U-Boot always inits MMC on startup, if present.

With this series it should be possible to migrate boards to standard boot by removing the inclusion of config_distro_bootcmd.h and instead adding a suitable value for boot_targets to the environment, e.g.:

boot_targets=mmc1 mmc0 nvme scsi usb pxe dhcp spi

Thus it is possible to boot automatically without scripts and boards can use a text-based environment instead of the config.h files.

To demonstrate this, rockpro64-rk3399 is migrated to standard boot in this series. Full migration could probably be automated using a script, similar in concept to moveconfig:

- obtain the board environment via 'make u-boot-initial-env'
- get the value of "boot_targets"
- drop config_distro_bootcmd.h from the config.h file
- rebuild again to get the environment without distro scripts
- write the environment (adding boot_targets) to board.env
- remove CONFIG_EXTRA_ENV_SETTINGS from the config.h file

This series is based on top of the boot menu series v3 [1]. The tree is available at u-boot-dm/dis-working

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=335364

Changes in v3:
- Rebase to -master

Changes in v2:
- Rebase to -next

Simon Glass (70):
dm: core: Correct ordering of uclasses IDs
dm: core: Support sorting devices with dm tree
dm: test: Correct assertion in dm_test_part()
lib: Add a function to split a string into substrings
bootstd: Remove special-case code for boot_targets
bootstd: Simplify locating existing bootdevs
test: Fix the help for the ut command
test: Drop duplicate restore of DM state
sandbox: mmc: Start off with a zeroed file
vbe: Avoid a build failure when bloblist is not enabled
vbe: sandbox: Drop VBE node in chosen
dm: part: Update test to use mmc2
dm: test: Correct ordering of DM setup
ide: Drop non-DM code for BLK
dm: mmc: Use bootdev_setup_sibling_blk()
bootstd: Add a default method to get bootflows
sandbox: Allow ethernet to be disabled at runtime
sandbox: Allow ethernet bootdevs to be disabled for tests
sandbox: Enable the Ethernet bootdev
lib: Support printing an error string
event: Correct duplicate log message in event_notify()
efi: Improve logging in efi_disk
bootstd: Add the concept of a bootdev hunter
bootstd: Support running bootdev hunters
dm: usb: Mark the device name as alloced when binding
test: Add a generic function to skip delays
bootstd: Add a USB hunter
bootstd: Add an MMC hunter
net: Add a function to run dhcp
bootstd: Add a hunter for ethernet
part: Add a function to find the first bootable partition
bootstd: Only scan bootable partitions
scsi: Correct allocation of block-device name
scsi: Remove all children of SCSI devices before rescanning
bootstd: Add a SCSI bootdev
bootstd: Add an IDE bootdev
bootstd: Add an NVMe bootdev
virtio: Avoid repeating a long expression
virtio: Fix returning -ENODEV
virtio: Avoid strange behaviour on removal
virtio: Add a block device
bootstd: Add a virtio bootdev
ata: Don't try to use non-existent ports
bootstd: Rename bootdev checkers
bootstd: Allow reading an EFI file from the network
bootstd: Include the device tree in the bootflow
bootstd: Support reading the device tree with EFI
bootstd: Set the distro_bootpart env var with scripts
bootstd: Update docs on bootmeth_try_file() for sandbox
bootstd: Move label parsing into its own function
bootstd: Add a new bootmeth method to set the bootflow
sandbox: Allow SPI flash bootdevs to be disabled for tests
bootstd: Add a SPI flash bootdev
bootstd: Support reading a script from network or SPI flash
bootstd: Treat DHCP and PXE as bootdev labels
bootstd: Use hunters when scanning for bootflows
bootstd: Allow hunting for bootdevs of a given priority
bootstd: Add a new pre-scan priority for bootdevs
bootstd: Allow hunting for a bootdev by label
bootstd: Allow iterating to the next label in a list
bootstd: Allow iterating to the next bootdev priortiy
extension: Refactor to allow non-command usage
bootstd: Add a hunter for the extension feature
bootstd: Switch bootdev scanning to use labels
bootstd: Allow scanning a single bootdev label
bootstd: Drop the old bootflow_scan_first()
bootstd: Record the bootdevs used during scanning
bootstd: Add a little more logging of bootflows
bootstd: Update documentation for new features
rockchip: Convert rockpro64-rk3399 to use standard boot

 arch/sandbox/cpu/state.c           |  30 ++
 arch/sandbox/dts/sandbox.dtsi      |  13 -
 arch/sandbox/dts/test.dts          |   6 +
 arch/sandbox/include/asm/state.h   |   2 +
 arch/sandbox/include/asm/test.h    |  30 ++
 boot/bootdev-uclass.c              | 551 +++++++++++++++++++---------
 boot/bootflow.c                    | 173 ++++++---
 boot/bootmeth-uclass.c             |  11 +
 boot/bootmeth_distro.c             |   2 +-
 boot/bootmeth_efi.c                | 220 ++++++++++-
 boot/bootmeth_efi_mgr.c            |   2 +-
 boot/bootmeth_pxe.c                |   5 +-
 boot/bootmeth_script.c             |  98 ++++-
 boot/bootstd-uclass.c              |  17 +-
 boot/vbe_simple_fw.c               |   2 +-
 cmd/bootdev.c                      |  42 ++-
 cmd/bootflow.c                     |  97 +++--
 cmd/dm.c                           |  10 +-
 cmd/extension_board.c              |  43 ++-
 cmd/net.c                          |  35 ++
 cmd/vbe.c                          |   7 +-
 common/event.c                     |   2 +-
 configs/sandbox_defconfig          |   2 +-
 configs/sandbox_flattree_defconfig |  10 +-
 disk/part.c                        |  16 +
 doc/develop/bootstd.rst            | 221 +++++++----
 doc/develop/driver-model/nvme.rst  |   2 +-
 doc/usage/cmd/bootdev.rst          |  48 ++-
 doc/usage/cmd/bootflow.rst         |  17 +-
 doc/usage/cmd/dm.rst               |   5 +-
 drivers/ata/ahci.c                 |   6 +
 drivers/block/ide.c                |  86 ++---
 drivers/core/dump.c                |  65 +++-
 drivers/mmc/mmc-uclass.c           |   2 +-
 drivers/mmc/mmc_bootdev.c          |  33 +-
 drivers/mmc/sandbox_mmc.c          |   2 +-
 drivers/mtd/spi/Kconfig            |   8 +
 drivers/mtd/spi/Makefile           |   1 +
 drivers/mtd/spi/sf-uclass.c        |  11 +
 drivers/mtd/spi/sf_bootdev.c       |  82 +++++
 drivers/nvme/nvme-uclass.c         |  54 +++
 drivers/nvme/nvme.c                |   5 +
 drivers/scsi/Makefile              |   7 +
 drivers/scsi/scsi.c                |  32 +-
 drivers/scsi/scsi_bootdev.c        |  62 ++++
 drivers/usb/host/usb-uclass.c      |   2 +
 drivers/usb/host/usb_bootdev.c     |  38 +-
 drivers/virtio/virtio-uclass.c     |  62 +++-
 drivers/virtio/virtio_sandbox.c    |  16 +-
 include/bootdev.h                  | 206 ++++++++++-
 include/bootflow.h                 | 134 +++++--
 include/bootmeth.h                 |  35 +-
 include/bootstd.h                  |  17 +-
 include/configs/rk3399_common.h    |   5 +-
 include/configs/rockchip-common.h  |   2 +
 include/dm/uclass-id.h             |   4 +-
 include/dm/util.h                  |   8 +-
 include/net.h                      |  31 ++
 include/part.h                     |   8 +
 include/test/test.h                |  72 ++++
 include/vsprintf.h                 |  24 ++
 lib/efi_loader/efi_disk.c          |  30 +-
 lib/strto.c                        |  41 +++
 lib/vsprintf.c                     |  12 +
 net/eth-uclass.c                   |  14 +-
 net/eth_bootdev.c                  |  68 ++--
 net/net.c                          |   4 +
 test/boot/bootdev.c                | 563 +++++++++++++++++++++++++++--
 test/boot/bootflow.c               | 138 +++++--
 test/boot/bootstd_common.c         |  19 +
 test/boot/bootstd_common.h         |  13 +
 test/cmd_ut.c                      |   2 +-
 test/dm/part.c                     |  37 +-
 test/dm/virtio_device.c            |   3 +
 test/py/tests/bootstd/mmc1.img.xz  | Bin 4448 -> 4480 bytes
 test/py/tests/test_dm.py           |  38 ++
 test/py/tests/test_ut.py           |  13 +-
 test/str_ut.c                      |  82 +++++
 test/test-main.c                   |  24 +-
 79 files changed, 3225 insertions(+), 715 deletions(-)
 create mode 100644 drivers/mtd/spi/sf_bootdev.c
 create mode 100644 drivers/scsi/scsi_bootdev.c
Signature · 1 line
2.39.0.246.g2a6d74b583-goog