Commit Graph

731 Commits

Author SHA1 Message Date
Simon Glass
dcddf6aa83 membuff: Rename functions to have membuf_ prefix
The double 'f' is not necessary and is a bit annoying as elsewhere in
U-Boot we use 'buf'. Rename all the functions before it is used more
widely.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:19 -07:00
Paul HENRYS
22f76b1c17 boot: Add support of the pre-load signature for host tools
Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-25 06:34:20 -07:00
Simon Glass
947dc55bff boot: Rename fit_image_get_data_and_size()
This function is really just getting the data. The size comes along for
the ride. In fact this function is only reliable way to obtain the data
for an image in a FIT, since the FIT may use external data.

Rename it to fit_image_get_data()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-15 19:07:09 -07:00
Simon Glass
a59fc82792 boot: Rename fit_image_get_data()
This function can only be used with FITs that use embedded data. Rename
it so this is clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-02-15 19:07:09 -07:00
Marek Vasut
f168da34d0 Makefile: Drop SPL_FIT_GENERATOR support
The SPL_FIT_GENERATOR is long superseded by binman, drop SPL_FIT_GENERATOR
support as there are no more users.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/22109373594b6a5d1110be9420ccd8fbb93a61d3.1730452668.git.michal.simek@amd.com
2025-02-10 04:38:21 -07:00
Michal Simek
3c472e4445 arm64: zynqmp: Remove mkimage fit script
Platform has been switched to binman that's why there is no need for this
script and also Kconfig symbols.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/cf438091e43c4c9d535a9cfa2886673aa42a4370.1730452668.git.michal.simek@amd.com
2025-02-10 04:38:21 -07:00
Simon Glass
943f2757e3 vbe: Add an implementation of VBE-ABrec
So far only VBE-simple is implemented in U-Boot. This supports a single
image which can be updated in situ.

It is often necessary to support two images (A and B) so that the board
is not bricked if the update is interrupted or is bad.

In some cases, a non-updatable recovery image is desirable, so that the
board can be returned to a known-good state in the event of a serious
failure.

Introduce ABrec which provides these features. It supports three
independent images and the logic to select the desired one on boot.

While we are here, fix a debug message to indicate the function it
called. Provide a maintainers entry for VBE.

Note that fwupdated only supports VBE-simple so far, but supports for
ABrec will appear in time.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-06 23:49:28 +00:00
Simon Glass
a189bac93d vbe: Allow VBE to disable adding loadables to the FDT
When VBE operates within VPL it does not want the FDT to be changed.
Provide a way to disable this feature.

Move the FIT_IMAGE_TINY condition out of spl_fit_record_loadable() so
that both conditions are together. This makes the code easier to
understand.

Replace the existing fit_loaded member, which is no-longer used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-06 23:49:28 +00:00
Simon Glass
a1d470030c vbe: Tidy up a few comments
Join the comment block for the fit_image_load() call back to where it
should be. Also fix a debug statement.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-06 23:49:28 +00:00
Simon Glass
972db76fea vbe: Support selecting images based on phase in FIT
With SPL we want to specify the phase of the image to be loaded. Add
support for this.

This is the implementation of a FIT feature added to the spec a few
years ago and entails a small code-size increase, about 70 bytes on
Thumb2.

Signed-off-by: Simon Glass <sjg@chromium.org>
Link: https://docs.u-boot.org/en/latest/usage/fit/index.html
2025-02-06 23:49:28 +00:00
Simon Glass
44d3e7f46a pxe_utils: Correct setting of no_prompt
This should only be forced on, never off. Fix this so that the menu is
shown when expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-25 11:19:30 -07:00
Simon Glass
c664684fc4 vbe: Update simple-fw to support using the SPL loader
For a sandbox implementation, where code size is no object, it makes sense
to use the full bootstd drivers to load images.

For real boards, running from SRAM, this adds quite a bit of overhead.

Add a way to load the next phase using just the underlying storage
driver, to reduce code size. For now, only MMC is supported.

Change the log_debug() to show the load address and size in a more
neutral way, rather than suggesting that the load has already happened.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
bfdc677be6 vbe: Support loading SPL images
VBE needs to load different images from a FIT depending on the xPL phase
in use. The IH_PHASE value is used to select the image to load.

