* [PATCH v2 0/4] Add support for RAM boot from maskrom mode
@ 2025-04-05 15:38 Jonas Karlman
2025-04-05 15:38 ` [PATCH v2 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Jonas Karlman @ 2025-04-05 15:38 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.
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.bin
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
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(-)
--
2.49.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM
2025-04-05 15:38 [PATCH v2 0/4] Add support for RAM boot from maskrom mode Jonas Karlman
@ 2025-04-05 15:38 ` Jonas Karlman
2025-05-08 2:44 ` Kever Yang
2025-04-05 15:38 ` [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Jonas Karlman @ 2025-04-05 15:38 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>
---
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 33a9f7a4dd4b..c9d8f9105083 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -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 || \
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 c589fd586993..a271782fac5c 100644
--- a/arch/arm/mach-rockchip/rk3568/Kconfig
+++ b/arch/arm/mach-rockchip/rk3568/Kconfig
@@ -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"
diff --git a/arch/arm/mach-rockchip/rk3588/Kconfig b/arch/arm/mach-rockchip/rk3588/Kconfig
index efd192068ad1..1c6a85d07394 100644
--- a/arch/arm/mach-rockchip/rk3588/Kconfig
+++ b/arch/arm/mach-rockchip/rk3588/Kconfig
@@ -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"
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode
2025-04-05 15:38 [PATCH v2 0/4] Add support for RAM boot from maskrom mode Jonas Karlman
2025-04-05 15:38 ` [PATCH v2 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
@ 2025-04-05 15:38 ` Jonas Karlman
2025-05-08 3:06 ` Kever Yang
2025-04-05 15:38 ` [PATCH v2 3/4] rockchip: Enable RAM boot using ROCKCHIP_MASKROM_IMAGE Jonas Karlman
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Jonas Karlman @ 2025-04-05 15:38 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.
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.bin
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
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Arnaud Patard <arnaud.patard@collabora.com>
---
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(-)
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index 0dfd45bb9bed..dafae297d0cf 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -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 */
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index c9d8f9105083..e817bf46e565 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -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
diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c
index 3dce9b30898d..20cbee8c9ff4 100644
--- a/arch/arm/mach-rockchip/spl-boot-order.c
+++ b/arch/arm/mach-rockchip/spl-boot-order.c
@@ -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;
}
diff --git a/boot/Kconfig b/boot/Kconfig
index f101200ba7a5..abfc9eaf325f 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -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
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/4] rockchip: Enable RAM boot using ROCKCHIP_MASKROM_IMAGE
2025-04-05 15:38 [PATCH v2 0/4] Add support for RAM boot from maskrom mode Jonas Karlman
2025-04-05 15:38 ` [PATCH v2 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
2025-04-05 15:38 ` [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
@ 2025-04-05 15:38 ` Jonas Karlman
2025-04-05 15:38 ` [PATCH v2 4/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588 Jonas Karlman
2025-04-05 16:02 ` [PATCH v2 0/4] Add support for RAM boot from maskrom mode Mark Kettenis
4 siblings, 0 replies; 10+ messages in thread
From: Jonas Karlman @ 2025-04-05 15:38 UTC (permalink / raw)
To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot,
Jonas Karlman
Imply ROCKCHIP_MASKROM_IMAGE to build maskrom RAM boot images for
RK3308, RK3328, RK3399, RK356x and RK3588.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Arnaud Patard <arnaud.patard@collabora.com>
---
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(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index e817bf46e565..f349431bb43c 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -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
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 4/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588
2025-04-05 15:38 [PATCH v2 0/4] Add support for RAM boot from maskrom mode Jonas Karlman
` (2 preceding siblings ...)
2025-04-05 15:38 ` [PATCH v2 3/4] rockchip: Enable RAM boot using ROCKCHIP_MASKROM_IMAGE Jonas Karlman
@ 2025-04-05 15:38 ` Jonas Karlman
2025-04-05 16:02 ` [PATCH v2 0/4] Add support for RAM boot from maskrom mode Mark Kettenis
4 siblings, 0 replies; 10+ messages in thread
From: Jonas Karlman @ 2025-04-05 15:38 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>
---
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 c1dce3ee3703..6395483f14f1 100644
--- a/arch/arm/mach-rockchip/rk3588/rk3588.c
+++ b/arch/arm/mach-rockchip/rk3588/rk3588.c
@@ -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
diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c
index f7d32829295c..0bdda77a7926 100644
--- a/arch/arm/mach-rockchip/sdram.c
+++ b/arch/arm/mach-rockchip/sdram.c
@@ -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)
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/4] Add support for RAM boot from maskrom mode
2025-04-05 15:38 [PATCH v2 0/4] Add support for RAM boot from maskrom mode Jonas Karlman
` (3 preceding siblings ...)
2025-04-05 15:38 ` [PATCH v2 4/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588 Jonas Karlman
@ 2025-04-05 16:02 ` Mark Kettenis
2025-04-06 22:48 ` Tom Rini
4 siblings, 1 reply; 10+ messages in thread
From: Mark Kettenis @ 2025-04-05 16:02 UTC (permalink / raw)
To: Jonas Karlman
Cc: kever.yang, sjg, philipp.tomsich, trini, arnaud.patard,
quentin.schulz, naoki, u-boot, jonas
> From: Jonas Karlman <jonas@kwiboo.se>
> Date: Sat, 5 Apr 2025 15:38:20 +0000
>
> 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.bin
>
> 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
> 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(-)
>
> --
> 2.49.0
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/4] Add support for RAM boot from maskrom mode
2025-04-05 16:02 ` [PATCH v2 0/4] Add support for RAM boot from maskrom mode Mark Kettenis
@ 2025-04-06 22:48 ` Tom Rini
0 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2025-04-06 22:48 UTC (permalink / raw)
To: Mark Kettenis
Cc: Jonas Karlman, kever.yang, sjg, philipp.tomsich, arnaud.patard,
quentin.schulz, naoki, u-boot
[-- Attachment #1: Type: text/plain, Size: 1804 bytes --]
On Sat, Apr 05, 2025 at 06:02:37PM +0200, Mark Kettenis wrote:
> > From: Jonas Karlman <jonas@kwiboo.se>
> > Date: Sat, 5 Apr 2025 15:38:20 +0000
> >
> > 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.bin
> >
> > 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?
I would just note that doc/README.rockchup should have any content not
found under doc/board/rockchip/ migrated there and then removed, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM
2025-04-05 15:38 ` [PATCH v2 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
@ 2025-05-08 2:44 ` Kever Yang
0 siblings, 0 replies; 10+ messages in thread
From: Kever Yang @ 2025-05-08 2:44 UTC (permalink / raw)
To: Jonas Karlman, Simon Glass, Philipp Tomsich, Tom Rini
Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot
On 2025/4/5 23:38, Jonas Karlman wrote:
> 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>
Thanks,
- Kever
> ---
> 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 33a9f7a4dd4b..c9d8f9105083 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -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 || \
> 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 c589fd586993..a271782fac5c 100644
> --- a/arch/arm/mach-rockchip/rk3568/Kconfig
> +++ b/arch/arm/mach-rockchip/rk3568/Kconfig
> @@ -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"
> diff --git a/arch/arm/mach-rockchip/rk3588/Kconfig b/arch/arm/mach-rockchip/rk3588/Kconfig
> index efd192068ad1..1c6a85d07394 100644
> --- a/arch/arm/mach-rockchip/rk3588/Kconfig
> +++ b/arch/arm/mach-rockchip/rk3588/Kconfig
> @@ -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"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode
2025-04-05 15:38 ` [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
@ 2025-05-08 3:06 ` Kever Yang
2025-05-08 23:23 ` FUKAUMI Naoki
0 siblings, 1 reply; 10+ messages in thread
From: Kever Yang @ 2025-05-08 3:06 UTC (permalink / raw)
To: Jonas Karlman, Simon Glass, Philipp Tomsich, Tom Rini
Cc: Arnaud Patard, Quentin Schulz, FUKAUMI Naoki, u-boot
Hi Jonas,
Thanks for your patch, and the ramboot with usb download do help
bootloader developers.
On 2025/4/5 23:38, 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.
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
> 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.bin
>
> 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
>
> Signed-off-by: Jonas Karlman<jonas@kwiboo.se>
> Tested-by: Arnaud Patard<arnaud.patard@collabora.com>
> ---
> 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(-)
>
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
> index 0dfd45bb9bed..dafae297d0cf 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -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 */
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index c9d8f9105083..e817bf46e565 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -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
>
> diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c
> index 3dce9b30898d..20cbee8c9ff4 100644
> --- a/arch/arm/mach-rockchip/spl-boot-order.c
> +++ b/arch/arm/mach-rockchip/spl-boot-order.c
> @@ -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;
> }
>
> diff --git a/boot/Kconfig b/boot/Kconfig
> index f101200ba7a5..abfc9eaf325f 100644
> --- a/boot/Kconfig
> +++ b/boot/Kconfig
> @@ -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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode
2025-05-08 3:06 ` Kever Yang
@ 2025-05-08 23:23 ` FUKAUMI Naoki
0 siblings, 0 replies; 10+ messages in thread
From: FUKAUMI Naoki @ 2025-05-08 23:23 UTC (permalink / raw)
To: Kever Yang, Jonas Karlman, Simon Glass, Philipp Tomsich, Tom Rini
Cc: Arnaud Patard, Quentin Schulz, u-boot
Hi Kever Yang,
On 5/8/25 12:06, Kever Yang wrote:
> Hi Jonas,
>
>
> Thanks for your patch, and the ramboot with usb download do help
> bootloader developers.
>
> On 2025/4/5 23:38, 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.
>
> 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.
> Thanks,
> - Kever
>> 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.bin
>>
>> 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
>>
>> Signed-off-by: Jonas Karlman<jonas@kwiboo.se>
>> Tested-by: Arnaud Patard<arnaud.patard@collabora.com>
>> ---
>> 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(-)
>>
>> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
>> index 0dfd45bb9bed..dafae297d0cf 100644
>> --- a/arch/arm/dts/rockchip-u-boot.dtsi
>> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
>> @@ -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 */
>> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
>> index c9d8f9105083..e817bf46e565 100644
>> --- a/arch/arm/mach-rockchip/Kconfig
>> +++ b/arch/arm/mach-rockchip/Kconfig
>> @@ -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
>>
>> diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c
>> index 3dce9b30898d..20cbee8c9ff4 100644
>> --- a/arch/arm/mach-rockchip/spl-boot-order.c
>> +++ b/arch/arm/mach-rockchip/spl-boot-order.c
>> @@ -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;
>> }
>>
>> diff --git a/boot/Kconfig b/boot/Kconfig
>> index f101200ba7a5..abfc9eaf325f 100644
>> --- a/boot/Kconfig
>> +++ b/boot/Kconfig
>> @@ -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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-05-08 23:24 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-05 15:38 [PATCH v2 0/4] Add support for RAM boot from maskrom mode Jonas Karlman
2025-04-05 15:38 ` [PATCH v2 1/4] rockchip: Move TEXT_BASE to 8 MiB offset from start of DRAM Jonas Karlman
2025-05-08 2:44 ` Kever Yang
2025-04-05 15:38 ` [PATCH v2 2/4] rockchip: Add support for RAM boot from maskrom mode Jonas Karlman
2025-05-08 3:06 ` Kever Yang
2025-05-08 23:23 ` FUKAUMI Naoki
2025-04-05 15:38 ` [PATCH v2 3/4] rockchip: Enable RAM boot using ROCKCHIP_MASKROM_IMAGE Jonas Karlman
2025-04-05 15:38 ` [PATCH v2 4/4] rockchip: sdram: Add fallback that fixup DRAM gaps on RK3588 Jonas Karlman
2025-04-05 16:02 ` [PATCH v2 0/4] Add support for RAM boot from maskrom mode Mark Kettenis
2025-04-06 22:48 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox