rockchip: Add support for RAM boot from maskrom mode
Subsystems (3)
v3 cover rockchip: Add support for RAM boot from maskrom mode
The BootROM in Rockchip SoCs will enter maskrom mode when boot firmware cannot be found in nand/spi/mmc storage.
In maskrom mode the USB OTG port can accept one of two custom commands.
Initially a 0x471 command to load TPL into SRAM. After TPL has been executed and it has returned back-to-BROM, a 0x472 command to load SPL into start of DRAM.
This series adds two binman images that can be used to RAM boot from maskrom mode:
- u-boot-rockchip-usb471.bin that contains TPL to init DRAM.
- u-boot-rockchip-usb472.bin that contains SPL and the normal FIT payload with i.e. U-Boot proper, TF-A and FDT.
The config fragment rockchip-ramboot.config can be used to enable building of these two binman images, e.g.:
make generic-rk3588_defconfig rockchip-ramboot.config
These binman images can be used with the proprietary rkbin boot_merger tool to create a special loader image that can be used with tools such as rkdeveloptool or rockusb tools to RAM boot from maskrom, e.g.:
Create loader image:
$ ../rkbin/tools/boot_merger ./RK3588MINIALL.ini
Boot from maskrom:
$ rkdeveloptool db u-boot-rockchip-rk3588-loader.bin
or
$ rockusb download-boot u-boot-rockchip-rk3588-loader.binAnother option that does not require use of proprietary tools is using open source tools such as rkflashtool or rkusbboot that can load the binman images directly without any need to first create a special loader image to RAM boot from maskrom, e.g.:
$ rkflashtool l < u-boot-rockchip-usb471.bin $ rkflashtool L < u-boot-rockchip-usb472.bin or $ rkusbboot u-boot-rockchip-usb471.bin u-boot-rockchip-usb472.bin
I am setting up a new personal lab for rockchip boards that primarily will use this RAM boot method for testing new U-Boot and Linux builds.
More detailed instructions on how RAM boot can be used will be added under doc/board/rockchip/ in a follow-up series, after this series has been accepted and my new lab is fully up and running.
Changes in v3:
- Use read_brom_bootsource_id() to support RAM boot on RK3576
- Add a rockchip-ramboot.config fragment to explicitly enable instead of imply the new Kconfig option on a few select SoCs
- Update commit message to highlight that the binman images can be used directly without use of the proprietary rkbin boot_merger tool
- Include a special patch, not intended to be merged, to demonstrate use of RAM boot with rk loader images
Changes in v2:
- Rebase on top of "rockchip: binman: Use a template for FIT and other improvements" series
- Add patch to fix booting into Linux on RK3588 board with 16+ GiB DRAM
This series depends on the "rockchip: Add support for ROCK 5B+" [1] and "board: rockchip: Add Radxa ROCK 4D" [2] series for a clean apply. See [3] for a branch including both depends.
[1] https://patchwork.ozlabs.org/cover/2118033/
[2] https://patchwork.ozlabs.org/cover/2118088/
[3] https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commits/ramboot-v3
Jonas Karlman (4):
rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM
rockchip: Add support for RAM boot from maskrom mode
rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588
HACK: rockchip: Add miniall.ini files to simplify test of RAM boot
RK3308MINIALL.ini | 22 +++++++++++++++++ RK3328MINIALL.ini | 20 +++++++++++++++ RK3399MINIALL.ini | 20 +++++++++++++++ RK3528MINIALL.ini | 25 +++++++++++++++++++ RK3566MINIALL.ini | 25 +++++++++++++++++++ RK3568MINIALL.ini | 25 +++++++++++++++++++ RK3576MINIALL.ini | 27 ++++++++++++++++++++ RK3588MINIALL.ini | 25 +++++++++++++++++++ arch/arm/dts/rockchip-u-boot.dtsi | 33 +++++++++++++++++++++++++ arch/arm/mach-rockchip/Kconfig | 14 ++++++++--- arch/arm/mach-rockchip/rk3308/Kconfig | 3 --- arch/arm/mach-rockchip/rk3568/Kconfig | 3 --- arch/arm/mach-rockchip/rk3588/Kconfig | 3 --- arch/arm/mach-rockchip/rk3588/rk3588.c | 27 ++++++++++++++++++++ arch/arm/mach-rockchip/sdram.c | 7 +++++- arch/arm/mach-rockchip/spl-boot-order.c | 14 ++++++++--- board/rockchip/rockchip-ramboot.config | 1 + boot/Kconfig | 3 +++ 18 files changed, 281 insertions(+), 16 deletions(-) create mode 100644 RK3308MINIALL.ini create mode 100644 RK3328MINIALL.ini create mode 100644 RK3399MINIALL.ini create mode 100644 RK3528MINIALL.ini create mode 100644 RK3566MINIALL.ini create mode 100644 RK3568MINIALL.ini create mode 100644 RK3576MINIALL.ini create mode 100644 RK3588MINIALL.ini create mode 100644 board/rockchip/rockchip-ramboot.config
Signature · 1 line
2.50.1
PATCH v3 1/4 rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM
Drop SoC specific TEXT_BASE and use a common TEXT_BASE for all SoCs.
Move the common TEXT_BASE to 8 MiB offset from start of DRAM to help support RAM boot from maskrom introduced in next patch.
RAM boot from maskrom mode will expect the FIT payload to be located at 2 MiB offset from start or DRAM.
---
v3: Collect r-b tag
v2: Collect t-b tag
--- arch/arm/mach-rockchip/Kconfig | 6 +++--- arch/arm/mach-rockchip/rk3308/Kconfig | 3 --- arch/arm/mach-rockchip/rk3568/Kconfig | 3 --- arch/arm/mach-rockchip/rk3588/Kconfig | 3 --- 4 files changed, 3 insertions(+), 12 deletions(-)
arch/arm/mach-rockchip/Kconfig +3 -3
@@ -768,9 +768,9 @@ config TPL_SYS_MALLOC_F_LEN default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000 config TEXT_BASE - default 0x60200000 if SPL_TEXT_BASE = 0x60000000 - default 0x40200000 if SPL_TEXT_BASE = 0x40000000 - default 0x00200000 if SPL_TEXT_BASE = 0x00000000 + default 0x60800000 if SPL_TEXT_BASE = 0x60000000 + default 0x40800000 if SPL_TEXT_BASE = 0x40000000 + default 0x00800000 if SPL_TEXT_BASE = 0x00000000 config SPL_TEXT_BASE default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
arch/arm/mach-rockchip/rk3308/Kconfig +0 -3
@@ -17,9 +17,6 @@ config ROCKCHIP_STIMER_BASE config SYS_SOC default "rk3308" -config TEXT_BASE - default 0x00600000 - source "board/rockchip/evb_rk3308/Kconfig" source "board/firefly/firefly-rk3308/Kconfig"
arch/arm/mach-rockchip/rk3568/Kconfig +0 -3
@@ -70,9 +70,6 @@ config ROCKCHIP_STIMER_BASE config SYS_SOC default "rk3568" -config TEXT_BASE - default 0x00a00000 - source "board/rockchip/evb_rk3568/Kconfig" source "board/anbernic/rgxx3_rk3566/Kconfig" source "board/hardkernel/odroid_m1/Kconfig"
arch/arm/mach-rockchip/rk3588/Kconfig +0 -3
@@ -400,9 +400,6 @@ config ROCKCHIP_STIMER_BASE config SYS_SOC default "rk3588" -config TEXT_BASE - default 0x00a00000 - source "board/armsom/sige7-rk3588/Kconfig" source "board/coolpi/genbook_cm5_rk3588/Kconfig" source "board/edgeble/neural-compute-module-6/Kconfig"
Signature · 1 line
2.50.1
PATCH v3 2/4 rockchip: Add support for RAM boot from maskrom mode
In reply to Jonas KarlmanThe BootROM in Rockchip SoCs will enter maskrom mode when boot firmware cannot be found in nand/spi/mmc storage.
In maskrom mode the USB OTG port can accept one of two custom commands.
Initially a 0x471 command to load TPL into SRAM. After TPL has been executed and it has returned back-to-BROM, a 0x472 command to load SPL into start of DRAM.
Add two binman images that can be used to RAM boot from maskrom mode:
- u-boot-rockchip-usb471.bin that contains TPL to init DRAM.
- u-boot-rockchip-usb472.bin that contains SPL and the normal FIT payload with i.e. U-Boot proper, TF-A and FDT.
A config fragment rockchip-ramboot.config can be used to enable building of these two binman images, e.g.:
make generic-rk3588_defconfig rockchip-ramboot.config
These binman images can be used with the proprietary rkbin boot_merger tool to create a special loader image that can be used with tools such as rkdeveloptool or rockusb tools to RAM boot from maskrom, e.g.:
Create loader image:
$ ../rkbin/tools/boot_merger ./RK3588MINIALL.ini
Boot from maskrom:
$ rkdeveloptool db u-boot-rockchip-rk3588-loader.bin
or
$ rockusb download-boot u-boot-rockchip-rk3588-loader.binAnother option that does not require use of proprietary tools is using open source tools such as rkflashtool or rkusbboot that can load the binman images directly without any need to first create a special loader image to RAM boot from maskrom, e.g.:
$ rkflashtool l < u-boot-rockchip-usb471.bin $ rkflashtool L < u-boot-rockchip-usb472.bin or $ rkusbboot u-boot-rockchip-usb471.bin u-boot-rockchip-usb472.bin
---
Changes in v3:
- Use read_brom_bootsource_id() to support RAM boot on RK3576
- Add a rockchip-ramboot.config fragment to enable the Kconfig option
- Update commit message to highlight that the binman images can be used directly without use of the proprietary rkbin boot_merger tool
Changes in v2:
- Use fit_template instead of common_part
- Collect t-b tag
--- arch/arm/dts/rockchip-u-boot.dtsi | 33 +++++++++++++++++++++++++ arch/arm/mach-rockchip/Kconfig | 8 ++++++ arch/arm/mach-rockchip/spl-boot-order.c | 14 ++++++++--- board/rockchip/rockchip-ramboot.config | 1 + boot/Kconfig | 3 +++ 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 board/rockchip/rockchip-ramboot.config
arch/arm/dts/rockchip-u-boot.dtsi +33 -0
@@ -226,5 +226,38 @@ }; }; #endif /* CONFIG_ROCKCHIP_SPI_IMAGE */ + +#ifdef CONFIG_ROCKCHIP_MASKROM_IMAGE + simple-bin-usb471 { + filename = "u-boot-rockchip-usb471.bin"; + +#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL + rockchip-tpl { + }; +#elif defined(CONFIG_TPL) + u-boot-tpl { + no-write-symbols; + }; +#endif + }; + + simple-bin-usb472 { + filename = "u-boot-rockchip-usb472.bin"; + pad-byte = <0x00>; + + u-boot-spl { + no-write-symbols; + }; + +#ifdef HAS_FIT + fit { + insert-template = <&fit_template>; +#else + u-boot-img { +#endif + offset = <(CONFIG_SPL_LOAD_FIT_ADDRESS - CFG_SYS_SDRAM_BASE)>; + }; + }; +#endif /* CONFIG_ROCKCHIP_MASKROM_IMAGE */ }; #endif /* CONFIG_SPL */
arch/arm/mach-rockchip/Kconfig +8 -0
@@ -706,6 +706,14 @@ config ROCKCHIP_SPI_IMAGE option to produce a SPI-flash image containing U-Boot. The image is built by binman. U-Boot sits near the start of the image. +config ROCKCHIP_MASKROM_IMAGE + bool "Build a maskrom mode image for Rockchip" + depends on TPL || ROCKCHIP_EXTERNAL_TPL + select SPL_RAM_DEVICE + help + Rockchip SoCs support maskrom mode boot over USB. Enable this + option to produce maskrom mode boot images containing U-Boot. + config LNX_KRNL_IMG_TEXT_OFFSET_BASE default TEXT_BASE
arch/arm/mach-rockchip/spl-boot-order.c +11 -3
@@ -8,6 +8,7 @@#include <log.h> #include <mmc.h> #include <spl.h> +#include <asm/arch-rockchip/bootrom.h> #include <asm/global_data.h> #include <dm/uclass-internal.h>
@@ -98,15 +99,22 @@ __weak const char *board_spl_was_booted_from(void)void board_boot_order (u32 *spl_boot_list) { +int idx =0 ; + +/* Add RAM boot for maskrom mode boot over USB */ +if (BROM_BOOTSOURCE_ID_ADDR &&CONFIG_IS_ENABLED (RAM_DEVICE ) && +read_brom_bootsource_id () ==BROM_BOOTSOURCE_USB ) { + spl_boot_list[idx++] =BOOT_DEVICE_RAM ; + } +/* In case of no fdt (or only plat), use spl_boot_device() */ if (!CONFIG_IS_ENABLED (OF_CONTROL ) ||CONFIG_IS_ENABLED (OF_PLATDATA )) { - spl_boot_list[0 ] =spl_boot_device (); + spl_boot_list[idx++] =spl_boot_device ();return ; }const void *blob = gd->fdt_blob;int chosen_node =fdt_path_offset (blob,"/chosen" ); -int idx =0 ;int elem;int boot_device;int node;
@@ -115,7 +123,7 @@ void board_boot_order(u32 *spl_boot_list)if (chosen_node <0 ) {debug ("%s: /chosen not found, using spl_boot_device()\n" , __func__); - spl_boot_list[0 ] =spl_boot_device (); + spl_boot_list[idx++] =spl_boot_device ();return ; }
board/rockchip/rockchip-ramboot.config new file +1 -0
@@ -0,0 +1 @@ +CONFIG_ROCKCHIP_MASKROM_IMAGE=y
boot/Kconfig +3 -0
@@ -257,6 +257,9 @@ config SPL_LOAD_FIT_ADDRESS hex "load address of fit image" depends on SPL_LOAD_FIT default 0x44000000 if ARCH_IMX8M + default 0x60080000 if ARCH_ROCKCHIP && SPL_TEXT_BASE = 0x60000000 + default 0x40200000 if ARCH_ROCKCHIP && SPL_TEXT_BASE = 0x40000000 + default 0x00200000 if ARCH_ROCKCHIP && SPL_TEXT_BASE = 0x00000000 default 0x0 help Specify the load address of the fit image that will be loaded
Signature · 1 line
2.50.1
Quoted 36 lines · Jonas Karlman
The BootROM in Rockchip SoCs will enter maskrom mode when boot firmware cannot be found in nand/spi/mmc storage.
In maskrom mode the USB OTG port can accept one of two custom commands.
Initially a
0x471command to load TPL into SRAM. After TPL has been executed and it has returned back-to-BROM, a0x472command to load SPL into start of DRAM.Add two binman images that can be used to RAM boot from maskrom mode:
- u-boot-rockchip-usb471.bin that contains TPL to init DRAM.
- u-boot-rockchip-usb472.bin that contains SPL and the normal FIT payload with i.e. U-Boot proper, TF-A and FDT.A config fragment rockchip-ramboot.config can be used to enable building of these two binman images, e.g.:
make generic-rk3588_defconfig rockchip-ramboot.config
These binman images can be used with the proprietary rkbin
boot_mergertool to create a special loader image that can be used with tools such as rkdeveloptool or rockusb tools to RAM boot from maskrom, e.g.:Create loader image:
$ ../rkbin/tools/boot_merger ./RK3588MINIALL.iniBoot from maskrom:
$ rkdeveloptool db u-boot-rockchip-rk3588-loader.bin or $ rockusb download-boot u-boot-rockchip-rk3588-loader.binAnother option that does not require use of proprietary tools is using open source tools such as rkflashtool or rkusbboot that can load the binman images directly without any need to first create a special loader image to RAM boot from maskrom, e.g.:
Quoted 7 lines
$ rkflashtool l < u-boot-rockchip-usb471.bin $ rkflashtool L < u-boot-rockchip-usb472.bin or $ rkusbboot u-boot-rockchip-usb471.bin u-boot-rockchip-usb472.binSigned-off-by Jonas Karlman <[email protected]>Tested-by Arnaud Patard <[email protected]>
Thanks,
- Kever
Quoted 148 lines
---
Changes in v3:
- Useread_brom_bootsource_id()to support RAM boot on RK3576
- Add a rockchip-ramboot.config fragment to enable theKconfigoption
- Update commit message to highlight that the binman images can be used directly without use of the proprietary rkbinboot_mergertoolChanges in v2:
- Usefit_templateinstead ofcommon_part
- Collect t-b tag--- arch/arm/dts/rockchip-u-boot.dtsi | 33 +++++++++++++++++++++++++ arch/arm/mach-rockchip/Kconfig | 8 ++++++ arch/arm/mach-rockchip/spl-boot-order.c | 14 ++++++++--- board/rockchip/rockchip-ramboot.config | 1 + boot/Kconfig | 3 +++ 5 files changed, 56 insertions(+), 3 deletions(-)create mode 100644
board/rockchip/rockchip-ramboot.configarch/arm/dts/rockchip-u-boot.dtsi +33
-0@@ -226,5 +226,38 @@ }; }; #endif /* CONFIG_ROCKCHIP_SPI_IMAGE */ + +#ifdef CONFIG_ROCKCHIP_MASKROM_IMAGE + simple-bin-usb471 { + filename = "u-boot-rockchip-usb471.bin"; + +#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL + rockchip-tpl { + }; +#elif defined(CONFIG_TPL) + u-boot-tpl { + no-write-symbols; + }; +#endif + }; + + simple-bin-usb472 { + filename = "u-boot-rockchip-usb472.bin"; + pad-byte = <0x00>; + + u-boot-spl { + no-write-symbols; + }; + +#ifdef HAS_FIT + fit { + insert-template = <&fit_template>; +#else + u-boot-img { +#endif + offset = <(CONFIG_SPL_LOAD_FIT_ADDRESS - CFG_SYS_SDRAM_BASE)>; + }; + }; +#endif /* CONFIG_ROCKCHIP_MASKROM_IMAGE */ }; #endif /* CONFIG_SPL */arch/arm/mach-rockchip/Kconfig +8
-0@@ -706,6 +706,14 @@ config ROCKCHIP_SPI_IMAGE option to produce a SPI-flash image containing U-Boot. The image is built by binman. U-Boot sits near the start of the image. +config ROCKCHIP_MASKROM_IMAGE + bool "Build a maskrom mode image for Rockchip" + depends on TPL || ROCKCHIP_EXTERNAL_TPL + select SPL_RAM_DEVICE + help + Rockchip SoCs support maskrom mode boot over USB. Enable this + option to produce maskrom mode boot images containing U-Boot. + config LNX_KRNL_IMG_TEXT_OFFSET_BASE default TEXT_BASEarch/arm/mach-rockchip/spl-boot-order.c +11
-3@@ -8,6 +8,7 @@#include <log.h> #include <mmc.h> #include <spl.h> +#include <asm/arch-rockchip/bootrom.h> #include <asm/global_data.h> #include <dm/uclass-internal.h> @@ -98,15 +99,22 @@ __weak const char *board_spl_was_booted_from(void)void board_boot_order (u32 *spl_boot_list) { +int idx =0 ; + +/* Add RAM boot for maskrom mode boot over USB */ +if (BROM_BOOTSOURCE_ID_ADDR &&CONFIG_IS_ENABLED (RAM_DEVICE ) && +read_brom_bootsource_id () ==BROM_BOOTSOURCE_USB ) { + spl_boot_list[idx++] =BOOT_DEVICE_RAM ; + } +/* In case of no fdt (or only plat), use spl_boot_device() */ if (!CONFIG_IS_ENABLED (OF_CONTROL ) ||CONFIG_IS_ENABLED (OF_PLATDATA )) { - spl_boot_list[0 ] =spl_boot_device (); + spl_boot_list[idx++] =spl_boot_device ();return ; }const void *blob = gd->fdt_blob;int chosen_node =fdt_path_offset (blob,"/chosen" ); -int idx =0 ;int elem;int boot_device;int node;@@ -115,7 +123,7 @@ void board_boot_order(u32 *spl_boot_list)if (chosen_node <0 ) {debug ("%s: /chosen not found, using spl_boot_device()\n" , __func__); - spl_boot_list[0 ] =spl_boot_device (); + spl_boot_list[idx++] =spl_boot_device ();return ; }board/rockchip/rockchip-ramboot.config new file +1
-0@@ -0,0 +1 @@ +CONFIG_ROCKCHIP_MASKROM_IMAGE=yboot/Kconfig +3
-0@@ -257,6 +257,9 @@ config SPL_LOAD_FIT_ADDRESS hex "load address of fit image" depends on SPL_LOAD_FIT default 0x44000000 if ARCH_IMX8M + default 0x60080000 if ARCH_ROCKCHIP && SPL_TEXT_BASE = 0x60000000 + default 0x40200000 if ARCH_ROCKCHIP && SPL_TEXT_BASE = 0x40000000 + default 0x00200000 if ARCH_ROCKCHIP && SPL_TEXT_BASE = 0x00000000 default 0x0 help Specify the load address of the fit image that will be loaded
PATCH v3 3/4 rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588
In reply to Jonas KarlmanRK3588 has two known memory gaps when using 16+ GiB DRAM, [0x3fc000000, 0x3fc500000) and [0x3fff00000, 0x400000000).
The vendor TPL blob encodes this information in the DDR_MEM tag data passed to later boot phases. U-Boot proper will normally use this information to configure the DRAM banks.
When a DDR_MEM tag cannot be found the fallback is to use the entire range above 4 GiB. Something that will cause issues when OS try to use memory from the two known memory gaps.
Add a weak dram init banksize fixup function and implement it for RK3588 to fix issues observed when trying to RAM boot RK3588 boards with 16+ GiB DRAM into Linux.
---
v3: No change
v2: New patch to fix booting into OS on RK3588 boards with 16+ GiB DRAM
--- arch/arm/mach-rockchip/rk3588/rk3588.c | 27 ++++++++++++++++++++++++++ arch/arm/mach-rockchip/sdram.c | 7 ++++++- 2 files changed, 33 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/rk3588/rk3588.c +27 -0
@@ -198,6 +198,33 @@ int arch_cpu_init(void) }#endif +/* +* RK3588 has two known memory gaps when using 16+ GiB DRAM, +* [0x3fc000000, 0x3fc500000) and [0x3fff00000, 0x400000000). +* +* Remove the [0x3fc000000, 0x400000000) range to ensure OS does not +* use memory from these gaps when a DDR_MEM tag cannot be found. +*/ + +#define DRAM_GAP_START 0x3FC000000 +#define DRAM_GAP_END 0x400000000 + +int rockchip_dram_init_banksize_fixup (struct bd_info *bd) +{ +size_t ram_top = bd->bi_dram[1 ].start + bd->bi_dram[1 ].size; + +if (ram_top >DRAM_GAP_START ) { + bd->bi_dram[1 ].size =DRAM_GAP_START - bd->bi_dram[1 ].start; + +if (ram_top >DRAM_GAP_END &&CONFIG_NR_DRAM_BANKS >2 ) { + bd->bi_dram[2 ].start =DRAM_GAP_END ; + bd->bi_dram[2 ].size = ram_top - bd->bi_dram[2 ].start; + } + } + +return 0 ; +} +#define RK3588_OTP_CPU_CODE_OFFSET 0x02#define RK3588_OTP_SPECIFICATION_OFFSET 0x06
arch/arm/mach-rockchip/sdram.c +6 -1
@@ -289,6 +289,11 @@ static int rockchip_dram_init_banksize(void) }#endif +__weak int rockchip_dram_init_banksize_fixup (struct bd_info *bd) +{ +return 0 ; +} +int dram_init_banksize (void ) {size_t ram_top = (unsigned long )(gd->ram_size +CFG_SYS_SDRAM_BASE );
@@ -342,7 +347,7 @@ int dram_init_banksize(void)#endif #endif -return 0 ; +return rockchip_dram_init_banksize_fixup (gd->bd); }u8 rockchip_sdram_type (phys_addr_t reg)
Signature · 1 line
2.50.1
Re: [PATCH v3 3/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588
Quoted 11 lines · Jonas Karlman
RK3588 has two known memory gaps when using 16+ GiB DRAM, [
0x3fc000000,0x3fc500000) and [0x3fff00000,0x400000000).The vendor TPL blob encodes this information in the
DDR_MEMtag data passed to later boot phases. U-Boot proper will normally use this information to configure the DRAM banks.When a
DDR_MEMtag cannot be found the fallback is to use the entire range above 4 GiB. Something that will cause issues when OS try to use memory from the two known memory gaps.
Quoted 5 lines
Add a weak dram init banksize fixup function and implement it for RK3588 to fix issues observed when trying to RAM boot RK3588 boards with 16+ GiB DRAM into Linux.
Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 71 lines
---
v3: No change
v2: New patch to fix booting into OS on RK3588 boards with 16+ GiB DRAM--- arch/arm/mach-rockchip/rk3588/rk3588.c | 27 ++++++++++++++++++++++++++ arch/arm/mach-rockchip/sdram.c | 7 ++++++- 2 files changed, 33 insertions(+), 1 deletion(-)arch/arm/mach-rockchip/rk3588/rk3588.c +27
-0@@ -198,6 +198,33 @@ int arch_cpu_init(void) }#endif +/* +* RK3588 has two known memory gaps when using 16+ GiB DRAM, +* [0x3fc000000, 0x3fc500000) and [0x3fff00000, 0x400000000). +* +* Remove the [0x3fc000000, 0x400000000) range to ensure OS does not +* use memory from these gaps when a DDR_MEM tag cannot be found. +*/ + +#define DRAM_GAP_START 0x3FC000000 +#define DRAM_GAP_END 0x400000000 + +int rockchip_dram_init_banksize_fixup (struct bd_info *bd) +{ +size_t ram_top = bd->bi_dram[1 ].start + bd->bi_dram[1 ].size; + +if (ram_top >DRAM_GAP_START ) { + bd->bi_dram[1 ].size =DRAM_GAP_START - bd->bi_dram[1 ].start; + +if (ram_top >DRAM_GAP_END &&CONFIG_NR_DRAM_BANKS >2 ) { + bd->bi_dram[2 ].start =DRAM_GAP_END ; + bd->bi_dram[2 ].size = ram_top - bd->bi_dram[2 ].start; + } + } + +return 0 ; +} +#define RK3588_OTP_CPU_CODE_OFFSET 0x02#define RK3588_OTP_SPECIFICATION_OFFSET 0x06arch/arm/mach-rockchip/sdram.c +6
-1@@ -289,6 +289,11 @@ static int rockchip_dram_init_banksize(void) }#endif +__weak int rockchip_dram_init_banksize_fixup (struct bd_info *bd) +{ +return 0 ; +} +int dram_init_banksize (void ) {size_t ram_top = (unsigned long )(gd->ram_size +CFG_SYS_SDRAM_BASE );@@ -342,7 +347,7 @@ int dram_init_banksize(void)#endif #endif -return 0 ; +return rockchip_dram_init_banksize_fixup (gd->bd); }u8 rockchip_sdram_type (phys_addr_t reg)
PATCH v3 4/4 HACK: rockchip: Add miniall.ini files to simplify test of RAM boot
In reply to Jonas KarlmanTHIS PATCH IS NOT INTENDED TO BE MERGED and is only included to help demonstrate how the RAM boot supported binman images can be used to generate loader images with the proprietary rkbin boot_merger tool.
First use the config fragment rockchip-ramboot.config to enable building of binman images with RAM boot support, e.g.:
make generic-rk3588_defconfig rockchip-ramboot.config
The generated u-boot-rockchip-usb47x.bin images can then be used with the proprietary rkbin boot_merger tool to create a loader image, e.g.:
$ ../rkbin/tools/boot_merger ./RK3588MINIALL.ini
Finally the generated loader image can be used with tools such as rkdeveloptool or rockusb tools when a device is in maskrom mode, e.g.:
$ rkdeveloptool db u-boot-rockchip-rk3588-loader.bin or $ rockusb download-boot u-boot-rockchip-rk3588-loader.bin
---
v3: New patch NOT intended to be merged
--- RK3308MINIALL.ini | 22 ++++++++++++++++++++++ RK3328MINIALL.ini | 20 ++++++++++++++++++++ RK3399MINIALL.ini | 20 ++++++++++++++++++++ RK3528MINIALL.ini | 25 +++++++++++++++++++++++++ RK3566MINIALL.ini | 25 +++++++++++++++++++++++++ RK3568MINIALL.ini | 25 +++++++++++++++++++++++++ RK3576MINIALL.ini | 27 +++++++++++++++++++++++++++ RK3588MINIALL.ini | 25 +++++++++++++++++++++++++ 8 files changed, 189 insertions(+) create mode 100644 RK3308MINIALL.ini create mode 100644 RK3328MINIALL.ini create mode 100644 RK3399MINIALL.ini create mode 100644 RK3528MINIALL.ini create mode 100644 RK3566MINIALL.ini create mode 100644 RK3568MINIALL.ini create mode 100644 RK3576MINIALL.ini create mode 100644 RK3588MINIALL.ini
RK3308MINIALL.ini new file +22 -0
@@ -0,0 +1,22 @@ +[CHIP_NAME] +NAME=RK3308 +[VERSION] +MAJOR=1 +MINOR=05 +[CODE471_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb471.bin +Sleep=1 +[CODE472_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb472.bin +[LOADER_OPTION] +NUM=2 +LOADER1=FlashData +LOADER2=FlashBoot +FlashData=u-boot-rockchip-usb471.bin +FlashBoot=u-boot-rockchip-usb472.bin +[OUTPUT] +PATH=u-boot-rockchip-rk3308-loader.bin +[FLAG] +RC4_OFF=true
RK3328MINIALL.ini new file +20 -0
@@ -0,0 +1,20 @@ +[CHIP_NAME] +NAME=RK322H +[VERSION] +MAJOR=2 +MINOR=50 +[CODE471_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb471.bin +Sleep=1 +[CODE472_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb472.bin +[LOADER_OPTION] +NUM=2 +LOADER1=FlashData +LOADER2=FlashBoot +FlashData=u-boot-rockchip-usb471.bin +FlashBoot=u-boot-rockchip-usb472.bin +[OUTPUT] +PATH=u-boot-rockchip-rk3328-loader.bin
RK3399MINIALL.ini new file +20 -0
@@ -0,0 +1,20 @@ +[CHIP_NAME] +NAME=RK330C +[VERSION] +MAJOR=1 +MINOR=30 +[CODE471_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb471.bin +Sleep=1 +[CODE472_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb472.bin +[LOADER_OPTION] +NUM=2 +LOADER1=FlashData +LOADER2=FlashBoot +FlashData=u-boot-rockchip-usb471.bin +FlashBoot=u-boot-rockchip-usb472.bin +[OUTPUT] +PATH=u-boot-rockchip-rk3399-loader.bin
RK3528MINIALL.ini new file +25 -0
@@ -0,0 +1,25 @@ +[CHIP_NAME] +NAME=RK3528 +[VERSION] +MAJOR=1 +MINOR=4 +[CODE471_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb471.bin +Sleep=1 +[CODE472_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb472.bin +[LOADER_OPTION] +NUM=2 +LOADER1=FlashData +LOADER2=FlashBoot +FlashData=u-boot-rockchip-usb471.bin +FlashBoot=u-boot-rockchip-usb472.bin +[OUTPUT] +PATH=u-boot-rockchip-rk3528-loader.bin +[SYSTEM] +NEWIDB=true +[FLAG] +471_RC4_OFF=true +RC4_OFF=true
RK3566MINIALL.ini new file +25 -0
@@ -0,0 +1,25 @@ +[CHIP_NAME] +NAME=RK3568 +[VERSION] +MAJOR=1 +MINOR=1 +[CODE471_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb471.bin +Sleep=1 +[CODE472_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb472.bin +[LOADER_OPTION] +NUM=2 +LOADER1=FlashData +LOADER2=FlashBoot +FlashData=u-boot-rockchip-usb471.bin +FlashBoot=u-boot-rockchip-usb472.bin +[OUTPUT] +PATH=u-boot-rockchip-rk3566-loader.bin +[SYSTEM] +NEWIDB=true +[FLAG] +471_RC4_OFF=true +RC4_OFF=true
RK3568MINIALL.ini new file +25 -0
@@ -0,0 +1,25 @@ +[CHIP_NAME] +NAME=RK3568 +[VERSION] +MAJOR=1 +MINOR=1 +[CODE471_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb471.bin +Sleep=1 +[CODE472_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb472.bin +[LOADER_OPTION] +NUM=2 +LOADER1=FlashData +LOADER2=FlashBoot +FlashData=u-boot-rockchip-usb471.bin +FlashBoot=u-boot-rockchip-usb472.bin +[OUTPUT] +PATH=u-boot-rockchip-rk3568-loader.bin +[SYSTEM] +NEWIDB=true +[FLAG] +471_RC4_OFF=true +RC4_OFF=true
RK3576MINIALL.ini new file +27 -0
@@ -0,0 +1,27 @@ +[CHIP_NAME] +NAME=RK3576 +[VERSION] +MAJOR=1 +MINOR=100 +[CODE471_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb471.bin +Sleep=1 +[CODE472_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb472.bin +[LOADER_OPTION] +NUM=2 +LOADER1=FlashData +LOADER2=FlashBoot +FlashData=u-boot-rockchip-usb471.bin +FlashBoot=u-boot-rockchip-usb472.bin +[OUTPUT] +PATH=u-boot-rockchip-rk3576-loader.bin +[SYSTEM] +NEWIDB=true +ALIGN=8 +[FLAG] +471_RC4_OFF=true +RC4_OFF=true +CRC_OFF=true
RK3588MINIALL.ini new file +25 -0
@@ -0,0 +1,25 @@ +[CHIP_NAME] +NAME=RK3588 +[VERSION] +MAJOR=1 +MINOR=11 +[CODE471_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb471.bin +Sleep=1 +[CODE472_OPTION] +NUM=1 +Path1=u-boot-rockchip-usb472.bin +[LOADER_OPTION] +NUM=2 +LOADER1=FlashData +LOADER2=FlashBoot +FlashData=u-boot-rockchip-usb471.bin +FlashBoot=u-boot-rockchip-usb472.bin +[OUTPUT] +PATH=u-boot-rockchip-rk3588-loader.bin +[SYSTEM] +NEWIDB=true +[FLAG] +471_RC4_OFF=true +RC4_OFF=true
Signature · 1 line
2.50.1
Tested on my PineTab 2 using rkusbboot.
Quoted 106 lines · Coordinated Universal Time Jonas Karlman
The BootROM in Rockchip SoCs will enter maskrom mode when boot firmware cannot be found in nand/spi/mmc storage.
In maskrom mode the USB OTG port can accept one of two custom commands.
Initially a
0x471command to load TPL into SRAM. After TPL has been executed and it has returned back-to-BROM, a0x472command to load SPL into start of DRAM.This series adds two binman images that can be used to RAM boot from maskrom mode:
- u-boot-rockchip-usb471.bin that contains TPL to init DRAM.
- u-boot-rockchip-usb472.bin that contains SPL and the normal FIT payload with i.e. U-Boot proper, TF-A and FDT.The config fragment rockchip-ramboot.config can be used to enable building of these two binman images, e.g.:
make generic-rk3588_defconfig rockchip-ramboot.config
These binman images can be used with the proprietary rkbin
boot_mergertool to create a special loader image that can be used with tools such as rkdeveloptool or rockusb tools to RAM boot from maskrom, e.g.:Create loader image:
$ ../rkbin/tools/boot_merger ./RK3588MINIALL.iniBoot from maskrom:
$ rkdeveloptool db u-boot-rockchip-rk3588-loader.bin or $ rockusb download-boot u-boot-rockchip-rk3588-loader.binAnother option that does not require use of proprietary tools is using open source tools such as rkflashtool or rkusbboot that can load the binman images directly without any need to first create a special loader image to RAM boot from maskrom, e.g.:
$ rkflashtool l < u-boot-rockchip-usb471.bin $ rkflashtool L < u-boot-rockchip-usb472.bin or $ rkusbboot u-boot-rockchip-usb471.bin u-boot-rockchip-usb472.binI am setting up a new personal lab for rockchip boards that primarily will use this RAM boot method for testing new U-Boot and Linux builds.
More detailed instructions on how RAM boot can be used will be added under doc/board/rockchip/ in a follow-up series, after this series has been accepted and my new lab is fully up and running.
Changes in v3:
- Useread_brom_bootsource_id()to support RAM boot on RK3576
- Add a rockchip-ramboot.config fragment to explicitly enable instead of imply the newKconfigoption on a few select SoCs
- Update commit message to highlight that the binman images can be used directly without use of the proprietary rkbinboot_mergertool
- Include a special patch, not intended to be merged, to demonstrate use of RAM boot with rk loader imagesChanges in v2:
- Rebase on top of "rockchip: binman: Use a template for FIT and other improvements" series
- Add patch to fix booting into Linux on RK3588 board with 16+ GiB DRAMThis series depends on the "rockchip: Add support for ROCK 5B+" [1] and "board: rockchip: Add Radxa ROCK 4D" [2] series for a clean apply. See [3] for a branch including both depends.
[1] https://patchwork.ozlabs.org/cover/2118033/
[2] https://patchwork.ozlabs.org/cover/2118088/
[3]
https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commits/ramboot-> v3Jonas Karlman (4):
rockchip: MoveTEXT_BASEto 8 MiB offset from start of DRAM
rockchip: Add support for RAM boot from maskrom mode
rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588
HACK: rockchip: Add miniall.ini files to simplify test of RAM bootRK3308MINIALL.ini | 22 +++++++++++++++++ RK3328MINIALL.ini | 20 +++++++++++++++ RK3399MINIALL.ini | 20 +++++++++++++++ RK3528MINIALL.ini | 25 +++++++++++++++++++ RK3566MINIALL.ini | 25 +++++++++++++++++++ RK3568MINIALL.ini | 25 +++++++++++++++++++ RK3576MINIALL.ini | 27 ++++++++++++++++++++ RK3588MINIALL.ini | 25 +++++++++++++++++++ arch/arm/dts/rockchip-u-boot.dtsi | 33 +++++++++++++++++++++++++ arch/arm/mach-rockchip/Kconfig | 14 ++++++++--- arch/arm/mach-rockchip/rk3308/Kconfig | 3 --- arch/arm/mach-rockchip/rk3568/Kconfig | 3 --- arch/arm/mach-rockchip/rk3588/Kconfig | 3 --- arch/arm/mach-rockchip/rk3588/rk3588.c | 27 ++++++++++++++++++++ arch/arm/mach-rockchip/sdram.c | 7 +++++- arch/arm/mach-rockchip/spl-boot-order.c | 14 ++++++++--- board/rockchip/rockchip-ramboot.config | 1 + boot/Kconfig | 3 +++ 18 files changed, 281 insertions(+), 16 deletions(-) create mode 100644 RK3308MINIALL.ini create mode 100644 RK3328MINIALL.ini create mode 100644 RK3399MINIALL.ini create mode 100644 RK3528MINIALL.ini create mode 100644 RK3566MINIALL.ini create mode 100644 RK3568MINIALL.ini create mode 100644 RK3576MINIALL.ini create mode 100644 RK3588MINIALL.ini create mode 100644 board/rockchip/rockchip-ramboot.config