[PATCH 3/7] rockchip: Add DFU to SPL for RK3588
Jonas Karlman
jonas at kwiboo.se
Sun Apr 13 11:39:42 CEST 2025
Hi,
On 2025-02-11 06:33, FUKAUMI Naoki wrote:
> 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
>
> Signed-off-by: FUKAUMI Naoki <naoki at radxa.com>
> ---
> 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(+)
>
> diff --git a/arch/arm/dts/rk3588s-u-boot.dtsi b/arch/arm/dts/rk3588s-u-boot.dtsi
> index 8880d162b11..1e961768341 100644
> --- a/arch/arm/dts/rk3588s-u-boot.dtsi
> +++ b/arch/arm/dts/rk3588s-u-boot.dtsi
> @@ -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.
> + bootph-some-ram;
I do not think USB is needed in U-Boot proper pre-reloc phase, please
drop bootph-some-ram.
> +};
> +
> &xin24m {
> bootph-all;
> };
> diff --git a/arch/arm/mach-rockchip/rk3588/rk3588.c b/arch/arm/mach-rockchip/rk3588/rk3588.c
> index c1dce3ee370..662b092d811 100644
> --- a/arch/arm/mach-rockchip/rk3588/rk3588.c
> +++ b/arch/arm/mach-rockchip/rk3588/rk3588.c
> @@ -53,6 +53,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
> [BROM_BOOTSOURCE_FSPI_M1] = "/spi at fe2b0000/flash at 0",
> [BROM_BOOTSOURCE_FSPI_M2] = "/spi at fe2b0000/flash at 0",
> [BROM_BOOTSOURCE_SD] = "/mmc at fe2c0000",
> + [BROM_BOOTSOURCE_USB] = "/usb at fc000000",
> };
>
> static struct mm_region rk3588_mem_map[] = {
> diff --git a/configs/generic-rk3588_defconfig b/configs/generic-rk3588_defconfig
> index 51e31dce3a9..0dd64783bc0 100644
> --- a/configs/generic-rk3588_defconfig
> +++ b/configs/generic-rk3588_defconfig
> @@ -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
> diff --git a/include/configs/rk3588_common.h b/include/configs/rk3588_common.h
> index e6654c275ac..0fad6b37589 100644
> --- a/include/configs/rk3588_common.h
> +++ b/include/configs/rk3588_common.h
> @@ -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
> +#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 */
More information about the U-Boot
mailing list