hw/arm/boot: load device tree to base of DRAM if no -kernel option was passed
PATCH 1/1 hw/arm/boot: load device tree to base of DRAM if no -kernel option was passed
If we are running the 'virt' machine, we may have a device tree blob but no kernel to supply it to if no -kernel option was passed. In that case, copy it to the base of DRAM where it can be picked up by a bootloader executing from NOR flash.
---
v2: comment style, call exit(1) on load_dtb() failure
hw/arm/boot.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
hw/arm/boot.c +11 -0
@@ -459,6 +459,17 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)/* Load the kernel. */ if (!info->kernel_filename) { + +if (have_dtb (info)) { +/* If we have a device tree blob, but no kernel to supply it to, +* copy it to the base of DRAM for a bootloader executing from +* NOR flash to pick up. +*/ +if (load_dtb (info->loader_start, info)) { +exit (1 ); + } + } +/* If no kernel specified, do nothing; we will start from address 0 * (typically a boot ROM image) in the same way as hardware. */
Signature · 1 line
1.8.3.2
Quoted 8 lines · Ard Biesheuvel
If we are running the 'virt' machine, we may have a device tree blob but no kernel to supply it to if no -kernel option was passed. In that case, copy it to the base of DRAM where it can be picked up by a bootloader executing from NOR flash.
Signed-off-by Ard Biesheuvel <[email protected]>---
v2: comment style, call exit(1) onload_dtb()failure
On respins, please add "Vx" to git subject prefix.
git fomat-patch --subject-prefix "PATCH v2"
Quoted 9 lines
hw/arm/boot.c | 11 +++++++++++ 1 file changed, 11 insertions(+)hw/arm/boot.c +0
-0
hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 466
Quoted 8 lines
hw/arm/boot.c +5
-0@@ -459,6 +459,17 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)/* Load the kernel. */ if (!info->kernel_filename) { + +if (have_dtb (info)) { +/* If we have a device tree blob, but no kernel to supply it to, +* copy it to the base of DRAM for a bootloader executing from +* NOR flash to pick up.
arm/boot is generic code so you shouldn't mention the specifics of DRAM/NOR implementation. s/DRAM/RAM and can remove "executing from NOR flash" completely.
hw/arm/boot.c void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) · line 472
Quoted 6 lines
hw/arm/boot.c +6
-0+*/ +if (load_dtb (info->loader_start, info)) { +exit (1 ); + } + } +
Can we get this functionality in the elf loading path too? With this patch, you now get:
1: -kernel Linux : dtb
2: -kernel elf : no dtb
3: nothing : dtb
It would be nice and consistent if you always got a dtb. If the elf sections overlap the dts, then the elf should take precedence. Not sure if the ROM loading framework supports this natively just yet though.
This would allow for easier debugging of your bootloader as an elf guest, rather that having to do build cycles all the way down to firmware blob image.
Regards,
Peter
Quoted 7 lines
hw/arm/boot.c +0
-1/* If no kernel specified, do nothing; we will start from address 0 * (typically a boot ROM image) in the same way as hardware. */ --1.8.3.2