Add the required logic to handle this. For compatibility with the
SPL-loader driver, fill out a struct spl_image_info with the details
needed to boot the next phase.

This is good enough for VBE-simple but ABrec will need the full set of
bootstd features. So add a USE_BOOTMETH define to control this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
f9c294de3a vbe: Support loading an FDT with the relocating loader
Add FDT support so that this can be copied down in memory after loading
and made available to the new image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
97c5e870aa vbe: Support loading an FDT from the FIT
In many cases the FIT includes a devicetree. Add support for loading
this into a suitable place in memory.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
db4749cda5 vbe: Allow loading loadables if there is no firmware
In some cases only the 'loadable' property is present in the FIT.
Handle this by loading the first such image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
ad40e24f18 vbe: Handle loading from an unaligned offset
There is no guarantee that an FIT image starts on a block boundary. When
it doesn't, the image starts part-way through the first block.

Add logic to detect this and copy the image down into place.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
528fe66358 vbe: Tidy up error checking with blk_read()
This function can read fewer blocks than requested, so update the checks
to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
0144102eb7 vbe: Allow VBE to load FITs on any architecture
At present the VBE implementation is limited to sandbox only. Adjust the
call to fit_image_load() to remove this limitation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
9e2b93aca4 vbe: Allocate space for the FIT header
It is convenient to use TEXT_BASE as a place to hold the FIT header, but
this does not work in VPL, since SDRAM is not inited yet.

Allocate the memory instead. Ensure the size is aligned to the media
block-size so that it can be read in directly. Improve the
error-checking for blk_read() and add some more debugging.

Keep the existing TEXT_BASE mechanism in sandbox to avoid an
'Exec format error' when trying to run the image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
8563672933 vbe: Split out reading a FIT into the common file
Loading a FIT is useful for other VBE methods, such as ABrec. Create a
new function to handling reading it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
f984c169fb vbe: Move reading the nvdata into the common file
All VBE methods read non-volatile data, so move this function into a
common file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
7573cc498e vbe: Move reading the version into the common file
All VBE methods read a version string, so move this function into a
common file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
6390fc0866 vbe: Create a common function to get the block device
Add a vbe_get_blk() function and use it to obtain the block device used
by VBE.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
dd9ee09bb1 vbe: Convert some checks to assertions
VBE is currently quite careful with function arguments because it is
used in VPL which cannot be updated after manufacture. Bugs can cause
security holes.

Unfortunately this adds to code size.

In several cases we are reading values from a devicetree which is part
of U-Boot (or at least VPL) and so known to be good. Also, in several
places, getting bad values does not matter.

So change a few checks to assert() to reduce code size.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
e136706441 vbe: Pass simple_priv to internal functions
Pass the private data instead of the device, to help the compiler
optimise better. This saves 16 bytes of code on pinecube (rk3288)

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
4896cae917 vbe: Use a block device instead of descriptor
Pass a struct udevice instead of the descriptor structure, since this is
the native argument for blk_read()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
35fd991e9b vbe: Start a common header file
Move a few things into a new, common header file so that vbe-simple can
share code with the upcoming abrec.

Put struct simple_nvdata in it and rename it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
0981c0fe2f vbe: Use blk_read() to read blocks
We should not be using the old blk_d...() interface, is only there to
aid migration to driver model.

Move to blk_read() instead.

Changes in v2:
- Split patch into several pieces

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 18:01:40 -07:00
Simon Glass
c410758acb boot: Imply CRC8 with VBE
VBE uses a crc8 checksum to verify that the nvdata is valid, so make
sure it is available if VBE is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-08 10:07:26 -07:00
Simon Glass
477fd6a301 boot: Allow use of FIT in TPL and VPL
With VBE we want to use FIT in all phases of the boot. Add Kconfig
options to support this.

