Commit Graph

98903 Commits

Author SHA1 Message Date
Simon Glass
ef2d6ec193 fs: Avoid calling efi_set_bootdev() from the app
This function is used by the EFI loader but we want to avoid it for the
app, since it records global state.

We don't intend to support running arbitrary EFI apps outside of a
bootstd context, so drop this call for the EFI app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 17:01:22 -06:00
Simon Glass
f7bcb46121 boot: Update BOOTM_EFI to depend on EFI_LOADER
The EFI loader uses a rather unpleasant global for starting images. For
now the only way we intended to support booting EFI apps from the U-Boot
EFI app is via a bootmeth.

Update the condition so that the 'bootefi' command only works from the
EFI loader.

Future work may enable the 'bootefi' command for the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 17:00:14 -06:00
Simon Glass
92aad5b59e efi: Move EFI_BINARY_EXEC to lib/efi
The EFI app will eventually execute binaries, but it does not enable
the CONFIG_EFI_LOADER option. So move the option to a common directory.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:11 -06:00
Simon Glass
0d481b9ff7 efi: Rename BOOTMETH_EFILOADER to BOOTMETH_EFI
Once the EFI app supports booting an OS, this bootmeth will work without
CONFIG_EFI_LOADER being enabled. Rename it so this is clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:11 -06:00
Simon Glass
28b512bad3 efi_client: Support running an app
Add support for running another app from with the EFI app. This can be
used to boot an OS, for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:11 -06:00
Simon Glass
75bf1ee3c5 efi_client: Allow access to the parent image
This value is useful when running a binary, so provide a function to
obtain it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:11 -06:00
Simon Glass
3d81bf9ac0 efi_loader: Split out efi_binary_run_dp() et all
efi_binary_run_dp() calls efi_init_obj_list() which is specific to the
EFI loader. Move this into a new file within lib/efi_loader

Similarly, move efi_run_image() since the app will need a different
implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:10 -06:00
Simon Glass
73ad2d9909 efi: Move efi_bootflow_run() to a common file
Move this function and some dependencies into the lib/efi directory so
that it can be used by the app, which does not enable CONFIG_EFI_LOADER

Since the networking has an #ifdef add CONFIG_EFI_LOADER to it, since
the definitions are in efi_loader.h for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:10 -06:00
Simon Glass
5ce96f0139 efi: Move EFI_FDT_USE_INTERNAL to a common header
Move this constant to the efi.h header so that it can be used by the
app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:10 -06:00
Simon Glass
a48a8929de efi: Move most of efi_device_path into lib/efi
Most of these utility functions are useful for the app, so move them
into the common directory.

Move the GUIDs used by this file from their various other location, so
they are available to the app, even if it doesn't enabled EFI_LOADER

Fix the rather large number of checkpath warnings in this file, except
for the lwip one, best left to the maintainer to sort out.

One noteable change is adding a return value to dp_fill() for the case
where an option is not enabled but its uclass is referenced. This
presuambly never happens during execution, since if the uclass is not
supported there can be no device in that uclass and therefore nothing
will ever request its path. So just handle this like an invalid device.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:10 -06:00
Simon Glass
ffde1a3922 efi: Use variables in dp_size()
This function calculates the parent size in many places and does the
same addition in most cases. Create a variable for the parent_size and
another for the size, so we can do the addition once at the end.

The uclass array is too sparse to consider an array.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:56:46 -06:00
Simon Glass
70b5f8dc80 efi: arm: Allow --gc-sections in the EFI app
This option is used on most other boards. Leaving it disabled creates
situations where the linker fails to build, due to symbols which are
referenced only it code that would have been garbage-collected.

To keep this disabled we would need to introduce #ifdefs not needed by
other platforms, which would be annoying.

The only current reason why this cannot be enabled is that the
linker lists are lost. Add a KEEP() around these, and enable the option.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:53:16 -06:00
Simon Glass
405986ff18 efi: Disable networking for the ARM EFI app
This is not fully functional yet, so disable it for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:53:16 -06:00
Simon Glass
ca57421d07 efi_client: Provide generic malloc() and free() functions
The device-path code requires memory allocation. Provide an
implementation of these for use by the client.

Note that this will not work for the stub, since in that case it needs
to use U-Boot's memory allocation. This was a subject of a long argument
on the mailing list about U-Boot using its own malloc() where possible,
so it seems best to just leave this broken.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:53:16 -06:00
Simon Glass
9398cb855e ide: Allow IDE_BUS() to be used without CONFIG_IDE
Using this macro, even bracketed with 'if (IS_ENABLED(CONFIG_IDE))'
causes a compile error if CONFIG_IDE is not enabled. Update the macros
to resolve this, so we can avoid #ifdefs in the C code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:53:16 -06:00
Simon Glass
7c63cdd830 scripts: Correct virtio-sci typo
Fix a small typo in the help.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:53:16 -06:00
Simon Glass
5f6e2806b0 scripts: build-efi: Enable the display on ARM
Enable the display on ARM devices, so it works when running Tianocore.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:53:16 -06:00
Simon Glass
79c09c4244 scripts: build-qemu: Always call the run() function
The helper deals with whether we are actually running or not. We want it
to show the arguments even if not. So always call it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:53:16 -06:00
Simon Glass
0d08920da2 scripts: build-qemu: Enable the display on ARM
ARM devices can use a GPU display, which U-Boot only recented supports.
Enable the option.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:52:48 -06:00
Simon Glass
219adf6bf8 scripts: build-qemu: Correct networking
Networking is not currently enabled, since the wrong variable is used.
Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 15:59:43 -06:00
Simon Glass
654bf17503 scripts: build-qemu: Support Tianocore on ARM
When ARM is selected, use the ARM Tianocore image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 15:59:43 -06:00
Simon Glass
4470f4f729 scripts: build-qemu: Move virtiofsd code into the helper
Move this code into the helper so that build-efi can use it too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 15:59:43 -06:00
Simon Glass
2a6a7e9716 scripts: build-qemu: Move qemu program-name to the helper
Put this in the helper so that we can (later) have it show the correct
error when the virtiofs daemon fails.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 15:59:43 -06:00
Simon Glass
a783a7ea64 scripts: build-qemu: Move memory size to the helper
Move this field to the helper so we can (later) have it set up the
virtiofs daemon.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 15:59:43 -06:00
Simon Glass
68ec2401ad scripts: Adjust EFI script to support an OS
At present the OS disk conflicts with the boot disk used to hold the
app (or payload). Number the OS disk after that.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 14:47:39 -06:00
Simon Glass
cbe563ed8b boot: pxe: Init initrd_str in label_boot()
When 'bootflow read' is used to read images, initrd_str is not inited
before strdup() is called. Note that this is only used by developers.

