summaryrefslogtreecommitdiff
path: root/boot
AgeCommit message (Collapse)AuthorFilesLines
2023-04-05image: Fix script execution from FIT images with external dataTobias Waldekranz1-1/+2
Update the script loading code to recognize when script data is stored externally from the FIT metadata (i.e., built with `mkimage -E`). Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-04android: boot: support bootconfigSafae Ouajih1-2/+56
Support Bootconfig feature. - The bootconfig feature replaces the androidboot.* kernel cmdline options. This was adapted from downstream [1] commit : 7af0a0506d4d ("cuttlefish: support bootconfig parameters"). Link:[1] https://android.googlesource.com/platform/external/u-boot/ Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: support boot image header version 3 and 4Safae Ouajih4-15/+58
Enable the support for boot image header version 3 and 4 using abootimg command. In order to use version 3 or 4: 1- Vendor boot image address should be given to abootimg cmd. abootimg addr $1 $vendor_boot_load_addr 2- "ramdisk_addr_r" env variable (ramdisk address) should be set to host the ramdisk : generic ramdisk + vendor ramdisk Replace "struct andr_boot_img_hdr_v0*" by "void *" in some functions since v3 and v4 are now supported as well. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: update android_image_get_dtb_img_addr to support v3, v4Safae Ouajih1-14/+33
Add support for boot image version 3 and 4 in android_image_get_dtb_img_addr(). Since the dtb is now included in vendor_boot image instead of boot image, extract the dtb address from vendor_boot image when a v3 or v4 is used. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: support extra command lineSafae Ouajih1-0/+11
In version 3 and 4 of boot image header, the vendor specific command line are located in vendor boot image. Thus, use extra command line to add those cmd to bootargs. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: ramdisk: support vendor ramdiskSafae Ouajih1-2/+11
Version 3 and 4 of boot image header introduced vendor boot ramdisk: Please check include/android_image.h for details. The ramdisk is now split into a generic ramdisk in boot image and a vendor ramdisk in vendor boot image. Support the new vendor ramdisk. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: update android_image_get_data to support v3, v4Safae Ouajih1-3/+77
Since boot image header version 3 and 4 introduced vendor boot image, use the following functions to fill the generic android structure : andr_image_data: - android_boot_image_v3_v4_parse_hdr() - android_vendor_boot_image_v3_v4_parse_hdr() Update android_image_get_data() to support v3 and v4 Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: add vendor boot image to prepare for v3, v4 supportSafae Ouajih4-26/+42
Introduce vendor boot image for version 3 and 4 of boot image header. The vendor boot image will hold extra information about kernel, dtb and ramdisk. This is done to prepare for boot image version 3 and 4 support. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: boot image header v3, v4 do not support recovery DTBOSafae Ouajih1-2/+2
android_image_get_dtbo() is used to get recovery DTBO via abootimg cmd. This is not supported in boot image header v3 and v4. Thus, print an error message when v1,v2 header version are not used. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: content print is not supported for v3, v4 header versionSafae Ouajih1-1/+5
Content print is not supported for version 3 and 4 of boot image header. Thus, only print that content when v2 is used. Update android_print_contents() to print an error message when trying to print boot image header version 3 or 4 content. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: move to andr_image_data structureSafae Ouajih1-56/+65
Move from andr_boot_img_hdr_v0 to andr_image_data structure to prepare for boot image header version 3 and 4. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: kcomp: support andr_image_dataSafae Ouajih1-1/+74
andr_image_data structure is used as a global representation of boot image header structure. Introduce this new structure to support all boot header versions : v0,v1.v2.v3.v4 and to support v3 and v4 while maitaining support for v0,v1,v2. The need of using andr_image_data comes from the change of header structure in both version 3 and 4. Rework android_image_get_kcomp() to support this new struct. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: replace android_image_check_headerSafae Ouajih2-14/+5
With the new vendor boot image introduced in versions 3 and 4 of boot image header, the header check must be done for both boot image and vendor boot image. Thus, replace android_image_check_header() by is_android_boot_image_header() to only refer to boot image header check. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-04android: boot: rename andr_img_hdr -> andr_boot_img_hdr_v0Safae Ouajih2-15/+24
Android introduced boot header version 3 or 4. The header structure change with version 3 and 4 to support the new updates such as: - Introducing Vendor boot image: with a vendor ramdisk - Bootconfig feature (v4) Change andr_img_hdr struct name to maintain support for version v0, v1 and v2 while introducing version 3 and 4. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-03-30image: Fix potentially uninitialized data variableMarek Vasut1-4/+11
In case fitImage support is disabled, and image_locate_script() is passed a fitImage, then the 'data' variable is used uninitialized. Drop into the default: branch of the switch-case statement and do not return the uninitialized data, and do not modify the return pointer either, just print an error message. Reported by clang build: " $ make HOSTCC=clang CC=clang KCFLAGS=-Werror sandbox64_defconfig && make HOSTCC=clang CC=clang KCFLAGS=-Werror ... boot/image-board.c:1006:7: error: variable 'data' is used uninitialized whenever switch case is taken [-Werror,-Wsometimes-uninitialized] case IMAGE_FORMAT_LEGACY: ^~~~~~~~~~~~~~~~~~~ include/image.h:608:29: note: expanded from macro 'IMAGE_FORMAT_LEGACY' ^~~~ boot/image-board.c:1128:19: note: uninitialized use occurs here *datap = (char *)data; ^~~~ boot/image-board.c:1001:11: note: initialize the variable 'data' to silence this warning u32 *data; ^ = NULL " Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-27Merge branch 'master' into nextTom Rini1-18/+40
2023-03-27boot: Create a common BOOT_DEFAULTS for distro and bootstdSimon Glass1-34/+28
These two features use a lot of common options. Move them into a common CONFIG to reduce duplication. Use 'select' for most options since these are things that boards aren't supposed to override. For now it is not possible to disable BOOT_DEFAULTS but we may take another look later. Note that five options use 'imply' to match existing behaviour. Signed-off-by: Simon Glass <sjg@chromium.org> [trini: Rework a bit so we don't grow so many platforms unintentionally] Signed-off-by: Tom Rini <trini@konsulko.com>
2023-03-27lmb: Enable LMB if SYS_BOOT_RAMDISK_HIGHSimon Glass1-0/+1
Ramdisk relocation requires LMB, so enable it automatically to avoid build errors. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-27Move DISTRO_DEFAULTS into boot/Simon Glass1-0/+27
This relates to booting so move it in to that Kconfig file, before changing it. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08bootstd: Replicate the dtb-filename quirks of distrobootSimon Glass2-9/+64
For EFI, the distro boot scripts search in three different directories for the .dtb file. The SOC-based filename fallback is supported only for 32-bit ARM. Adjust the code to mirror this behaviour. Also some boards can use a prior-stage FDT if one is not found in the normal way. Support this and show a message in that case. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Mark Kettenis <kettenis@openbsd.org>
2023-03-08bootflow: Rename bootflow_flags_tSimon Glass2-18/+18
These flags actually relate to the iterator, not the bootflow struct itself. Rename them. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-03bootstd: Correct 'VPL' typoSimon Glass1-1/+1
Correct a 'VPL' typo in the Kconfig. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-03Correct SPL use of DM_RNGSimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_DM_RNG defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-03boot: Add Kconfigs for BOOTMETH_VBE_REQUESTSimon Glass2-1/+22
Allow this to be enabled separately in U-Boot proper and in SPL, since it is not needed in SPL. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-03bootstd: Disable QFW bootmeth in SPLSimon Glass1-1/+1
Move this Makefile line into the non-SPL area so we don't have to repy on the SPL_TPL_ macro. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10Correct SPL uses of CMD_BOOTEFI_BOOTMGRSimon Glass1-1/+2
This converts 3 usages of this option to the non-SPL form, since there is no SPL_CMD_BOOTEFI_BOOTMGR defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10Correct SPL uses of LMBSimon Glass1-1/+1
This converts 9 usages of this option to the non-SPL form, since there is no SPL_LMB defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10Correct SPL use of CMD_PSTORESimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_CMD_PSTORE defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10Correct SPL uses of CMD_FDTSimon Glass2-2/+2
This converts 2 usages of this option to the non-SPL form, since there is no SPL_CMD_FDT defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10Correct SPL uses of CMD_BOOTM_PRE_LOADSimon Glass1-2/+2
This converts 2 usages of this option to the non-SPL form, since there is no SPL_CMD_BOOTM_PRE_LOAD defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10Correct SPL use of CMD_BOOTISimon Glass1-1/+1
This converts 1 usage of this option to the non-SPL form, since there is no SPL_CMD_BOOTI defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-06qemu: Add a bootmeth for qfwSimon Glass3-1/+104
This supports reading a kernel and ramdisk from qfw, then loading it with either the booti or bootz commands. For now this uses the existing booti and bootz commands, rather than trying to call that functionality directly (e.g. do_bootm_states()). It does not require the HUSH parser though, which helps a little with size. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-06bootstd: Add some default filesystems and commandsSimon Glass1-0/+27
We need to support a basic set of filesystems for booting to work in most cases. Add these in via a new option, letting the board disable them individually (for space reasons) if desired. This enables the filesystem commands as well as the actual functionality, even though bootstd is quite happy to use ext4 without the ext4 command. Further work would be needed to disintangle this and reduce code size. Add several other options as well, providing sensible defaults. We cannot enable this by default, since it expands the size of many boards quite a lot. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-06bootstd: Probe the block device before useSimon Glass2-0/+7
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-02-06bootstd: Allow enabling BOOTSTD_FULL without needing EXPOSimon Glass2-2/+3
It is sometimes useful to have one without the other, e.g. on a device without a display, since at present the expo feature requires CONFIG_VIDEO to be enabled. Update the Makefile and bootflow command to support this, as well as the EXPO dependency. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24bootstd: 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-24bootstd: Record the bootdevs used during scanningSimon Glass1-10/+19
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-24bootstd: Drop the old bootflow_scan_first()Simon Glass1-15/+3
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-24bootstd: Allow scanning a single bootdev labelSimon Glass2-13/+58
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-24bootstd: Switch bootdev scanning to use labelsSimon Glass2-133/+81
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-24bootstd: Allow iterating to the next bootdev priortiySimon Glass1-0/+64
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-24bootstd: Allow iterating to the next label in a listSimon Glass1-2/+24
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-24bootstd: Allow hunting for a bootdev by labelSimon Glass1-2/+25
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-24bootstd: Add a new pre-scan priority for bootdevsSimon Glass1-0/+8
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-24bootstd: Allow hunting for bootdevs of a given prioritySimon Glass1-0/+25
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-24bootstd: Treat DHCP and PXE as bootdev labelsSimon Glass5-24/+40
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-24bootstd: 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-24bootstd: Add a SPI flash bootdevSimon Glass2-2/+20
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-24bootstd: Add a new bootmeth method to set the bootflowSimon Glass1-0/+11
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-24bootstd: 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>