Commit Graph

98298 Commits

Author SHA1 Message Date
Simon Glass
56c6289442 fs: Create a header file for filesystem-related commands
Most commands access the filesystem through the command-line interface
rather than the filesystem API itself. Add a new header file which
contains these functions, so we can separate commands from the API.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 12:30:56 -06:00
Simon Glass
05e5d61cf7 fs: Create a common header for legacy and new
Some parts of fs_legacy.h are useful for the new fs subsystem. Add a
common header and move the filesystem types and some definition into it.

Use an enum for the filesystem type, to permit type checking.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 12:30:56 -06:00
Simon Glass
fba734be3c fs: Provide an SPL Kconfig for legacy-filesystem support
Add a new SPL_FS_LEGACY which mirrors the recently added FS_LEGACY
option.

Select this new option when filesystems are required, either due to
SPL_FS_LOADER or one of the filesystems.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 12:30:55 -06:00
Simon Glass
14d2361c95 fs: Provide a Kconfig option for legacy-filesystem support
There is currently no Kconfig used and the filesystem code is always
included in U-Boot proper. Add an option to control this. For now it is
always on.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 10:16:25 -06:00
Simon Glass
4acf3a243b fs: Rename fs.c to fs_legacy.c
A new filesystem interface is coming, so rename the main fs.c file to
indicate that it is the old one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 07:53:25 -06:00
Simon Glass
8a698cf850 fs: Rename fs.h to fs_legacy.h
A new filesystem interface is coming, so rename the current header to
indicate that it is the old one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 07:53:25 -06:00
Simon Glass
ddaa12e605 sandbox: Update os_open() to return an error code
It is convenient to be able to report the system error when available.
Update os_open() to return it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 07:53:25 -06:00
Simon Glass
8abb925523 dm: Rename dev_get_child_count() to dev_read_child_count()
The existing name is confusing as this function relates to the
devicetree rather than the device itself.

