Skip to contentSkip to conversation

rockchip: Add boot from USB OTG port

PATCH In review FUKAUMI Naoki 4 participants 16 messages Feb 11, 2025 – May 8, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover rockchip: Add boot from USB OTG port

This patch series adds the ability to boot from the USB OTG port to the RK3588, RK3568, RK3566, RK3399, RK3328, and RK3308.

Use rkflashtool[1] or rkusbboot[2] to download TPL and SPL from MASKROM mode, and dfu-util to download U-Boot from DFU mode.

This patch series depends on patches[3] that fix TPL/SPL link errors and patches[4] that add generic RK3399 and RK3328 defconfigs.

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot
[3] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
[4] https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

FUKAUMI Naoki (7):
rockchip: Change memory location of FIT and U-Boot proper
rockchip: Add DFU to SPL
rockchip: Add DFU to SPL for RK3588
rockchip: Add DFU to SPL for RK3568
rockchip: Add DFU to SPL for RK3399
rockchip: Add DFU to SPL for RK3328
rockchip: Add DFU to SPL for RK3308

 arch/arm/dts/rk3308-u-boot.dtsi         |  5 +++++
 arch/arm/dts/rk3328-u-boot.dtsi         |  5 +++++
 arch/arm/dts/rk3399-u-boot.dtsi         | 10 ++++++++++
 arch/arm/dts/rk356x-u-boot.dtsi         |  5 +++++
 arch/arm/dts/rk3588s-u-boot.dtsi        |  5 +++++
 arch/arm/mach-rockchip/Kconfig          |  6 +++---
 arch/arm/mach-rockchip/rk3308/Kconfig   |  3 ---
 arch/arm/mach-rockchip/rk3308/rk3308.c  |  1 +
 arch/arm/mach-rockchip/rk3328/rk3328.c  |  1 +
 arch/arm/mach-rockchip/rk3399/rk3399.c  |  1 +
 arch/arm/mach-rockchip/rk3568/Kconfig   |  3 ---
 arch/arm/mach-rockchip/rk3568/rk3568.c  |  1 +
 arch/arm/mach-rockchip/rk3588/Kconfig   |  3 ---
 arch/arm/mach-rockchip/rk3588/rk3588.c  |  1 +
 arch/arm/mach-rockchip/rv1126/Kconfig   |  3 ---
 arch/arm/mach-rockchip/spl-boot-order.c |  4 ++++
 boot/Kconfig                            |  3 +++
 configs/generic-rk3328_defconfig        |  8 ++++++++
 configs/generic-rk3399_defconfig        |  9 +++++++++
 configs/generic-rk3568_defconfig        |  9 +++++++++
 configs/generic-rk3588_defconfig        |  9 +++++++++
 include/configs/rk3308_common.h         |  7 +++++++
 include/configs/rk3328_common.h         |  7 +++++++
 include/configs/rk3399_common.h         | 11 +++++++----
 include/configs/rk3568_common.h         |  7 +++++++
 include/configs/rk3588_common.h         |  7 +++++++
 26 files changed, 115 insertions(+), 19 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/7 rockchip: Change memory location of FIT and U-Boot proper

Place U-Boot at 8MiB in order to place FIT at 2MiB.

---
 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 ---
 arch/arm/mach-rockchip/rv1126/Kconfig | 3 ---
 boot/Kconfig                          | 3 +++
 6 files changed, 6 insertions(+), 15 deletions(-)
arch/arm/mach-rockchip/Kconfig +3 -3
index cf8f987569f..bc31b43d630 100644
@@ -665,9 +665,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
index 06572d545f6..b8d25c52542 100644
@@ -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
index c589fd58699..a271782fac5 100644
@@ -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
index efd192068ad..1c6a85d0739 100644
@@ -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"
arch/arm/mach-rockchip/rv1126/Kconfig +0 -3
index 330b7df2312..27ed756870d 100644
@@ -61,9 +61,6 @@ config TPL_TEXT_BASE
 config SYS_MALLOC_F_LEN
 	default 0x2000
 
-config TEXT_BASE
-	default 0x600000
-
 source "board/edgeble/neural-compute-module-2/Kconfig"
 source "board/itead/sonoff-ihost/Kconfig"
 
boot/Kconfig +3 -0
index 20935a269c6..26a71fc8d3b 100644
@@ -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 0x60200000 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.43.0
#2 lore raw

PATCH 2/7 rockchip: Add DFU to SPL

In reply to FUKAUMI Naoki

Allows SPL to use DFU when SPL is booted from USB.

---
 arch/arm/mach-rockchip/spl-boot-order.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/mach-rockchip/spl-boot-order.c +4 -0
