Commit graph

13 commits

Author SHA1 Message Date
Simon Glass
68727fac69 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-22 09:47:50 -06:00
Simon Glass
9ecc1cabe1 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-22 09:47:50 -06:00
Simon Glass
65250625c5 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-22 09:47:50 -06:00
Simon Glass
df42d54b96 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-22 09:47:50 -06:00
Simon Glass
42fb767da4 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-22 09:47:50 -06:00
Simon Glass
36d6c89950 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-22 09:47:49 -06:00
Simon Glass
d337037e1a 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-22 09:47:49 -06:00
Simon Glass
91f27b5b07 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-22 09:47:49 -06:00
Simon Glass
0148c14e04 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-22 09:47:49 -06:00
Simon Glass
ea6cfc55e0 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-22 09:47:49 -06:00
Simon Glass
0a59dc4199 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-22 09:47:49 -06:00
Simon Glass
47e5618508 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-22 09:47:49 -06:00
Simon Glass
190b128252 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-22 09:47:49 -06:00