Commit Graph

98903 Commits

Author SHA1 Message Date
Simon Glass
c1e0847bc6 test: Provide a test for the ARM EFI app booting Ubuntu
Build the app and use it to boot Ubuntu 2025.04 so that we can ensure
this continues to work.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
c999c238be efi: arm: Increase the cyclic timeout
The video sync sometimes takes 8ms on this board when running under
emulation, so increase the limit to 15ms.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
5cd3f28e09 efi: arm: Add the memory map to the FDT
Before booting using extlinux we must add the memory map to the FDT.
Provide a ft_system_setup() function to handle this.

To determine the memory size, scan the memory map looking for entries
that look like real memory.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
af34860c2d efi: arm: Expand app to use 512M of memory
When booting an OS with a large ramdisk, we need enough memory to load
it. Expand the app's memory to 512M to allow this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
ed46c28b48 efi: Update the ARM app to boot from extlinux
When extlinux is used, the boot partition is often 2, which is ignored.
Use the 'bootflow scan' -p flag to resolve this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
ea30e7c267 efi: boot: Correct calculation of load address in app
The conversion to using an event was not done correctly, with the
result that it has no effect. Fix it, by passing in the length and
actually using the returned address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 207bf34de7 ("boot: efi: Use an event to relocate the OS")
2025-08-14 07:45:25 -06:00
Simon Glass
4bccd4ea31 efi: Set the FDT address for QEMU
When running under QEMU the FDT is available at the start of RAM. Set
fdt_addr to this address, so that the FDT can be passed onto the OS.

If the OS provides its own devicetree, that is used instead of the QEMU
one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
10e31d38f8 efi: Exit EFI boot-services before starting the next app
When the app is booting a kernel without using EFI, it must first exit
the boot services provided by EFI. Add a hook for this, using
bootm_final()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
082666ec3e efi: Rename efi_block_device driver
This driver name conflicts with another driver in U-Boot. Rename it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
cb6bd231b7 efi: Run happily without a video display
It is common to run the EFI app without a display, e.g. for testing.
Drop the unwanted warnings about this:

   EFI graphics output protocol not found (err=-524)
   No video mode configured in EFI!

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
d07934b67e efi: Add a function to obtain the memory type as a string
It is sometimes useful to display the memory type in logs, etc. Add a
function to convert it to a string, which is more user-friendly than a
number.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
02e141912b efi: Move memory-map dumping into a common file
The 'efi mem' command dumps out the memory map. This is useful within
the app, even if commands are not enabled, so move it to a common file.
Rename it from 'print' to 'dump' since most things that dump information
use that word.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
7fb1c0760e efi: Add a few more GUIDs
We can never hope to have a definitive list of GUIDs, but add four more,
discovered when booting from QEMU on ARM.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
41d386529a efi: Use the same format for all EFI_GUID() declarations
The declarations in efi_api.h are inconsistent. Tidy them up, so that
the final 8 bytes appear on their own line aways.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
22d39d1c53 efi: Adjust serial to work better on real devices
The EFI serial driver checks for keypresses but does not allow other
events to be processed. For devices which have a USB keyboard, the USB
message must be processed before any keys can emerge for the serial
driver to pick up.

Add a periodic timer to the list of events. This allows the keyboard to
work on Qualcomm laptops, for example.

Series-changes: 2
- Add a comment to serial_efi_get_key() about the 1ms delay

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:06 -06:00
Simon Glass
bd5194356b efi: Move efi_store_memory_map() to the stub
This function is not called from the app at present. Even if it were, it
would be called later, after stdio is working, so there is no need to
use printhex2() and the like.

Move the function into the stub.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-12 13:41:07 -06:00
Simon Glass
c6883b8a71 scripts: Add an option for the build directory
When running in CI it is better to specify the build directory rather
than provide a device. Add a --build-dir option.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-12 13:41:05 -06:00
Simon Glass
c7e33a6646 treewide: Correct paramters typo
This typo appears a handful of times in U-Boot. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 15:01:27 -06:00
Simon Glass
97a083c86c Merge branch 'loadm' into 'master'
boot: Allow lmb-allocation of compression buffer with booti

See merge request u-boot/u-boot!150
2025-08-11 19:48:17 +00:00
Simon Glass
6916ad7d21 boot: Emit an event just before starting the OS
In some cases a board may wish to do some final processing before
starting the OS. An example is the EFI app, which may wish to call
exit-boot-services.

Add an event to permit this.

Series-to: concept
Cover-letter:
boot: Allow lmb-allocation of compression buffer with booti
ARM 'booti' images (as created by Linux 'make Image') typically need to
be compressed. At present the decompression buffer is described by a
pair of environment variables: kernel_comp_addr_r and kernel_comp_size