Set the variable to an empty string to start.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-07 04:37:15 -06:00
Simon Glass
e385bac1b6 boot: Given up pxe boot if kernel_addr_r is missing
At present we require this environment variable in order to do any
booting. The check for this actually later (the '"malloc fail' message)
but there is a possible NULL access before getting to that point.

Check it immediately after reading.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-07 05:12:19 -06:00
Simon Glass
091ac902b1 Merge branch 'loadh' into 'master'
efi: Support video output on ARM

See merge request u-boot/u-boot!147
2025-08-05 19:41:40 +00:00
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
725d2c8c89 dm: core: Provide oftree_dispose() when OF_LIVE is disabled
This function is only defined if CONFIG_OF_LIVE is enabled. Provide a
static inline to handle it being disabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-05 11:49:30 -06:00
Simon Glass
7b25e5e9ff efi: Support bootstd and video with ARM app
We need CONFIG_BOARD_EARLY_INIT_R to enable block devices. Enable
bootstd as well, so that booting is supported. Provide the 'lsblk'
command to allow listing block devices.

Use white-on-black as this is a little easier on the eyes.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-05 11:49:30 -06:00
Simon Glass
f7a683d3f3 scripts: Adjust EFI script to support a root disk
At present the root disk conflicts with the boot disk used to hold the
app (or payload). Use virtio for this disk and number the others after
that.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-05 11:49:30 -06:00
Simon Glass
636ec26bc4 efi: Add an enum for the GOP blt operation
Create an enum for the 'operation' argument, so that drivers can make
use of this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-05 11:49:30 -06:00
Simon Glass
c494a7e5e9 efi: Support the EFI GOP blit method
With arm64 we generally use the virtio-gpu driver, which does not
support direct access to a framebuffer. Add support for this, so that
the display works as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-05 11:49:30 -06:00
Simon Glass
3d1ff42987 video: efi: Store the GOP in priv data
At present the EFI GOP is read in the probe() method but is not stored,
so it is not possible to use it later.

With the EFI app we need to be able to access it after probing, when
blitting is used. Create a struct to hold it. Store the framebuffer
pointer in there as well, to simplify the code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-05 11:49:30 -06:00
Simon Glass
9179000b50 Merge branch 'loadg' into 'master'
boot: Enhance VBE to support a separate devicetree FIT

See merge request u-boot/u-boot!146
2025-08-04 21:16:41 +00:00
Simon Glass
7d92da0eef boot: Add documentation for the VBE-OS bootmeth
Add some information about this new bootmeth, including how to enable it
and how it works.

Series-to: concept
Cover-letter:
boot: Enhance VBE to support a separate devicetree FIT
It is sometimes desirable to have the devicetrees packaged with firware,
or in a different FIT from the OS. This series adds support for this,
including a test.

The new bootmeth can automatically locate a state file and use that to
decide what images to use when booting. The OS must update the file
before rebooting, if a different selection is required.

For now there is no logic to deal with boot failures.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -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
324a3ac00a boot: Add comments for struct pxe_label
Some members are not commented. Add the missing comments and tidy up the
style a little.

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
e0588c48f1 test: Drop double removal of the FS image on failure
We already have a cleanup function which removes the filesystem, so drop
the unnecessary try...except for this. It results in an error on the
error path, as we try to remove the filesystem twice.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
9680c3f2d7 test: Allow inspection of input filesystems
At present a temporary directory is used to hold the files before
placing them in the filesystem. Use a suitably named directory inside
the persistent-data directory, so that it is easy to take a look at what
was produced.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:40:00 -06:00
Simon Glass
812c9f2a20 mkimage: Set the timestamp with -f auto
When creating a FIT, ensure that a timestamp is added, even if there is
no OS image present.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
037a9c0b7f mkimage: Support a load-only FIT
Support creation of a load-only FIT (where there is no OS), with a new
--load-only option. Allow FITs to be created without an OS image.

Update the auto-generated FIT description to make this clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
449c65e028 mkimage: Add compatible strings to configuration node
When using '-f auto', mkimage automatically creates a FIT given the
images. For devicetree files, FIT expects that the compatible string
from each is copied to its corresponding configuration node.

Implement this in mkimage, so far only for uncompressed devicetrees.

This requires a few more fields in struct content_info, so take this
opportunity to comment it properly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00