1110 Commits

Author SHA1 Message Date
Simon Glass
932b6cfd23 expo: Tidy up image position with the menu
The bootflow menu creates an image at position -4, expecting that it
will be relative to the right side of the display.

With the recently added alignment feature, this is not supported. Update
the implementation to calculation the correct position instead. Update
the tests to match.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
d738ddf73f expo: Provide a way to enable the mouse
In some cases it is useful to use expo with a mouse (or touchpad). Add
a way to tell expo to find and record a mouse device.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
8960f0a4c8 expo: Add comments for enum bootmenu_id_t
Document the ranges in this enum, so it is clear what they a used for.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
e3e1b7aeb2 expo: Tidy up a few key-related comments
Fix up send_key_obj() to mention a missing argument. Add a bit more
detail in scene_send_key() to explain what 'processing' means.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
9f3b86c8f6 expo: Support boxes fully
At present boxes are not supported in the expo_build format. Also, it is
now possible to draw filled boxes, a recently added feature to the video
API.

Expand the box feature slightly to resolve these two items.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
f4b0561e8a expo: Guard against a crash in scene_textline_calc_dims()
If there is no console (e.g. in a test) this function segfaults. Add
the console as a parameter so it is clear that it is needed. Check for
it in the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
9fa8a01d50 video: Support drawing filled boxes
At present only an outline boxes is supported, albeit with a thickness
parameter. Provide a way to draw a filled rectangle.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
e196abb182 boot: Drop an unwanted blank line in distro_efi_boot()
This crept in a while back, so let's drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 184fc0379d ("bootflow: bootmeth_efi: Handle fdt not available.")
2025-09-02 08:45:36 -06:00
Simon Glass
c9b4950ed5 boot: Use the new label finder in bootflow_menu_add()
Make use of bootflow_guess_label() to get the label for a menu, since it
provides more information for the EFI app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-02 08:45:36 -06:00
Simon Glass
bd78e82720 boot: Move obtaining the label into a common file
The 'bootflow list' command supports looking at the EFI device-path when
available. Move this piece into a common function so it can be used
elsewhere.

This updates the output from 'bootflow list'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-02 08:45:35 -06:00
Simon Glass
0dc72120b7 fdt: Add a command to show reserved-memory regions
Add a new 'fdt reserved' subcommand that displays all reserved memory
regions defined in the device tree's /reserved-memory node. This command
provides a formatted table showing the ID, name, start address, and size
of each reserved memory region.

Avoid a conflict with the existing 'fdt resize' command. Update the docs
and add a test.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 06:55:49 -06:00
Simon Glass
ecca5cc322 fdt: Add a function to show the reserved-memory nodes
Add a new helper which lists the subnodes of the reserved-memory node.
This can be helpful when checking the devicetree before booting.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 06:55:49 -06:00
Simon Glass
ead588c067 boot: Correct filename in bootmeth_common_read_file()
This should add the filename provided to the image, not the original
bootflow filename. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 114dd14e38 ("bootmeth: Update the read_file() method to...")
2025-08-28 05:21:49 -06:00
Simon Glass
4e0efad3c5 fdt: Add debugging for fdt_simplefb
Add some simple debug output to see what it is doing.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-19 17:36:44 -06:00
Simon Glass
ddb78711fd boot: Pass flags to the bootm_final event
For a fake go, we should tell the event not to actually do anything
irreversable, so pass the flag along.

Move the enum into a separate event_decl.h header file since otherwise
we must include bootm.h which causes a breakage with qemu-ppce500

We also don't want to pull event.h into the tools build, since it uses
types like u8 which are not available outside U-Boot

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-19 17:36:44 -06:00
Simon Glass
cc6a9fe314 boot: Improve debugging in bootm_load_os()
This shows an image type as an OS, which is not correct. Fix it up to
show both.

Series-changes: 2
- Add a colon so it is clear that 'load_os type' is not a compound term

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-19 17:36:44 -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
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
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
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
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
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
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