index 3dce9b30898..2943c8bb494 100644
@@ -35,6 +35,10 @@ static int spl_node_to_boot_device(int node)
 {
 	struct udevice *parent;
 
+	if (!uclass_get_device_by_of_offset(UCLASS_USB_GADGET_GENERIC,
+					    node, &parent))
+		return BOOT_DEVICE_DFU;
+
 	/*
 	 * This should eventually move into the SPL code, once SPL becomes
 	 * aware of the block-device layer.  Until then (and to avoid unneeded
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH 2/7] rockchip: Add DFU to SPL

Hi,

Quoted 12 lines · FUKAUMI Naoki

Allows SPL to use DFU when SPL is booted from USB.

---
 arch/arm/mach-rockchip/spl-boot-order.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/mach-rockchip/spl-boot-order.c +0 -0
index 3dce9b30898..2943c8bb494 100644

arch/arm/mach-rockchip/spl-boot-order.c static int spl_node_to_boot_device(int node) · line 40

Quoted 6 lines
arch/arm/mach-rockchip/spl-boot-order.c +3 -0
@@ -35,6 +35,10 @@ static int spl_node_to_boot_device(int node)
 {
 	struct udevice *parent;
 
+	if (!uclass_get_device_by_of_offset(UCLASS_USB_GADGET_GENERIC,
+					    node, &parent))
+		return BOOT_DEVICE_DFU;

Please move this to the end of the function after the UCLASS_SPI_FLASH / BOOT_DEVICE_SPI part. DFU boot is likely to be the least of mmc, spi-flash and dfu being looked up.

This should probably also check for CONFIG_IS_ENABLED(DFU).

Regards,
Jonas

Quoted 4 lines
arch/arm/mach-rockchip/spl-boot-order.c +1 -0
+
 	/*
 	 * This should eventually move into the SPL code, once SPL becomes
 	 * aware of the block-device layer.  Until then (and to avoid unneeded
#4 lore raw

PATCH 3/7 rockchip: Add DFU to SPL for RK3588

In reply to FUKAUMI Naoki

Boot the RK3588 from the USB OTG port using rkflashtool[1] or rkusbboot[2] and dfu-util.

1a. Download the TPL and SPL using rkflashtool

$ rkflashtool l < mkimage-in-simple-bin.mkimage-rockchip-tpl
$ rkflashtool L < mkimage-in-simple-bin.mkimage-u-boot-spl

1b. Download the TPL and SPL using rkusbboot

$ rkusbboot \
	mkimage-in-simple-bin.mkimage-rockchip-tpl \
	mkimage-in-simple-bin.mkimage-u-boot-spl

2. Download the U-Boot

$ dfu-util -a 0 -D u-boot.itb

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot

---
 arch/arm/dts/rk3588s-u-boot.dtsi       | 5 +++++
 arch/arm/mach-rockchip/rk3588/rk3588.c | 1 +
 configs/generic-rk3588_defconfig       | 9 +++++++++
 include/configs/rk3588_common.h        | 7 +++++++
 4 files changed, 22 insertions(+)
arch/arm/dts/rk3588s-u-boot.dtsi +5 -0
index 8880d162b11..1e961768341 100644
@@ -161,6 +161,11 @@
 	bootph-all;
 };
 
+&usb_host0_xhci {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
 &xin24m {
 	bootph-all;
 };
arch/arm/mach-rockchip/rk3588/rk3588.c +1 -0
index c1dce3ee370..662b092d811 100644
@@ -53,6 +53,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 	[BROM_BOOTSOURCE_FSPI_M1] = "/spi@fe2b0000/flash@0",
 	[BROM_BOOTSOURCE_FSPI_M2] = "/spi@fe2b0000/flash@0",
 	[BROM_BOOTSOURCE_SD] = "/mmc@fe2c0000",
+	[BROM_BOOTSOURCE_USB] = "/usb@fc000000",
 };
 
 static struct mm_region rk3588_mem_map[] = {
configs/generic-rk3588_defconfig +9 -0
index 51e31dce3a9..0dd64783bc0 100644
@@ -21,7 +21,9 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-generic.dtb"
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_ATF=y
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MISC=y
@@ -41,6 +43,9 @@ CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
 # CONFIG_ADC is not set
 CONFIG_SPL_CLK=y
+CONFIG_DFU_RAM=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
 # CONFIG_USB_FUNCTION_FASTBOOT is not set
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_MISC=y
@@ -60,9 +65,13 @@ CONFIG_SYS_NS16550_MEM32=y
 CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
+CONFIG_SPL_DM_USB_GADGET=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
 CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_FUNCTION_ROCKUSB=y
+CONFIG_SPL_DFU=y
 CONFIG_ERRNO_STR=y
include/configs/rk3588_common.h +7 -0
index e6654c275ac..0fad6b37589 100644
@@ -26,11 +26,18 @@
 	"ramdisk_addr_r=0x12180000\0"	\
 	"kernel_comp_size=0x8000000\0"
 
+#if defined(CONFIG_SPL_DFU) && defined(CONFIG_XPL_BUILD)
+#define CFG_EXTRA_ENV_SETTINGS				\
+	"dfu_alt_info_ram=u-boot.itb ram "		\
+	__stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " "	\
+	__stringify(CONFIG_SYS_DFU_MAX_FILE_SIZE) "\0"
+#else
 #define CFG_EXTRA_ENV_SETTINGS		\
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
 	"partitions=" PARTS_DEFAULT	\
 	ENV_MEM_LAYOUT_SETTINGS		\
 	ROCKCHIP_DEVICE_SETTINGS	\
 	"boot_targets=" BOOT_TARGETS "\0"
+#endif
 
 #endif /* __CONFIG_RK3588_COMMON_H */
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH 3/7] rockchip: Add DFU to SPL for RK3588

Hi Naoki,

    Please split the code change and dts/config change into different patch.

Thanks,

- Kever

Quoted 118 lines · FUKAUMI Naoki

Boot the RK3588 from the USB OTG port using rkflashtool[1] or rkusbboot[2] and dfu-util.

1a. Download the TPL and SPL using rkflashtool

$ rkflashtool l < mkimage-in-simple-bin.mkimage-rockchip-tpl
$ rkflashtool L < mkimage-in-simple-bin.mkimage-u-boot-spl

1b. Download the TPL and SPL using rkusbboot

$ rkusbboot \
	mkimage-in-simple-bin.mkimage-rockchip-tpl \
	mkimage-in-simple-bin.mkimage-u-boot-spl

2. Download the U-Boot

$ dfu-util -a 0 -D u-boot.itb

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot

---
  arch/arm/dts/rk3588s-u-boot.dtsi       | 5 +++++
  arch/arm/mach-rockchip/rk3588/rk3588.c | 1 +
  configs/generic-rk3588_defconfig       | 9 +++++++++
  include/configs/rk3588_common.h        | 7 +++++++
  4 files changed, 22 insertions(+)
arch/arm/dts/rk3588s-u-boot.dtsi +5 -0
index 8880d162b11..1e961768341 100644
@@ -161,6 +161,11 @@
  	bootph-all;
  };
 
