public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode
@ 2025-08-02 22:07 Jonas Karlman
  2025-08-02 22:07 ` [PATCH v3 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Jonas Karlman @ 2025-08-02 22:07 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot,
	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 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.bin

Another 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

-- 
2.50.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM
  2025-08-02 22:07 [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
@ 2025-08-02 22:07 ` Jonas Karlman
  2025-08-02 22:07 ` [PATCH v3 2/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Jonas Karlman @ 2025-08-02 22:07 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot,
	Jonas Karlman

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.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Arnaud Patard <arnaud.patard@collabora.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
---
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(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 342933ca5099..c9ce30760292 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -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 || \
diff --git a/arch/arm/mach-rockchip/rk3308/Kconfig b/arch/arm/mach-rockchip/rk3308/Kconfig
index 06572d545f6e..b8d25c525424 100644
--- a/arch/arm/mach-rockchip/rk3308/Kconfig
+++ b/arch/arm/mach-rockchip/rk3308/Kconfig
@@ -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"
 
diff --git a/arch/arm/mach-rockchip/rk3568/Kconfig b/arch/arm/mach-rockchip/rk3568/Kconfig
index 01b53a47ddbe..2730220a18e8 100644
--- a/arch/arm/mach-rockchip/rk3568/Kconfig
+++ b/arch/arm/mach-rockchip/rk3568/Kconfig
@@ -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"
diff --git a/arch/arm/mach-rockchip/rk3588/Kconfig b/arch/arm/mach-rockchip/rk3588/Kconfig
index 4e7942ada875..dfc19c4fc8fa 100644
--- a/arch/arm/mach-rockchip/rk3588/Kconfig
+++ b/arch/arm/mach-rockchip/rk3588/Kconfig
@@ -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"
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 2/4] rockchip: Add support for RAM boot from maskrom mode
  2025-08-02 22:07 [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
  2025-08-02 22:07 ` [PATCH v3 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
@ 2025-08-02 22:07 ` Jonas Karlman
  2025-11-16 12:37   ` Kever Yang
  2025-08-02 22:07 ` [PATCH v3 3/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588 Jonas Karlman
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Jonas Karlman @ 2025-08-02 22:07 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot,
	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 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.bin

Another 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

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Arnaud Patard <arnaud.patard@collabora.com>
---
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

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index cc2feed6464f..71d7623fe2ca 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -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 */
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index c9ce30760292..e32e49ff59ac 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -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
 
diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c
index 6b1b84dc86d1..15f1cba8e8fd 100644
--- a/arch/arm/mach-rockchip/spl-boot-order.c
+++ b/arch/arm/mach-rockchip/spl-boot-order.c
@@ -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;
 	}
 
diff --git a/board/rockchip/rockchip-ramboot.config b/board/rockchip/rockchip-ramboot.config
new file mode 100644
index 000000000000..312363e542b7
--- /dev/null
+++ b/board/rockchip/rockchip-ramboot.config
@@ -0,0 +1 @@
+CONFIG_ROCKCHIP_MASKROM_IMAGE=y
diff --git a/boot/Kconfig b/boot/Kconfig
index 2ff6f0037384..2afad56ddfa6 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -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
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 3/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588
  2025-08-02 22:07 [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
  2025-08-02 22:07 ` [PATCH v3 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
  2025-08-02 22:07 ` [PATCH v3 2/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
@ 2025-08-02 22:07 ` Jonas Karlman
  2025-11-16 12:38   ` Kever Yang
  2025-08-02 22:07 ` [PATCH v3 4/4] HACK: rockchip: Add miniall.ini files to simplify test of RAM boot Jonas Karlman
  2025-10-19  9:39 ` [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Dang Huynh
  4 siblings, 1 reply; 8+ messages in thread
From: Jonas Karlman @ 2025-08-02 22:07 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot,
	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_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.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
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(-)

diff --git a/arch/arm/mach-rockchip/rk3588/rk3588.c b/arch/arm/mach-rockchip/rk3588/rk3588.c
index c01a40020896..719daa7714e3 100644
--- a/arch/arm/mach-rockchip/rk3588/rk3588.c
+++ b/arch/arm/mach-rockchip/rk3588/rk3588.c
@@ -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
 
diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c
index d560f90e873d..ea0e3621af72 100644
--- a/arch/arm/mach-rockchip/sdram.c
+++ b/arch/arm/mach-rockchip/sdram.c
@@ -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)
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 4/4] HACK: rockchip: Add miniall.ini files to simplify test of RAM boot
  2025-08-02 22:07 [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
                   ` (2 preceding siblings ...)
  2025-08-02 22:07 ` [PATCH v3 3/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588 Jonas Karlman
@ 2025-08-02 22:07 ` Jonas Karlman
  2025-10-19  9:39 ` [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Dang Huynh
  4 siblings, 0 replies; 8+ messages in thread
From: Jonas Karlman @ 2025-08-02 22:07 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot,
	Jonas Karlman

THIS 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

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
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

diff --git a/RK3308MINIALL.ini b/RK3308MINIALL.ini
new file mode 100644
index 000000000000..4802757418e9
--- /dev/null
+++ b/RK3308MINIALL.ini
@@ -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
diff --git a/RK3328MINIALL.ini b/RK3328MINIALL.ini
new file mode 100644
index 000000000000..590744f7f893
--- /dev/null
+++ b/RK3328MINIALL.ini
@@ -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
diff --git a/RK3399MINIALL.ini b/RK3399MINIALL.ini
new file mode 100644
index 000000000000..22517a7fb091
--- /dev/null
+++ b/RK3399MINIALL.ini
@@ -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
diff --git a/RK3528MINIALL.ini b/RK3528MINIALL.ini
new file mode 100644
index 000000000000..483ea8ebff5f
--- /dev/null
+++ b/RK3528MINIALL.ini
@@ -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
diff --git a/RK3566MINIALL.ini b/RK3566MINIALL.ini
new file mode 100644
index 000000000000..cedf9cb69dfb
--- /dev/null
+++ b/RK3566MINIALL.ini
@@ -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
diff --git a/RK3568MINIALL.ini b/RK3568MINIALL.ini
new file mode 100644
index 000000000000..d871d74b5f93
--- /dev/null
+++ b/RK3568MINIALL.ini
@@ -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
diff --git a/RK3576MINIALL.ini b/RK3576MINIALL.ini
new file mode 100644
index 000000000000..162513bb0183
--- /dev/null
+++ b/RK3576MINIALL.ini
@@ -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
diff --git a/RK3588MINIALL.ini b/RK3588MINIALL.ini
new file mode 100644
index 000000000000..bbf40dbe16c3
--- /dev/null
+++ b/RK3588MINIALL.ini
@@ -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
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode
  2025-08-02 22:07 [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
                   ` (3 preceding siblings ...)
  2025-08-02 22:07 ` [PATCH v3 4/4] HACK: rockchip: Add miniall.ini files to simplify test of RAM boot Jonas Karlman
@ 2025-10-19  9:39 ` Dang Huynh
  4 siblings, 0 replies; 8+ messages in thread
From: Dang Huynh @ 2025-10-19  9:39 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini, u-boot
  Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot,
	Jonas Karlman, Jonas Karlman

Tested on my PineTab 2 using rkusbboot.

Tested-by: Dang Huynh <dang.huynh@mainlining.org> (RK3566 - PineTab 2)

On Saturday, August 2, 2025 10:07:21 PM Coordinated Universal Time Jonas 
Karlman wrote:
> 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.bin
> 
> Another 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





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/4] rockchip: Add support for RAM boot from maskrom mode
  2025-08-02 22:07 ` [PATCH v3 2/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
@ 2025-11-16 12:37   ` Kever Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Kever Yang @ 2025-11-16 12:37 UTC (permalink / raw)
  To: Jonas Karlman, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot


On 2025/8/3 06:07, Jonas Karlman wrote:
> 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.
>
> 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.bin
>
> Another 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
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> Tested-by: Arnaud Patard <arnaud.patard@collabora.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
> 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
>
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
> index cc2feed6464f..71d7623fe2ca 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -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 */
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index c9ce30760292..e32e49ff59ac 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -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
>   
> diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c
> index 6b1b84dc86d1..15f1cba8e8fd 100644
> --- a/arch/arm/mach-rockchip/spl-boot-order.c
> +++ b/arch/arm/mach-rockchip/spl-boot-order.c
> @@ -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;
>   	}
>   
> diff --git a/board/rockchip/rockchip-ramboot.config b/board/rockchip/rockchip-ramboot.config
> new file mode 100644
> index 000000000000..312363e542b7
> --- /dev/null
> +++ b/board/rockchip/rockchip-ramboot.config
> @@ -0,0 +1 @@
> +CONFIG_ROCKCHIP_MASKROM_IMAGE=y
> diff --git a/boot/Kconfig b/boot/Kconfig
> index 2ff6f0037384..2afad56ddfa6 100644
> --- a/boot/Kconfig
> +++ b/boot/Kconfig
> @@ -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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 3/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588
  2025-08-02 22:07 ` [PATCH v3 3/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588 Jonas Karlman
@ 2025-11-16 12:38   ` Kever Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Kever Yang @ 2025-11-16 12:38 UTC (permalink / raw)
  To: Jonas Karlman, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot


