rpi: Tidy up booting
v2 cover 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.
The patch to expand the devicetree was dropped, meaning that people should be careful to unset fdt_addr in the environment.
Changes in v2:
- Add new patch to make myself an rpi maintainer
- Add new patch to set bootm_size
- Add new patch to drop fdt_high and initrd_high
- Drop patch to allow expanding the devicetree during relocation
Simon Glass (5):
rpi: Add myself to the list of maintainers
rpi: Set bootm_size to 512MB
rpi: Drop fdt_high and initrd_high
rpi: Update environment to support booti and large initrd
rpi: Use the U-Boot control FDT for fdt_addr
MAINTAINERS | 1 + board/raspberrypi/rpi/rpi.c | 20 ++++++++------------ board/raspberrypi/rpi/rpi.env | 24 +++++++++++++----------- 3 files changed, 22 insertions(+), 23 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/5 rpi: Add myself to the list of maintainers
Add my own name to the list, since existing maintainers are fairly busy.
---
Changes in v2:
- Add new patch to make myself an rpi maintainer
MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -210,6 +210,7 @@ N: aspeed ARM BROADCOM BCM283X / BCM27XX M: Matthias Brugger <[email protected]> M: Peter Robinson <[email protected]> +M: Simon Glass <[email protected]> S: Maintained F: arch/arm/dts/bcm283* F: arch/arm/mach-bcm283x/
Signature · 1 line
2.34.1
PATCH v2 2/5 rpi: Set bootm_size to 512MB
In reply to Simon GlassSet this option so that all boot images stay within the bottom 512MB of memory. This should allow us to drop the fdt_high and initrd_high options.
---
Changes in v2:
- Add new patch to set bootm_size
board/raspberrypi/rpi/rpi.env | 7 +++++++ 1 file changed, 7 insertions(+)
board/raspberrypi/rpi/rpi.env +7 -0
@@ -61,6 +61,13 @@ dfu_alt_info+=zImage fat 0 1 * only 64M, the remaining 25M starting at 0x02700000 should allow quite * large initrds before they start colliding with U-Boot. */ + +/* + * limit bootm_size to 512MB so that all boot images stay within the bottom + * 512MB of memory + */ +bootm_size=0x20000000 + #ifdef CONFIG_ARM64 fdt_high=ffffffffffffffff initrd_high=ffffffffffffffff
Signature · 1 line
2.34.1
Re: [PATCH v2 2/5] rpi: Set bootm_size to 512MB
Quoted 6 lines · Simon Glass
Set this option so that all boot images stay within the bottom 512MB of memory. This should allow us to drop the
fdt_highandinitrd_highoptions.Signed-off-by Simon Glass <[email protected]>Suggested-by Tom Rini <[email protected]>
Signature · 1 line
Tom
PATCH v2 3/5 rpi: Drop fdt_high and initrd_high
In reply to Simon GlassThese are not needed now since there is a bootm_size setting to keep things within the lower part of memory.
Drop them.
---
Changes in v2:
- Add new patch to drop fdt_high and initrd_high
board/raspberrypi/rpi/rpi.env | 7 ------- 1 file changed, 7 deletions(-)
board/raspberrypi/rpi/rpi.env +0 -7
@@ -68,13 +68,6 @@ dfu_alt_info+=zImage fat 0 1 */ bootm_size=0x20000000 -#ifdef CONFIG_ARM64 -fdt_high=ffffffffffffffff -initrd_high=ffffffffffffffff -#else -fdt_high=ffffffff -initrd_high=ffffffff -#endif kernel_addr_r=0x00080000 scriptaddr=0x02400000 pxefile_addr_r=0x02500000
Signature · 1 line
2.34.1
Re: [PATCH v2 3/5] rpi: Drop fdt_high and initrd_high
Quoted 7 lines · Simon Glass
These are not needed now since there is a
bootm_sizesetting to keep things within the lower part of memory.Drop them.
Signed-off-by Simon Glass <[email protected]>Suggested-by Tom Rini <[email protected]>
Signature · 1 line
Tom
PATCH v2 4/5 rpi: Update environment to support booti and large initrd
In reply to Simon GlassThe 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 accommodated.
---
(no changes since v1)
board/raspberrypi/rpi/rpi.env | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
board/raspberrypi/rpi/rpi.env +6 -4
@@ -69,9 +69,11 @@ dfu_alt_info+=zImage fat 0 1 bootm_size=0x20000000 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
Signature · 1 line
2.34.1
Re: [PATCH v2 4/5] rpi: Update environment to support booti and large initrd
Quoted 22 lines · Simon Glass
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 accommodated.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
board/raspberrypi/rpi/rpi.env | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)board/raspberrypi/rpi/rpi.env +0
-2@@ -69,9 +69,11 @@ dfu_alt_info+=zImage fat 0 1 bootm_size=0x20000000 kernel_addr_r=0x00080000 -scriptaddr=0x02400000 -pxefile_addr_r=0x02500000
board/raspberrypi/rpi/rpi.env dfu_alt_info+=zImage fat 0 1 · line 79
Quoted 10 lines
board/raspberrypi/rpi/rpi.env +6
-2-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
As shown in
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
there's a large comment block to update to reflect and explain why the addresses are where they are. Please update that as well to explain the "why" of the "where" things are placed, thanks.
Signature · 1 line
Tom
PATCH v2 5/5 rpi: Use the U-Boot control FDT for fdt_addr
In reply to Simon GlassThe 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.
In version 2, it incorporates some changes to fdt_addr, etc. suggested by Tom, as well as adding myself as a maintainer.
---
Changes in v2:
- Drop patch to allow expanding the devicetree during relocation
board/raspberrypi/rpi/rpi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
board/raspberrypi/rpi/rpi.c +8 -12
@@ -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 )
Signature · 1 line
2.34.1
Re: [PATCH v2 5/5] rpi: Use the U-Boot control FDT for fdt_addr
Quoted 70 lines · Simon Glass
The
fdt_addrvariable 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_4I am using, this is at2b35ef00which 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.In version 2, it incorporates some changes to
fdt_addr, etc. suggested by Tom, as well as adding myself as a maintainer.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Drop patch to allow expanding the devicetree during relocationboard/raspberrypi/rpi/rpi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)board/raspberrypi/rpi/rpi.c +4
-11@@ -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) {
board/raspberrypi/rpi/rpi.c int ft_board_setup(void *blob, struct bd_info *bd) · line 574
Quoted 10 lines
board/raspberrypi/rpi/rpi.c +4
-1int 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 )
Have you tested this to make sure that assorted overlays specified in config.txt are still passed on correctly to the kernel? Or do we end up being OK here due to board_fdt_blob_setup() meaning that we set gd->fdt_blob to fw_dtb_pointer much earlier on, and that hook simply didn't exist back in 2016 when commitade243a211d6 ("rpi: passthrough of the firmware provided FDT blob") introduced some of what you're removing here?
Signature · 1 line
Tom
Re: [PATCH v2 5/5] rpi: Use the U-Boot control FDT for fdt_addr
HI Tom,
Quoted 81 lines · Tom Rini
Quoted 78 lines · Simon Glass
The
fdt_addrvariable 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_4I am using, this is at2b35ef00which 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.In version 2, it incorporates some changes to
fdt_addr, etc. suggested by Tom, as well as adding myself as a maintainer.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Drop patch to allow expanding the devicetree during relocationboard/raspberrypi/rpi/rpi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)board/raspberrypi/rpi/rpi.c +8
-12@@ -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);
Quoted 10 lines
board/raspberrypi/rpi/rpi.c int ft_board_setup(void *blob, struct bd_info *bd) · line 574
Quoted 2 lines
board/raspberrypi/rpi/rpi.c +0
-0node =fdt_node_offset_by_compatible (blob,-1 ,"simple-framebuffer" );if (node <0 )Have you tested this to make sure that assorted overlays specified in config.txt are still passed on correctly to the kernel? Or do we end up being OK here due to
board_fdt_blob_setup()meaning that we setgd->fdt_blobtofw_dtb_pointermuch earlier on, and that hook simply didn't exist back in 2016 when commitade243a211d6("rpi: passthrough of the firmware provided FDT blob") introduced some of what you're removing here?
No I have not tested what happens with overlays, but I believe they are handled by the pre-U-Boot firmware. U-Boot certainly doesn't look at the config.txt file.
Regards,
Simon
Re: [PATCH v2 5/5] rpi: Use the U-Boot control FDT for fdt_addr
Quoted 95 lines · Simon Glass
HI Tom,
Quoted 81 lines · Tom Rini
Quoted 78 lines · Simon Glass
The
fdt_addrvariable 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_4I am using, this is at2b35ef00which 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.In version 2, it incorporates some changes to
fdt_addr, etc. suggested by Tom, as well as adding myself as a maintainer.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Drop patch to allow expanding the devicetree during relocationboard/raspberrypi/rpi/rpi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)board/raspberrypi/rpi/rpi.c +8
-12@@ -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);Quoted 10 lines
board/raspberrypi/rpi/rpi.c int ft_board_setup(void *blob, struct bd_info *bd) · line 574
Quoted 2 lines
board/raspberrypi/rpi/rpi.c +0
-0node =fdt_node_offset_by_compatible (blob,-1 ,"simple-framebuffer" );if (node <0 )Have you tested this to make sure that assorted overlays specified in config.txt are still passed on correctly to the kernel? Or do we end up being OK here due to
board_fdt_blob_setup()meaning that we setgd->fdt_blobtofw_dtb_pointermuch earlier on, and that hook simply didn't exist back in 2016 when commitade243a211d6("rpi: passthrough of the firmware provided FDT blob") introduced some of what you're removing here?
Quoted 3 lines
No I have not tested what happens with overlays, but I believe they are handled by the pre-U-Boot firmware. U-Boot certainly doesn't look at the config.txt file.
Yes, they're handled by being applied to the device tree we're passed by the previous stage and stored in fw_dtb_pointer. So checking that the device tree has the expected overlay applied is something that needs doing before this can be applied.
Signature · 1 line
Tom
Re: [PATCH v2 5/5] rpi: Use the U-Boot control FDT for fdt_addr
Hi Tom,
Quoted 97 lines · Tom Rini
Quoted 95 lines · Simon Glass
HI Tom,
Quoted 91 lines · Tom Rini
Quoted 70 lines · Simon Glass
The
fdt_addrvariable 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_4I am using, this is at2b35ef00which 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.In version 2, it incorporates some changes to
fdt_addr, etc. suggested by Tom, as well as adding myself as a maintainer.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Drop patch to allow expanding the devicetree during relocationboard/raspberrypi/rpi/rpi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)board/raspberrypi/rpi/rpi.c +4
-11@@ -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) {board/raspberrypi/rpi/rpi.c int ft_board_setup(void *blob, struct bd_info *bd) · line 574
Quoted 10 lines
board/raspberrypi/rpi/rpi.c +4
-1int 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 )Have you tested this to make sure that assorted overlays specified in config.txt are still passed on correctly to the kernel? Or do we end up being OK here due to
board_fdt_blob_setup()meaning that we setgd->fdt_blobtofw_dtb_pointermuch earlier on, and that hook simply didn't exist back in 2016 when commitade243a211d6("rpi: passthrough of the firmware provided FDT blob") introduced some of what you're removing here?
Quoted 8 lines
Quoted 3 lines
No I have not tested what happens with overlays, but I believe they are handled by the pre-U-Boot firmware. U-Boot certainly doesn't look at the config.txt file.
Yes, they're handled by being applied to the device tree we're passed by the previous stage and stored in
fw_dtb_pointer. So checking that the device tree has the expected overlay applied is something that needs doing before this can be applied.
Just so I understand this request, the checks are:
1. That adding/removing an overlay in config.txt is reflected in the devicetree seen by U-Boot
2. That U-Boot then passes that DT to Linux?
If I add this line:
dtoverlay=disable-bt
then Linux boots with serial output (I have enable_uart=1 in there as well)
If I remove the dtoverlay, it does not have serial output. So yes, this seems to be working fine.
For the record, the flow (within U-Boot, with this series) is:
a. fw_dtb_pointer is set in lowlevel.S
b. board_fdt_blob_setup() is called to set gd->fdt_blob to that value c. during relocation, U-Boot copies the devicetree to the top of memory, setting gd->fdt_blob to the new value
d. during loading, U-Boot creates a copy of the gd->fdt_blob devicetree and sets working_fdt to it*
e. U-Boot applies fix-ups to working_fdt
* fdt_high is unset and there is no devicetree packaged with the OS
Regards,
Simon
Re: [PATCH v2 5/5] rpi: Use the U-Boot control FDT for fdt_addr
Quoted 135 lines · Simon Glass
Hi Tom,
Quoted 97 lines · Tom Rini
Quoted 95 lines · Simon Glass
HI Tom,
Quoted 91 lines · Tom Rini
Quoted 70 lines · Simon Glass
The
fdt_addrvariable 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_4I am using, this is at2b35ef00which 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.In version 2, it incorporates some changes to
fdt_addr, etc. suggested by Tom, as well as adding myself as a maintainer.Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Drop patch to allow expanding the devicetree during relocationboard/raspberrypi/rpi/rpi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)board/raspberrypi/rpi/rpi.c +4
-11@@ -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) {board/raspberrypi/rpi/rpi.c int ft_board_setup(void *blob, struct bd_info *bd) · line 574
Quoted 10 lines
board/raspberrypi/rpi/rpi.c +4
-1int 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 )Have you tested this to make sure that assorted overlays specified in config.txt are still passed on correctly to the kernel? Or do we end up being OK here due to
board_fdt_blob_setup()meaning that we setgd->fdt_blobtofw_dtb_pointermuch earlier on, and that hook simply didn't exist back in 2016 when commitade243a211d6("rpi: passthrough of the firmware provided FDT blob") introduced some of what you're removing here?Quoted 8 lines
Quoted 3 lines
No I have not tested what happens with overlays, but I believe they are handled by the pre-U-Boot firmware. U-Boot certainly doesn't look at the config.txt file.
Yes, they're handled by being applied to the device tree we're passed by the previous stage and stored in
fw_dtb_pointer. So checking that the device tree has the expected overlay applied is something that needs doing before this can be applied.Just so I understand this request, the checks are:
1. That adding/removing an overlay in config.txt is reflected in the devicetree seen by U-Boot
2. That U-Boot then passes that DT to Linux?If I add this line:
dtoverlay=disable-bt
then Linux boots with serial output (I have enable_uart=1 in there as well)
If I remove the dtoverlay, it does not have serial output. So yes, this seems to be working fine.
For the record, the flow (within U-Boot, with this series) is:
a.
fw_dtb_pointeris set inlowlevel.S
b.board_fdt_blob_setup()is called to setgd->fdt_blobto that value c. during relocation, U-Boot copies the devicetree to the top of memory, settinggd->fdt_blobto the new value
d. during loading, U-Boot creates a copy of thegd->fdt_blobdevicetree and setsworking_fdtto it*
e. U-Boot applies fix-ups toworking_fdt
Quoted 1 line
*
fdt_highis unset and there is no devicetree packaged with the OS
Thanks. It seems likely that some no longer required work-arounds have built up in the pi code. But it's worth being extra cautious here given the breadth of the user base for these platforms and the need for them to really Just Work and the high cost associated with breakage.
Signature · 1 line
Tom
Quoted 3 lines · Simon Glass
This series allows rpi to boot a compressed Ubuntu kernel with ~100MB ramdisk, by expanding the available space.
What version of the RPi hardware have you tested this on?
Quoted 30 lines
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.
The patch to expand the devicetree was dropped, meaning that people should be careful to unset
fdt_addrin the environment.Changes in v2:
- Add new patch to make myself an rpi maintainer
- Add new patch to setbootm_size
- Add new patch to dropfdt_highandinitrd_high
- Drop patch to allow expanding the devicetree during relocationSimon Glass (5):
rpi: Add myself to the list of maintainers
rpi: Setbootm_sizeto 512MB
rpi: Dropfdt_highandinitrd_high
rpi: Update environment to support booti and large initrd
rpi: Use the U-Boot control FDT forfdt_addrMAINTAINERS | 1 + board/raspberrypi/rpi/rpi.c | 20 ++++++++------------ board/raspberrypi/rpi/rpi.env | 24 +++++++++++++----------- 3 files changed, 22 insertions(+), 23 deletions(-)--
2.34.1
Hi Peter,
Quoted 10 lines · Peter Robinson
Quoted 3 lines · Simon Glass
This series allows rpi to boot a compressed Ubuntu kernel with ~100MB ramdisk, by expanding the available space.
What version of the RPi hardware have you tested this on?
Only rpi_4 and rpi_5
The U-Boot change itself is tested on rpi_0 and rpi_2 but not actually booting a kernel[1]. I don't seem to have an rpi_1 in my lab.
Quoted 23 lines
Quoted 23 lines
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.
The patch to expand the devicetree was dropped, meaning that people should be careful to unset
fdt_addrin the environment.Changes in v2:
- Add new patch to make myself an rpi maintainer
- Add new patch to setbootm_size
- Add new patch to dropfdt_highandinitrd_high
- Drop patch to allow expanding the devicetree during relocationSimon Glass (5):
rpi: Add myself to the list of maintainers
rpi: Setbootm_sizeto 512MB
rpi: Dropfdt_highandinitrd_high
rpi: Update environment to support booti and large initrd
rpi: Use the U-Boot control FDT forfdt_addr
Quoted 8 lines
Quoted 8 lines
MAINTAINERS | 1 + board/raspberrypi/rpi/rpi.c | 20 ++++++++------------ board/raspberrypi/rpi/rpi.env | 24 +++++++++++++----------- 3 files changed, 22 insertions(+), 23 deletions(-)--
2.34.1