+&usb_host0_xhci {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
  &xin24m {
  	bootph-all;
  };
arch/arm/mach-rockchip/rk3588/rk3588.c +1 -0
index c1dce3ee370..662b092d811 100644
@@ -53,6 +53,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
  	[BROM_BOOTSOURCE_FSPI_M1] = "/spi@fe2b0000/flash@0",
  	[BROM_BOOTSOURCE_FSPI_M2] = "/spi@fe2b0000/flash@0",
  	[BROM_BOOTSOURCE_SD] = "/mmc@fe2c0000",
+	[BROM_BOOTSOURCE_USB] = "/usb@fc000000",
  };
 
  static struct mm_region rk3588_mem_map[] = {
configs/generic-rk3588_defconfig +9 -0
index 51e31dce3a9..0dd64783bc0 100644
@@ -21,7 +21,9 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-generic.dtb"
  CONFIG_SPL_MAX_SIZE=0x40000
  CONFIG_SPL_PAD_TO=0x7f8000
  # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ENV_SUPPORT=y
  CONFIG_SPL_ATF=y
+CONFIG_CMD_DFU=y
  CONFIG_CMD_GPIO=y
  CONFIG_CMD_GPT=y
  CONFIG_CMD_MISC=y
@@ -41,6 +43,9 @@ CONFIG_SPL_REGMAP=y
  CONFIG_SPL_SYSCON=y
  # CONFIG_ADC is not set
  CONFIG_SPL_CLK=y
+CONFIG_DFU_RAM=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
  # CONFIG_USB_FUNCTION_FASTBOOT is not set
  CONFIG_ROCKCHIP_GPIO=y
  CONFIG_MISC=y
@@ -60,9 +65,13 @@ CONFIG_SYS_NS16550_MEM32=y
  CONFIG_SYSRESET=y
  CONFIG_SYSRESET_PSCI=y
  CONFIG_USB=y
+CONFIG_SPL_DM_USB_GADGET=y
  CONFIG_USB_DWC3=y
  CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
  CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
  CONFIG_USB_GADGET_DOWNLOAD=y
  CONFIG_USB_FUNCTION_ROCKUSB=y
+CONFIG_SPL_DFU=y
  CONFIG_ERRNO_STR=y
include/configs/rk3588_common.h +7 -0
index e6654c275ac..0fad6b37589 100644
@@ -26,11 +26,18 @@
  	"ramdisk_addr_r=0x12180000\0"	\
  	"kernel_comp_size=0x8000000\0"
 
+#if defined(CONFIG_SPL_DFU) && defined(CONFIG_XPL_BUILD)
+#define CFG_EXTRA_ENV_SETTINGS				\
+	"dfu_alt_info_ram=u-boot.itb ram "		\
+	__stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " "	\
+	__stringify(CONFIG_SYS_DFU_MAX_FILE_SIZE) "\0"
+#else
  #define CFG_EXTRA_ENV_SETTINGS		\
  	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
  	"partitions=" PARTS_DEFAULT	\
  	ENV_MEM_LAYOUT_SETTINGS		\
  	ROCKCHIP_DEVICE_SETTINGS	\
  	"boot_targets=" BOOT_TARGETS "\0"
+#endif
 
  #endif /* __CONFIG_RK3588_COMMON_H */
#6 lore raw

Re: [PATCH 3/7] rockchip: Add DFU to SPL for RK3588

In reply to FUKAUMI Naoki

Hi,

Quoted 34 lines · FUKAUMI Naoki

Boot the RK3588 from the USB OTG port using rkflashtool[1] or rkusbboot[2] and dfu-util.

1a. Download the TPL and SPL using rkflashtool

$ rkflashtool l < mkimage-in-simple-bin.mkimage-rockchip-tpl
$ rkflashtool L < mkimage-in-simple-bin.mkimage-u-boot-spl

1b. Download the TPL and SPL using rkusbboot

$ rkusbboot \
	mkimage-in-simple-bin.mkimage-rockchip-tpl \
	mkimage-in-simple-bin.mkimage-u-boot-spl

2. Download the U-Boot

$ dfu-util -a 0 -D u-boot.itb

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot

---
 arch/arm/dts/rk3588s-u-boot.dtsi       | 5 +++++
 arch/arm/mach-rockchip/rk3588/rk3588.c | 1 +
 configs/generic-rk3588_defconfig       | 9 +++++++++
 include/configs/rk3588_common.h        | 7 +++++++
 4 files changed, 22 insertions(+)
arch/arm/dts/rk3588s-u-boot.dtsi +0 -0
index 8880d162b11..1e961768341 100644

arch/arm/dts/rk3588s-u-boot.dtsi line 165

Quoted 5 lines
arch/arm/dts/rk3588s-u-boot.dtsi +2 -0
@@ -161,6 +161,11 @@
 	bootph-all;
 };
 
+&usb_host0_xhci {
+	bootph-pre-ram;

Please wrap bootph-pre-ram in IS_ENABLED(CONFIG_SPL_DFU) or similar, we do not need or want to include the usb node in SPL unless SPL_DFU have been enabled for the build.

arch/arm/dts/rk3588s-u-boot.dtsi line 166

Quoted 1 line
arch/arm/dts/rk3588s-u-boot.dtsi +1 -0
+	bootph-some-ram;

I do not think USB is needed in U-Boot proper pre-reloc phase, please drop bootph-some-ram.

Quoted 60 lines
arch/arm/dts/rk3588s-u-boot.dtsi +2 -0
+};
+
 &xin24m {
 	bootph-all;
 };
arch/arm/mach-rockchip/rk3588/rk3588.c +1 -0
index c1dce3ee370..662b092d811 100644
@@ -53,6 +53,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 	[BROM_BOOTSOURCE_FSPI_M1] = "/spi@fe2b0000/flash@0",
 	[BROM_BOOTSOURCE_FSPI_M2] = "/spi@fe2b0000/flash@0",
 	[BROM_BOOTSOURCE_SD] = "/mmc@fe2c0000",
