Skip to contentSkip to conversation

J721e: Add support for DFU boot mode

PATCH New Vignesh Raghavendra 3 participants 10 messages Jan 27, 2020 – Feb 4, 2020

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

cover J721e: Add support for DFU boot mode

This series adds support to boot via USB DFU mode.

Vignesh Raghavendra (7):
arm: mach-k3: j721e: Rename BOOT_DEVICE_USB to BOOT_DEVICE_DFU
arm: mach-k3: sysfw-loader: Add support to download SYSFW via DFU
arm: dts: k3-j721e-common-proc-board: Enable USB0 in peripheral mode
configs: j721e_evm: Add DFU related variables
configs: j721e_evm_r5_defconfig: Increase early malloc size
configs: j721e_evm_r5/a72_defconfig: Enable USB Gadget related configs
configs: j721e_evm_r5/a72_defconfig: Enable DFU related configs

 .../arm/dts/k3-j721e-r5-common-proc-board.dts | 18 +++++++++++
 arch/arm/mach-k3/include/mach/j721e_spl.h     |  2 +-
 arch/arm/mach-k3/sysfw-loader.c               | 30 +++++++++++++++++++
 configs/j721e_evm_a72_defconfig               |  6 ++++
 configs/j721e_evm_r5_defconfig                | 17 ++++++++++-
 include/configs/j721e_evm.h                   |  4 +++
 6 files changed, 75 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.0
#1 lore raw

PATCH 1/7 arm: mach-k3: j721e: Rename BOOT_DEVICE_USB to BOOT_DEVICE_DFU

J721e does not support USB Host MSC boot, but only supports DFU boot. Since BOOT_DEVICE_USB is often used for host boot mode and BOOT_DEVICE_DFU is used for DFU boot, rename BOOT_DEVICE_USB macro to BOOT_DEVICE_DFU

---
 arch/arm/mach-k3/include/mach/j721e_spl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-k3/include/mach/j721e_spl.h +1 -1
index 2b52faf9443b..475278bd041a 100644
@@ -18,7 +18,7 @@
 /* With BootMode B = 1 */
 #define BOOT_DEVICE_MMC2		0x10
 #define BOOT_DEVICE_MMC1		0x11
-#define BOOT_DEVICE_USB			0x12
+#define BOOT_DEVICE_DFU			0x12
 #define BOOT_DEVICE_UFS			0x13
 #define BOOT_DEVIE_GPMC			0x14
 #define BOOT_DEVICE_PCIE		0x15
Signature · 1 line
2.25.0
#2 lore raw

PATCH 2/7 arm: mach-k3: sysfw-loader: Add support to download SYSFW via DFU

In reply to Vignesh Raghavendra

Add support to download SYSFW into internal RAM via DFU in DFU boot mode. Prepare a DFU config entity entry dynamically using buffer address allocated for SYSFW and start DFU gadget to get SYSFW.

---
 arch/arm/mach-k3/sysfw-loader.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
arch/arm/mach-k3/sysfw-loader.c +30 -0
index 5903bbe12aa3..94dbeb9437d9 100644
@@ -11,6 +11,10 @@
 #include <malloc.h>
 #include <remoteproc.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
+#include <g_dnl.h>
+#include <usb.h>
+#include <dfu.h>
+
 #include <asm/arch/sys_proto.h>
 #include "common.h"
 
@@ -172,6 +176,27 @@ static void k3_sysfw_configure_using_fit(void *fit,
 		      ret);
 }
 
+#if CONFIG_IS_ENABLED(DFU)
+static int k3_sysfw_dfu_download(void *addr)
+{
+	char dfu_str[50];
+	int ret;
+
+	sprintf(dfu_str, "sysfw.itb ram 0x%p 0x%x", addr,
+		CONFIG_K3_SYSFW_IMAGE_SIZE_MAX);
+	ret = dfu_config_entities(dfu_str, "ram", "0");
+	if (ret) {
+		dfu_free_entities();
+		goto exit;
+	}
+
+	run_usb_dnl_gadget(0, "usb_dnl_dfu");
+exit:
+	dfu_free_entities();
+	return ret;
+}
+#endif
+
 void k3_sysfw_loader(void (*config_pm_done_callback)(void))
 {
 	struct spl_image_info spl_image = { 0 };
@@ -235,6 +260,11 @@ void k3_sysfw_loader(void (*config_pm_done_callback)(void))
 #endif
 		ret = spl_ymodem_load_image(&spl_image, &bootdev);
 		break;
+#endif
+#if CONFIG_IS_ENABLED(DFU)
+	case BOOT_DEVICE_DFU:
+		ret = k3_sysfw_dfu_download(sysfw_load_address);
+		break;
 #endif
 	default:
 		panic("Loading SYSFW image from device %u not supported!\n",
Signature · 1 line
2.25.0
#3 lore raw

PATCH 3/7 arm: dts: k3-j721e-common-proc-board: Enable USB0 in peripheral mode

In reply to Vignesh Raghavendra

Enable USB0 in peripheral mode so that it be used for DFU

---
 arch/arm/dts/k3-j721e-r5-common-proc-board.dts | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/arm/dts/k3-j721e-r5-common-proc-board.dts +18 -0
index 28a355d49c9b..585cc839632b 100644
@@ -40,6 +40,13 @@
 		clock-frequency = <200000000>;
 		u-boot,dm-spl;
 	};
+
+	clk_19_2mhz: dummy_clock {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <19200000>;
+		u-boot,dm-spl;
+	};
 };
 
 &cbass_mcu_wakeup {
@@ -207,4 +214,15 @@
 	u-boot,dm-spl;
 };
 
+&usbss0 {
+	/delete-property/ power-domains;
+	/delete-property/ assigned-clocks;
+	/delete-property/ assigned-clock-parents;
+	clocks = <&clk_19_2mhz>;
+	clock-names = "usb2_refclk";
+	pinctrl-names = "default";
+	pinctrl-0 = <&main_usbss0_pins_default>;
+	ti,vbus-divider;
+};
+
 #include "k3-j721e-common-proc-board-u-boot.dtsi"
Signature · 1 line
2.25.0
#4 lore raw

PATCH 4/7 configs: j721e_evm: Add DFU related variables

In reply to Vignesh Raghavendra

Add configs to download varies stages of bootloader images to RAM during DFU boot.

---
 include/configs/j721e_evm.h | 4 ++++
 1 file changed, 4 insertions(+)
include/configs/j721e_evm.h +4 -0
index eaed520e6be0..4371c471e5a9 100644
@@ -23,6 +23,8 @@
 #ifdef CONFIG_TARGET_J721E_A72_EVM
 #define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SPL_TEXT_BASE +	\
 					 CONFIG_SYS_K3_NON_SECURE_MSRAM_SIZE)
+/* Image load address in RAM for DFU boot*/
+#define CONFIG_SPL_LOAD_FIT_ADDRESS	0x81000000
 #else
 /*
  * Maximum size in memory allocated to the SPL BSS. Keep it as tight as
@@ -45,6 +47,8 @@
 /* Configure R5 SPL post-relocation malloc pool in DDR */
 #define CONFIG_SYS_SPL_MALLOC_START	0x84000000
 #define CONFIG_SYS_SPL_MALLOC_SIZE	SZ_16M
+/* Image load address in RAM for DFU boot*/
+#define CONFIG_SPL_LOAD_FIT_ADDRESS	0x80080000
 #endif
 
 #ifdef CONFIG_SYS_K3_SPL_ATF
Signature · 1 line
2.25.0
#5 lore raw

PATCH 5/7 configs: j721e_evm_r5_defconfig: Increase early malloc size

In reply to Vignesh Raghavendra

Increase R5 SPL early malloc memory pool by ~7K to accommodate SPL USB DFU boot requirements

---
 configs/j721e_evm_r5_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/j721e_evm_r5_defconfig +1 -1
index a90ab62195e3..efe5389cc93e 100644
@@ -3,7 +3,7 @@ CONFIG_ARCH_K3=y
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_SYS_MALLOC_F_LEN=0x55000
+CONFIG_SYS_MALLOC_F_LEN=0x70000
 CONFIG_SOC_K3_J721E=y
 CONFIG_TARGET_J721E_R5_EVM=y
 CONFIG_ENV_SIZE=0x20000
Signature · 1 line
2.25.0
#6 lore raw

PATCH 6/7 configs: j721e_evm_r5/a72_defconfig: Enable USB Gadget related configs

In reply to Vignesh Raghavendra

Enable USB Gadget for R5 SPL, A72 SPL and A72 U-Boot to support DFU boot

---
 configs/j721e_evm_a72_defconfig |  2 ++
 configs/j721e_evm_r5_defconfig  | 12 ++++++++++++
 2 files changed, 14 insertions(+)
