Compare commits

..

17 Commits
load2 ... hein

Author SHA1 Message Date
Simon Glass
c0ca15a113 scripts: Always use the RNG device with QEMU
There is no harm in always having this device enabled, thus reducing the
number of script arguments. Enable RNG always.

Series-to: concept
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-07-28 07:09:32 +12:00
Simon Glass
a6e328e9e1 Merge branch 'ci2' into 'master'
boot: Fix select_image() as per the v2 series

See merge request u-boot/u-boot!135
2025-07-26 11:54:01 +00:00
Simon Glass
e43877b1e7 boot: Fix select_image() as per the v2 series
The v1 series was applied instead of v2. This has a bug in
select_image(). Bring in the v2 patch.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 782cfbb259 ("image: Introduce fit_image_load() to load images from FITs")
2025-07-26 23:41:14 +12:00
Simon Glass
190d459c52 Merge branch 'load' into 'master'
boot: Make fit_image_load() easier to maintain

See merge request u-boot/u-boot!132
2025-07-24 04:51:34 +00:00
Simon Glass
44d8b15319 boot: Tidy local variables in fit_image_load()
Arrange these so that they look a little nicer.

Series-to: u-boot
Cover-letter:
boot: Make fit_image_load() easier to maintain
Before fit_image_load() was created, The code to load kernels, ramdisks
and devicetrees from a FIT was spread around many functions. By
combining most of the code in one place, it became possible to add more
features in a consistent way. The 'loadables' feature much easier to
plumb in, for example.

While fit_image_load() was a substantial advance, it has never been a
svelte function and the passing years have not been entirely kind. With
a few new features on the horizon, this is a good time to improve the
implementation.

This series splits much of the code from fit_image_load() into a number
of smaller functions. Most of the changes are fairly mechanical, with
just a few renames and tweaks here and there.

This should make the function much easier to maintain. It may also
encourage someone to take a look at its callers, which could also use
some attention.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
15d7dce9ef boot: Drop unnecessary data variable
This is always the same as 'buf' and is not used in any case. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
cc26525a8d boot: Move setting the OS arch into check_allowed()
Remove a few more lines from fit_image_load() by dealing with this small
detail in check_allowed().

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
270e4ca401 boot: Move decomp_image() into handle_load_op()
Decompress is really part of loading, so simplify the code slightly by
moving decompression out of the top-level fit_image_load() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
c449c3b1ba boot: Move image-decompression into a separate function
Move handling of decompression (or perhaps relocation) of the image into
a separate function, to slim down fit_image_load() a little more.

Move the bootstage_mark() call in there too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
ac3df70b19 boot: Move the architecture check into check_allowed()
We may as well have all the checks together, so move the call to
fit_image_check_target_arch() into check_allowed().

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
d26ffac393 boot: Check the image is allowed before setting os.arch
There is no point in setting the architecture if the image cannot be
used. Move the check a little higher within fit_image_load().

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
0816223cda boot: Move obtaining data from a FIT image into a function
Move this code into a separate function, to help further slim down
fit_image_load().

Move the bootstage_mark() call in there too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
32af0ac54c boot: Move handling of the load_op into a separate function
Since fit_image_load() is still too long, move the load-operation
handling into a separate function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
f7f6b1e585 boot: Move type and OS checking into a new function
Move the code which checks whether the image can be loaded into a
separate check_allowed() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
fcbd824835 boot: Tidy up setting of the OS arch on host builds
This field is not present in host builds. Create an inline function to
handle this complexity, so we can drop the #ifdef in the C file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
84985dc633 boot: Move call to fit_image_select() and rename it
This function is named a bit vaguely, since it prints some info and then
does verification of the image.

Rename it to print_and_verify() and move the call to select_image().

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00
Simon Glass
f79ae3e036 boot: Split out the first part of fit_image_load()
This function is over 250 lines long. Split out the image-selection part
into its own function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 20:19:42 -06:00

View File

@@ -178,10 +178,9 @@ sct_mnt = /mnt/sct
else:
tout.warning(f"Disk image '{disk}' not found")
if args.rand:
cmd.extend(['-object', 'rng-random,filename=/dev/random,id=rng0',
'-device',
'virtio-rng-pci,rng=rng0,max-bytes=1024,period=1000'])
cmd.extend(['-object', 'rng-random,filename=/dev/random,id=rng0',
'-device',
'virtio-rng-pci,rng=rng0,max-bytes=1024,period=1000'])
def add_common_args(parser):
"""Add some arguments which are common to build-efi/qemu scripts
@@ -211,8 +210,6 @@ def add_common_args(parser):
parser.add_argument(
'-R', '--release', default='24.04.1',
help='Select OS release version (e.g, 24.04) Default: 24.04.1')
parser.add_argument('--rand', '--random', action='store_true',
help='Provide a random-number device')
parser.add_argument('-s', '--serial-only', action='store_true',
help='Run QEMU with serial only (no display)')
parser.add_argument(