+	[BROM_BOOTSOURCE_USB] = "/usb@fc000000",
 };
 
 static struct mm_region rk3588_mem_map[] = {
configs/generic-rk3588_defconfig +9 -0
index 51e31dce3a9..0dd64783bc0 100644
@@ -21,7 +21,9 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-generic.dtb"
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_ATF=y
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MISC=y
@@ -41,6 +43,9 @@ CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
 # CONFIG_ADC is not set
 CONFIG_SPL_CLK=y
+CONFIG_DFU_RAM=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
 # CONFIG_USB_FUNCTION_FASTBOOT is not set
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_MISC=y
@@ -60,9 +65,13 @@ CONFIG_SYS_NS16550_MEM32=y
 CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
+CONFIG_SPL_DM_USB_GADGET=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
 CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_FUNCTION_ROCKUSB=y
+CONFIG_SPL_DFU=y
 CONFIG_ERRNO_STR=y
include/configs/rk3588_common.h +0 -0
index e6654c275ac..0fad6b37589 100644

include/configs/rk3588_common.h line 33

Quoted 8 lines
include/configs/rk3588_common.h +5 -0
@@ -26,11 +26,18 @@
 	"ramdisk_addr_r=0x12180000\0"	\
 	"kernel_comp_size=0x8000000\0"
 
+#if defined(CONFIG_SPL_DFU) && defined(CONFIG_XPL_BUILD)
+#define CFG_EXTRA_ENV_SETTINGS				\
+	"dfu_alt_info_ram=u-boot.itb ram "		\
+	__stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " "	\
+	__stringify(CONFIG_SYS_DFU_MAX_FILE_SIZE) "\0"

Is this not needed using DFU in U-Boot proper? And if we use this in U-Boot proper the load addresses may need to change to match other load addresses used for booting?

Regards,
Jonas

Quoted 10 lines
include/configs/rk3588_common.h +2 -0
+#else
 #define CFG_EXTRA_ENV_SETTINGS		\
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
 	"partitions=" PARTS_DEFAULT	\
 	ENV_MEM_LAYOUT_SETTINGS		\
 	ROCKCHIP_DEVICE_SETTINGS	\
 	"boot_targets=" BOOT_TARGETS "\0"
+#endif
 
 #endif /* __CONFIG_RK3588_COMMON_H */
#7 lore raw

PATCH 4/7 rockchip: Add DFU to SPL for RK3568

In reply to FUKAUMI Naoki

Boot the RK3568 from the USB OTG port using rkflashtool[1] or rkusbboot[2] and dfu-util.

1a. Download the TPL and SPL using rkflashtool

$ rkflashtool l < mkimage-in-simple-bin.mkimage-rockchip-tpl
$ rkflashtool L < mkimage-in-simple-bin.mkimage-u-boot-spl

1b. Download the TPL and SPL using rkusbboot

$ rkusbboot \
	mkimage-in-simple-bin.mkimage-rockchip-tpl \
	mkimage-in-simple-bin.mkimage-u-boot-spl

2. Download the U-Boot

$ dfu-util -a 0 -D u-boot.itb

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot

---
 arch/arm/dts/rk356x-u-boot.dtsi        | 5 +++++
 arch/arm/mach-rockchip/rk3568/rk3568.c | 1 +
 configs/generic-rk3568_defconfig       | 9 +++++++++
 include/configs/rk3568_common.h        | 7 +++++++
 4 files changed, 22 insertions(+)
arch/arm/dts/rk356x-u-boot.dtsi +5 -0
index 24a976cf7e2..8d2485586bd 100644
@@ -170,6 +170,11 @@
 	bootph-all;
 };
 
+&usb_host0_xhci {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
 &xin24m {
 	bootph-all;
 };
arch/arm/mach-rockchip/rk3568/rk3568.c +1 -0
index c2b96902d2d..b087c08b3d0 100644
@@ -88,6 +88,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 	[BROM_BOOTSOURCE_EMMC] = "/mmc@fe310000",
 	[BROM_BOOTSOURCE_SPINOR] = "/spi@fe300000/flash@0",
 	[BROM_BOOTSOURCE_SD] = "/mmc@fe2b0000",
+	[BROM_BOOTSOURCE_USB] = "/usb@fcc00000",
 };
 
 struct mm_region *mem_map = rk3568_mem_map;
configs/generic-rk3568_defconfig +9 -0
index f79f0e84400..32c6fdc2846 100644
@@ -25,9 +25,11 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3568-generic.dtb"
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
 CONFIG_SPL_ATF=y
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MISC=y
@@ -47,6 +49,9 @@ CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
 # CONFIG_ADC is not set
 CONFIG_SPL_CLK=y
+CONFIG_DFU_RAM=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
 # CONFIG_USB_FUNCTION_FASTBOOT is not set
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_MISC=y
@@ -74,9 +79,13 @@ CONFIG_ROCKCHIP_SFC=y
 CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
+CONFIG_SPL_DM_USB_GADGET=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
 CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_FUNCTION_ROCKUSB=y
+CONFIG_SPL_DFU=y
 CONFIG_ERRNO_STR=y
include/configs/rk3568_common.h +7 -0
index 09b7b71c6af..7b6aeca2a15 100644
@@ -27,11 +27,18 @@
 	"ramdisk_addr_r=0x12180000\0"	\
 	"kernel_comp_size=0x8000000\0"
 
+#if defined(CONFIG_SPL_DFU) && defined(CONFIG_XPL_BUILD)
+#define CFG_EXTRA_ENV_SETTINGS				\
+	"dfu_alt_info_ram=u-boot.itb ram "		\
+	__stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " "	\
+	__stringify(CONFIG_SYS_DFU_MAX_FILE_SIZE) "\0"
+#else
 #define CFG_EXTRA_ENV_SETTINGS		\
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
 	"partitions=" PARTS_DEFAULT	\
 	ENV_MEM_LAYOUT_SETTINGS		\
 	ROCKCHIP_DEVICE_SETTINGS	\
 	"boot_targets=" BOOT_TARGETS "\0"
+#endif
 
 #endif /* __CONFIG_RK3568_COMMON_H */
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH 4/7] rockchip: Add DFU to SPL for RK3568

Hi,

Quoted 34 lines · FUKAUMI Naoki

Boot the RK3568 from the USB OTG port using rkflashtool[1] or rkusbboot[2] and dfu-util.

1a. Download the TPL and SPL using rkflashtool

$ rkflashtool l < mkimage-in-simple-bin.mkimage-rockchip-tpl
$ rkflashtool L < mkimage-in-simple-bin.mkimage-u-boot-spl

1b. Download the TPL and SPL using rkusbboot

$ rkusbboot \
	mkimage-in-simple-bin.mkimage-rockchip-tpl \
	mkimage-in-simple-bin.mkimage-u-boot-spl

2. Download the U-Boot

$ dfu-util -a 0 -D u-boot.itb

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot

---
 arch/arm/dts/rk356x-u-boot.dtsi        | 5 +++++
 arch/arm/mach-rockchip/rk3568/rk3568.c | 1 +
 configs/generic-rk3568_defconfig       | 9 +++++++++
 include/configs/rk3568_common.h        | 7 +++++++
 4 files changed, 22 insertions(+)
arch/arm/dts/rk356x-u-boot.dtsi +0 -0
index 24a976cf7e2..8d2485586bd 100644

arch/arm/dts/rk356x-u-boot.dtsi line 175

Quoted 6 lines
arch/arm/dts/rk356x-u-boot.dtsi +3 -0
@@ -170,6 +170,11 @@
 	bootph-all;
 };
 