Disable the options for sandbox_vpl for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-08 10:07:26 -07:00
Simon Glass
30158145ac boot: Respect the load_op in fit_image_load()
Some code has crept in which ignores this parameter. Fix this and add a
little debugging.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-08 10:07:26 -07:00
Simon Glass
b7a93ebdaa bootstd: Avoid sprintf() in SPL when creating bootdevs
The name of the bootdev device is not that important, particular in SPL.
Save a little code space by using a simpler name.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-08 10:07:26 -07:00
Simon Glass
59e8a1ef24 boot: Allow FIT to fall back from best-match option
When the best-match feature fails to find something, use the provided
config name as a fallback. The allows SPL to select a suitable config
when best-match is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-08 10:07:26 -07:00
Simon Glass
fc1906ea72 bootmeth_extlinux: Refactor extlinux to split boot
Add a new extlinux_setup() function which sets things up so that the
bootflow can either be booted, or just probed.

Provide a readall() method so that images can be read into memory,
without booting the OS. Adjust the boot() method so that it can boot,
after any changes have been made by the user.

Update the test to change the bootargs and check that they are booted
with the changes intact.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
a976bcf2b4 pxe_utils: Refactor to separate reading from booting
It is useful to be able to select a bootflow and read its images,
without actually doing the boot. This allows adjusting the bootargs, for
example.

Provide support for this in the pxe_utils module, by adding a 'probe'
method which selects a label and saves its settings, so it can be booted
later, if desired.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
13eb86be35 boot: Detect booti format properly in pxe_utils
Rather than assuming that a file can be booted with bootm, check that
the format is correct first. Do the same for booti.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
c137ff3399 pxe: Deal with a missing FDT in the bootflow
Move processing of a missing FDT so that it happens before booting, so
we can see the result in the bootflow.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
4edac0db4d pxe: Collect the FDT in the bootflow
Move processing of the FDT so that it happens before booting. Add a test
to check that the FDT is now visible.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
2283ab0538 bootstd: Update extlinux and pxe to allow boot interruption
It is useful to be able to inspect things before the OS is actually
booted, perhaps to check that all is well or to adjust the kernel
command-line. Implement the 'read_all()' method to allow this.

Provide a simple test to check that the images are found.

For now it is not possible to actually continue the uninterrupted boot,
without re-reading all the images.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
2d7ae1a1b5 bootmeth_extlinux: Move boot code into common file
The extlinux and PXE code for booting is almost the same. Move it into
the common file so it is easier to keep it in sync.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
c4ec5afb7b bootmeth_pxe: Drop the driver-private data
Since this driver's plat-data already contains a PXE context, use that.
Drop the priv-data. Use the extlinux_info which is in there, as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
178bfbad7f bootmeth_pxe: Implement the fallback option
Provide this feature in PXE, so that it matches extlinux. Use plat data
for this, just like extlinux.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
2b999dc440 bootmeth: Refactor to put options in a common file
The fallback feature is implemented for extlinux but not for PXE. Move
the code into common files so we can keep both pieces in sync.

Tidy up the comment for set_property() while we are here, fixing the
return value and some missing hyphens.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
66fa52bb1b bootmeth_extlinux: Move pxe_context into plat
Move this struct into the plat data so that we can use it multiple times
during the boot process.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
e413f1735c bootmeth_extlinux: Move extlinux_info into plat
Move this struct into the plat data so that we can use it multiple times
during the boot process.

This struct is missing a comment, so add one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
415cd2e8c0 pxe: Allow skipping the boot
Provide a way to skip booting the OS and just return. This will allow
bootstd to read out useful information.

Add debugging to help figure out the flow.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
35dea9df30 pxe: Record the bootflow in the PXE context
At present the only option with PXE is to boot it and see what happens.

Provide a bootflow, when available, so that PXE will eventually be able
to add some useful information to it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
70d37cbab9 pxe: Drop the cmdline parameter
Now that PXE can operate without the command line, drop the parameter
throughout the code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00
Simon Glass
c4da3552b2 boot: Avoid using the cmdline in bootmeth_pxe and pxe cmd
Use the new netboot_run() function to avoid building a command line,
when running these network operations.

For the one board which uses lwip, it is not quite clear how to avoid
using the cmdline interface, so produce an error, for now. This can be
figured out later.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-19 05:55:32 -07:00