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>
57 lines
2.1 KiB
ReStructuredText
57 lines
2.1 KiB
ReStructuredText
.. SPDX-License-Identifier: GPL-2.0+
|
|
|
|
Devicetree in QEMU
|
|
==================
|
|
|
|
For QEMU on ARM, RISC-V and one PPC target, the devicetree is created on-the-fly
|
|
by QEMU. It is intended for use in Linux but can be used by U-Boot also, so long
|
|
as any nodes/properties needed by U-Boot are merged in.
|
|
|
|
When `CONFIG_OF_BOARD` is enabled
|
|
|
|
|
|
Obtaining the QEMU devicetree
|
|
-----------------------------
|
|
|
|
Where QEMU generates its own devicetree to pass to U-Boot you can use
|
|
`-dtb u-boot.dtb` to force QEMU to use U-Boot's in-tree version.
|
|
|
|
To obtain the devicetree that qemu generates, add `-machine dumpdtb=qemu.dtb`,
|
|
e.g.::
|
|
|
|
qemu-system-arm -machine virt -machine dumpdtb=qemu.dtb
|
|
|
|
qemu-system-aarch64 -machine virt -machine dumpdtb=qemu.dtb
|
|
|
|
qemu-system-riscv64 -machine virt -machine dumpdtb=qemu.dtb
|
|
|
|
|
|
Merging in U-Boot nodes/properties
|
|
----------------------------------
|
|
|
|
Various U-Boot features require nodes and properties in the U-Boot devicetree
|
|
and at present QEMU is unaware of these. To use these you must manually merge
|
|
in the appropriate pieces.
|
|
|
|
One way to do this is with dtc. This command runs dtc on each .dtb file in turn,
|
|
to produce a text file. It drops the duplicate header on the qemu one. Then it
|
|
joins them up and runs them through dtc to compile the output::
|
|
|
|
qemu-system-arm -machine virt -machine dumpdtb=qemu.dtb
|
|
cat <(dtc -I dtb qemu.dtb) <(dtc -I dtb u-boot.dtb | grep -v /dts-v1/) | dtc - -o merged.dtb
|
|
|
|
You can then run qemu with the merged devicetree, e.g.::
|
|
|
|
qemu-system-arm -machine virt -nographic -bios u-boot.bin -dtb merged.dtb
|
|
|
|
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>`_.
|