Rename it to include the word 'read' like other functions in this API.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 07:53:25 -06:00
Simon Glass
d40e88a868 blk: Use hex indices for the device name
It is confusing to use decimal values in device names. For example, with
virtio:

  => dm tree
  ...
  pci           5  [ + ]   pci_bridge_drv        |   |-- pci_0:1.5
    virtio        5  [ + ]   virtio-pci.m          |   |   `-- virtio-pci.m#5
   blk           0  [ + ]   virtio-blk            |   |       |-- virtio-blk#5
   partition     0  [ + ]   blk_partition         |   |       |   |-- virtio-blk#5:1
   partition     1  [ + ]   blk_partition         |   |       |   |-- virtio-blk#5:14
   partition     2  [ + ]   blk_partition         |   |       |   |-- virtio-blk#5:15
   partition     3  [ + ]   blk_partition         |   |       |   `-- virtio-blk#5:16
   bootdev       2  [ + ]   virtio_bootdev        |   |       `-- virtio-blk#5.bootdev
   pci           6  [ + ]   pci_bridge_drv        |   |-- pci_0:1.6
   ...
  => ls virtio 0:14
  ** Invalid partition 20 **
  Couldn't find partition virtio 0:14

Fix this by using hex for both the block-device number and the partition.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 07:53:25 -06:00
Simon Glass
1c71a3f024 Merge branch 'qemd' into 'master'
virtio: Add a fully functional virtio emulator

See merge request u-boot/u-boot!109
blob-28jun25
2025-06-28 13:52:26 +00:00
Simon Glass
9fec7f9af0 sandbox: Enable the new virtio emulator
Add the devicetree snippet to include the new virtio block-device
emulator in the test devicetree.

Series-to: u-boot
Cover-letter:
virtio: Add a fully functional virtio emulator
The current implementation of virtio in sandbox is fairly basic. It is
enough to test the behaviour of queues, but it does not test the full
stack, e.g. using MMIO to access a block device.

This series adds a new type of virtio emulator which is capable of
handling MMIO. Some support for MMIO is added to sandbox in the process.
With this, a dummy block device can be used from within U-Boot, without
running on QEMU
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 06:36:10 -06:00
Simon Glass
fed943af6b virtio: Implement a simple block-device emulator
Add an emulator driver for block devices, so that sandbox can test these
fully. The emulator uses MMIO to communicate with the controlling virtio
device.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 06:36:10 -06:00
Simon Glass
3092ddbc88 virtio: Implement a proper sandbox emulator
The existing sandbox implementation of virtio only tests the basic API.
It is not able to provide a block device, for example.

Add a new implementation which operations at a higher level. It makes
use of the existing MMIO driver to perform virtio operations.

This emulator-device should be the parent of a function-specific
emulator. That emulator uses this MMIO transport to communicate with the
controller:

	virtio-blk {
		compatible = "sandbox,virtio-blk-emul";

		mmio {
			compatible = "sandbox,virtio-emul";
		};
	};

A new UCLASS_VIRTIO_EMUL uclass is created for the child devices, which
implement the actual function (block device, random-number generator,
etc.)

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 06:36:09 -06:00
Simon Glass
9377438d02 virtio: Export a few things from virtio_mmio.c
Add a header file to allow other drivers to implement MMIO and share the
code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 20:55:01 -06:00
Simon Glass
48fa764914 virtio: Move bindings for virtio IDs to dt-bindings
These values are used in the devicetree and the C code, so move them to
a new dt-bindings header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 20:55:01 -06:00
Simon Glass
f09acc02f2 sandbox: Support memory-mapped I/O
Add a way for calls to readl()/writel() etc. to be picked up by a driver
in order to implement MMIO.

This works by registering some functions, which are then called when
accesses occur.

Add comments to sandbox_read() and sandbox_write() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 20:55:01 -06:00
Simon Glass
0807f9a068 sandbox: Move memory-related functions to a separate file
Add a new mem.c file and move memory-related functions to it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 20:55:01 -06:00
Simon Glass
b1936206e2 alist: Allow inclusion from OS headers
Sandbox needs to include system headers in some files, but also wants
to use alist. Adjust the headers to permit this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 07:50:11 -06:00
Simon Glass
1f24e6ec71 dm: Move UCLASS_FFA_EMUL into the correct place
This uclass ID should be up with the other emulators, so move it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 20:19:42 -06:00
Simon Glass
92a414bba0 test: Unset make variables before running make again
The new Kbuild changes have broken this script, so 'make qcheck' and
'make pcheck' don't work anymore.

Unset some environment variables to resolve this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: bf030467d2 (Merge patch series "Update kbuild")
2025-06-27 20:19:42 -06:00
Simon Glass
7452a49d13 mbed: Remove check_files.py
This script has conflict markers in it so comes up as an unwanted match
when searching them. Remove the file since it is not used in U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-27 05:48:01 -06:00
Simon Glass
f737237d29 Merge branch 'fast' into 'master'
emulation: Improve support for booting from QFW

Closes #7

See merge request u-boot/u-boot!103
2025-06-12 20:47:50 +00:00
Simon Glass
3cac4dd7a4 emulation: Allow booting without CMDLINE
Use programmatic boot so that it is possible to boot without
CONFIG_CMDLINE enabled.

Series-to: u-boot
Cover-letter:
emulation: Improve support for booting from QFW
U-Boot supports booting Linux from QFW which means that the kernel and
any initrd are provided on the QEMU command line instead of being found
in boot media.

This series improves this support in several ways:
- Enhances bootstd to implement 'bootflow read', thus allowing the
  files to be loaded and inspected (with potential cmdline changes)
  before booting
- Updates bootstd to use programmatic boot, so that it works even when
  CONFIG_CMDLINE is disabled
- Expands build-qemu script to allow providing cmdline and root disk

It also includes a rough script to time U-Boot when running QEMU with
kvm, making use of the qemu-boot-time repo:

   https://github.com/stefano-garzarella/qemu-boot-time.git
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
28548b43b6 emulation: Support zboot in the qfw bootmeth
The zboot option is used on x86, so add support for it. Use the
programmatic boot API rather than building a command to run, so that it
can work without CONFIG_CMDLINE

For now the other boot options still use the cmdline.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
90aa800f03 emulation: Support read_all() in qfw bootmeth
It is useful to be able to read the images into memory without actually
booting the kernel. This allows the cmdline to be changed using
'bootflow cmd', for example. Implement this for the QFW bootmeth.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
2d5444b467 emulation: Place the setup area as QEMU requests
QEMU provides a SETUP_ADDR value which should be honoured when placing
the setup block, since that block can include pointers into other parts
of itself.

Instead of putting the setup block immediately before the kernel, put it
where QEMU requests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
550cf4ca0c emulation: Move qfw reading into a new function
Add a new qemu_fwcfg_read_files() function which reads files into the
provided location. Use this from qemu_fwcfg_setup_kernel()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
10d50ff11a emulation: Refactor how the kernel is set up
The qemu_fwcfg_setup_kernel() function checks whether a kernel exists
and also reads it. With bootstd we want to do those two steps
separately.

Add a new qemu_fwcfg_read_info() function which gets all the values and
returns then, including the full cmdline. Use that from the outer
function.

The new function also reads the setup address, although this it not used
by the code at present.

Use an abuf for the cmdline since we don't want the read_info function
to alter unallocated memory.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
a79751c65d emulation: Move endianness conversion into qfw_read_size()
Instead of worrying about endianness in each expression, move the
conversion into the function.

Use ulong for values, since this is the normal type for addresses in
U-Boot

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
97dd8f5b13 emulation: Use a function to get a selector size
Move the selector reading into a separate function so we can simplify
qemu_fwcfg_setup_kernel().

Read all sizes at the start and add an enum for the selector.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
4a504a9c59 emulation: Rename data_addr in qemu_fwcfg_setup_kernel()
This is a pointer, not an address, so rename the variable. Also drop the
unnecessary assignment.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
2e1d6e0db8 boot: Add a way to get writable image information
The bootflow_img_find() function does not permit updating the image.
Some bootmeths may want to do this, e.g. to change the address. Add a
function which returns a writeable pointer.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
8fd296aae9 abuf: Add a way to set up an abuf with a given address
In some cases it is convenient to provide an address when initing an
abuf, instead of a pointer. Add a function for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
a6fca9a51b x86: Move ramdisk higher
With kernel size going above 15M we need enough space between where the
kernel loaded and the ramdisk, otherwise the kernel corrupts its ramdisk
while relocating itself. Move the ramdisk up to 128M

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
78dead849f x86: Emit a post code before booting
It is possible to benchmark U-Boot using QEMU as described here:

   https://github.com/stefano-garzarella/qemu-boot-time

On x86 devices, that script can read post codes from a perf trace. Add
a code which is emitted just before handing off to the Linux kernel.
Existing post codes can be used to determine when U-Boot starts.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
f82cc0ee80 contrib: Add a script to time booting with QEMU
It is possible to use QEMU and kvm to measure the time taken by U-Boot
to hand off to Linux. Add a script to support this and print the
resulting time.

This requires a fair bit of setup; see the script for details.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
8001779b9b scripts: build-qemu: Support running qboot
Qboot is a good demonstration of the fastest possible boot on x86. Add
a way to run Qboot instead of U-Boot, for easy comparison.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
2d461a7186 scripts: build-qemu: Add a way to set the linux root
Add -t and -U flags to set the root for Linux, to a device or a UUID,
respectively.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
b6f9ded4bc scripts: build-qemu: Add a way to enable linux console
Add a -C flag to enable the serial console when booting Linux. This is
only supported on x86, but a future -c flag might perhaps support other
archs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
8f28573146 scripts: build-qemu: Add a way to pass kernel and ramdisk
QEMU provides a special way to pass a kernel and a devicetree via the
QFW interface. Add -K and -I options to provide these.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
b3743e7120 scripts: build-qemu: Fix message when creating config file
The message is missing an f-string specifier. Add it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-12 19:43:54 +00:00
Simon Glass
0b86fd51f0 Merge branch 'ci' into 'master'
tools updates, boot docs, fdt ramdisk fix

Closes #4, #3, and #2

See merge request u-boot/u-boot!106
2025-06-10 20:51:26 +00:00
Yang Xiwen
95308540b7 arm: qemu: Add imply CONFIG_POSITION_INDEPENDENT
Add 'imply CONFIG_POSITION_INDEPENTDENT' for QEMU arm arch. This allows
qemu arm boards to load u-boot.bin at any address. It is skipped by
default when u-boot is loaded by either --bios or --kernel.

To load u-boot.bin at a different address, one can use u-boot
chain-loading or qemu loader device[1].

[1] https://www.qemu.org/docs/master/system/generic-loader.html

Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
Fixes: #4
2025-06-10 14:09:14 -06:00
Yang Xiwen
f46720788b arm: armv7: restore section to .text after saved_args
when CONFIG_BLOBLIST is enabled, the section is switched to .data but is
not switched back to .text. It makes all the code below placed in .data
section, also breaks CONFIG_POSITION_INDEPENDENT.

Fix it by adding `.section .text` to switch the section back to .text.

Fixes: 5103e69344 ("arm: armv7: save boot arguments")
Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
2025-06-10 14:09:14 -06:00
Moteen Shah
a791ce800d binman: ftest.py: Add testcase for bootph-* propagation
Add a testcase to ensure that scan_and_prop_bootph() actually
propagates bootph-* properties to supernodes.

Signed-off-by: Moteen Shah <m-shah@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reduce subject below 60-char limit:
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-10 14:09:14 -06:00
Moteen Shah
e4e3075659 binman: Propagate bootph-all/-some-ram to supernodes
As per bootph schema, bootph-* property in child node should be
implied in their parent, but this feature is not implemented in
the U-Boot proper stage (before relocation) resulting in devices
not being bound because of the missing bootph-all or bootph-some-ram
property in the parent node.

To mitigate this issue, add a function to scan through all the nodes
in the device-tree for bootph-all and bootph-some-ram properties. If
found, propagate it to all of its parent nodes up the hierarchy.

Signed-off-by: Moteen Shah <m-shah@ti.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Reduce subject below 60-char limit:
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-10 14:09:14 -06:00
Bryan Brattlof
fd7290c2b2 binman: add atf-bl1 to etypes
Some SoCs require a Trusted Firmware-A (TF-A) AP Trusted ROM (BL1) to
initialize the SoC before U-Boot can run properly. Add an atf-bl1 etype
so we can properly package BL1 into a final binary

Signed-off-by: Bryan Brattlof <bb@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>
2025-06-10 14:09:14 -06:00
Quentin Schulz
204dd218a9 binman: Provide more explicit error for key-name-hint with path
key-name-hint property in u-boot-spl-pubkey-dtb binman entry may contain
a path instead of a filename due to user mistake.

Because we currently assume it is a filename instead of a path, binman
will find the full path to the key based on that path, and return the
dirname of the full path but keeps the path in key-name-hint instead of
stripping the directories from it.

This means mkimage will fail with the following error message if we have
key-name-hint set to keys/dev:

binman: Error 1 running 'fdt_add_pubkey -a sha256,rsa2048 -k /home/qschulz/work/upstream/u-boot/keys -n keys/dev -r conf /home/qschulz/work/upstream/u-boot/build/ringneck/u-boot-spl-dtbdhsfx3mf': Couldn't open RSA certificate: '/home/qschulz/work/upstream/u-boot/keys/keys/dev.crt': No such file or directory

Let's make it a bit more obvious what the error is by erroring out in
binman if a path is provided in key-name-hint (it is named key-name-hint
and not key-path-hint after all).

Fixes: 5609843b57 ("binman: etype: Add u-boot-spl-pubkey-dtb etype")
Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reduce subject below 60-char limit
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-10 14:09:14 -06:00
Quentin Schulz
122a4942eb binman: etype: fit: raise ValueError if key-name-hint is a path
mkimage doesn't fail if it cannot find the public key but it prints to
stderr. Considering that btool.run() discards stderr, it means binman
happily returns an unsigned FIT and doesn't tell you something went
wrong.

Binman will actually find the file if there's a path in the
key-name-hint property but the current logic expects key-name-hint to be
a filename and thus returns the dirname of the found path for the key,
but with the original key-name-hint appended. This means we can have the
following:

- key-name-hint = "keys/dev"
- name = "/home/qschulz/work/upstream/u-boot/keys/"

so we pass /home/qschulz/work/upstream/u-boot/keys/ to the -k option of
mkimage but the FIT still contains "keys/dev" in key-name-hint which
means mkimage will try to find the key at
/home/qschulz/work/upstream/u-boot/keys/keys/, which doesn't exist.

Let's assume paths are simply not supported (it is named key-name-hint
and not key-path-hint after all) and raise an error if the property
contains a path so that the build fails and not quietly.

Fixes: 133c000ca3 ("binman: implement signing FIT images during image build")
Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-06-10 14:09:14 -06:00
George Chan
139bca49c5 fdt: fdt chosen cmd had off-by-one issue
The kernel searching bootconfig will be off-by-1 and never match
thus always not found in this case.

Signed-off-by: George Chan <gchan9527@gmail.com>
Use 'fdt' as the tag and update fdt_test_chosen:
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-10 14:08:51 -06:00