On 2025/8/3 06:07, Jonas Karlman wrote:
> 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_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.
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
> 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(-)
>
> diff --git a/arch/arm/mach-rockchip/rk3588/rk3588.c b/arch/arm/mach-rockchip/rk3588/rk3588.c
> index c01a40020896..719daa7714e3 100644
> --- a/arch/arm/mach-rockchip/rk3588/rk3588.c
> +++ b/arch/arm/mach-rockchip/rk3588/rk3588.c
> @@ -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
>   
> diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c
> index d560f90e873d..ea0e3621af72 100644
> --- a/arch/arm/mach-rockchip/sdram.c
> +++ b/arch/arm/mach-rockchip/sdram.c
> @@ -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)


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-11-16 12:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-02 22:07 [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
2025-08-02 22:07 ` [PATCH v3 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
2025-08-02 22:07 ` [PATCH v3 2/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
2025-11-16 12:37   ` Kever Yang
2025-08-02 22:07 ` [PATCH v3 3/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588 Jonas Karlman
2025-11-16 12:38   ` Kever Yang
2025-08-02 22:07 ` [PATCH v3 4/4] HACK: rockchip: Add miniall.ini files to simplify test of RAM boot Jonas Karlman
2025-10-19  9:39 ` [PATCH v3 0/4] rockchip: Add support for RAM boot from maskrom mode Dang Huynh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox