* [U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support in SPL
2016-06-14 11:02 [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL Ravi Babu
@ 2016-06-14 11:02 ` Ravi Babu
2016-06-24 8:50 ` Lukasz Majewski
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU Ravi Babu
` (5 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Ravi Babu @ 2016-06-14 11:02 UTC (permalink / raw)
To: u-boot
Traditionally the DFU support is available only
as part 2nd stage boot loader(u-boot) and DFU
is not supported in SPL.
The SPL-DFU feature is useful for boards which has
only USB inteface and do not have external interface
like ethernet or MMC/SD to boot the board.
This patch add DFU support in SPL to flash boot inital
binary images to factory or bare-metal boards to
memory devices like SPI, eMMC, MMC/SD card using
USB interface.
This SPL-DFU support can be enabled through
Menuconfig->Boot Images->Enable SPL-DFU support
Signed-off-by: Ravi Babu <ravibabu@ti.com>
---
Kconfig | 33 +++++++++++++++++++++++++++++++++
common/Makefile | 26 +++++++++++++++++++-------
common/command.c | 2 +-
scripts/Makefile.spl | 13 +++++++++++++
4 files changed, 66 insertions(+), 8 deletions(-)
diff --git a/Kconfig b/Kconfig
index f53759a..969641e 100644
--- a/Kconfig
+++ b/Kconfig
@@ -285,6 +285,39 @@ config SPL_LOAD_FIT
particular it can handle selecting from multiple device tree
and passing the correct one to U-Boot.
+config SPL_DFU
+ bool "Enable SPL with DFU to load binaries to bootdevices using USB"
+ depends on USB && CMD_DFU && TARGET_DRA7XX_EVM
+ help
+ Currently the SPL does not have capability to load the
+ binaries or boot images to boot devices like eMMC,SPI,etc.
+ This feature enables the DFU (Device Firmware Upgarde) in SPL with
+ RAM device as default bootdevice. The ROM code will load and execute
+ the SPL/MLO dfu image. The user can flash the binaries to selected
+ dfu device partition from host-pc using dfu-utils.
+ This feature will be useful to flash the binaries to factory
+ or bare-metal boards using USB interface.
+
+choice
+ bool "DFU device selection"
+ depends on CMD_DFU && SPL_DFU
+
+config SPL_DFU_RAM
+ bool "RAM device"
+ depends on CMD_DFU
+ help
+ select DDR memory device for flashing binary images to
+ the selected partition using DFU.
+
+config SPL_DFU_SF
+ bool "SPI device"
+ depends on CMD_DFU && SPL_DFU
+ help
+ select SPI flash memory device for flashing binary images to
+ the selected partition using DFU.
+
+endchoice
+
config SYS_CLK_FREQ
depends on ARC || ARCH_SUNXI
int "CPU clock frequency"
diff --git a/common/Makefile b/common/Makefile
index b23f312..0fa441f 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -6,15 +6,30 @@
#
# core
-ifndef CONFIG_SPL_BUILD
-obj-y += init/
-obj-y += main.o
-obj-y += exports.o
+
+CONFIG_INC_DFU=y
+ifdef CONFIG_SPL_BUILD
+ifndef CONFIG_SPL_DFU
+CONFIG_INC_DFU=n
+endif
+endif
+
+ifeq ($(CONFIG_INC_DFU),y)
obj-y += hash.o
ifdef CONFIG_SYS_HUSH_PARSER
obj-y += cli_hush.o
endif
+obj-y += env_attr.o
+obj-y += env_callback.o
+obj-y += env_flags.o
+endif
+
+ifndef CONFIG_SPL_BUILD
+obj-y += init/
+obj-y += main.o
+obj-y += exports.o
+
# This option is not just y/n - it can have a numeric value
ifdef CONFIG_BOOTDELAY
obj-y += autoboot.o
@@ -34,9 +49,6 @@ obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
# environment
-obj-y += env_attr.o
-obj-y += env_callback.o
-obj-y += env_flags.o
obj-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o
obj-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o
extra-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
diff --git a/common/command.c b/common/command.c
index e5d9b9c..d1c049c 100644
--- a/common/command.c
+++ b/common/command.c
@@ -520,7 +520,7 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[],
if (argc > cmdtp->maxargs)
rc = CMD_RET_USAGE;
-#if defined(CONFIG_CMD_BOOTD)
+#if defined(CONFIG_CMD_BOOTD) && !defined(CONFIG_SPL_BUILD)
/* avoid "bootd" recursion */
else if (cmdtp->cmd == do_bootd) {
if (flag & CMD_FLAG_BOOTD) {
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index ec8d8f1..be74991 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -35,6 +35,13 @@ else
SPL_BIN := u-boot-spl
endif
+CONFIG_INC_DFU=y
+ifdef CONFIG_SPL_BUILD
+ifndef CONFIG_SPL_DFU
+CONFIG_INC_DFU=n
+endif
+endif
+
include $(srctree)/config.mk
include $(srctree)/arch/$(ARCH)/Makefile
@@ -56,6 +63,12 @@ libs-y += common/init/
libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/
libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
libs-y += drivers/
+ifeq ($(CONFIG_INC_DFU),y)
+libs-y += drivers/dfu/
+libs-y += drivers/usb/gadget/
+libs-y += drivers/usb/gadget/udc/
+libs-y += drivers/usb/dwc3/
+endif
libs-y += dts/
libs-y += fs/
libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support in SPL
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support " Ravi Babu
@ 2016-06-24 8:50 ` Lukasz Majewski
2016-06-24 8:54 ` B, Ravi
0 siblings, 1 reply; 19+ messages in thread
From: Lukasz Majewski @ 2016-06-24 8:50 UTC (permalink / raw)
To: u-boot
Hi Ravi,
> Traditionally the DFU support is available only
> as part 2nd stage boot loader(u-boot) and DFU
> is not supported in SPL.
>
> The SPL-DFU feature is useful for boards which has
> only USB inteface and do not have external interface
> like ethernet or MMC/SD to boot the board.
>
> This patch add DFU support in SPL to flash boot inital
> binary images to factory or bare-metal boards to
> memory devices like SPI, eMMC, MMC/SD card using
> USB interface.
>
> This SPL-DFU support can be enabled through
> Menuconfig->Boot Images->Enable SPL-DFU support
>
> Signed-off-by: Ravi Babu <ravibabu@ti.com>
> ---
> Kconfig | 33 +++++++++++++++++++++++++++++++++
> common/Makefile | 26 +++++++++++++++++++-------
> common/command.c | 2 +-
> scripts/Makefile.spl | 13 +++++++++++++
> 4 files changed, 66 insertions(+), 8 deletions(-)
>
> diff --git a/Kconfig b/Kconfig
> index f53759a..969641e 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -285,6 +285,39 @@ config SPL_LOAD_FIT
> particular it can handle selecting from multiple device
> tree and passing the correct one to U-Boot.
>
> +config SPL_DFU
> + bool "Enable SPL with DFU to load binaries to bootdevices
> using USB"
> + depends on USB && CMD_DFU && TARGET_DRA7XX_EVM
Is this dependency correct? Especially the CONFIG_CMD_DFU? As fair as I
remember, we don't need "dfu" command to make SPL dfu working.
What we do need are
CONFIG_USB_GADGET_DOWNLOAD,CONFIG_USB_FUNCTION_THOR,
CONFIG_USB_FUNCTION_DFU, etc.
> + help
> + Currently the SPL does not have capability to load the
> + binaries or boot images to boot devices like eMMC,SPI,etc.
> + This feature enables the DFU (Device Firmware Upgarde) in
> SPL with
> + RAM device as default bootdevice. The ROM code will load
> and execute
> + the SPL/MLO dfu image. The user can flash the binaries to
> selected
> + dfu device partition from host-pc using dfu-utils.
> + This feature will be useful to flash the binaries to
> factory
> + or bare-metal boards using USB interface.
> +
> +choice
> + bool "DFU device selection"
> + depends on CMD_DFU && SPL_DFU
> +
> +config SPL_DFU_RAM
> + bool "RAM device"
> + depends on CMD_DFU
> + help
> + select DDR memory device for flashing binary images to
> + the selected partition using DFU.
> +
> +config SPL_DFU_SF
> + bool "SPI device"
> + depends on CMD_DFU && SPL_DFU
> + help
> + select SPI flash memory device for flashing binary images to
> + the selected partition using DFU.
> +
> +endchoice
> +
> config SYS_CLK_FREQ
> depends on ARC || ARCH_SUNXI
> int "CPU clock frequency"
> diff --git a/common/Makefile b/common/Makefile
> index b23f312..0fa441f 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -6,15 +6,30 @@
> #
>
> # core
> -ifndef CONFIG_SPL_BUILD
> -obj-y += init/
> -obj-y += main.o
> -obj-y += exports.o
> +
> +CONFIG_INC_DFU=y
> +ifdef CONFIG_SPL_BUILD
> +ifndef CONFIG_SPL_DFU
> +CONFIG_INC_DFU=n
> +endif
> +endif
> +
> +ifeq ($(CONFIG_INC_DFU),y)
> obj-y += hash.o
> ifdef CONFIG_SYS_HUSH_PARSER
> obj-y += cli_hush.o
> endif
>
> +obj-y += env_attr.o
> +obj-y += env_callback.o
> +obj-y += env_flags.o
> +endif
> +
> +ifndef CONFIG_SPL_BUILD
> +obj-y += init/
> +obj-y += main.o
> +obj-y += exports.o
> +
> # This option is not just y/n - it can have a numeric value
> ifdef CONFIG_BOOTDELAY
> obj-y += autoboot.o
> @@ -34,9 +49,6 @@ obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
> obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
>
> # environment
> -obj-y += env_attr.o
> -obj-y += env_callback.o
> -obj-y += env_flags.o
> obj-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o
> obj-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o
> extra-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
> diff --git a/common/command.c b/common/command.c
> index e5d9b9c..d1c049c 100644
> --- a/common/command.c
> +++ b/common/command.c
> @@ -520,7 +520,7 @@ enum command_ret_t cmd_process(int flag, int
> argc, char * const argv[], if (argc > cmdtp->maxargs)
> rc = CMD_RET_USAGE;
>
> -#if defined(CONFIG_CMD_BOOTD)
> +#if defined(CONFIG_CMD_BOOTD) && !defined(CONFIG_SPL_BUILD)
> /* avoid "bootd" recursion */
> else if (cmdtp->cmd == do_bootd) {
> if (flag & CMD_FLAG_BOOTD) {
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
> index ec8d8f1..be74991 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -35,6 +35,13 @@ else
> SPL_BIN := u-boot-spl
> endif
>
> +CONFIG_INC_DFU=y
> +ifdef CONFIG_SPL_BUILD
> +ifndef CONFIG_SPL_DFU
> +CONFIG_INC_DFU=n
> +endif
> +endif
> +
> include $(srctree)/config.mk
> include $(srctree)/arch/$(ARCH)/Makefile
>
> @@ -56,6 +63,12 @@ libs-y += common/init/
> libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/
> libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
> libs-y += drivers/
> +ifeq ($(CONFIG_INC_DFU),y)
> +libs-y += drivers/dfu/
> +libs-y += drivers/usb/gadget/
> +libs-y += drivers/usb/gadget/udc/
> +libs-y += drivers/usb/dwc3/
> +endif
> libs-y += dts/
> libs-y += fs/
> libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support in SPL
2016-06-24 8:50 ` Lukasz Majewski
@ 2016-06-24 8:54 ` B, Ravi
0 siblings, 0 replies; 19+ messages in thread
From: B, Ravi @ 2016-06-24 8:54 UTC (permalink / raw)
To: u-boot
Hi Lukasz
> > Traditionally the DFU support is available only as part 2nd stage boot
> > loader(u-boot) and DFU is not supported in SPL.
> >
> > The SPL-DFU feature is useful for boards which has only USB inteface
> > and do not have external interface like ethernet or MMC/SD to boot the
> > board.
> >
> > This patch add DFU support in SPL to flash boot inital binary images
> > to factory or bare-metal boards to memory devices like SPI, eMMC,
> > MMC/SD card using USB interface.
> >
> > This SPL-DFU support can be enabled through
> > Menuconfig->Boot Images->Enable SPL-DFU support
> >
> > Signed-off-by: Ravi Babu <ravibabu@ti.com>
> > ---
> > Kconfig | 33 +++++++++++++++++++++++++++++++++
> > common/Makefile | 26 +++++++++++++++++++-------
> > common/command.c | 2 +-
> > scripts/Makefile.spl | 13 +++++++++++++
> > 4 files changed, 66 insertions(+), 8 deletions(-)
> >
> > diff --git a/Kconfig b/Kconfig
> > index f53759a..969641e 100644
> > --- a/Kconfig
> > +++ b/Kconfig
> > @@ -285,6 +285,39 @@ config SPL_LOAD_FIT
> > particular it can handle selecting from multiple device tree and
> > passing the correct one to U-Boot.
> >
> > +config SPL_DFU
> > + bool "Enable SPL with DFU to load binaries to bootdevices
> > using USB"
> > + depends on USB && CMD_DFU && TARGET_DRA7XX_EVM
> Is this dependency correct? Especially the CONFIG_CMD_DFU? As fair as I remember, we don't need "dfu" command to make SPL dfu working.
I do agree, I did not use cmd/dfu.c. Will clean it up.
> What we do need are
> CONFIG_USB_GADGET_DOWNLOAD,CONFIG_USB_FUNCTION_THOR,
> CONFIG_USB_FUNCTION_DFU, etc.
Regards
Ravi
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU
2016-06-14 11:02 [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL Ravi Babu
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support " Ravi Babu
@ 2016-06-14 11:02 ` Ravi Babu
2016-06-24 9:00 ` Lukasz Majewski
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 3/6] dfu: spl: add generic spl-dfu function in common-spl Ravi Babu
` (4 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Ravi Babu @ 2016-06-14 11:02 UTC (permalink / raw)
To: u-boot
Adding support functions to run dfu commands
Signed-off-by: Ravi Babu <ravibabu@ti.com>
---
common/spl/Makefile | 1 +
common/spl/spl_dfu.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/spl.h | 10 ++++
3 files changed, 164 insertions(+)
create mode 100644 common/spl/spl_dfu.c
diff --git a/common/spl/Makefile b/common/spl/Makefile
index 2e0f695..7a34697 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
obj-$(CONFIG_SPL_FAT_SUPPORT) += spl_fat.o
obj-$(CONFIG_SPL_EXT_SUPPORT) += spl_ext.o
obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
+obj-$(CONFIG_SPL_DFU) += spl_dfu.o
endif
diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
new file mode 100644
index 0000000..8b8432b
--- /dev/null
+++ b/common/spl/spl_dfu.c
@@ -0,0 +1,153 @@
+/*
+ * (C) Copyright 2010
+ * Texas Instruments, <www.ti.com>
+ *
+ * Ravi B <ravibabu@ti.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include <common.h>
+#include <dm.h>
+#include <spl.h>
+#include <linux/compiler.h>
+#include <errno.h>
+#include <asm/u-boot.h>
+#include <errno.h>
+#include <mmc.h>
+#include <watchdog.h>
+#include <console.h>
+#include <g_dnl.h>
+#include <usb.h>
+#include <dfu.h>
+#include <environment.h>
+
+static int run_dfu(int usb_index, char *interface, char *devstring)
+{
+ int ret;
+
+ ret = dfu_init_env_entities(interface, devstring);
+ if (ret)
+ goto done;
+
+ ret = CMD_RET_SUCCESS;
+
+ board_usb_init(usb_index, USB_INIT_DEVICE);
+ g_dnl_clear_detach();
+ g_dnl_register("usb_dnl_dfu");
+
+ while (1) {
+ if (ctrlc())
+ goto exit;
+
+ if (dfu_get_defer_flush()) {
+ /*
+ * Call to usb_gadget_handle_interrupts() is necessary
+ * to act on ZLP OUT transaction from HOST PC after
+ * transmitting the whole file.
+ *
+ * If this ZLP OUT packet is NAK'ed, the HOST libusb
+ * function fails after timeout (by default it is set to
+ * 5 seconds). In such situation the dfu-util program
+ * exits with error message.
+ */
+ usb_gadget_handle_interrupts(usb_index);
+ ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0);
+ dfu_set_defer_flush(NULL);
+ if (ret) {
+ error("Deferred dfu_flush() failed!");
+ goto exit;
+ }
+ }
+
+ WATCHDOG_RESET();
+ usb_gadget_handle_interrupts(usb_index);
+ }
+exit:
+ g_dnl_unregister();
+ board_usb_cleanup(usb_index, USB_INIT_DEVICE);
+done:
+ dfu_free_entities();
+ g_dnl_clear_detach();
+
+ return ret;
+}
+
+int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr)
+{
+ char *str_env;
+ int ret;
+
+ /* set default environment */
+ set_default_env(0);
+ str_env = getenv(dfu_alt_info);
+ if (!str_env) {
+ error("\"dfu_alt_info\" env variable not defined!\n");
+ return -EINVAL;
+ }
+
+ ret = setenv("dfu_alt_info", str_env);
+ if (ret) {
+ error("unable to set env variable \"dfu_alt_info\"!\n");
+ return -EINVAL;
+ }
+
+ /* invoke dfu command */
+ return run_dfu(usbctrl, interface, devstr);
+}
+
+int spl_dfu_mmc(int usb_index, int mmc_dev, char *dfu_alt_info)
+{
+ struct mmc *mmcdev;
+ struct mmc **mmc = &mmcdev;
+ int device = mmc_dev;
+ int ret;
+
+ /* initialize the mmc module */
+ mmc_initialize(0);
+
+ *mmc = find_mmc_device(device);
+ if (!*mmc) {
+ error("failed to find mmc device %d\n", device);
+ return -ENODEV;
+ }
+
+ ret = mmc_init(*mmc);
+ if (ret) {
+ error("spl: mmc init failed with error: %d\n", ret);
+ return ret;
+ }
+
+ return spl_dfu_cmd(usb_index, dfu_alt_info, "mmc", mmc_dev ? "1" : "0");
+}
+
+ulong spl_fit_ram_read(struct spl_load_info *load, ulong sector, ulong count,
+ void *buf)
+{
+ memcpy(buf, (void *)sector, count);
+ return count;
+}
+
+int spl_dfu_ram_load_image(void)
+{
+ int err = 0;
+ struct image_header *header;
+ unsigned int addr = 0x80200000;
+ char *filename = (char *)addr;
+
+ header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
+ sizeof(struct image_header));
+
+ memcpy(header, filename, sizeof(struct image_header));
+
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+ struct spl_load_info load;
+ debug("Found FIT\n");
+ load.priv = NULL;
+ load.read = spl_fit_ram_read;
+
+ err = spl_load_simple_fit(&load, (ulong)filename, header);
+ } else {
+ spl_parse_image_header(header);
+ }
+ return err;
+}
diff --git a/include/spl.h b/include/spl.h
index af02a6d..8849678 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -139,4 +139,14 @@ void spl_board_init(void);
*/
bool spl_was_boot_source(void);
+/* spl dfu functions */
+/* spl_dfu_mmc - run dfu command with chosen mmc device interface
+ * @param usb_index - usb controller number
+ * @param mmc_dev - mmc device nubmer
+ *
+ * @return 0 on success, otherwise error code
+ */
+int spl_dfu_mmc(int usb_index, int mmc_dev, char *dfu_alt_info);
+int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr);
+int spl_dfu_ram_load_image(void);
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU Ravi Babu
@ 2016-06-24 9:00 ` Lukasz Majewski
2016-06-24 9:02 ` B, Ravi
0 siblings, 1 reply; 19+ messages in thread
From: Lukasz Majewski @ 2016-06-24 9:00 UTC (permalink / raw)
To: u-boot
Hi Ravi,
> Adding support functions to run dfu commands
>
> Signed-off-by: Ravi Babu <ravibabu@ti.com>
> ---
> common/spl/Makefile | 1 +
> common/spl/spl_dfu.c | 153
> ++++++++++++++++++++++++++++++++++++++++++++++++++
> include/spl.h | 10 ++++ 3 files changed, 164 insertions(+)
> create mode 100644 common/spl/spl_dfu.c
>
> diff --git a/common/spl/Makefile b/common/spl/Makefile
> index 2e0f695..7a34697 100644
> --- a/common/spl/Makefile
> +++ b/common/spl/Makefile
> @@ -21,4 +21,5 @@ obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
> obj-$(CONFIG_SPL_FAT_SUPPORT) += spl_fat.o
> obj-$(CONFIG_SPL_EXT_SUPPORT) += spl_ext.o
> obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
> +obj-$(CONFIG_SPL_DFU) += spl_dfu.o
> endif
> diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
> new file mode 100644
> index 0000000..8b8432b
> --- /dev/null
> +++ b/common/spl/spl_dfu.c
> @@ -0,0 +1,153 @@
> +/*
> + * (C) Copyright 2010
IMHO, now we have 2016 :-)
> + * Texas Instruments, <www.ti.com>
> + *
> + * Ravi B <ravibabu@ti.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +#include <common.h>
> +#include <dm.h>
> +#include <spl.h>
> +#include <linux/compiler.h>
> +#include <errno.h>
> +#include <asm/u-boot.h>
> +#include <errno.h>
> +#include <mmc.h>
> +#include <watchdog.h>
> +#include <console.h>
> +#include <g_dnl.h>
> +#include <usb.h>
> +#include <dfu.h>
> +#include <environment.h>
> +
> +static int run_dfu(int usb_index, char *interface, char *devstring)
> +{
> + int ret;
> +
> + ret = dfu_init_env_entities(interface, devstring);
> + if (ret)
> + goto done;
> +
> + ret = CMD_RET_SUCCESS;
> +
> + board_usb_init(usb_index, USB_INIT_DEVICE);
> + g_dnl_clear_detach();
> + g_dnl_register("usb_dnl_dfu");
> +
> + while (1) {
> + if (ctrlc())
> + goto exit;
> +
> + if (dfu_get_defer_flush()) {
> + /*
> + * Call to usb_gadget_handle_interrupts() is
> necessary
> + * to act on ZLP OUT transaction from HOST
> PC after
> + * transmitting the whole file.
> + *
> + * If this ZLP OUT packet is NAK'ed, the
> HOST libusb
> + * function fails after timeout (by default
> it is set to
> + * 5 seconds). In such situation the
> dfu-util program
> + * exits with error message.
> + */
> + usb_gadget_handle_interrupts(usb_index);
> + ret = dfu_flush(dfu_get_defer_flush(), NULL,
> 0, 0);
> + dfu_set_defer_flush(NULL);
> + if (ret) {
> + error("Deferred dfu_flush()
> failed!");
> + goto exit;
> + }
> + }
> +
> + WATCHDOG_RESET();
> + usb_gadget_handle_interrupts(usb_index);
> + }
> +exit:
> + g_dnl_unregister();
> + board_usb_cleanup(usb_index, USB_INIT_DEVICE);
> +done:
> + dfu_free_entities();
> + g_dnl_clear_detach();
> +
> + return ret;
> +}
> +
> +int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface,
> char *devstr) +{
> + char *str_env;
> + int ret;
> +
> + /* set default environment */
> + set_default_env(0);
> + str_env = getenv(dfu_alt_info);
> + if (!str_env) {
> + error("\"dfu_alt_info\" env variable not
> defined!\n");
> + return -EINVAL;
> + }
> +
> + ret = setenv("dfu_alt_info", str_env);
> + if (ret) {
> + error("unable to set env variable
> \"dfu_alt_info\"!\n");
> + return -EINVAL;
> + }
> +
> + /* invoke dfu command */
> + return run_dfu(usbctrl, interface, devstr);
> +}
> +
> +int spl_dfu_mmc(int usb_index, int mmc_dev, char *dfu_alt_info)
> +{
> + struct mmc *mmcdev;
> + struct mmc **mmc = &mmcdev;
> + int device = mmc_dev;
> + int ret;
> +
> + /* initialize the mmc module */
> + mmc_initialize(0);
> +
> + *mmc = find_mmc_device(device);
> + if (!*mmc) {
> + error("failed to find mmc device %d\n", device);
> + return -ENODEV;
> + }
> +
> + ret = mmc_init(*mmc);
> + if (ret) {
> + error("spl: mmc init failed with error: %d\n", ret);
> + return ret;
> + }
> +
> + return spl_dfu_cmd(usb_index, dfu_alt_info, "mmc", mmc_dev ?
> "1" : "0"); +}
> +
> +ulong spl_fit_ram_read(struct spl_load_info *load, ulong sector,
> ulong count,
> + void *buf)
> +{
> + memcpy(buf, (void *)sector, count);
> + return count;
> +}
> +
> +int spl_dfu_ram_load_image(void)
> +{
> + int err = 0;
> + struct image_header *header;
> + unsigned int addr = 0x80200000;
This 0x80200000 constant should be defined in the Kconfig
or ./include/dra7xx.h file.
Maybe it would be beneficial to get this value from envs (maybe
"loadadr" env would appropriate to be reused here?).
Nothing also prevents us from defining new one.
> + char *filename = (char *)addr;
> +
> + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
> + sizeof(struct
> image_header)); +
> + memcpy(header, filename, sizeof(struct image_header));
> +
> + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
> + struct spl_load_info load;
> + debug("Found FIT\n");
> + load.priv = NULL;
> + load.read = spl_fit_ram_read;
> +
> + err = spl_load_simple_fit(&load, (ulong)filename,
> header);
> + } else {
> + spl_parse_image_header(header);
> + }
> + return err;
> +}
> diff --git a/include/spl.h b/include/spl.h
> index af02a6d..8849678 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -139,4 +139,14 @@ void spl_board_init(void);
> */
> bool spl_was_boot_source(void);
>
> +/* spl dfu functions */
> +/* spl_dfu_mmc - run dfu command with chosen mmc device interface
> + * @param usb_index - usb controller number
> + * @param mmc_dev - mmc device nubmer
> + *
> + * @return 0 on success, otherwise error code
> + */
> +int spl_dfu_mmc(int usb_index, int mmc_dev, char *dfu_alt_info);
> +int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface,
> char *devstr); +int spl_dfu_ram_load_image(void);
I think that it would be nice to have doxygen like (/**
/*
...... )
Function description comments for each function.
In this way we would have high quality comments in the code.
> #endif
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU
2016-06-24 9:00 ` Lukasz Majewski
@ 2016-06-24 9:02 ` B, Ravi
0 siblings, 0 replies; 19+ messages in thread
From: B, Ravi @ 2016-06-24 9:02 UTC (permalink / raw)
To: u-boot
> > diff --git a/include/spl.h b/include/spl.h index af02a6d..8849678
> > 100644
> > --- a/include/spl.h
> > +++ b/include/spl.h
> > @@ -139,4 +139,14 @@ void spl_board_init(void);
> > */
> > bool spl_was_boot_source(void);
> >
> > +/* spl dfu functions */
> > +/* spl_dfu_mmc - run dfu command with chosen mmc device interface
> > + * @param usb_index - usb controller number
> > + * @param mmc_dev - mmc device nubmer
> > + *
> > + * @return 0 on success, otherwise error code */ int spl_dfu_mmc(int
> > +usb_index, int mmc_dev, char *dfu_alt_info); int spl_dfu_cmd(int
> > +usbctrl, char *dfu_alt_info, char *interface,
> > char *devstr); +int spl_dfu_ram_load_image(void);
> I think that it would be nice to have doxygen like (/**
/*
...... )
> Function description comments for each function.
> In this way we would have high quality comments in the code.
Ok, sure.
Regards
Ravi
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 3/6] dfu: spl: add generic spl-dfu function in common-spl
2016-06-14 11:02 [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL Ravi Babu
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support " Ravi Babu
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU Ravi Babu
@ 2016-06-14 11:02 ` Ravi Babu
2016-06-24 9:01 ` Lukasz Majewski
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform Ravi Babu
` (3 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Ravi Babu @ 2016-06-14 11:02 UTC (permalink / raw)
To: u-boot
Add generic spl-dfu function in common-spl, specific
implemention for configuring dfu memory device is
done in platform board specific source file.
Signed-off-by: Ravi Babu <ravibabu@ti.com>
---
common/spl/spl.c | 9 +++++++++
include/spl.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 82e7f58..0726378 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -273,6 +273,11 @@ static void announce_boot_device(u32 boot_device)
static inline void announce_boot_device(u32 boot_device) { }
#endif
+__weak int spl_run_dfu(void)
+{
+ return 0;
+}
+
static int spl_load_image(u32 boot_device)
{
switch (boot_device) {
@@ -367,6 +372,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
spl_board_init();
#endif
+ if (spl_run_dfu())
+ goto os_boot;
+
board_boot_order(spl_boot_list);
for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
@@ -381,6 +389,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
hang();
}
+os_boot:
switch (spl_image.os) {
case IH_OS_U_BOOT:
debug("Jumping to U-Boot\n");
diff --git a/include/spl.h b/include/spl.h
index 8849678..f21a76a 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -149,4 +149,5 @@ bool spl_was_boot_source(void);
int spl_dfu_mmc(int usb_index, int mmc_dev, char *dfu_alt_info);
int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr);
int spl_dfu_ram_load_image(void);
+int spl_run_dfu(void);
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 3/6] dfu: spl: add generic spl-dfu function in common-spl
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 3/6] dfu: spl: add generic spl-dfu function in common-spl Ravi Babu
@ 2016-06-24 9:01 ` Lukasz Majewski
0 siblings, 0 replies; 19+ messages in thread
From: Lukasz Majewski @ 2016-06-24 9:01 UTC (permalink / raw)
To: u-boot
Hi Ravi,
> Add generic spl-dfu function in common-spl, specific
> implemention for configuring dfu memory device is
> done in platform board specific source file.
>
> Signed-off-by: Ravi Babu <ravibabu@ti.com>
> ---
> common/spl/spl.c | 9 +++++++++
> include/spl.h | 1 +
> 2 files changed, 10 insertions(+)
>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 82e7f58..0726378 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -273,6 +273,11 @@ static void announce_boot_device(u32 boot_device)
> static inline void announce_boot_device(u32 boot_device) { }
> #endif
>
> +__weak int spl_run_dfu(void)
> +{
> + return 0;
> +}
> +
> static int spl_load_image(u32 boot_device)
> {
> switch (boot_device) {
> @@ -367,6 +372,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> spl_board_init();
> #endif
>
> + if (spl_run_dfu())
> + goto os_boot;
> +
> board_boot_order(spl_boot_list);
> for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
> spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
> @@ -381,6 +389,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> hang();
> }
>
> +os_boot:
> switch (spl_image.os) {
> case IH_OS_U_BOOT:
> debug("Jumping to U-Boot\n");
> diff --git a/include/spl.h b/include/spl.h
> index 8849678..f21a76a 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -149,4 +149,5 @@ bool spl_was_boot_source(void);
> int spl_dfu_mmc(int usb_index, int mmc_dev, char *dfu_alt_info);
> int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface,
> char *devstr); int spl_dfu_ram_load_image(void);
> +int spl_run_dfu(void);
> #endif
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform
2016-06-14 11:02 [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL Ravi Babu
` (2 preceding siblings ...)
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 3/6] dfu: spl: add generic spl-dfu function in common-spl Ravi Babu
@ 2016-06-14 11:02 ` Ravi Babu
2016-06-24 9:10 ` Lukasz Majewski
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu " Ravi Babu
` (2 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Ravi Babu @ 2016-06-14 11:02 UTC (permalink / raw)
To: u-boot
Adding SPL-DFU support for dra7x platform. The DFU
support for dra7x includes QSPI, MMC/SD and eMMC
memory devices. The SPL-DFU memory devices can be
selected through meunconfig->Boot Images.
---
board/ti/dra7xx/evm.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index c5f7190..bd1f5be 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -29,6 +29,7 @@
#include <ti-usb-phy-uboot.h>
#include <miiphy.h>
#include <pcf8575.h>
+#include <spl.h>
#include "mux_data.h"
#include "../common/board_detect.h"
@@ -706,6 +707,22 @@ int spl_start_uboot(void)
}
#endif
+#ifdef CONFIG_SPL_DFU
+int spl_run_dfu(void)
+{
+ int os_boot = 0;
+#ifdef CONFIG_SPL_DFU_SF
+ spl_dfu_cmd(0, "dfu_alt_info_qspi", "sf", "0:0:64000000:0");
+#endif
+#ifdef CONFIG_SPL_DFU_RAM
+ spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
+ spl_dfu_ram_load_image();
+ os_boot = 1;
+#endif
+ return os_boot;
+}
+#endif
+
#ifdef CONFIG_DRIVER_TI_CPSW
extern u32 *const omap_si_rev;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform Ravi Babu
@ 2016-06-24 9:10 ` Lukasz Majewski
2016-06-24 9:27 ` B, Ravi
0 siblings, 1 reply; 19+ messages in thread
From: Lukasz Majewski @ 2016-06-24 9:10 UTC (permalink / raw)
To: u-boot
Hi Ravi,
> Adding SPL-DFU support for dra7x platform. The DFU
> support for dra7x includes QSPI, MMC/SD and eMMC
> memory devices. The SPL-DFU memory devices can be
> selected through meunconfig->Boot Images.
> ---
> board/ti/dra7xx/evm.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
> index c5f7190..bd1f5be 100644
> --- a/board/ti/dra7xx/evm.c
> +++ b/board/ti/dra7xx/evm.c
> @@ -29,6 +29,7 @@
> #include <ti-usb-phy-uboot.h>
> #include <miiphy.h>
> #include <pcf8575.h>
> +#include <spl.h>
>
> #include "mux_data.h"
> #include "../common/board_detect.h"
> @@ -706,6 +707,22 @@ int spl_start_uboot(void)
> }
> #endif
>
> +#ifdef CONFIG_SPL_DFU
> +int spl_run_dfu(void)
We can replace int with bool here.
> +{
> + int os_boot = 0;
> +#ifdef CONFIG_SPL_DFU_SF
> + spl_dfu_cmd(0, "dfu_alt_info_qspi", "sf", "0:0:64000000:0");
^^^^^^^^^^^^^^^
could you add some
description to this
magic value (as e.g.
comment) or replace
it with some #define?
> +#endif
> +#ifdef CONFIG_SPL_DFU_RAM
> + spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
> + spl_dfu_ram_load_image();
> + os_boot = 1;
> +#endif
> + return os_boot;
> +}
> +#endif
> +
> #ifdef CONFIG_DRIVER_TI_CPSW
> extern u32 *const omap_si_rev;
>
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform
2016-06-24 9:10 ` Lukasz Majewski
@ 2016-06-24 9:27 ` B, Ravi
0 siblings, 0 replies; 19+ messages in thread
From: B, Ravi @ 2016-06-24 9:27 UTC (permalink / raw)
To: u-boot
Hi Lukasz
>> #include <ti-usb-phy-uboot.h>
>> #include <miiphy.h>
>> #include <pcf8575.h>
>> +#include <spl.h>
>>
>> #include "mux_data.h"
>> #include "../common/board_detect.h"
>> @@ -706,6 +707,22 @@ int spl_start_uboot(void) } #endif
>>
>> +#ifdef CONFIG_SPL_DFU
>> +int spl_run_dfu(void)
>We can replace int with bool here.
Ok, make sense.
>> +{
>> + int os_boot = 0;
>> +#ifdef CONFIG_SPL_DFU_SF
>> + spl_dfu_cmd(0, "dfu_alt_info_qspi", "sf", "0:0:64000000:0");
^^^^^^^^^^^^^^^
could you add some
description to this
magic value (as e.g.
comment) or replace
it with some #define?
Ok, I can use default CONFIG_XX use for SPI and make string to pass.
Regards
Ravi
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu support for dra7x platform
2016-06-14 11:02 [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL Ravi Babu
` (3 preceding siblings ...)
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform Ravi Babu
@ 2016-06-14 11:02 ` Ravi Babu
2016-06-24 9:12 ` Lukasz Majewski
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x Ravi Babu
2016-06-21 8:39 ` [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL B, Ravi
6 siblings, 1 reply; 19+ messages in thread
From: Ravi Babu @ 2016-06-14 11:02 UTC (permalink / raw)
To: u-boot
Enable the SPL-DFU support for dra7x platform.
Signed-off-by: Ravi Babu <ravibabu@ti.com>
---
include/configs/dra7xx_evm.h | 8 ++++----
include/configs/ti_omap5_common.h | 2 --
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index e7fb469..686f5d4 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -44,7 +44,6 @@
#define CONFIG_SYS_OMAP_ABE_SYSCK
-#ifndef CONFIG_SPL_BUILD
/* Define the default GPT table for eMMC */
#define PARTS_DEFAULT \
/* Linux partitions */ \
@@ -119,6 +118,7 @@
DFU_ALT_INFO_QSPI
/* Fastboot */
+#ifndef CONFIG_SPL_BUILD
#define CONFIG_USB_FUNCTION_FASTBOOT
#define CONFIG_CMD_FASTBOOT
#define CONFIG_ANDROID_BOOT_IMAGE
@@ -216,10 +216,10 @@
/* USB Device Firmware Update support */
#define CONFIG_USB_FUNCTION_DFU
#define CONFIG_DFU_RAM
-
-#define CONFIG_DFU_MMC
-#define CONFIG_DFU_RAM
#define CONFIG_DFU_SF
+#ifndef CONFIG_SPL_DFU
+#define CONFIG_DFU_MMC
+#endif
/* SATA */
#define CONFIG_BOARD_LATE_INIT
diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h
index 59f0f70..f9c6576 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -66,7 +66,6 @@
#define DFUARGS
#endif
-#ifndef CONFIG_SPL_BUILD
#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
#define CONFIG_EXTRA_ENV_SETTINGS \
DEFAULT_LINUX_BOOT_ENV \
@@ -136,7 +135,6 @@
"setenv mmcroot /dev/mmcblk0p2 rw; " \
"run mmcboot;" \
""
-#endif
/*
* SPL related defines. The Public RAM memory map the ROM defines the
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu support for dra7x platform
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu " Ravi Babu
@ 2016-06-24 9:12 ` Lukasz Majewski
2016-06-24 9:21 ` B, Ravi
0 siblings, 1 reply; 19+ messages in thread
From: Lukasz Majewski @ 2016-06-24 9:12 UTC (permalink / raw)
To: u-boot
Hi Ravi,
> Enable the SPL-DFU support for dra7x platform.
>
> Signed-off-by: Ravi Babu <ravibabu@ti.com>
> ---
> include/configs/dra7xx_evm.h | 8 ++++----
> include/configs/ti_omap5_common.h | 2 --
> 2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/include/configs/dra7xx_evm.h
> b/include/configs/dra7xx_evm.h index e7fb469..686f5d4 100644
> --- a/include/configs/dra7xx_evm.h
> +++ b/include/configs/dra7xx_evm.h
> @@ -44,7 +44,6 @@
>
> #define CONFIG_SYS_OMAP_ABE_SYSCK
>
> -#ifndef CONFIG_SPL_BUILD
> /* Define the default GPT table for eMMC */
> #define PARTS_DEFAULT \
> /* Linux partitions */ \
> @@ -119,6 +118,7 @@
> DFU_ALT_INFO_QSPI
>
> /* Fastboot */
> +#ifndef CONFIG_SPL_BUILD
> #define CONFIG_USB_FUNCTION_FASTBOOT
> #define CONFIG_CMD_FASTBOOT
> #define CONFIG_ANDROID_BOOT_IMAGE
> @@ -216,10 +216,10 @@
> /* USB Device Firmware Update support */
> #define CONFIG_USB_FUNCTION_DFU
> #define CONFIG_DFU_RAM
> -
> -#define CONFIG_DFU_MMC
> -#define CONFIG_DFU_RAM
Please correct me if I am wrong, but from this patch it seems like you
disable MMC and RAM DFU support in the fully-fledge u-boot on your
dra7xx board. Is this intentional?
> #define CONFIG_DFU_SF
> +#ifndef CONFIG_SPL_DFU
> +#define CONFIG_DFU_MMC
> +#endif
>
> /* SATA */
> #define CONFIG_BOARD_LATE_INIT
> diff --git a/include/configs/ti_omap5_common.h
> b/include/configs/ti_omap5_common.h index 59f0f70..f9c6576 100644
> --- a/include/configs/ti_omap5_common.h
> +++ b/include/configs/ti_omap5_common.h
> @@ -66,7 +66,6 @@
> #define DFUARGS
> #endif
>
> -#ifndef CONFIG_SPL_BUILD
> #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
> #define CONFIG_EXTRA_ENV_SETTINGS \
> DEFAULT_LINUX_BOOT_ENV \
> @@ -136,7 +135,6 @@
> "setenv mmcroot /dev/mmcblk0p2 rw; " \
> "run mmcboot;" \
> ""
> -#endif
>
> /*
> * SPL related defines. The Public RAM memory map the ROM defines
> the
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu support for dra7x platform
2016-06-24 9:12 ` Lukasz Majewski
@ 2016-06-24 9:21 ` B, Ravi
0 siblings, 0 replies; 19+ messages in thread
From: B, Ravi @ 2016-06-24 9:21 UTC (permalink / raw)
To: u-boot
Hi Lukasz
>> /* USB Device Firmware Update support */ #define
>> CONFIG_USB_FUNCTION_DFU #define CONFIG_DFU_RAM
>> -
>> -#define CONFIG_DFU_MMC
>> -#define CONFIG_DFU_RAM
>Please correct me if I am wrong, but from this patch it seems like you disable MMC and RAM DFU support in the fully-fledge u-boot on your dra7xx board. Is this intentional?
Actually, for SPL-DFU, I want to enable DFU_RAM in order to reduce the foot print. Then the user must rebuild full fledge u-boot without SPL-DFU and load to RAM.
> #define CONFIG_DFU_SF
> +#ifndef CONFIG_SPL_DFU
> +#define CONFIG_DFU_MMC
> +#endif
Here I have included DFU_MMC if SPL_DFU (from menuconfig) is not defined.
Regards
Ravi
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x
2016-06-14 11:02 [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL Ravi Babu
` (4 preceding siblings ...)
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu " Ravi Babu
@ 2016-06-14 11:02 ` Ravi Babu
2016-06-24 9:15 ` Lukasz Majewski
2016-06-21 8:39 ` [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL B, Ravi
6 siblings, 1 reply; 19+ messages in thread
From: Ravi Babu @ 2016-06-14 11:02 UTC (permalink / raw)
To: u-boot
enable the SPL-DFU support for am335x platform.
Signed-off-by: Ravi Babu <ravibabu@ti.com>
---
Kconfig | 2 +-
board/ti/am335x/board.c | 15 +++++++++++++++
common/spl/spl_dfu.c | 1 +
include/configs/am335x_evm.h | 17 ++++++++++++++++-
4 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/Kconfig b/Kconfig
index 969641e..c4eb4bd 100644
--- a/Kconfig
+++ b/Kconfig
@@ -287,7 +287,7 @@ config SPL_LOAD_FIT
config SPL_DFU
bool "Enable SPL with DFU to load binaries to bootdevices using USB"
- depends on USB && CMD_DFU && TARGET_DRA7XX_EVM
+ depends on USB && CMD_DFU && (TARGET_DRA7XX_EVM || TARGET_AM335X_EVM)
help
Currently the SPL does not have capability to load the
binaries or boot images to boot devices like eMMC,SPI,etc.
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 690c298..fe56004 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -246,6 +246,21 @@ const struct dpll_params dpll_ddr_evm_sk = {
const struct dpll_params dpll_ddr_bone_black = {
400, OSC-1, 1, -1, -1, -1, -1};
+#ifdef CONFIG_SPL_DFU
+int spl_run_dfu(void)
+{
+ int os_boot = 0;
+#ifdef CONFIG_SPL_DFU_SF
+ spl_dfu_cmd(0, "dfu_alt_info_qspi", "sf", "0:0:24000000:0");
+#endif
+#ifdef CONFIG_SPL_DFU_RAM
+ spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
+ spl_dfu_ram_load_image();
+ os_boot = 1;
+#endif
+ return os_boot;
+}
+#endif
void am33xx_spl_board_init(void)
{
int mpu_vdd;
diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
index 8b8432b..f2badb6 100644
--- a/common/spl/spl_dfu.c
+++ b/common/spl/spl_dfu.c
@@ -143,6 +143,7 @@ int spl_dfu_ram_load_image(void)
struct spl_load_info load;
debug("Found FIT\n");
load.priv = NULL;
+ load.bl_len = 1;
load.read = spl_fit_ram_read;
err = spl_load_simple_fit(&load, (ulong)filename, header);
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 1139526..558be7b 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -187,6 +187,9 @@
NETARGS \
DFUARGS \
BOOTENV
+#else
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ DFUARGS
#endif
/* NS16550 Configuration */
@@ -297,12 +300,14 @@
#define CONFIG_AM335X_USB1_MODE MUSB_HOST
#ifndef CONFIG_SPL_USBETH_SUPPORT
+#ifndef CONFIG_SPL_DFU
/* Fastboot */
#define CONFIG_USB_FUNCTION_FASTBOOT
#define CONFIG_CMD_FASTBOOT
#define CONFIG_ANDROID_BOOT_IMAGE
#define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR
#define CONFIG_FASTBOOT_BUF_SIZE 0x07000000
+#endif
/* To support eMMC booting */
#define CONFIG_STORAGE_EMMC
@@ -314,9 +319,11 @@
#endif
#ifdef CONFIG_USB_MUSB_GADGET
+#ifndef CONFIG_SPL_DFU
#define CONFIG_USB_ETHER
#define CONFIG_USB_ETH_RNDIS
#define CONFIG_USBNET_HOST_ADDR "de:ad:be:af:00:00"
+#endif
#endif /* CONFIG_USB_MUSB_GADGET */
/*
@@ -348,9 +355,9 @@
#endif
/* USB Device Firmware Update support */
-#ifndef CONFIG_SPL_BUILD
#define CONFIG_USB_FUNCTION_DFU
#define CONFIG_DFU_MMC
+#define CONFIG_DFU_RAM
#define DFU_ALT_INFO_MMC \
"dfu_alt_info_mmc=" \
"boot part 0 1;" \
@@ -364,6 +371,7 @@
"spl-os-image fat 0 1;" \
"u-boot.img fat 0 1;" \
"uEnv.txt fat 0 1\0"
+#ifndef CONFIG_SPL_DFU
#ifdef CONFIG_NAND
#define CONFIG_DFU_NAND
#define DFU_ALT_INFO_NAND \
@@ -379,17 +387,24 @@
#else
#define DFU_ALT_INFO_NAND ""
#endif
+#endif
#define CONFIG_DFU_RAM
#define DFU_ALT_INFO_RAM \
"dfu_alt_info_ram=" \
"kernel ram 0x80200000 0xD80000;" \
"fdt ram 0x80F80000 0x80000;" \
"ramdisk ram 0x81000000 0x4000000\0"
+#ifndef CONFIG_SPL_DFU
#define DFUARGS \
"dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \
DFU_ALT_INFO_MMC \
DFU_ALT_INFO_RAM \
DFU_ALT_INFO_NAND
+#else
+#define DFUARGS \
+ "dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \
+ DFU_ALT_INFO_MMC \
+ DFU_ALT_INFO_RAM
#endif
/*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x Ravi Babu
@ 2016-06-24 9:15 ` Lukasz Majewski
2016-06-24 9:29 ` B, Ravi
0 siblings, 1 reply; 19+ messages in thread
From: Lukasz Majewski @ 2016-06-24 9:15 UTC (permalink / raw)
To: u-boot
Hi Ravi,
> enable the SPL-DFU support for am335x platform.
>
> Signed-off-by: Ravi Babu <ravibabu@ti.com>
> ---
> Kconfig | 2 +-
> board/ti/am335x/board.c | 15 +++++++++++++++
> common/spl/spl_dfu.c | 1 +
> include/configs/am335x_evm.h | 17 ++++++++++++++++-
> 4 files changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/Kconfig b/Kconfig
> index 969641e..c4eb4bd 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -287,7 +287,7 @@ config SPL_LOAD_FIT
>
> config SPL_DFU
> bool "Enable SPL with DFU to load binaries to bootdevices
> using USB"
> - depends on USB && CMD_DFU && TARGET_DRA7XX_EVM
> + depends on USB && CMD_DFU && (TARGET_DRA7XX_EVM ||
Here also please remove not needed dependencies (CMD_DFU).
> TARGET_AM335X_EVM) help
> Currently the SPL does not have capability to load the
> binaries or boot images to boot devices like eMMC,SPI,etc.
> diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
> index 690c298..fe56004 100644
> --- a/board/ti/am335x/board.c
> +++ b/board/ti/am335x/board.c
> @@ -246,6 +246,21 @@ const struct dpll_params dpll_ddr_evm_sk = {
> const struct dpll_params dpll_ddr_bone_black = {
> 400, OSC-1, 1, -1, -1, -1, -1};
>
> +#ifdef CONFIG_SPL_DFU
> +int spl_run_dfu(void)
> +{
> + int os_boot = 0;
> +#ifdef CONFIG_SPL_DFU_SF
> + spl_dfu_cmd(0, "dfu_alt_info_qspi", "sf", "0:0:24000000:0");
^^^^^^^^^^^^^^^
the same comment as in
the previous patch.
Please replace this
magic value to
something more
descriptive.
> +#endif
> +#ifdef CONFIG_SPL_DFU_RAM
> + spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
> + spl_dfu_ram_load_image();
> + os_boot = 1;
> +#endif
> + return os_boot;
> +}
> +#endif
> void am33xx_spl_board_init(void)
> {
> int mpu_vdd;
> diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
> index 8b8432b..f2badb6 100644
> --- a/common/spl/spl_dfu.c
> +++ b/common/spl/spl_dfu.c
> @@ -143,6 +143,7 @@ int spl_dfu_ram_load_image(void)
> struct spl_load_info load;
> debug("Found FIT\n");
> load.priv = NULL;
> + load.bl_len = 1;
> load.read = spl_fit_ram_read;
>
> err = spl_load_simple_fit(&load, (ulong)filename,
> header); diff --git a/include/configs/am335x_evm.h
> b/include/configs/am335x_evm.h index 1139526..558be7b 100644
> --- a/include/configs/am335x_evm.h
> +++ b/include/configs/am335x_evm.h
> @@ -187,6 +187,9 @@
> NETARGS \
> DFUARGS \
> BOOTENV
> +#else
> +#define CONFIG_EXTRA_ENV_SETTINGS \
> + DFUARGS
> #endif
>
> /* NS16550 Configuration */
> @@ -297,12 +300,14 @@
> #define CONFIG_AM335X_USB1_MODE MUSB_HOST
>
> #ifndef CONFIG_SPL_USBETH_SUPPORT
> +#ifndef CONFIG_SPL_DFU
> /* Fastboot */
> #define CONFIG_USB_FUNCTION_FASTBOOT
> #define CONFIG_CMD_FASTBOOT
> #define CONFIG_ANDROID_BOOT_IMAGE
> #define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR
> #define CONFIG_FASTBOOT_BUF_SIZE 0x07000000
> +#endif
>
> /* To support eMMC booting */
> #define CONFIG_STORAGE_EMMC
> @@ -314,9 +319,11 @@
> #endif
>
> #ifdef CONFIG_USB_MUSB_GADGET
> +#ifndef CONFIG_SPL_DFU
> #define CONFIG_USB_ETHER
> #define CONFIG_USB_ETH_RNDIS
> #define CONFIG_USBNET_HOST_ADDR "de:ad:be:af:00:00"
> +#endif
> #endif /* CONFIG_USB_MUSB_GADGET */
>
> /*
> @@ -348,9 +355,9 @@
> #endif
>
> /* USB Device Firmware Update support */
> -#ifndef CONFIG_SPL_BUILD
> #define CONFIG_USB_FUNCTION_DFU
> #define CONFIG_DFU_MMC
> +#define CONFIG_DFU_RAM
> #define DFU_ALT_INFO_MMC \
> "dfu_alt_info_mmc=" \
> "boot part 0 1;" \
> @@ -364,6 +371,7 @@
> "spl-os-image fat 0 1;" \
> "u-boot.img fat 0 1;" \
> "uEnv.txt fat 0 1\0"
> +#ifndef CONFIG_SPL_DFU
> #ifdef CONFIG_NAND
> #define CONFIG_DFU_NAND
> #define DFU_ALT_INFO_NAND \
> @@ -379,17 +387,24 @@
> #else
> #define DFU_ALT_INFO_NAND ""
> #endif
> +#endif
> #define CONFIG_DFU_RAM
> #define DFU_ALT_INFO_RAM \
> "dfu_alt_info_ram=" \
> "kernel ram 0x80200000 0xD80000;" \
> "fdt ram 0x80F80000 0x80000;" \
> "ramdisk ram 0x81000000 0x4000000\0"
> +#ifndef CONFIG_SPL_DFU
> #define DFUARGS \
> "dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \
> DFU_ALT_INFO_MMC \
> DFU_ALT_INFO_RAM \
> DFU_ALT_INFO_NAND
> +#else
> +#define DFUARGS \
> + "dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \
> + DFU_ALT_INFO_MMC \
> + DFU_ALT_INFO_RAM
> #endif
>
> /*
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x
2016-06-24 9:15 ` Lukasz Majewski
@ 2016-06-24 9:29 ` B, Ravi
0 siblings, 0 replies; 19+ messages in thread
From: B, Ravi @ 2016-06-24 9:29 UTC (permalink / raw)
To: u-boot
Hi Lukasz
>>
>> config SPL_DFU
>> bool "Enable SPL with DFU to load binaries to bootdevices using USB"
>> - depends on USB && CMD_DFU && TARGET_DRA7XX_EVM
>> + depends on USB && CMD_DFU && (TARGET_DRA7XX_EVM ||
>Here also please remove not needed dependencies (CMD_DFU).
Ok. Will remove it.
>> TARGET_AM335X_EVM) help
>> Currently the SPL does not have capability to load the
>> binaries or boot images to boot devices like eMMC,SPI,etc.
>> diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index
Regards
Ravi
^ permalink raw reply [flat|nested] 19+ messages in thread
* [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL
2016-06-14 11:02 [U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL Ravi Babu
` (5 preceding siblings ...)
2016-06-14 11:02 ` [U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x Ravi Babu
@ 2016-06-21 8:39 ` B, Ravi
6 siblings, 0 replies; 19+ messages in thread
From: B, Ravi @ 2016-06-21 8:39 UTC (permalink / raw)
To: u-boot
Lukasz
Ping !!
Did you get time to look into these patches.
Regards
Ravi
-----Original Message-----
From: B, Ravi
Sent: Tuesday, June 14, 2016 4:32 PM
To: u-boot at lists.denx.de; l.majewski at samsung.com
Cc: trini at konsulko.com; marex at denx.de; B, Ravi
Subject: [RFC PATCH v1 0/6] SPL: DFU Support in SPL
Traditionally the DFU support is available only as part 2nd stage boot loader(u-boot) and DFU is not supported in SPL.
The SPL-DFU feature is useful for boards which has only USB inteface and do not have external interface like ethernet or MMC/SD to boot the board.
This feature enable DFU to be builtin part of SPL and boot the u-boot directly by loading u-boot image to RAM from PC using dfu-util.
This patch series adds DFU support in SPL to flash binary images to factory or bare-metal boards to memory devices like SPI, RAM, eMMC, MMC/SD card using USB interface.
As a reference, refer to application note [3] on SPL-DFU support based on 2014.07 u-boot.
steps for SPL-DFU/RAM:
1) Soc ROMcode loads the u-boot-spl.bin(+DFU) to IRAM from PC host via usb interface and execute DFU(RAM/SPI).
2) if DFU/RAM is selected, then load u-boot.img to RAM using dfu-util from PC-host.
3) After loading u-boot, press ctrl+c to exit to jump to u-boot. Once u-boot
steps for SPL-DFU/SPI:
1) Soc ROMcode loads the u-boot-spl.bin(+DFU) to IRAM from PC host via usb interface and execute DFU(RAM/SPI).
2) If DFU/SPI is selected, then load MLO/u-boot/kernel/dtb images directly to spi partitions.
Note: I could not find better option to isolate dfu source to include/exclude in Makefile when SPL-DFU feature enabled/disabled, please suggest any better option.
Tested on dra7xx SoCs family.
[1] is EVM console output with SPL-DFU/SPI enabled.
[2] is ubuntu host console output.
references:
[1] http://pastebin.ubuntu.com/16730701/
[2] http://pastebin.ubuntu.com/16730765/
[3] http://www.ti.com/lit/an/sprac33/sprac33.pdf
Ravi Babu (6):
spl: dfu: add dfu support in SPL
spl: dfu: adding dfu support functions for SPL-DFU
dfu: spl: add generic spl-dfu function in common-spl
dra7x: spl: dfu: adding SPL-DFU support for dra7x platform
dfu: spl: dra7x: enable SPL-dfu support for dra7x platform
dfu: spl: am335x: SPL-DFU support for am335x
Kconfig | 33 ++++++++
board/ti/am335x/board.c | 15 ++++
board/ti/dra7xx/evm.c | 17 ++++
common/Makefile | 26 +++++--
common/command.c | 2 +-
common/spl/Makefile | 1 +
common/spl/spl.c | 9 +++
common/spl/spl_dfu.c | 154 +++++++++++++++++++++++++++++++++++++
include/configs/am335x_evm.h | 17 +++-
include/configs/dra7xx_evm.h | 8 +-
include/configs/ti_omap5_common.h | 2 -
include/spl.h | 11 +++
scripts/Makefile.spl | 13 ++++
13 files changed, 293 insertions(+), 15 deletions(-) create mode 100644 common/spl/spl_dfu.c
--
1.7.9.5
^ permalink raw reply [flat|nested] 19+ messages in thread