+&usb_host0_xhci {
+	bootph-pre-ram;
+	bootph-some-ram;

Same as in the RK3588 review, and same goes for remaining SoCs.

Please drop the bootph-some-ram and wrap the bootph-pre-ram in IF_ENABLED(CONFIG_SPL_DFU).

Quoted 44 lines
arch/arm/dts/rk356x-u-boot.dtsi +2 -0
+};
+
 &xin24m {
 	bootph-all;
 };
arch/arm/mach-rockchip/rk3568/rk3568.c +1 -0
index c2b96902d2d..b087c08b3d0 100644
@@ -88,6 +88,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 	[BROM_BOOTSOURCE_EMMC] = "/mmc@fe310000",
 	[BROM_BOOTSOURCE_SPINOR] = "/spi@fe300000/flash@0",
 	[BROM_BOOTSOURCE_SD] = "/mmc@fe2b0000",
+	[BROM_BOOTSOURCE_USB] = "/usb@fcc00000",
 };
 
 struct mm_region *mem_map = rk3568_mem_map;
configs/generic-rk3568_defconfig +5 -0
index f79f0e84400..32c6fdc2846 100644
@@ -25,9 +25,11 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3568-generic.dtb"
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
 CONFIG_SPL_ATF=y
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MISC=y
@@ -47,6 +49,9 @@ CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
 # CONFIG_ADC is not set
 CONFIG_SPL_CLK=y
+CONFIG_DFU_RAM=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
 # CONFIG_USB_FUNCTION_FASTBOOT is not set
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_MISC=y

configs/generic-rk3568_defconfig CONFIG_ROCKCHIP_SFC=y · line 85

Quoted 7 lines
configs/generic-rk3568_defconfig +2 -0
@@ -74,9 +79,13 @@ CONFIG_ROCKCHIP_SFC=y
 CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
+CONFIG_SPL_DM_USB_GADGET=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y

Back when Eugen Hristev sent a "rockchip: rk3588: add support for DFU in SPL" series [1] there was a few dwc3 patches required for stable operation. Are these no longer required or was only for rk3588 dwc3 affected?

[1] https://patchwork.ozlabs.org/cover/1815387/

Quoted 11 lines
configs/generic-rk3568_defconfig +2 -0
 CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_FUNCTION_ROCKUSB=y
+CONFIG_SPL_DFU=y
 CONFIG_ERRNO_STR=y
include/configs/rk3568_common.h +0 -0
index 09b7b71c6af..7b6aeca2a15 100644

include/configs/rk3568_common.h line 34

Quoted 8 lines
include/configs/rk3568_common.h +5 -0
@@ -27,11 +27,18 @@
 	"ramdisk_addr_r=0x12180000\0"	\
 	"kernel_comp_size=0x8000000\0"
 
+#if defined(CONFIG_SPL_DFU) && defined(CONFIG_XPL_BUILD)
+#define CFG_EXTRA_ENV_SETTINGS				\
+	"dfu_alt_info_ram=u-boot.itb ram "		\
+	__stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " "	\
+	__stringify(CONFIG_SYS_DFU_MAX_FILE_SIZE) "\0"

Same as in the RK3588 review, and same goes for remaining SoCs.

Do we not need to set similar for U-Boot proper if we want to use DFU from U-Boot cli?

Regards,
Jonas

Quoted 10 lines
include/configs/rk3568_common.h +2 -0
+#else
 #define CFG_EXTRA_ENV_SETTINGS		\
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
 	"partitions=" PARTS_DEFAULT	\
 	ENV_MEM_LAYOUT_SETTINGS		\
 	ROCKCHIP_DEVICE_SETTINGS	\
 	"boot_targets=" BOOT_TARGETS "\0"
+#endif
 
 #endif /* __CONFIG_RK3568_COMMON_H */
#9 lore raw

PATCH 5/7 rockchip: Add DFU to SPL for RK3399

In reply to FUKAUMI Naoki

Boot the RK3399 from the USB OTG port using rkflashtool[1] or rkusbboot[2] and dfu-util.

1a. Download the TPL and SPL using rkflashtool

$ openssl rc4 -provider legacy -K 7c4e0304550509072d2c7b38170d1711 \
	< mkimage-in-simple-bin.mkimage-rockchip-tpl | rkflashtool l
$ openssl rc4 -provider legacy -K 7c4e0304550509072d2c7b38170d1711 \
	< mkimage-in-simple-bin.mkimage-u-boot-spl | rkflashtool L

1b. Download the TPL and SPL using rkusbboot

$ rkusbboot \
	mkimage-in-simple-bin.mkimage-rockchip-tpl \
	mkimage-in-simple-bin.mkimage-u-boot-spl

2. Download the U-Boot

$ dfu-util -a 0 -D u-boot.itb

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot

---
 arch/arm/dts/rk3399-u-boot.dtsi        | 10 ++++++++++
 arch/arm/mach-rockchip/rk3399/rk3399.c |  1 +
 configs/generic-rk3399_defconfig       |  9 +++++++++
 include/configs/rk3399_common.h        | 11 +++++++----
 4 files changed, 27 insertions(+), 4 deletions(-)
arch/arm/dts/rk3399-u-boot.dtsi +10 -0
index 0e3143f8235..ce703d02538 100644
@@ -192,6 +192,16 @@
 	bootph-pre-ram;
 };
 
