[PATCH v2 1/4] qemu: overlay signature nodes

Ludwig Nussel ludwig.nussel at siemens.com
Mon May 11 13:18:40 CEST 2026


On 5/7/26 17:33, Simon Glass wrote:
> On Wed, 6 May 2026 at 09:29, Ludwig Nussel <ludwig.nussel at siemens.com> wrote:
>>
>> On 5/4/26 14:26, Simon Glass wrote:
>>> On 2026-04-30T12:25:59, Ludwig Nussel <ludwig.nussel at siemens.com> wrote:
>>>> qemu: overlay signature nodes
>>>> [...]
>>>> diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c
>>>> @@ -147,7 +147,38 @@ int dram_init_banksize(void)
>>>>    int board_fdt_blob_setup(void **fdtp)
>>>>    {
>>>>         /* QEMU loads a generated DTB for us at the start of RAM. */
>>>> -     *fdtp = (void *)CFG_SYS_SDRAM_BASE;
>>>> +     void *qemu_fdt = (void *)CFG_SYS_SDRAM_BASE;
>>>> +     int ret;
>>>> +
>>>> +     if (!*fdtp)
>>>> +             goto out;
>>>
>>> This runs the opposite direction to qemu-sbsa, which uses the U-Boot
>>> DT as the base and overlays the QEMU DT onto it (see
>>> fdtdec_board_setup() in board/emulation/qemu-sbsa/qemu-sbsa.c). Done
>>> this way, any node in U-Boot's built-in DT that shares a name with a
>>> QEMU node (/cpus, /memory, /chosen, ...) will have its properties
>>> merged into QEMU's, potentially clobbering the hardware description.
>>> If this is correct, please explain in the commit message why the merge
>>> runs in this direction.
>>
>> IIUC the FDT patching happens before relocation. QEMU starts u-boot from
>> a ROM at address 0 so writing to the embedded DT does not work. QEMU's
>> provided DT is at a writable RAM location so patching that one works.
>>
>> I don't know which direction makes more sense really. If you say merging
>> QEMU's DT into U-Boot's is better then board_fix_fdt() could be used for
>> the merging I guess. Looks like that could work with
>> CONFIG_OF_INITIAL_DTB_READONLY and CONFIG_OF_BOARD_FIXUP set.
> 
> Hmmm now I am wondering how this actually works with sbsa. As you
> point out it's hard to see how the fdtdec_board_setup() works before
> relocation...I don't have the energy to dig into it, though.

AFAICS SBSA relocates u-boot into RAM via 
arch/arm/include/asm/arch-qemu-sbsa/boot0.h on startup.

cu
Ludwig

-- 
Ludwig Nussel
Siemens AG
www.siemens.com


More information about the U-Boot mailing list