This is quite inflexible, since the buffer size and location must be
pre-set in the environment, before the OS size is known.

For the EFI app, it is quite difficult to work with a fixed buffer. It
is not in control of the memory map so it may be that the requested
buffer address is not available.

This series updates the boot implementation to allow the variables to
be omitted, with lmb allocations done in this case. This resolves the
problem in the EFI app, with kernels which come from extlinux.conf

When the EFI app loads another app, a similar problem is present, but
with the EFI bootmeth, also resolved in this series.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:06:11 -06:00
Simon Glass
e7d72484f7 boot: Correct a comment in image_setup_libfdt()
Unfortunately no one else has taken up this migration. For now, reword a
a comment to more correctly describe what the event uses.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:04:39 -06:00
Simon Glass
8b46f05b1b boot: Support lmb reservation in resolve_os_comp_buf()
This function is very simple at present, only supporting a fixed buffer
of a fixed size.

For cases where the address is not provided, we may still want to set a
limit on the size.

Support lmb reservation of an existing buffer as using lmb to reserved a
new buffer. Use the provided size information to select a suitable size
for the decompression buffer.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:04:09 -06:00
Simon Glass
fa473ba1ed boot: Check OS size when decompressing with booti
If the OS size is not known, or zero, refuse to decompress it.

Note that the 'booti' command does not have this information, but in
that case, kernel loading is handled by its own function called
booti_start()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:03:03 -06:00
Simon Glass
36e81b81f5 boot: Record the kernel size in pxe_utils
Write the kernel size into the bootm_info so it can be used as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:02:16 -06:00
Simon Glass
d37a89fda7 boot: Add an OS-size field in bootm_info
The size of the loaded OS file can be useful when decompressing, or to
check that the. FIT image matches its size. Add an os_size field for
this in struct bootm_info so it can be recorded.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:02:16 -06:00
Simon Glass
3bef4dbecd boot: Move compression-buffer handling to its own function
Before expanding this code, create a new function to hold it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:02:15 -06:00
Simon Glass
7618b665a7 boot: Read environment variables at start
Some environment variables affect the operation of bootm. Reading these
variables is buried within the boot code at present.

Ideally this information should be in struct bootm_info so that it can
be provided directly, without needing the environment variables. Also it
should support allocation if the variables are not provided.

As a first step towards this, add an explicit read of the variables,
storing the values. For now this only covers kernel_comp_addr_r and
kernel_comp_size

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:00:54 -06:00
Simon Glass
751381658b boot: Add more debugging to image-baord and image-fdt
Add some debugging to these files, which can be enabled if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 09:38:17 -06:00
Simon Glass
739acca70e boot: Add more debugging to bootm code
The bootm code handles a large number of variables. It is helpful to be
able to see which code paths are taken, when something doesn't work as
expected.

Add some debugging which can be enabled if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 09:38:17 -06:00
Simon Glass
0d90733a31 efi: Allocate the kernel buffer when running in the app
The app cannot know the address to use in advance, so does not have a
value for kernel_addr_r in its environment, if it even has an
environment.

Allocate memory for the kernel instead. Limit it to 64MB which seems
like plenty for the distros out there. It is enough to load a full
kernel if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 09:38:13 -06:00
Simon Glass
c9dbf55855 Merge branch 'loadk' into 'master'
boot: Start to remove dependency on kernel_addr_r etc.

See merge request u-boot/u-boot!149
2025-08-09 22:09:51 +00:00
Simon Glass
94fb03e96b boot: Pass the full bootm_info to bootm_find_os()
At present this function only uses two fields, but it also needs to
access the kernel-compression info. In preparation for that, pass in the
whole struct.

Series-to: concept
Series-cc: heinrich
Cover-letter:
boot: Start to remove dependency on kernel_addr_r etc.
Before bootstd, boot scripts were used to boot distros. These worked by
using a 'load' command to load a file and a 'bootm' command to boot.

Obviously these commands need addresses, so the approach taken was to
define a number of environment variables to provide them, for the
various situations. These are documented at [1].

With bootstd, booting is built into U-Boot so there is no real need for
these variables. Also, bootstd records all loaded images in a list, so
knows where and what they are.

However, since bootstd uses much of the same code as the bootm command,
for example, to date it has used these same variables.

This is OK to some extent, since boards maintainers have got used to the
need to statically configure the addresses used for a kernel, ramdisk,
devicetree, etc. But is does cause problems:

- since the kernel and initrd can grow quite a bit from year to year,
  sometimes the values need to be updated to save space [2]
- some boards don't have fixed addresses (such as the EFI app)
- fixed values means that much more space must be provided than is
  normally needed; for this reason the ramdisk is generally at the
  highest address

The variables do have some benefit, e.g. for people who want things
loaded at a known location, so it makes sense to keep them around. But
they should be optional.