+&usbdrd3_0 {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
+&usbdrd_dwc3_0 {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
 &vopb {
 	bootph-some-ram;
 };
arch/arm/mach-rockchip/rk3399/rk3399.c +1 -0
index 1ce43c6f0d4..681eecb1edd 100644
@@ -27,6 +27,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 	[BROM_BOOTSOURCE_EMMC] = "/mmc@fe330000",
 	[BROM_BOOTSOURCE_SPINOR] = "/spi@ff1d0000/flash@0",
 	[BROM_BOOTSOURCE_SD] = "/mmc@fe320000",
+	[BROM_BOOTSOURCE_USB] = "/usb@fe800000/usb@fe800000",
 };
 
 static struct mm_region rk3399_mem_map[] = {
configs/generic-rk3399_defconfig +9 -0
index 4df70fa4c15..fd08159fa6b 100644
@@ -24,11 +24,13 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-generic.dtb"
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
 CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_MEMINFO_MAP=y
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MISC=y
@@ -44,6 +46,9 @@ CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigne
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NO_NET=y
 # CONFIG_ADC is not set
+CONFIG_DFU_RAM=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
 # CONFIG_USB_FUNCTION_FASTBOOT is not set
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SUPPORT_EMMC_RPMB=y
@@ -68,9 +73,13 @@ CONFIG_ROCKCHIP_SPI=y
 CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
+CONFIG_SPL_DM_USB_GADGET=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
+CONFIG_SPL_USB_DWC3_GENERIC=y
 CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_FUNCTION_ROCKUSB=y
+CONFIG_SPL_DFU=y
 CONFIG_ERRNO_STR=y
include/configs/rk3399_common.h +7 -4
index 76f40e7cd5f..c6db5e5d8e2 100644
@@ -13,8 +13,6 @@
 #define CFG_SYS_SDRAM_BASE		0
 #define SDRAM_MAX_SIZE			0xf8000000
 
-#ifndef CONFIG_XPL_BUILD
-
 #ifndef ROCKCHIP_DEVICE_SETTINGS
 #define ROCKCHIP_DEVICE_SETTINGS
 #endif
@@ -31,13 +29,18 @@
 	"ramdisk_addr_r=0x12180000\0"	\
 	"kernel_comp_size=0x8000000\0"
 
+#if defined(CONFIG_SPL_DFU) && defined(CONFIG_XPL_BUILD)
+#define CFG_EXTRA_ENV_SETTINGS				\
+	"dfu_alt_info_ram=u-boot.itb ram "		\
+	__stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " "	\
+	__stringify(CONFIG_SYS_DFU_MAX_FILE_SIZE) "\0"
+#else
 #define CFG_EXTRA_ENV_SETTINGS		\
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
 	"partitions=" PARTS_DEFAULT	\
 	ENV_MEM_LAYOUT_SETTINGS		\
 	ROCKCHIP_DEVICE_SETTINGS	\
 	"boot_targets=" BOOT_TARGETS "\0"
-
-#endif /* CONFIG_XPL_BUILD */
+#endif
 
 #endif /* __CONFIG_RK3399_COMMON_H */
Signature · 1 line
2.43.0
#10 lore raw

PATCH 6/7 rockchip: Add DFU to SPL for RK3328

In reply to FUKAUMI Naoki

Boot the RK3328 from the USB OTG port using rkflashtool[1] or rkusbboot[2] and dfu-util.

1a. Download the TPL and SPL using rkflashtool

$ openssl rc4 -provider legacy -K 7c4e0304550509072d2c7b38170d1711 \
	< mkimage-in-simple-bin.mkimage-rockchip-tpl | rkflashtool l
$ openssl rc4 -provider legacy -K 7c4e0304550509072d2c7b38170d1711 \
	< mkimage-in-simple-bin.mkimage-u-boot-spl | rkflashtool L

1b. Download the TPL and SPL using rkusbboot

$ rkusbboot \
	mkimage-in-simple-bin.mkimage-rockchip-tpl \
	mkimage-in-simple-bin.mkimage-u-boot-spl

2. Download the U-Boot

$ dfu-util -a 0 -D u-boot.itb

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot

---
 arch/arm/dts/rk3328-u-boot.dtsi        | 5 +++++
 arch/arm/mach-rockchip/rk3328/rk3328.c | 1 +
 configs/generic-rk3328_defconfig       | 8 ++++++++
 include/configs/rk3328_common.h        | 7 +++++++
 4 files changed, 21 insertions(+)
arch/arm/dts/rk3328-u-boot.dtsi +5 -0
index b0e50a973a8..30d0d3df751 100644
@@ -142,6 +142,11 @@
 	bootph-pre-ram;
 };
 
+&usb20_otg {
+	bootph-pre-sram;
+	bootph-pre-ram;
+};
+
 &vop {
 	bootph-some-ram;
 };
arch/arm/mach-rockchip/rk3328/rk3328.c +1 -0
index 12ad17d9e8b..f31f7197999 100644
@@ -36,6 +36,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 	[BROM_BOOTSOURCE_EMMC] = "/mmc@ff520000",
 	[BROM_BOOTSOURCE_SPINOR] = "/spi@ff190000/flash@0",
 	[BROM_BOOTSOURCE_SD] = "/mmc@ff500000",
+	[BROM_BOOTSOURCE_USB] = "/usb@ff580000",
 };
 
 static struct mm_region rk3328_mem_map[] = {
configs/generic-rk3328_defconfig +8 -0
index 8d34a293fd4..bf3d70a5e6e 100644
@@ -26,12 +26,14 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3328-generic.dtb"
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
 CONFIG_SPL_ATF=y
 CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_MEMINFO_MAP=y
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MISC=y
@@ -54,6 +56,9 @@ CONFIG_SPL_SYSCON=y
 # CONFIG_ADC is not set
 CONFIG_CLK=y
 CONFIG_SPL_CLK=y
+CONFIG_DFU_RAM=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
 # CONFIG_USB_FUNCTION_FASTBOOT is not set
 CONFIG_ROCKCHIP_GPIO=y
 # CONFIG_ROCKCHIP_IODOMAIN is not set
@@ -83,8 +88,11 @@ CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
 CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
 CONFIG_USB_GADGET=y
+CONFIG_SPL_USB_GADGET=y
 CONFIG_USB_GADGET_DWC2_OTG=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_FUNCTION_ROCKUSB=y
+CONFIG_SPL_DFU=y
 CONFIG_ERRNO_STR=y
include/configs/rk3328_common.h +7 -0
index bd2bfe29103..b32dd4a6dbb 100644
@@ -25,11 +25,18 @@
 	"kernel_comp_addr_r=0x08000000\0"	\
 	"kernel_comp_size=0x2000000\0"
 
+#if defined(CONFIG_SPL_DFU) && defined(CONFIG_XPL_BUILD)
+#define CFG_EXTRA_ENV_SETTINGS				\
+	"dfu_alt_info_ram=u-boot.itb ram "		\
+	__stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " "	\
+	__stringify(CONFIG_SYS_DFU_MAX_FILE_SIZE) "\0"
+#else
 #define CFG_EXTRA_ENV_SETTINGS		\
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
 	"partitions=" PARTS_DEFAULT	\
 	ENV_MEM_LAYOUT_SETTINGS		\
 	ROCKCHIP_DEVICE_SETTINGS	\
 	"boot_targets=" BOOT_TARGETS "\0"
+#endif
 
 #endif /* __CONFIG_RK3328_COMMON_H */
Signature · 1 line
2.43.0
#11 lore raw

PATCH 7/7 rockchip: Add DFU to SPL for RK3308

In reply to FUKAUMI Naoki

Boot the RK3308 from the USB OTG port using rkflashtool[1] or rkusbboot[2] and dfu-util.

1a. Download the TPL and SPL using rkflashtool

$ openssl rc4 -provider legacy -K 7c4e0304550509072d2c7b38170d1711 \
	< mkimage-in-simple-bin.mkimage-rockchip-tpl | rkflashtool l
$ openssl rc4 -provider legacy -K 7c4e0304550509072d2c7b38170d1711 \
	< mkimage-in-simple-bin.mkimage-u-boot-spl | rkflashtool L

1b. Download the TPL and SPL using rkusbboot

$ rkusbboot \
	mkimage-in-simple-bin.mkimage-rockchip-tpl \
	mkimage-in-simple-bin.mkimage-u-boot-spl

2. Download the U-Boot

$ dfu-util -a 0 -D u-boot.itb

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot

---
 arch/arm/dts/rk3308-u-boot.dtsi        | 5 +++++
 arch/arm/mach-rockchip/rk3308/rk3308.c | 1 +
 include/configs/rk3308_common.h        | 7 +++++++
 3 files changed, 13 insertions(+)
arch/arm/dts/rk3308-u-boot.dtsi +5 -0
index b7964e2756f..cf7e41da65b 100644
@@ -122,6 +122,11 @@
 	bootph-some-ram;
 };
 
