Compare commits

...

3 Commits
stc2 ... stc

Author SHA1 Message Date
Simon Glass
77caae89c6 rpi: Use the U-Boot control FDT for fdt_addr
The fdt_addr variable is used in extlinux as a fallback devicetree if
none is provided by the boot command.

The existing mechanism uses the devicetree provided to U-Boot, but in
its original, unrelocated position. For the rpi_4 I am using, this is
at 2b35ef00 which is not a convenient place in memory, if the ramdisk
is large.

U-Boot already deals with this sort of problem by relocating the FDT
to a safe address.

So use the control-FDT address instead.

Remove the existing comment, which is confusing, since the FDT is not
actually passed unmodified to the kernel: U-Boot adds various things
using its FDT-fixup mechanism.

Note that board_get_usable_ram_top() reduces the RAM top for boards with
less RAM. This behaviour is left unchanged as there is no other
mechanism for U-Boot to handle this.

Series-to: u-boot
Cover-letter:
rpi: Tidy up booting
This series allows rpi to boot a compressed Ubuntu kernel with ~100MB
ramdisk, by expanding the available space.

It also tidies up some strange behaviour with the provided FDT, where a
separate pointer is maintained to it, even though U-Boot has copied it
and placed it in its own space. This avoids strange bugs where it
accidentally gets overwritten when loading a file into memory.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-06 06:09:56 -07:00
Simon Glass
a88f242a01 fdt: Allow expanding the devicetree during relocation
Some boards set fdt_high to -1 which means that the FDT is not relocated
in boot_relocate_fdt().

A comment in that function says that we assume there is space after the
existing fdt to use for padding, with the padding size set to
CONFIG_SYS_FDT_PAD

However, there is no guarantee that this space is available. If using
the control FDT, then global_data is immediately above it, so expanding
the FDT and adding FDT properties will cause U-Boot to fail.

Add a new Kconfig option to provide the required space, enabling it by
default.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-06 06:09:26 -07:00
Simon Glass
6c54214460 rpi: Update environment to support booti and large initrd
The existing values don't provide for decompressing an arm64 boot-image.
Add those values and move things apart a bit so that a 50MB kernel can be
accomodated.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-05 19:39:04 -07:00
4 changed files with 29 additions and 18 deletions

View File

@@ -3,6 +3,8 @@
* (C) Copyright 2012-2016 Stephen Warren
*/
#define LOG_CATEGORY LOGC_BOARD
#include <config.h>
#include <dm.h>
#include <env.h>
@@ -325,19 +327,10 @@ static void set_fdtfile(void)
env_set("fdtfile", fdtfile);
}
/*
* If the firmware provided a valid FDT at boot time, let's expose it in
* ${fdt_addr} so it may be passed unmodified to the kernel.
*/
/* Allow U-Boot to use its control FDT with extlinux if one is not provided */
static void set_fdt_addr(void)
{
if (env_get("fdt_addr"))
return;
if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
return;
env_set_hex("fdt_addr", fw_dtb_pointer);
env_set_hex("fdt_addr", (ulong)gd->fdt_blob);
}
/*
@@ -572,7 +565,10 @@ int ft_board_setup(void *blob, struct bd_info *bd)
{
int node;
update_fdt_from_fw(blob, (void *)fw_dtb_pointer);
if (blob == gd->fdt_blob)
log_debug("Same FDT: nothing to do\n");
else
update_fdt_from_fw(blob, (void *)gd->fdt_blob);
node = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
if (node < 0)

View File

@@ -69,9 +69,11 @@ fdt_high=ffffffff
initrd_high=ffffffff
#endif
kernel_addr_r=0x00080000
scriptaddr=0x02400000
pxefile_addr_r=0x02500000
fdt_addr_r=0x02600000
ramdisk_addr_r=0x02700000
kernel_comp_addr_r=0x02000000
kernel_comp_size=0x02000000
scriptaddr=0x05400000
pxefile_addr_r=0x05500000
fdt_addr_r=0x05600000
ramdisk_addr_r=0x05700000
boot_targets=mmc usb pxe dhcp

View File

@@ -553,8 +553,10 @@ static int reserve_fdt(void)
* section, then it will be relocated with other data.
*/
if (gd->fdt_blob) {
gd->boardf->fdt_size =
ALIGN(fdt_totalsize(gd->fdt_blob), 32);
int size = fdt_totalsize(gd->fdt_blob);
gd->boardf->fdt_size = ALIGN(size + CONFIG_OF_EXPAND,
32);
gd->start_addr_sp = reserve_stack_aligned(
gd->boardf->fdt_size);

View File

@@ -219,6 +219,17 @@ config OF_OMIT_DTB
This is used for boards which normally provide a devicetree via a
runtime mechanism (such as OF_BOARD), to avoid confusion.
config OF_EXPAND
hex # "Amount to allow the control FDT to expand"
default SYS_FDT_PAD if OF_LIBFDT
default 0
help
Some boards make use of the control FDT to boot an OS, thus when
image_setup_libfdt() adds extra things to the end of the FDT, there
needs to be enough space.
Set this to the number of bytes of extra space required for the FDT.
config DEFAULT_DEVICE_TREE
string "Default Device Tree for DT control"
depends on OF_CONTROL