1110 Commits

Author SHA1 Message Date
Simon Glass
b65c86177e boot: Enable the VBE-OS bootmeth for EFI app and payload
This method is useful for locating an OS using the VBE approach. Enable
it for the app and payload, for both x86 and ARM.

Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: Support video output on ARM
So far the EFI app supports video on x86 but not ARM. This series adds
this feature, using EFI GOP's 'blt' feature.

Support for bootstd is enabled at the same time, so that the app can
boot an OS automatically.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-05 11:49:30 -06:00
Simon Glass
07f5b96985 boot: test: Add a test for the VBE OS flow
Create two new images (vbe0 and vbe1) containing the two types of VBE-OS
setups: with and without an OEM FIT. Put this in a new img/ subdirectory
since the test_ut.py file is getting quite large.

Most of the test is in C, with just the image-setup done in Python.

Enable the test for non-SPL sandbox builds.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
68c0c6f27e boot: Add support for VBE for the OS
When booting an OS it is useful to be able to read devicetrees provided
by the OEM, from a separate FIT to the OS.

Add a new method which supports this, along with the usual A/B/recovery
flows, using a state file on the boot device.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
53b02e1015 boot: Support restarting a bootm sequence from PXE
If a load-only FIT has already provided a devicetree, PXE boot may need
to restart the bootm sequence, rather than starting an entirely new one,
so that the devicetree is preserved and used for booting.

Add support for this by adding a new field in the context and updating
extlinux_boot() to receive the value as a new parameter.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
8af19e54f7 boot: Use provided filename with bootmeth_alloc_other()
Rather than using bflow->fname, which assumes that it is the same as the
passed-in filename, use the passed in filename. This can be different in
some cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
129a820581 boot: pxe: Add a token for FIT
It is not obvious that PXE supports FIT, but it does, by detecting
whether an image is a FIT or not.

In many cases a FIT is more convenient than using separate files for
the kernel, initrd and devicetree.

Really we should promote FIT as an important format, rather than
silentily dealing with it if detected.

Add a new 'fit' token which indicates that a FIT is being used.

When the 'fit' token is used, the expectation is that the devicetree
is within the FIT, but this is not required, for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
74c9ceb22a boot: Remove blank lines in pxe_parse
This file has quite a few more blank lines than is usual in the U-Boot
code base. Remove them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
cd8057dd58 boot: Move PXE-parsing logic out to a separate file
The pxe_utils.c file is quite large and has a mix of parsing and booting
code. Split out the parsing into a new 'pxe_parse.c' file.

Add function prototypes for parse_pxefile_top() and label_destroy(), the
two functions used by pxe_utils.c

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
49a901f18c sandbox: Enable FIT best-match
Enable this feature so that it can be tested on sandbox.

Update the vboot FDT to avoid having it match on conf-1 instead of
conf-1

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
40fd6b04b9 boot: Show compatible strings with FIT information
The compatible strings used by each configuration comprise useful
information about how the system will boot. Show these after the current
configuration-node information.

Swap the order of the desc argument in its caller, fit_image_print()
since it is easier to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
08676cf417 boot: Add a constant for the FIT-configuration compatible
This property is part of the configuration node, so add a constant for
it, instead of open-coding the value. This allows easy searching for
places in U-Boot where the configuration node's compatible string is
used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
3a370b854e boot: Show messages when using FIT best-match
This matching happens silently at present, which can lead one to wonder
if U-Boot has been built without the feature. Add a few basic messages.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
329cdd4db2 boot: Use a common index in fit_conf_print
Rather than using two variables for the stringlist index, use one.
Simplify the i == 0 expression.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
0bc0fc2d00 boot: Tidy up fit_get_desc()
This should return a constant pointer, since modifying the description
within a devicetree node is not allowed. Also there is no need to set
the return value unless there is actually a description.

Update the function and move the docs to the header file while we are
here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
684fc8c4d7 Revert "Merge branch 'loadg' into 'master'"
This reverts merge request !141
2025-08-02 19:50:30 +00:00
Simon Glass
3c2f152a9b boot: test: Add a test for the VBE OS flow
Create two new images (vbe0 and vbe1) containing the two types of VBE-OS
setups: with and without an OEM FIT. Put this in a new img/ subdirectory
since the test_ut.py file is getting quite large.

Most of the test is in C, with just the image-setup done in Python.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:31:52 -06:00
Simon Glass
74a49fcd3d boot: Add support for VBE for the OS
When booting an OS it is useful to be able to read devicetrees provided
by the OEM, from a separate FIT to the OS.

Add a new method which supports this, along with the usual A/B/recovery
flows, using a state file on the boot device.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:29:35 -06:00
Simon Glass
87c3760161 boot: Support restarting a bootm sequence from PXE
If a load-only FIT has already provided a devicetree, PXE boot may need
to restart the bootm sequence, rather than starting an entirely new one,
so that the devicetree is preserved and used for booting.