configs/j721e_evm_a72_defconfig +2 -0
index d5e54a228d07..d4e4bd30a34a 100644
@@ -34,6 +34,7 @@ CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_POWER_DOMAIN=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x280000
+CONFIG_SPL_USB_GADGET=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_DFU=y
@@ -139,6 +140,7 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_CDNS3=y
 CONFIG_USB_CDNS3_GADGET=y
 CONFIG_USB_CDNS3_HOST=y
+CONFIG_SPL_USB_CDNS3_GADGET=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
configs/j721e_evm_r5_defconfig +12 -0
index efe5389cc93e..f18eeed118c2 100644
@@ -36,6 +36,7 @@ CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_REMOTEPROC=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x80000
+CONFIG_SPL_USB_GADGET=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMD_FLASH is not set
@@ -104,5 +105,16 @@ CONFIG_SYSRESET_TI_SCI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_OMAP_TIMER=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_SPL_DM_USB_GADGET=y
+CONFIG_USB_CDNS3=y
+CONFIG_USB_CDNS3_GADGET=y
+CONFIG_SPL_USB_CDNS3_GADGET=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0451
+CONFIG_USB_GADGET_PRODUCT_NUM=0x6163
 CONFIG_FS_EXT4=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
Signature · 1 line
2.25.0
#7 lore raw

PATCH 7/7 configs: j721e_evm_r5/a72_defconfig: Enable DFU related configs

In reply to Vignesh Raghavendra

Enable DFU, Fastboot and USB mass storage gadget related configs

---
 configs/j721e_evm_a72_defconfig | 4 ++++
 configs/j721e_evm_r5_defconfig  | 3 +++
 2 files changed, 7 insertions(+)
configs/j721e_evm_a72_defconfig +4 -0
index d4e4bd30a34a..162fa3b53caf 100644
@@ -32,9 +32,12 @@ CONFIG_SPL_DM_MAILBOX=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_POWER_SUPPORT=y
 CONFIG_SPL_POWER_DOMAIN=y
+CONFIG_SPL_RAM_SUPPORT=y
+CONFIG_SPL_RAM_DEVICE=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x280000
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_DFU=y
@@ -118,6 +121,7 @@ CONFIG_PINCTRL_SINGLE=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_TI_SCI_POWER_DOMAIN=y
 CONFIG_RAM=y
+CONFIG_SPL_RAM=y
 CONFIG_REMOTEPROC_TI_K3_DSP=y
 CONFIG_REMOTEPROC_TI_K3_R5F=y
 CONFIG_DM_RESET=y
configs/j721e_evm_r5_defconfig +3 -0
index f18eeed118c2..116470fb5e47 100644
@@ -37,8 +37,10 @@ CONFIG_SPL_REMOTEPROC=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x80000
 CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_DFU=y
 CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_HUSH_PARSER=y
+CONFIG_CMD_DFU=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
@@ -116,5 +118,6 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0x6163
+CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_FS_EXT4=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
Signature · 1 line
2.25.0
#8 lore raw

cover J721e: Add support for DFU boot mode

In reply to Vignesh Raghavendra
Quoted 10 lines · Vignesh Raghavendra

This series adds support to boot via USB DFU mode.

Vignesh Raghavendra (7):
arm: mach-k3: j721e: Rename BOOT_DEVICE_USB to BOOT_DEVICE_DFU
arm: mach-k3: sysfw-loader: Add support to download SYSFW via DFU
arm: dts: k3-j721e-common-proc-board: Enable USB0 in peripheral mode
configs: j721e_evm: Add DFU related variables
configs: j721e_evm_r5_defconfig: Increase early malloc size
configs: j721e_evm_r5/a72_defconfig: Enable USB Gadget related configs
configs: j721e_evm_r5/a72_defconfig: Enable DFU related configs

For all patches in the series:

--
Andreas Dannenberg
Texas Instruments Inc

Quoted 12 lines
 .../arm/dts/k3-j721e-r5-common-proc-board.dts | 18 +++++++++++
 arch/arm/mach-k3/include/mach/j721e_spl.h     |  2 +-
 arch/arm/mach-k3/sysfw-loader.c               | 30 +++++++++++++++++++
 configs/j721e_evm_a72_defconfig               |  6 ++++
 configs/j721e_evm_r5_defconfig                | 17 ++++++++++-
 include/configs/j721e_evm.h                   |  4 +++
 6 files changed, 75 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.0
#9 lore raw

cover J721e: Add support for DFU boot mode

In reply to Vignesh Raghavendra
Quoted 1 line · Vignesh Raghavendra

This series adds support to boot via USB DFU mode.

Series pulled into u-boot-ti tree.

Thanks and regards,
Lokesh