Add support for RAM boot from maskrom mode
Subsystems (3)
v2 cover 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.
These images can be used with rkbin tools/boot_merger to create a loader image to be used with rkdeveloptool or rockusb tools, 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.binOr directly with tools such as rkflashtool or rkusbboot:
$ 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 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: ROCKCHIP_COMMON_STACK_ADDR improvements" series [1] and the "rockchip: binman: Use a template for FIT and other improvements" series [2]. See [3] for a branch including both depends.
[1] https://patchwork.ozlabs.org/cover/2050003/
[2] https://patchwork.ozlabs.org/cover/2066701/
[3] https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commits/ramboot-v2
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: Enable RAM boot using ROCKCHIP_MASKROM_IMAGE
rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588
arch/arm/dts/rockchip-u-boot.dtsi | 33 +++++++++++++++++++++++++ arch/arm/mach-rockchip/Kconfig | 19 +++++++++++--- 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 | 15 ++++++++--- boot/Kconfig | 3 +++ 9 files changed, 97 insertions(+), 16 deletions(-)
Signature · 1 line
2.49.0
PATCH v2 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.
---
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
@@ -667,9 +667,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
@@ -71,9 +71,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
@@ -420,9 +420,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.49.0
Re: [PATCH v2 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM
Quoted 10 lines · Jonas Karlman
Drop SoC specific
TEXT_BASEand use a commonTEXT_BASEfor all SoCs.Move the common
TEXT_BASEto 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.
Signed-off-by Jonas Karlman <[email protected]>Tested-by Arnaud Patard <[email protected]>
Thanks,
- Kever
Quoted 68 lines
---
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@@ -667,9 +667,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@@ -71,9 +71,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@@ -420,9 +420,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"
PATCH v2 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.
These images can be used with rkbin tools/boot_merger to create a loader image to be used with rkdeveloptool or rockusb tools, 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.binOr directly with tools such as rkflashtool or rkusbboot:
$ 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
---
v2: Use fit_template instead of common_part
v2: 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 | 15 ++++++++--- boot/Kconfig | 3 +++ 4 files changed, 56 insertions(+), 3 deletions(-)
arch/arm/dts/rockchip-u-boot.dtsi +33 -0
@@ -231,5 +231,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
@@ -607,6 +607,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 +12 -3
@@ -8,7 +8,9 @@#include <log.h> #include <mmc.h> #include <spl.h> +#include <asm/arch-rockchip/bootrom.h> #include <asm/global_data.h> +#include <asm/io.h> #include <dm/uclass-internal.h> #if CONFIG_IS_ENABLED (OF_LIBFDT )
@@ -98,15 +100,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 ) && +readl (BROM_BOOTSOURCE_ID_ADDR ) ==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 +124,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 ; }
boot/Kconfig +3 -0
@@ -246,6 +246,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.49.0
Re: [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode
Hi Jonas,
Thanks for your patch, and the ramboot with usb download do help bootloader developers.
Quoted 5 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.
Quoted 8 lines
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.
This makes things quite complicated, needs so many new binaries and tools which
lead to confuse to users.
Let's make it simple for RAM boot with usb download so that user can use it easily:
use rkdeveloptool to download the loader and boot from RAM, and that's all.
Thanks,
- Kever
Quoted 154 lines
These images can be used with rkbin
tools/boot_mergerto create a loader image to be used with rkdeveloptool or rockusb tools, 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.binOr directly with tools such as rkflashtool or rkusbboot:
$ 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]>---
v2: Usefit_templateinstead ofcommon_part
v2: 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 | 15 ++++++++--- boot/Kconfig | 3 +++ 4 files changed, 56 insertions(+), 3 deletions(-)arch/arm/dts/rockchip-u-boot.dtsi +33
-0@@ -231,5 +231,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@@ -607,6 +607,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 +12
-3@@ -8,7 +8,9 @@#include <log.h> #include <mmc.h> #include <spl.h> +#include <asm/arch-rockchip/bootrom.h> #include <asm/global_data.h> +#include <asm/io.h> #include <dm/uclass-internal.h> #if CONFIG_IS_ENABLED (OF_LIBFDT )@@ -98,15 +100,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 ) && +readl (BROM_BOOTSOURCE_ID_ADDR ) ==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 +124,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 ; }boot/Kconfig +3
-0@@ -246,6 +246,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
Re: [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode
Hi Kever Yang,
Quoted 21 lines · Kever Yang
Hi Jonas,
Thanks for your patch, and the ramboot with usb download do help
bootloader developers.Quoted 5 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.
Quoted 8 lines
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.
Quoted 7 lines
This makes things quite complicated, needs so many new binaries and tools which
lead to confuse to users.
Let's make it simple for RAM boot with usb download so that user can use it easily:
use rkdeveloptool to download the loader and boot from RAM, and that's all.
It requires boot_merger which is not included in U-Boot, right?
Best regards,
--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.
Quoted 156 lines
Thanks,
- KeverQuoted 154 lines
These images can be used with rkbin
tools/boot_mergerto create a loader image to be used with rkdeveloptool or rockusb tools, 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.binOr directly with tools such as rkflashtool or rkusbboot:
$ 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]>---
v2: Usefit_templateinstead ofcommon_part
v2: 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 | 15 ++++++++--- boot/Kconfig | 3 +++ 4 files changed, 56 insertions(+), 3 deletions(-)arch/arm/dts/rockchip-u-boot.dtsi +33
-0@@ -231,5 +231,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@@ -607,6 +607,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 +12
-3@@ -8,7 +8,9 @@#include <log.h> #include <mmc.h> #include <spl.h> +#include <asm/arch-rockchip/bootrom.h> #include <asm/global_data.h> +#include <asm/io.h> #include <dm/uclass-internal.h> #if CONFIG_IS_ENABLED (OF_LIBFDT )@@ -98,15 +100,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 ) && +readl (BROM_BOOTSOURCE_ID_ADDR ) ==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 +124,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 ; }boot/Kconfig +3
-0@@ -246,6 +246,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 v2 3/4 rockchip: Enable RAM boot using ROCKCHIP_MASKROM_IMAGE
In reply to Jonas KarlmanImply ROCKCHIP_MASKROM_IMAGE to build maskrom RAM boot images for RK3308, RK3328, RK3399, RK356x and RK3588.
---
v2: Collect t-b tag
These are SoCs that have fully migrated to COMMON_STACK_ADDR and that I have been able to runtime test maskrom RAM boot on.
An alternative approach could be to add a rockchip_ramboot.config that enables the ROCKCHIP_MASKROM_IMAGE Kconfig symbol.
--- arch/arm/mach-rockchip/Kconfig | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/mach-rockchip/Kconfig +5 -0
@@ -180,6 +180,7 @@ config ROCKCHIP_RK3308 imply ROCKCHIP_COMMON_BOARD imply ROCKCHIP_COMMON_STACK_ADDR imply ROCKCHIP_EXTERNAL_TPL + imply ROCKCHIP_MASKROM_IMAGE imply ROCKCHIP_OTP imply SPL_CLK imply SPL_DM_SEQ_ALIAS
@@ -213,6 +214,7 @@ config ROCKCHIP_RK3328 imply ROCKCHIP_COMMON_BOARD imply ROCKCHIP_COMMON_STACK_ADDR imply ROCKCHIP_EFUSE + imply ROCKCHIP_MASKROM_IMAGE imply ROCKCHIP_SDRAM_COMMON imply SPL_ROCKCHIP_COMMON_BOARD imply SPL_SEPARATE_BSS
@@ -293,6 +295,7 @@ config ROCKCHIP_RK3399 imply ROCKCHIP_COMMON_BOARD imply ROCKCHIP_COMMON_STACK_ADDR imply ROCKCHIP_EFUSE + imply ROCKCHIP_MASKROM_IMAGE imply ROCKCHIP_SDRAM_COMMON imply SPL_DM_SEQ_ALIAS imply SPL_FIT_SIGNATURE
@@ -343,6 +346,7 @@ config ROCKCHIP_RK3568 imply ROCKCHIP_COMMON_BOARD imply ROCKCHIP_COMMON_STACK_ADDR imply ROCKCHIP_EXTERNAL_TPL + imply ROCKCHIP_MASKROM_IMAGE imply ROCKCHIP_OTP imply SPL_ATF_NO_PLATFORM_PARAM if SPL_ATF imply SPL_MMC_HS200_SUPPORT if SPL_MMC && MMC_HS200_SUPPORT
@@ -378,6 +382,7 @@ config ROCKCHIP_RK3588 imply ROCKCHIP_COMMON_BOARD imply ROCKCHIP_COMMON_STACK_ADDR imply ROCKCHIP_EXTERNAL_TPL + imply ROCKCHIP_MASKROM_IMAGE imply ROCKCHIP_OTP imply SCMI_FIRMWARE imply SPL_ATF_NO_PLATFORM_PARAM if SPL_ATF
Signature · 1 line
2.49.0
PATCH v2 4/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.
---
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
@@ -183,6 +183,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
@@ -287,6 +287,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 );
@@ -340,7 +345,7 @@ int dram_init_banksize(void)#endif #endif -return 0 ; +return rockchip_dram_init_banksize_fixup (gd->bd); }size_t rockchip_sdram_size (phys_addr_t reg)
Signature · 1 line
2.49.0
Quoted 29 lines
From: Jonas Karlman <[email protected]>
Date: Sat, 5 Apr 2025 15:38:20 +0000The 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.These images can be used with rkbin
tools/boot_mergerto create a loader image to be used with rkdeveloptool or rockusb tools, 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.bin
Quoted 6 lines
Or directly with tools such as rkflashtool or rkusbboot:
$ 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
Hi Jonas,
Would be great if you could document this, maybe in doc/README.rockchup and/or doc/board/rockchip/rockchip.rst?
Thanks,
Mark
Quoted 35 lines
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 DRAMThis series depends on the "rockchip:
ROCKCHIP_COMMON_STACK_ADDRimprovements" series [1] and the "rockchip: binman: Use a template for FIT and other improvements" series [2]. See [3] for a branch including both depends.[1] https://patchwork.ozlabs.org/cover/2050003/
[2] https://patchwork.ozlabs.org/cover/2066701/
[3] https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commits/ramboot-v2Jonas Karlman (4):
rockchip: MoveTEXT_BASEto 8 MiB offset from start of DRAM
rockchip: Add support for RAM boot from maskrom mode
rockchip: Enable RAM boot usingROCKCHIP_MASKROM_IMAGE
rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588arch/arm/dts/rockchip-u-boot.dtsi | 33 +++++++++++++++++++++++++ arch/arm/mach-rockchip/Kconfig | 19 +++++++++++--- 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 | 15 ++++++++--- boot/Kconfig | 3 +++ 9 files changed, 97 insertions(+), 16 deletions(-)Signature · 1 line
2.49.0
Quoted 36 lines · Mark Kettenis
Quoted 29 lines
From: Jonas Karlman <[email protected]>
Date: Sat, 5 Apr 2025 15:38:20 +0000The 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.These images can be used with rkbin
tools/boot_mergerto create a loader image to be used with rkdeveloptool or rockusb tools, 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.binQuoted 6 lines
Or directly with tools such as rkflashtool or rkusbboot:
$ 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
Quoted 4 lines
Hi Jonas,
Would be great if you could document this, maybe in doc/README.rockchup and/or
doc/board/rockchip/rockchip.rst?
I would just note that doc/README.rockchup should have any content not found under doc/board/rockchip/ migrated there and then removed, thanks!
Signature · 1 line
Tom