Add support for this by adding a new field in the context and updating
extlinux_boot() to receive the value as a new parameter.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:29:35 -06:00
Simon Glass
43b35c9a2c boot: Use provided filename with bootmeth_alloc_other()
Rather than using bflow->fname, which assumes that it is the same as the
passed-in filename, use the passed in filename. This can be different in
some cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:29:35 -06:00
Simon Glass
50e2c42569 boot: pxe: Add a token for FIT
It is not obvious that PXE supports FIT, but it does, by detecting
whether an image is a FIT or not.

In many cases a FIT is more convenient than using separate files for
the kernel, initrd and devicetree.

Really we should promote FIT as an important format, rather than
silentily dealing with it if detected.

Add a new 'fit' token which indicates that a FIT is being used.

When the 'fit' token is used, the expectation is that the devicetree
is within the FIT, but this is not required, for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:29:35 -06:00
Simon Glass
f9c9f2b8ee boot: Remove blank lines in pxe_parse
This file has quite a few more blank lines than is usual in the U-Boot
code base. Remove them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:29:35 -06:00
Simon Glass
4c423e6711 boot: Move PXE-parsing logic out to a separate file
The pxe_utils.c file is quite large and has a mix of parsing and booting
code. Split out the parsing into a new 'pxe_parse.c' file.

Add function prototypes for parse_pxefile_top() and label_destroy(), the
two functions used by pxe_utils.c

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:29:34 -06:00
Simon Glass
eec742ca39 sandbox: Enable FIT best-match
Enable this feature so that it can be tested on sandbox.

Update the vboot FDT to avoid having it match on conf-1 instead of
conf-1

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:29:33 -06:00
Simon Glass
20851c1330 boot: Show compatible strings with FIT information
The compatible strings used by each configuration comprise useful
information about how the system will boot. Show these after the current
configuration-node information.

Swap the order of the desc argument in its caller, fit_image_print()
since it is easier to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:22:11 -06:00
Simon Glass
e05844907d boot: Add a constant for the FIT-configuration compatible
This property is part of the configuration node, so add a constant for
it, instead of open-coding the value. This allows easy searching for
places in U-Boot where the configuration node's compatible string is
used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:22:11 -06:00
Simon Glass
f5f480a507 boot: Show messages when using FIT best-match
This matching happens silently at present, which can lead one to wonder
if U-Boot has been built without the feature. Add a few basic messages.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:22:11 -06:00
Simon Glass
3fa1f83c09 boot: Use a common index in fit_conf_print
Rather than using two variables for the stringlist index, use one.
Simplify the i == 0 expression.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:22:11 -06:00
Simon Glass
ebcbcdef0a boot: Tidy up fit_get_desc()
This should return a constant pointer, since modifying the description
within a devicetree node is not allowed. Also there is no need to set
the return value unless there is actually a description.

Update the function and move the docs to the header file while we are
here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:22:11 -06:00
Simon Glass
7a37413818 pxe_utils: Support the SAY command
This shows a message for the user. Implement it to keep the user
informed.

Series-to: u-boot
pxe: Support an automatic localboot
It seems that extlinux expects that boards know how to boot a local OS
from attached media. U-Boot currently assumes that boards define a
"localcmd" environment variable to support this. None does.

Provide an automatic means to find a kernel and ramdisk, using common
filenames. This addresses booting on MAAS, at least.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-07-30 15:01:52 +12:00
Simon Glass
de881bfad7 pxe_utils: Support a backup for localboot
The current localboot implementation assumes that a 'localcmd'
environment variable is provided, with the instructions to follow. This
may not be included, so provide a fallback in that case.

Add a test image and test as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-30 15:00:59 +12:00
Simon Glass
6657f739a3 pxe_utils: Allow the FDT to be missing
The devicetree file may not be provided, so avoid a failure in that
case.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-07-30 14:59:40 +12:00
Simon Glass
dee24f9071 vbe: Remove 'simple' from vbe_abrec
It is confusing to use the word 'simple' within the ABrec driver. Rename
a few identifiers to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-29 07:06:45 +12:00
Simon Glass
aec5fbeee8 boot: Support bootm restart
Normally bootm proceeds sequentially through the various states, from
'start' to 'go'.

In some cases we want to load the devicetree from one FIT and the kernel
and ramdisk from another. This requires two bootm commands.

Of course it is possible to just do a second 'bootm start' to load the
kernel. But that removes all record of the devicetree from the
boot_images information, so it is then not provided to the OS.

