summaryrefslogtreecommitdiff
path: root/boot/bootdev-uclass.c
AgeCommit message (Collapse)Author
45 hoursuclass: Cleanup uclass_find_next_deviceAndrew Goodbody
uclass_find_next_device always returns 0, so instead make it a void and update calling sites. Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
2025-04-03boot: Handle running out of labelsSimon Glass
If only a single label is provided in the list, bootdev_next_label() does not operate correctly and reads beyond the end of the pointer list. Fix this by adding a new check. Also add a note to convert this array to an alist Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03boot: Consider non-bootable partitionsSimon Glass
Any 'bootable' flag in a DOS partition causes boostd to only scan bootable partitions for that media. This can mean that extlinux.conf files on the root disk are missed. Put this logic behind a flag and update the documentation. For now, the flag is enabled, to preserve the existing behaviour of bootstd which is to ignore non-bootable partitions so long as there is at least one bootable partition on the disk. Future work may provide a command (or some other mechanism) to control this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-15Merge patch series "bootstd: Support recording images"Tom Rini
Simon Glass <sjg@chromium.org> says: This series provides a way to keep track of the images used in bootstd, including the type of each image. At present this is sort-of handled by struct bootflow but in quite an ad-hoc way. The structure has become quite large and is hard to query. Future work will be able to reduce its size. Ultimately the 'bootflow info' command may change to also show images as a list, but that is left for later, as this series is already fairly long. So for now, just introduce the concept and adjust bootstd to use it, with a simple command to list the images. This series includes various alist enhancements, to make use of this new data structure a little easier. [trini: Drop patch 18 and 19 for now due to size considerations] Link: https://lore.kernel.org/r/20241115231926.211999-1-sjg@chromium.org
2025-01-15bootstd: Export bootdev_get_from_blk()Simon Glass
Export this function so it can be used from other files. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-15bootstd: Move the bootflow list into an alistSimon Glass
Use an alist for this data structure as it is somewhat simpler to manage. This means that bootstd holds a simple list of bootflow structs and can drop it at will, without chasing down lists. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-15bootstd: Drop the bootdev-specific list of bootflowsSimon Glass
This list is only used by two functions, which can be updated to iterate through the global list. Take this approach, which allows the bootdev list to be dropped. Overall this makes the code slightly more complicated, but will allow moving the bootflow list into an alist Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-15bootstd: Move bootflow-clearing to bootstdSimon Glass
This relates to more than just the bootdev, since there is a global list of bootflows. Move the function to the bootstd file and rename it. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-01-15bootstd: Move bootflow-adding to bootstdSimon Glass
This relates to more than just the bootdev, since there is a global list of bootflows. Move the function to the bootstd file and rename it. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-27bootstd: Avoid sprintf() in SPL when creating bootdevsSimon Glass
The name of the bootdev device is not that important, particular in SPL. Save a little code space by using a simpler name. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-12Revert "Merge patch series "vbe: Series part E""Tom Rini
This reverts commit 1fdf53ace13f745fe8ad4d2d4e79eed98088d555, reversing changes made to e5aef1bbf11412eebd4c242b46adff5301353c30. I had missed that this caused too much size growth on rcar3_salvator-x. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-12-12bootstd: Avoid sprintf() in SPL when creating bootdevsSimon Glass
The name of the bootdev device is not that important, particular in SPL. Save a little code space by using a simpler name. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-10-18bootstd: Avoid calling unavailable block functionsSimon Glass
When BLK is not enabled but BOOTSTD is, some features of standard boot become unavailable. Add a check for this in the only site that is currently apparent. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-08-27bootstd: Make bootdev_next_prio() continue after failureSimon Glass
When a device fails to probe, the next device should be tried, until either we find a suitable device or run out of devices. A device should never be tried twice. When we run out of devices of a particular priority, the hunter should be used to generate devices of the next priority. Only if all attempts fail should this function return an error. Update the function to use the latent 'found' boolean to determine whether another loop iteration is warranted, rather than setting 'dev' to NULL, which creates confusion, suggesting that no devices have been scanned and the whole process is starting from the beginning. Note that the upcoming bootflow_efi() test is used to test this behaviour. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/17
2024-08-27Revert "bootdev: avoid infinite probe loop"Simon Glass
This turns out to be insufficient to fix the problem, since when bootdev_next_prio() exits, the caller has no idea that this really is the end. Nor is it, since there may be other devices which should be checked. The caller iterates which calls iter_incr() which calls bootdev_next_prio() again, which finds the same device and the loop continues. We never did create a test for this[1], which makes it hard to be sure which problem was fixed. The original code had the virtue of staying in the loop looking for a bootdev, so let's go back to that and try to fix this another way. A future patch will make bootdev_next_prio() continue after failure which should provide same effect. This reverts commit 9d92c418acfb7576e12e2bd53fed294bb9543724. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-06boot: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from all "boot/" files and when needed add missing include files directly. Signed-off-by: Tom Rini <trini@konsulko.com>
2024-03-04bootstd: support scanning a single partitionNam Cao
The "bootflow" command currently doesn't support scanning a single partition. This is inconvenient in setups with multiple bootable partitions within a single disk, but only one is desired. Support scanning a single disk partition. Specifically, support the syntax: bootflow scan mmc1:4 which scans only mmc device 1, partition 4. Signed-off-by: Nam Cao <namcao@linutronix.de>
2024-03-02bootdev: drop unnecessary assert on bootflow->bdevThomas Weißschuh
Not all flows have a device and the function already contains logic to handle this case. Fixes: eccb25cd5922 ("bootstd: Allow the bootdev to be optional in bootflows") Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
2024-01-18bootdev: avoid infinite probe loopCaleb Connolly
Sometimes, when only one bootdev is available, and it fails to probe, we end up in an infinite loop calling probe() on the same device over and over. With only debug level log output. Break the loop if we fail to probe the same device twice in a row, and promote the probe failure message to log_warning(). Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Dragan Simic <dsimic@manjaro.org>
2023-11-10bootstd: Skip over bad device during bootflows scanningTony Dinh
During bootstd scanning for bootdevs, if bootdev_hunt_drv() encounters a device not found error (e.g. ENOENT), let it return a successful status so that bootstd will continue scanning the next devices, not stopping prematurely. Background: During scanning for bootflows, it's possible for bootstd to encounter a faulty device controller. Also when the same u-boot is used for another variant of the same board, some device controller such as SATA might not exist. I've found this issue while converting the Marvell Sheevaplug board to use bootstd. This board has 2 variants, the original Sheevaplug has MMC and USB only, but the later variant comes with USB, MMC, and eSATA ports. We have been using the same u-boot (starting with CONFIG_IDE and later with DM CONFIG_SATA) for both variants. This worked well with the old envs-scripting booting scheme. Signed-off-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-13bootstd: Scan all bootdevs in a boot_targets entrySimon Glass
When the boot_targets environment variable is used with the distro-boot scripts, each device is included individually. For example, if there are three mmc devices, then we will have something like: boot_targets="mmc0 mmc1 mmc2" In contrast, standard boot supports specifying just the uclass, i.e.: boot_targets="mmc" The intention is that this should scan all MMC devices, but in fact it currently only scans the first. Update the logic to handle this case, without required BOOTSTD_FULL to be enabled. I believe at least three people reported this, but I found two. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Date Huang <tjjh89017@hotmail.com> Reported-by: Vincent Stehlé <vincent.stehle@arm.com>
2023-09-22bootstd: Keep track of use of usb stopSimon Glass
When 'usb stop' is run, doing 'bootflow scan' does not run the USB hunter again so does not see any devices. Fix this by telling bootstd about the state of USB. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25bootstd: Support bootmeths which can scan any partitionSimon Glass
Some bootmeths support scanning a partition without a filesystem on it. Add a flag to support this. This will allow the ChromiumOS bootmeth to find kernel partition, which are stored in a special format, without a filesystem. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-25part: Add an accessor for struct disk_partition sys_indSimon Glass
This field is only present when a CONFIG is set. To avoid annoying #ifdefs in the source code, add an accessor. Update the only usage. Note that the accessor is optional. It can be omitted if it is known that the option is enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-09bootstd: Add some more debugging in the bootdev uclassSimon Glass
Add some more output to make it easier to see what is going wrong when a bootdev hunter fails. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-08-09bootstd: Rename bootdev_setup_sibling_blk()Simon Glass
This name is a little confusing since it suggests that it sets up the sibling block device. In fact it sets up a bootdev for it. Rename the function to make this clearer. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-08-02boot: fix bootdev_list()Heinrich Schuchardt
uclass_get_device_by_name() is meant to return 0 or a negative error code. simple_itoa() cannot handle negative numbers. This leads to output like: => bootdev list -p Seq Probed Status Uclass Name --- ------ ------ -------- ------------------ c [ ] 18446744073709551614 spi_flash spi.bin@0.bootdev Convert the status to a positive number. Now we get Seq Probed Status Uclass Name --- ------ ------ -------- ------------------ c [ ] 2 spi_flash spi.bin@0.bootdev Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13bootstd: Work around missing partition 1Simon Glass
If there is no partition numbered 1, we decide that there are no partitions at all. That may not be correct, since at least one Debian installed has just a single partition numbered 2. Continue searching up to partition 3, just in case. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26bootstd: Adjust code ordering to work around compiler quirkSimon Glass
At present when debugging is off, bootdev_find_in_blk() sometimes fails to find a valid bootflow, e.g. with virtio. Accessing the 'blk' variable later in the function seems to correct it. Move the 'ret' check before the debug statement and set the block device again aftewards, to work around this. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26bootstd: Report missing labels only when askedSimon Glass
Use the -l flag to indicate whether to report missing uclasses. Also try to be more helpful when no devices are found. For example, when we see something 'scsi0' requested and nothing was found, this indicates that there are no SCSI devices, so show a suitable message. Move messages out of the low-level functions so that silent operation is possible. This means they are never reported unless BOOTSTD_FULL is enabled, since the -l flag cannot otherwise be set. Suggested-by: Tom Rini <trini@konsulko.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08bootflow: Rename bootflow_flags_tSimon Glass
These flags actually relate to the iterator, not the bootflow struct itself. Rename them. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-06bootstd: Probe the block device before useSimon Glass
In some cases the block device is obtained but is not probed, since it is a sibling of the bootdev. Make sure it is probed, so it can be used without any trouble. This fixes a bug with virtio, where the device is accessed before it has been set up by the virtio uclass. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 201417d700a ("bootstd: Add the bootdev uclass") Reported-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-23bootstd: Add a little more logging of bootflowsSimon Glass
Add some logging to aid debugging of problems with bootflows. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23bootstd: Allow scanning a single bootdev labelSimon Glass
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 Glass
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: Allow iterating to the next bootdev priortiySimon Glass
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 Glass
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 Glass
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 Glass
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 Glass
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: Treat DHCP and PXE as bootdev labelsSimon Glass
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: Add a SPI flash bootdevSimon Glass
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-23bootstd: Move label parsing into its own functionSimon Glass
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: Only scan bootable partitionsSimon Glass
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-23bootstd: Support running bootdev huntersSimon Glass
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 Glass
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-23bootstd: Add a default method to get bootflowsSimon Glass
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>
2023-01-23dm: mmc: Use bootdev_setup_sibling_blk()Simon Glass
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>