emulation: fdt: Allow using U-Boot's device tree with QEMU

At present it is impossible to change the qemu_arm64 defconfig to
obtain a devicetree from the U-Boot build.

This is necessary for FIT validation, for example, where the signature
node must be compiled into U-Boot.

A proposed change to QEMU to allow device tree additions has been
blocked for several years. The only known workaround is to use QEMU's
dumpdtb option, merge in the signature node manually, disable
OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
complicated enough that it is documented in U-Boot[1].

Unfortunately the only way to disable OF_HAS_PRIOR_STAGE at present is
to hack the Kconfig.

Add a new QEMU_MANUAL_DTB Kconfig option which makes OF_HAS_PRIOR_STAGE
optional, thus avoiding needing to patch U-Boot to get this working.

This seems a clearer solution than just making OF_HAS_PRIOR_STAGE
visible, since that symbol is intended to be set automatically by each
platform.

Series-to: u-boot
Series-cc: trini
Series-cc: Peter Maydell <peter.maydell@linaro.org>
Series-cc: Andrew Phelps <andrew.phelps@canonical.com>
Series-cc: ilias
Series-changes: 2
- Add a new QEMU-specific Kconfig instead
- Move patch into the standard-passage series

Series-changes: 3
- Fix 'usiing' typo
- Add mention of QEMU_MANUAL_DTB in doc/

[1] https://docs.u-boot.org/en/latest/develop/devicetree/dt_qemu.html
Link: https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Simon Glass
2025-04-04 06:42:25 +13:00
parent 6c1e1062ac
commit 14cce62f78
4 changed files with 28 additions and 3 deletions

View File

@@ -46,3 +46,11 @@ You can then run qemu with the merged devicetree, e.g.::
Note that there seems to be a bug in some versions of qemu where the output of
dumpdtb does not quite match what is provided to U-Boot.
It is also possible to enable CONFIG_QEMU_MANUAL_DTB so that U-Boot's devicetree
is built as part of u-boot.bin and can potentially be supplied to QEMU.
See also the
`rejected QEMU patch <https://patchwork.kernel.org/project/qemu-devel/patch/20231117021840.117874-1-sjg@chromium.org>`_
and
`discussion <https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org>`_.