+&usb20_otg {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
 &xin24m {
 	bootph-all;
 };
arch/arm/mach-rockchip/rk3308/rk3308.c +1 -0
index 03d97e1d746..8b2832ef0f2 100644
@@ -142,6 +142,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 	[BROM_BOOTSOURCE_EMMC] = "/mmc@ff490000",
 	[BROM_BOOTSOURCE_SPINOR] = "/spi@ff4c0000/flash@0",
 	[BROM_BOOTSOURCE_SD] = "/mmc@ff480000",
+	[BROM_BOOTSOURCE_USB] = "/usb@ff400000",
 };
 
 int rk_board_init(void)
include/configs/rk3308_common.h +7 -0
index 2de55538fdf..11eeef3942a 100644
@@ -25,11 +25,18 @@
 	"kernel_comp_addr_r=0x08000000\0"	\
 	"kernel_comp_size=0x2000000\0"
 
+#if defined(CONFIG_SPL_DFU) && defined(CONFIG_XPL_BUILD)
+#define CFG_EXTRA_ENV_SETTINGS				\
+	"dfu_alt_info_ram=u-boot.itb ram "		\
+	__stringify(CONFIG_SPL_LOAD_FIT_ADDRESS) " "	\
+	__stringify(CONFIG_SYS_DFU_MAX_FILE_SIZE) "\0"
+#else
 #define CFG_EXTRA_ENV_SETTINGS		\
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"	\
 	"partitions=" PARTS_DEFAULT	\
 	ENV_MEM_LAYOUT_SETTINGS		\
 	ROCKCHIP_DEVICE_SETTINGS	\
 	"boot_targets=" BOOT_TARGETS "\0"
+#endif
 
 #endif /* __CONFIG_RK3308_COMMON_H */
Signature · 1 line
2.43.0
#12 lore raw
In reply to FUKAUMI Naoki

Hi Naoki,

Quoted 4 lines · FUKAUMI Naoki

This patch series adds the ability to boot from the USB OTG port to the RK3588, RK3568, RK3566, RK3399, RK3328, and RK3308.

Use rkflashtool[1] or rkusbboot[2]

Does these two tool have the same functionality? I don't know the second one :(

And I know there is another tool named rkdeveloptool from rockchip.

Quoted 2 lines

to download TPL and SPL from
MASKROM mode, and dfu-util to download U-Boot from DFU mode.

What's the main target for this patchset, boot from usb with ramboot support and without any eMMC/SD/SPI driver?

I would prefer to keep using one tool instead of two or more tools, so I don't think

enable DFU in SPL is a good idea, using rockusb in SPL is better here.

Thanks,
- Kever

Quoted 46 lines

This patch series depends on patches[3] that fix TPL/SPL link errors and patches[4] that add generic RK3399 and RK3328 defconfigs.

[1] https://github.com/linux-rockchip/rkflashtool
[2] https://github.com/RadxaNaoki/rkusbboot
[3] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
[4] https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

FUKAUMI Naoki (7):
rockchip: Change memory location of FIT and U-Boot proper
rockchip: Add DFU to SPL
rockchip: Add DFU to SPL for RK3588
rockchip: Add DFU to SPL for RK3568
rockchip: Add DFU to SPL for RK3399
rockchip: Add DFU to SPL for RK3328
rockchip: Add DFU to SPL for RK3308

  arch/arm/dts/rk3308-u-boot.dtsi         |  5 +++++
  arch/arm/dts/rk3328-u-boot.dtsi         |  5 +++++
  arch/arm/dts/rk3399-u-boot.dtsi         | 10 ++++++++++
  arch/arm/dts/rk356x-u-boot.dtsi         |  5 +++++
  arch/arm/dts/rk3588s-u-boot.dtsi        |  5 +++++
  arch/arm/mach-rockchip/Kconfig          |  6 +++---
  arch/arm/mach-rockchip/rk3308/Kconfig   |  3 ---
  arch/arm/mach-rockchip/rk3308/rk3308.c  |  1 +
  arch/arm/mach-rockchip/rk3328/rk3328.c  |  1 +
  arch/arm/mach-rockchip/rk3399/rk3399.c  |  1 +
  arch/arm/mach-rockchip/rk3568/Kconfig   |  3 ---
  arch/arm/mach-rockchip/rk3568/rk3568.c  |  1 +
  arch/arm/mach-rockchip/rk3588/Kconfig   |  3 ---
  arch/arm/mach-rockchip/rk3588/rk3588.c  |  1 +
  arch/arm/mach-rockchip/rv1126/Kconfig   |  3 ---
  arch/arm/mach-rockchip/spl-boot-order.c |  4 ++++
  boot/Kconfig                            |  3 +++
  configs/generic-rk3328_defconfig        |  8 ++++++++
  configs/generic-rk3399_defconfig        |  9 +++++++++
  configs/generic-rk3568_defconfig        |  9 +++++++++
  configs/generic-rk3588_defconfig        |  9 +++++++++
  include/configs/rk3308_common.h         |  7 +++++++
  include/configs/rk3328_common.h         |  7 +++++++
  include/configs/rk3399_common.h         | 11 +++++++----
  include/configs/rk3568_common.h         |  7 +++++++
  include/configs/rk3588_common.h         |  7 +++++++
  26 files changed, 115 insertions(+), 19 deletions(-)