This series starts the process of removing the requirement for these
variables, focussing on the extlinux code. It mostly consists of
refactoring.

Several functions are updated to support lmb reservation. At least for
filesystems, bootstd can query the file size and use lmb to reserve the
required amount of (aligned) memory. The bootmeth read_file() method is
updated to handle this. When decompressing, bootm is updated to support
reservation (instead of an address) for the decompressed file.

With these in place, various patches are provided to work this new
feature into the pxe_utils code used by extlinux.

The next step after this is to attack the bootm code itself, so that the
struct bootm_info controls the addresses, without any environment
variables. That will be the subject of the next series.

[1] https://docs.u-boot.org/en/latest/develop/distro.html#required-environment-variables
[2] https://patchwork.ozlabs.org/project/uboot/patch/20241220003447.2913443-5-sjg@chromium.org/

END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
123f73037b boot: pxe: Retain the kernel address in the context
Converting back and forth between a string and a ulong does not make
much sense. Simplify the code by adding a separate value for the kernel
address.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
7ed6c096ee boot: pxe: Rename kern_addr in struct pxe_context
This variable is a string, so add a _str suffix to make this clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
137765cf69 boot: pxe: Allow loading a kernel without kernel_addr_r
When this environment variable is missing, reserve space using lmb.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
d6c2e45c4f boot: Simplify kernel-address handling in label_boot()
This function is needlessly convoluted, reading the kernel address as a
string, possibly adding the FIT configuration, then parsing that to
obtain the kernel address again.

Create a kern_addr variable to hold the kernel address, so we can
simplify the code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
90e9403749 boot: Rename kern_addr in label_boot()
Rename this variable to kern_addr_str so that it is clear it is a string
and not an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
d252bf77da boot: Support reserving memory in get_relfile_envaddr()
We normally require environment variables when loading files using PXE/
syslinux. This is not really necessary, since we can use lmb to find a
suitable space.

Add support for reserving space in get_relfile_envaddr(), which is the
commonly used function for reading a file. Use env_get() so no error is
shown if the environment variable does not exist.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
9fdd26efc1 boot: Drop the allocation in label_boot()
It doesn't seem worth allocating space for a label when it is normally
going to be under 20 characters. Use a fixed-sized string (with plenty
of space) instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
c9c2faad2f boot: Add a conf_fdt ulong to struct pxe_context
Keep this value around separately from the string, since the string
needs to be converted before use.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
793839d6e7 boot: pxe: Rename conf_fdt to conf_fdt_str
This is a string, so add a string suffix to make that clear.

Switch the assignment order in label_run_boot(), since the FDT is loaded
after the kernel.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
cbd55c1d88 boot: Convert struct pxe_context initrd_filesize to ulong
Convert initrd_filesize to a ulong and rename it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
258c30f7af boot: Convert struct pxe_context initrd address to ulong
Several of the strings in this struct would be better off as addresses,
now that they are passed around a fair bit.

Start by converting initrd_addr_str to ulong

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
20c5318124 boot: Return the chosen address from get_relfile_envaddr()
Update this function to return the address obtained from the environment
variable. That will allow the caller to know where the image ended up.
For now this is not used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
3f94b241cd boot: Provide functions to set the bootm string-fields
Provide some helper functions which can set the string value of a field
in struct bootm_info from an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
ceef5b5949 boot: Adjust PXE get_relfile() to support reservation
In some cases we don't have a particular address to read into so would
like one reserved. Adjust this function to support that.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
5ead77edd5 boot: Update pxe_getfile_func() to support reservation
In some cases we don't have a particular address to read into so would
like one reserved. Adjust this function to support that.

For now, sysbot_read_file() fails if the address is not provided. This
will be resolved in a later patch.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:30 -06:00
Simon Glass
c545f0762b boot: Update bootmeth read_file() to support reservation
In some cases we don't have a particular address to read into so would
like one reserved. Adjust the read_file() method to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-09 12:04:29 -06:00
Simon Glass
6cff8aa606 Merge branch 'loadi' into 'master'
Continue development of the EFI app (part A)

See merge request u-boot/u-boot!148
2025-08-09 01:15:04 +00:00
Simon Glass
4592eb369b boot: Pass the maximum size to efiload_read_file()
Some callers may want a maximum size smaller than 1G so add a parameter
for the caller to use.

Series-to: concept
Cover-letter:
Continue development of the EFI app (part A)
This series expand the EFI app to include more of the required
functionality for booting:

- access to device-path functions
- disable networking (to be dealt with later)
- rename BOOTMETH_EFI_LOADER since this should be usable by the app
- move towards getting EFI booting going in the app
- various script improvemens to support continued development
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 17:01:22 -06:00