Add a 'restart' subcommand which allows more images to be loaded,
without erasing those already loaded.
2025-07-28 13:06:51 +12:00
Simon Glass
b0eb6cb6fc boot: Update boot_get_fdt() return arguments
If an error is returned, leave the return arguments alone. There is no
point in setting them to zero, since the caller already knows (from the
error code) that they are not being returned.

This makes things simpler for callers which have an existing devicetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:51 +12:00
Simon Glass
c1264fdf09 boot: Tidy up boot_get_fdt()
Tidy up the function comment. Shorten the names of the return arguments
since it is clear that they relate to devicetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:51 +12:00
Simon Glass
ba372fcc56 boot: Update boot_get_ramdisk() return arguments
If an error is returned, leave the return arguments alone. There is no
point in setting them to zero, since the caller already knows (from the
error code) that they are not being returned.

This makes things simpler for callers which have an existing ramdisk.

Handle the -ENOPKG error code in bootm_find_images()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:51 +12:00
Simon Glass
56f7aa238b boot: Update boot_get_ramdisk() to return an error
This function returns 1 on error (at least in some cases). Change it to
use an error code, so that more information can be provided. For now it
mostly returns either 0 or -ENOPKG

Rename the return arguments, dropping the rd_ prefix and adding a 'p'
(for pointer) suffix to return arguments so that is clear that this is
what they are.

Update the comments for clarity and to fit with the usual style. Avoid
documenting the return arguments in two places.

Provide a common path for all error returns.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:51 +12:00
Simon Glass
6f81e09ab0 boot: Finish the plumbing for the load-only FIT
Detect the lack of OS and deal with it through the rest of the bootm
logic.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:51 +12:00
Simon Glass
a50aa108aa boot: Detect the lack of an OS in a load-only FIT
Detect this condition and set a flag in the images struct to remember
that no OS is being loaded.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:51 +12:00
Simon Glass
36a7c36c36 boot: Update fit_image_load() to support load-only FITs
The load-only property in a configuration node indicates that there is
not necessarily a kernel or firmware image in the configuration. Handle
this case and return an error code.

Fix the 'NOEXEC' typo while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:51 +12:00
Simon Glass
dd56e0b92d boot: Correct comment for fit_image_get_phase()
This function has a comment in both C and header files. Drop the one in
the C file and tweak the header-file one for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:51 +12:00
Simon Glass
8bb6261c94 boot: Split out FIT-config handling from select_image()
This code is complicated enough that it deserves its own function. Split
it out.

Fix up a missing argument from the select_image() docs while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:06:49 +12:00
Simon Glass
e76cdf68ea boot: Add a function comment for fit_parse_spec()
Add a little documentation so that the purpose of this function is
clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:04:32 +12:00
Simon Glass
4ce09ba58c boot: Drop unnecessary assignment in bootm_find_images()
Since 'select' is already assigned in the declarations for this
function, there is no need to do it again. Drop the duplicate
assignment.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-28 13:04:32 +12:00
Simon Glass
e43877b1e7 boot: Fix select_image() as per the v2 series
The v1 series was applied instead of v2. This has a bug in
select_image(). Bring in the v2 patch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 782cfbb259 ("image: Introduce fit_image_load() to load images from FITs")
2025-07-26 23:41:14 +12:00
Simon Glass
44d8b15319 boot: Tidy local variables in fit_image_load()
Arrange these so that they look a little nicer.

Series-to: u-boot
Cover-letter:
boot: Make fit_image_load() easier to maintain
Before fit_image_load() was created, The code to load kernels, ramdisks
and devicetrees from a FIT was spread around many functions. By
combining most of the code in one place, it became possible to add more
features in a consistent way. The 'loadables' feature much easier to
plumb in, for example.

While fit_image_load() was a substantial advance, it has never been a
svelte function and the passing years have not been entirely kind. With
a few new features on the horizon, this is a good time to improve the
implementation.

This series splits much of the code from fit_image_load() into a number
of smaller functions. Most of the changes are fairly mechanical, with
just a few renames and tweaks here and there.

This should make the function much easier to maintain. It may also
encourage someone to take a look at its callers, which could also use
some attention.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
15d7dce9ef boot: Drop unnecessary data variable
This is always the same as 'buf' and is not used in any case. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
cc26525a8d boot: Move setting the OS arch into check_allowed()
Remove a few more lines from fit_image_load() by dealing with this small
detail in check_allowed().

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
270e4ca401 boot: Move decomp_image() into handle_load_op()
Decompress is really part of loading, so simplify the code slightly by
moving decompression out of the top-level fit_image_load() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
c449c3b1ba boot: Move image-decompression into a separate function
Move handling of decompression (or perhaps relocation) of the image into
a separate function, to slim down fit_image_load() a little more.

Move the bootstage_mark() call in there too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00