aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-01-23rockchip: Convert rockpro64-rk3399 to use standard bootWIP/2022-01-23-bootstd-allow-migration-from-distro_bootcmd-scriptSimon Glass2-4/+3
Drop the use of scripts and rely on standard boot for all operation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-01-23bootstd: Update documentation for new featuresSimon Glass4-70/+216
Document the hunters and the new way that iteration works. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a little more logging of bootflowsSimon Glass2-0/+5
Add some logging to aid debugging of problems with bootflows. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Record the bootdevs used during scanningSimon Glass3-43/+63
Add a way to record the bootdevs used when scanning for bootflows. This is useful for testing. Enable this only with BOOTSTD_FULL and do the same for the progress reporting. Re-enable and update the affected tests now that we have this feature. For bootdev_test_order_default() there is no-longer any support for using the bootdev aliases to specify an ordering, so drop that part of the test. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Drop the old bootflow_scan_first()Simon Glass5-45/+19
This function is not used outside tests. Drop it and rename bootflow_scan_dev() since it is how we start a scan now. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Allow scanning a single bootdev labelSimon Glass7-76/+166
We want to support scanning a single label, like 'mmc' or 'usb0'. Add this feature by plumbing the label through to the iterator, setting a flag to indicate that only siblings of the initial device should be used. This means that scanning a bootdev by its name is not supported anymore. That feature doesn't seem very useful in practice, so it is no great loss. Add a test for bootdev_find_by_any() while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Switch bootdev scanning to use labelsSimon Glass6-152/+147
At present we set up the bootdev order at the start, then scan the bootdevs one by one. However this approach cannot be used with hunters, since the bootdevs may not exist until the hunter is used. Nor can we just run all the hunters at the start, since that violate's U-Boot's 'lazy init' requirement. It also increases boot time. So we need to adjust the algorithm to scan by labels instead. As a first step, drop the dev_order[] array in favour of a list of labels. Update the name of bootdev_setup_iter_order() to better reflect what it does. Update some related comments and log messages. Also disable a few tests until a later commit where we can use them. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a hunter for the extension featureSimon Glass4-24/+63
This needs to run before any bootdev is used, so add a hunter for it. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23extension: Refactor to allow non-command usageSimon Glass1-4/+14
The current extension code is designed to be used from commands. We want to add a boot driver which uses it. To help with this, split the code into the command processing and a function which actually does the scan. Really the extension code should be in common/ or use driver model, but this is a start. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Allow iterating to the next bootdev priortiySimon Glass4-0/+165
Add a function which moves to the next priority to be processed. This works by storing the current priority in the bootflow iterator. The logic to set this up is included in a subsequent commit. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Allow iterating to the next label in a listSimon Glass4-3/+123
Add a function which moves to the next label in a list of labels. This allows processing the boot_targets environment variable. This works using a new label list in the bootflow iterator. The logic to set this up is included in a subsequent commit. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Allow hunting for a bootdev by labelSimon Glass6-5/+195
Add a function to hunt for a bootdev label and find the bootdev produced by the hunter (or already present). Add a few extra flags so that we can distinguish between "mmc1", "mmc" and "1" which all need to be handled differently. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a new pre-scan priority for bootdevsSimon Glass12-44/+84
We need extensions to be set up before we start trying to boot any of the bootdevs. Add a new priority before all the others for tht sort of thing. Also add a 'none' option, so that the first one is not 0. While we are here, comment enum bootdev_prio_t fully and expand the test for the 'bootdev hunt' command. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Allow hunting for bootdevs of a given prioritySimon Glass3-0/+61
Add a way to run the hunter function for a particular priority, so that new bootdevs can be found. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Use hunters when scanning for bootflowsSimon Glass2-6/+20
Add a flag to control whether hunters are used when scanning for bootflows. Enable it by default and tidy up the flag comments a little. Fow now this has no effect, until a future patch enables this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Treat DHCP and PXE as bootdev labelsSimon Glass10-34/+81
These are associated with the ethernet boot device but do not match its uclass name, so handle them as special cases. Provide a way to pass flags through with the bootdev so that we know how to process it. The flags are checked by the bootmeths, to ensure that only the selected bootmeth is used. While these both use the network device, they work quite differently. It is common to run only one of these, or to run PXE before DHCP. Provide bootflow flags to control which methods are used. Check these in the two bootmeths so that only the chosen one is used. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Support reading a script from network or SPI flashSimon Glass1-13/+80
At present this bootmeth only supports a block device and the sandbox host filesystem. Add support for obtaining the script from a network device. Also implement the set_bootflow() method so that it is easy for other bootdevs (such as enabling SPI flash to support scripts). Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a SPI flash bootdevSimon Glass10-10/+144
Add a bootdev for SPI flash so that these devices can be used with standard boot. It only supports loading a script. Add a special case for the label, since we want to use "spi", not "spi_flash". Enable the new bootdev on sandbox. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23sandbox: Allow SPI flash bootdevs to be disabled for testsSimon Glass5-0/+49
Most tests don't want these and they can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a new bootmeth method to set the bootflowSimon Glass2-0/+44
Normally the bootmeth driver reads the bootflow from the bootdev, since it knows the correct way to do it. However it is easier for some bootdevs to handle this themselves. For example, reading from SPI flash is quite different from other devices. Add a way for the bootdev to pass a bootflow to the bootmeth, so that this can be supported. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Move label parsing into its own functionSimon Glass1-12/+36
This is complicated enough to merit its own function, particularly as we are about to add to it. Create a new label_to_uclass() function to decode a label. Also update the code to ignore an empty label or one consisting of just a number. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Update docs on bootmeth_try_file() for sandboxSimon Glass2-2/+2
Mention that this function is also used with a NULL block devices to access files on the host, when using sandbox. Update the comment on struct bootflow also. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Set the distro_bootpart env var with scriptsSimon Glass2-0/+6
This environment variable is supposed to be set so that the script knows which partition holds the script. Set it before invoking the script. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Support reading the device tree with EFISimon Glass1-6/+99
With EFI booting the device tree is required but is not actually specified in any way. The normal method is to use a fdtfile environment variable to get the filename, then look for that file on the media. Implement this in the bootmeth. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Include the device tree in the bootflowSimon Glass4-0/+14
Some bootmeths provide a way to load a device tree as well as the base OS image. Add a way to store this in the bootflow. Update the 'bootflow info' command to show this information. Note that the device tree is not allocated, but instead is stored at an address provided by an environment variable. This may need to be adjusted at some point, but for now it works well and fits in with the existing distro-boot scripts. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Allow reading an EFI file from the networkSimon Glass1-8/+109
At present this bootmeth only supports reading from a filesystem. Add support for reading from a network also, using DHCP with autoload. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Rename bootdev checkersSimon Glass8-15/+15
These functions return 0 if the check passes, so the names are somewhat confusing. Rename them. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23ata: Don't try to use non-existent portsSimon Glass1-0/+6
The controller indicates the number of ports but also has a port map which specifies which ports are actually valid. Make use of this to avoid trying to send commands to an invalid port. This avoids a crash on some controllers. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a virtio bootdevSimon Glass2-5/+57
Add a bootdev for virtio so that these devices can be used with standard boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23virtio: Add a block deviceSimon Glass2-1/+8
The test code for virtio is fairly simplistic and does not actually create a block device. Add a way to specify the device type in the device tree. Add a block device so that we can do more testing. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23virtio: Avoid strange behaviour on removalSimon Glass2-13/+3
This device does a check on removal which is better handled in the actual test. Move it. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23virtio: Fix returning -ENODEVSimon Glass1-1/+1
This has a special meaning in driver model. There is clearly a device, so it does not make sense to return this error code. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23virtio: Avoid repeating a long expressionSimon Glass1-5/+5
Use a local variable to hold this name, to reduce the amount of code that needs to be read. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add an NVMe bootdevSimon Glass3-6/+68
Add a bootdev for NVMe so that these devices can be used with standard boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add an IDE bootdevSimon Glass3-6/+62
Add a bootdev for IDE so that these devices can be used with standard boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a SCSI bootdevSimon Glass4-8/+86
Add a bootdev for SCSI so that these devices can be used with standard boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23scsi: Remove all children of SCSI devices before rescanningSimon Glass1-2/+13
At present this only unbinds block devices of a certain type. But SCSI device can have different types of children, including bootdevs. Unbind all children so tht everything is clean and ready for a new scan. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23scsi: Correct allocation of block-device nameSimon Glass1-2/+8
This should be allocated so that it does not go out of scope. Fix this and set the log category while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Only scan bootable partitionsSimon Glass4-3/+50
At present all partitions are scanned, whether marked bootable or not. Use only bootable partitions, defaulting to partition 1 if none is found. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23part: Add a function to find the first bootable partitionSimon Glass6-7/+49
If a disk has a bootable partition we are expected to use it to locate the boot files. Add a function to find it. To test this, update mmc1 to have two paritions, fixing up other tests accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a hunter for ethernetSimon Glass2-29/+52
Sometimes ethernet devices are attached to PCI. Since it is quick to scan, add this into the ethernet hunter. Run dhcp to establish the network connection. Drop this from the bootdev since that is not needed now. Update a log message for clarity. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23net: Add a function to run dhcpSimon Glass2-0/+50
At present this must be done by executing the command. Also it involves fiddling with the environment to determine the correct autoload behaviour. Ideally it should be possible to run network operations without even having the command line present (CONFIG_CMDLINE). For now, add a function to handle DHCP, so it can be called from a bootdev more easily. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2023-01-23bootstd: Add an MMC hunterSimon Glass2-6/+16
Add a hunter for MMC. This doesn't do anything at present, since MMC is currently set up when U-Boot starts. If MMC moves to lazy init then we can add a hunter function. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add a USB hunterSimon Glass2-5/+33
Add a hunter for USB which enumerates the bus to find new bootdevs. Update the tests and speed up bootdev_test_prio() while we are here, by dropping the USB delays. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23test: Add a generic function to skip delaysSimon Glass1-0/+16
At present this feature is sandbox-specific. For running tests on boards, we need a nop version. Add one. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23dm: usb: Mark the device name as alloced when bindingSimon Glass1-0/+2
Since usb_find_and_bind_driver() allocates the device name it should tell driver about that, to avoid memory leaks. Fix this. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Support running bootdev huntersSimon Glass4-1/+84
Add a way to run a bootdev hunter to find bootdevs of a certain type. Add this to the 'bootdev hunt' command. Test for this are added in a later patch, since a useful test needs some hunters to work with. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Add the concept of a bootdev hunterSimon Glass5-3/+176
Some bootdevs must be enumerated before they appear. For example, USB bootdevs are not visible until USB is enumerated. With standard boot this needs to happen automatically, since we only want to enumerate a bus if it is needed. Add a way to define bootdev 'hunters' which can be used to hunt for bootdevs of a given type. Track which ones have been used and add a command to list them. Include a clang work-around which seems to be needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23efi: Improve logging in efi_diskSimon Glass1-9/+21
When this fails it can be time-consuming to debug. Add some debugging to help with this. Also try to return error codes instead of just using -1. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23event: Correct duplicate log message in event_notify()Simon Glass1-1/+1
Use a different one for each call. Signed-off-by: Simon Glass <sjg@chromium.org>