#13 lore raw

Hi,

Quoted 12 lines · Kever Yang

Hi Naoki,

Quoted 4 lines · FUKAUMI Naoki

This patch series adds the ability to boot from the USB OTG port to the RK3588, RK3568, RK3566, RK3399, RK3328, and RK3308.

Use rkflashtool[1] or rkusbboot[2]

Does these two tool have the same functionality? I don't know the second
one :(

Quoted 8 lines

And I know there is another tool named rkdeveloptool from rockchip.

Quoted 2 lines

  to download TPL and SPL from
MASKROM mode, and dfu-util to download U-Boot from DFU mode.

What's the main target for this patchset, boot from usb with ramboot support and without any eMMC/SD/SPI driver?

I can't talk for Naoki, but my use case is to test easily u-boot on my rockchip platforms without having to flash u-boot or to have some storage.

Quoted 6 lines

I would prefer to keep using one tool instead of two or more tools, so I
don't think

enable DFU in SPL is a good idea, using rockusb in SPL is better here.

To test u-boot, I'd like to use snagflash/snagboot as it's not rockchip specific. So, this means adding support for maskrom (which I've already written) and rockusb protocols to it. With DFU in SPL support in u- boot, this would mean nothing to do as the support for DFU is already in snagboot/snagflash.

Arnaud

#14 lore raw

Hi Arnaud,

Quoted 16 lines · Arnaud Patard

Hi,

Quoted 13 lines · Kever Yang

Hi Naoki,

Quoted 4 lines · FUKAUMI Naoki

This patch series adds the ability to boot from the USB OTG port to the RK3588, RK3568, RK3566, RK3399, RK3328, and RK3308.

Use rkflashtool[1] or rkusbboot[2]

Does these two tool have the same functionality? I don't know the second
one :(

And I know there is another tool named rkdeveloptool from rockchip.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

  to download TPL and SPL from
MASKROM mode, and dfu-util to download U-Boot from DFU mode.

What's the main target for this patchset, boot from usb with ramboot support and without any eMMC/SD/SPI driver?

I can't talk for Naoki, but my use case is to test easily u-boot on my rockchip platforms without having to flash u-boot or to have some storage.

Yes, I agree the usb boot+RAM boot can help u-boot developers.

But this function can be done directly in BootRom mode with rockusb protocol;

or add support for it in U-Boot Proper gadget(rockusb or DFU).

Quoted 9 lines
Quoted 7 lines

I would prefer to keep using one tool instead of two or more tools, so I
don't think

enable DFU in SPL is a good idea, using rockusb in SPL is better here.

To test u-boot, I'd like to use snagflash/snagboot as it's not rockchip specific.

Two more tools other than rkdeveloptool/rkflashtool/rkusbtool/rockusb :(

Quoted 4 lines

So, this means adding support for maskrom (which I've already
written) and rockusb protocols to it. With DFU in SPL support in u- boot, this would mean nothing to do as the support for DFU is already in snagboot/snagflash.

I understand your requirement, but you didn't say why you need SPL DFU.

There are two modes for usb download in rockchip platform:

- Maskrom mode (in bootRom), may have speed limit due to bootRom driver setting,

    for download bootloader including U-Boot which size is not big;

- Loader mode(in U-Boot), all the speed including CPU, eMMC has promote to performance mode,

    for download all the big size image including system and userdata.

Of cause we can add any function to the SPL, and it's simple because it already in U-Boot,

but do we really need it for all the user and product?

We should keep the SPL simple and fast, and get into U-Boot proper quickly with full function.

Thank,
- Kever

Quoted 4 lines

Arnaud

#15 lore raw

Hi Kever Yang,

Quoted 28 lines · Kever Yang

Hi Arnaud,

Quoted 16 lines · Arnaud Patard

Hi,

Quoted 13 lines · Kever Yang

Hi Naoki,

Quoted 4 lines · FUKAUMI Naoki

This patch series adds the ability to boot from the USB OTG port to the RK3588, RK3568, RK3566, RK3399, RK3328, and RK3308.

Use rkflashtool[1] or rkusbboot[2]

Does these two tool have the same functionality? I don't know the second
one :(

And I know there is another tool named rkdeveloptool from rockchip.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

   to download TPL and SPL from
MASKROM mode, and dfu-util to download U-Boot from DFU mode.

What's the main target for this patchset, boot from usb with ramboot support and without any eMMC/SD/SPI driver?

I can't talk for Naoki, but my use case is to test easily u-boot on my rockchip platforms without having to flash u-boot or to have some storage.

Quoted 5 lines

Yes, I agree the usb boot+RAM boot can help u-boot developers.

But this function can be done directly in BootRom mode with rockusb protocol;

or add support for it in U-Boot Proper gadget(rockusb or DFU).

Does this mean I should use rockusb or DFU on U-Boot to test the new U-Boot?

Quoted 29 lines
Quoted 8 lines
Quoted 6 lines

I would prefer to keep using one tool instead of two or more tools, so I
don't think

enable DFU in SPL is a good idea, using rockusb in SPL is better here.

To test u-boot, I'd like to use snagflash/snagboot as it's not rockchip specific.

Two more tools other than rkdeveloptool/rkflashtool/rkusbtool/rockusb :(

Quoted 4 lines

  So, this means adding support for maskrom (which I've already written) and rockusb protocols to it. With DFU in SPL support in u- boot, this would mean nothing to do as the support for DFU is already in snagboot/snagflash.

I understand your requirement, but you didn't say why you need SPL DFU.

There are two modes for usb download in rockchip platform:

- Maskrom mode (in bootRom), may have speed limit due to bootRom driver setting,

    for download bootloader including U-Boot which size is not big;

- Loader mode(in U-Boot), all the speed including CPU, eMMC has promote to performance mode,

Quoted 7 lines

    for download all the big size image including system and userdata.

Of cause we can add any function to the SPL, and it's simple because it already in U-Boot,

but do we really need it for all the user and product?

We should keep the SPL simple and fast, and get into U-Boot proper quickly with full function.

I agree that SPL should be simple and require fewer tools.

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

Quoted 7 lines

Thank,
- Kever

Quoted 4 lines

Arnaud