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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
It is often useful to show an error code to give the user a clue as to
what went wrong. When error strings are compiled into U-Boot it is
possible to show a message as well.
But at present it is not very convenient, since code must check if the
error strings are present, then obtain the error string and use it in
a printf() string.
Add a %dE option which shows an error code along with an error string,
if available. This makes it easy to show one or both.
Signed-off-by: Simon Glass <sjg@chromium.org>
This bootdev is disabled at present since it messes with the tests. Now
that there is a way to disable networking at runtime, enable the driver.
This allows running tests with it if necessary.
Signed-off-by: Simon Glass <sjg@chromium.org>
Most tests don't want these and 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>
For bootstd tests it is seldom useful to have ethernet enabled. Add a way
to disable it, so that ethernet operations like tftpboot do nothing.
Signed-off-by: Simon Glass <sjg@chromium.org>
The code in these functions turns out to often be the same. Add a default
get_bootflow() function and allow the drivers to select it by setting
the method to NULL.
This saves a little code space.
Signed-off-by: Simon Glass <sjg@chromium.org>
At present MMC uses the bootdev_setup_for_dev() function to set up the
bootdev. This is because MMC only has one block-device child, so does not
need to worry about naming of the bootdev.
However this inconsistency with other bootdevs that use block devices is a
bit annoying. The only real reason for it is to have a name like
'mmc0.bootdev' instead of 'mmc0.blk.bootdev'.
Update bootdev_setup_sibling_blk() to drop '.blk' from the name where it
appears, thus removing the only reason to use the bootdev_setup_for_dev().
Switch MMC over to the subling function.
Signed-off-by: Simon Glass <sjg@chromium.org>
We must call dm_scan_other() after devices from the device tree have been
created, since that function behaves differently if there is no bootstd
device.
Adjust the logic to achieve this.
Also fix the bootflow_system() test which was relying on this broken
behaviour.
Signed-off-by: Simon Glass <sjg@chromium.org>
At present this test sets up a partition table on mmc1. But this is used
by the bootstd tests, so it is not possible to run those after this test
has run, without restarting the Python test harness.
This is inconvenient when running tests repeatedly with 'ut dm'. Move the
test to use mmc2, which is not used by anything.
Signed-off-by: Simon Glass <sjg@chromium.org>