[U-Boot] [PATCH v2 2/3] common: dfu: ignore reset for spl-dfu

2017-05-04 Thread Ravi Babu
The SPL-DFU feature enable to load and
execute u-boot from RAM over usb from
PC using dfu-util.
Hence dfu-reset should not be issued
when dfu-util -R switch is issued.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/dfu.c   | 2 +-
 common/spl/Kconfig | 4 
 drivers/dfu/dfu.c  | 4 
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/dfu.c b/common/dfu.c
index 0e9f5f5..546a1ab 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -88,7 +88,7 @@ exit:
board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE);
 
if (dfu_reset)
-   run_command("reset", 0);
+   do_reset(NULL, 0, 0, NULL);
 
g_dnl_clear_detach();
 
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 1231351..f51ae2c 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -6,6 +6,9 @@ config SUPPORT_SPL
 config SUPPORT_TPL
bool
 
+config SPL_DFU_NO_RESET
+   bool
+
 config SPL
bool
depends on SUPPORT_SPL
@@ -646,6 +649,7 @@ config SPL_USBETH_SUPPORT
 config SPL_DFU_SUPPORT
bool "Support DFU (Device Firmware Upgarde)"
select SPL_HASH_SUPPORT
+   select SPL_DFU_NO_RESET
depends on SPL_RAM_SUPPORT
help
  This feature enables the DFU (Device Firmware Upgarde) in SPL with
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 8dacc1a..ceb33e3 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -35,7 +35,11 @@ static struct hash_algo *dfu_hash_algo;
  */
 __weak bool dfu_usb_get_reset(void)
 {
+#ifdef CONFIG_SPL_DFU_NO_RESET
+   return false;
+#else
return true;
+#endif
 }
 
 static int dfu_find_alt_num(const char *s)
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 1/3] spl: Kconfig: dfu: spl-dfu depends on SPL_RAM_SUPPORT

2017-05-04 Thread Ravi Babu
Since SPL_DFU_SUPPORT is depends on SPL_RAM_SUPPORT,
hence select SPL_DFU_SUPPORT only when
SPL_RAM_SUPPORT is chosen.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ea6fbb6..1231351 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -646,6 +646,7 @@ config SPL_USBETH_SUPPORT
 config SPL_DFU_SUPPORT
bool "Support DFU (Device Firmware Upgarde)"
select SPL_HASH_SUPPORT
+   depends on SPL_RAM_SUPPORT
help
  This feature enables the DFU (Device Firmware Upgarde) in SPL with
  RAM memory device support. The ROM code will load and execute
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 3/3] spl: dfu: reduce spl-dfu MLO size

2017-05-04 Thread Ravi Babu
compile out cli_hush.c for spl/dfu and
use cli_simple_run_command for dfu to
reduce the spl-dfu memory foot print.

Adding CONFIG_SPL_DFU_MMC to Kconfig and
use CONFIG_IS_ENABLED(DFU_MMC).

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
---
 common/Makefile   | 1 -
 drivers/dfu/Kconfig   | 5 +
 drivers/dfu/Makefile  | 3 +++
 drivers/dfu/dfu_mmc.c | 5 +
 include/dfu.h | 2 +-
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 86225f1..6e90078 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -90,7 +90,6 @@ endif # !CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
-obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
index 56a98f5..99a0db1 100644
--- a/drivers/dfu/Kconfig
+++ b/drivers/dfu/Kconfig
@@ -17,6 +17,11 @@ config DFU_MMC
help
  This option enables using DFU to read and write to MMC based storage.
 
+config SPL_DFU_MMC
+   bool "MMC back end for SPL-DFU"
+   help
+ This option enables DFU for SPL to read and write to MMC based 
storage.
+
 config DFU_NAND
bool "NAND back end for DFU"
help
diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
index 61f2b71..7060908 100644
--- a/drivers/dfu/Makefile
+++ b/drivers/dfu/Makefile
@@ -6,7 +6,10 @@
 #
 
 obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o
+ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_DFU_MMC) += dfu_mmc.o
+endif
+obj-$(CONFIG_SPL_DFU_MMC) += dfu_mmc.o
 obj-$(CONFIG_DFU_NAND) += dfu_nand.o
 obj-$(CONFIG_DFU_RAM) += dfu_ram.o
 obj-$(CONFIG_DFU_SF) += dfu_sf.o
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 926ccbd..ba509db 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static unsigned char *dfu_file_buf;
 static long dfu_file_buf_len;
@@ -154,7 +155,11 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity 
*dfu,
 
debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
 
+#if CONFIG_IS_ENABLED(DFU_MMC)
+   ret = cli_simple_run_command(cmd_buf, 0);
+#else
ret = run_command(cmd_buf, 0);
+#endif
if (ret) {
puts("dfu: Read error!\n");
return ret;
diff --git a/include/dfu.h b/include/dfu.h
index f39d3f1..94d2a49 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -203,7 +203,7 @@ static inline void dfu_set_defer_flush(struct dfu_entity 
*dfu)
 int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size);
 
 /* Device specific */
-#ifdef CONFIG_DFU_MMC
+#if CONFIG_IS_ENABLED(DFU_MMC)
 extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s);
 #else
 static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 3/3] spl: dfu: reduce spl-dfu MLO size

2017-04-27 Thread Ravi Babu
Since spl-dfu does not dfu-reset, there is no need
of run_command_cli, hence compiling out cli.c and
cli_hush.c to reduce the spl-dfu memory foot print.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
need better way for how to compile out CONFIG_DFU_MMC

 common/Makefile  | 3 +--
 drivers/dfu/Makefile | 2 ++
 include/dfu.h| 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 86225f1..8976cbc 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -11,6 +11,7 @@ obj-y += init/
 obj-y += main.o
 obj-y += exports.o
 obj-y += hash.o
+obj-y += cli.o
 obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
 
@@ -90,7 +91,6 @@ endif # !CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
-obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
@@ -171,7 +171,6 @@ endif
 # We always have this since drivers/ddr/fs/interactive.c needs it
 obj-$(CONFIG_CMDLINE) += cli_simple.o
 
-obj-y += cli.o
 obj-$(CONFIG_CMDLINE) += cli_readline.o
 obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
index 61f2b71..5628734 100644
--- a/drivers/dfu/Makefile
+++ b/drivers/dfu/Makefile
@@ -6,7 +6,9 @@
 #
 
 obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o
+ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_DFU_MMC) += dfu_mmc.o
+endif
 obj-$(CONFIG_DFU_NAND) += dfu_nand.o
 obj-$(CONFIG_DFU_RAM) += dfu_ram.o
 obj-$(CONFIG_DFU_SF) += dfu_sf.o
diff --git a/include/dfu.h b/include/dfu.h
index f39d3f1..70eeaef 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -203,7 +203,7 @@ static inline void dfu_set_defer_flush(struct dfu_entity 
*dfu)
 int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size);
 
 /* Device specific */
-#ifdef CONFIG_DFU_MMC
+#if defined(CONFIG_DFU_MMC) && !defined(CONFIG_SPL_BUILD)
 extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s);
 #else
 static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/3] common: dfu: ignore reset for spl-dfu

2017-04-27 Thread Ravi Babu
The SPL-DFU feature enable to load and
execute u-boot over usb from PC using
dfu-util.
Hence dfu-reset should not be issued
when dfu-util -R switch is issued.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/dfu.c   | 2 +-
 common/spl/Kconfig | 4 
 drivers/dfu/dfu.c  | 4 
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/dfu.c b/common/dfu.c
index 0e9f5f5..546a1ab 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -88,7 +88,7 @@ exit:
board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE);
 
if (dfu_reset)
-   run_command("reset", 0);
+   do_reset(NULL, 0, 0, NULL);
 
g_dnl_clear_detach();
 
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 1231351..f51ae2c 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -6,6 +6,9 @@ config SUPPORT_SPL
 config SUPPORT_TPL
bool
 
+config SPL_DFU_NO_RESET
+   bool
+
 config SPL
bool
depends on SUPPORT_SPL
@@ -646,6 +649,7 @@ config SPL_USBETH_SUPPORT
 config SPL_DFU_SUPPORT
bool "Support DFU (Device Firmware Upgarde)"
select SPL_HASH_SUPPORT
+   select SPL_DFU_NO_RESET
depends on SPL_RAM_SUPPORT
help
  This feature enables the DFU (Device Firmware Upgarde) in SPL with
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 8dacc1a..ceb33e3 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -35,7 +35,11 @@ static struct hash_algo *dfu_hash_algo;
  */
 __weak bool dfu_usb_get_reset(void)
 {
+#ifdef CONFIG_SPL_DFU_NO_RESET
+   return false;
+#else
return true;
+#endif
 }
 
 static int dfu_find_alt_num(const char *s)
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/3] spl: Kconfig: dfu: spl-dfu depends on SPL_RAM_SUPPORT

2017-04-27 Thread Ravi Babu
Since SPL_DFU_SUPPORT is depends on SPL_RAM_SUPPORT,
hence select SPL_DFU_SUPPORT only when
SPL_RAM_SUPPORT is chosen.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ea6fbb6..1231351 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -646,6 +646,7 @@ config SPL_USBETH_SUPPORT
 config SPL_DFU_SUPPORT
bool "Support DFU (Device Firmware Upgarde)"
select SPL_HASH_SUPPORT
+   depends on SPL_RAM_SUPPORT
help
  This feature enables the DFU (Device Firmware Upgarde) in SPL with
  RAM memory device support. The ROM code will load and execute
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 0/3] spl: dfu: misc fixes and reduce MLO foot print

2017-04-27 Thread Ravi Babu
The patch series spl-dfu fixes includes
- select spl-dfu only spl-ram supported
- ignore the dfu-reset for spl-dfu
- reduce the spl-dfu MLO foot print

buildman ran for arm targets

Change history:

v1: 
- Kconfig fix for dfu-reset for SPL-DFU
- compile out CONFIG_DFU_MMC for SPL-DFU
  

Ravi Babu (3):
  spl: Kconfig: dfu: spl-dfu depends on SPL_RAM_SUPPORT
  common: dfu: ignore reset for spl-dfu
  spl: dfu: reduce spl-dfu MLO size

 common/Makefile  | 3 +--
 common/dfu.c | 2 +-
 common/spl/Kconfig   | 5 +
 drivers/dfu/Makefile | 2 ++
 drivers/dfu/dfu.c| 4 
 include/dfu.h| 2 +-
 6 files changed, 14 insertions(+), 4 deletions(-)

-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/3] common: dfu: ignore reset for spl-dfu

2017-04-26 Thread Ravi Babu
The SPL-DFU feature enable to load and
execute u-boot over usb from PC using
dfu-util.
Hence dfu-reset should not be issued
when dfu-util -R switch is issued.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/dfu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/dfu.c b/common/dfu.c
index 0e9f5f5..fa77526 100644
--- a/common/dfu.c
+++ b/common/dfu.c
@@ -87,6 +87,9 @@ exit:
g_dnl_unregister();
board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE);
 
+#ifdef CONFIG_SPL_BUILD
+   dfu_reset = 0;
+#endif
if (dfu_reset)
run_command("reset", 0);
 
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/3] spl: Kconfig: dfu: spl-dfu depends on SPL_RAM_SUPPORT

2017-04-26 Thread Ravi Babu
Since SPL_DFU_SUPPORT is depends on SPL_RAM_SUPPORT,
hence select SPL_DFU_SUPPORT only when
SPL_RAM_SUPPORT is chosen.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ea6fbb6..1231351 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -646,6 +646,7 @@ config SPL_USBETH_SUPPORT
 config SPL_DFU_SUPPORT
bool "Support DFU (Device Firmware Upgarde)"
select SPL_HASH_SUPPORT
+   depends on SPL_RAM_SUPPORT
help
  This feature enables the DFU (Device Firmware Upgarde) in SPL with
  RAM memory device support. The ROM code will load and execute
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 0/3] spl: dfu: misc fixes and reduce MLO foot print

2017-04-26 Thread Ravi Babu
The patch series spl-dfu fixes includes
- select spl-dfu only spl-ram supported
- ignore the dfu-reset for spl-dfu
- reduce the spl-dfu MLO foot print

buildman ran for arm targets

Ravi Babu (3):
  spl: Kconfig: dfu: spl-dfu depends on SPL_RAM_SUPPORT
  common: dfu: ignore reset for spl-dfu
  spl: dfu: reduce spl-dfu MLO size

 common/Makefile  | 3 +--
 common/dfu.c | 3 +++
 common/spl/Kconfig   | 1 +
 drivers/dfu/Makefile | 4 +++-
 include/dfu.h| 8 
 5 files changed, 12 insertions(+), 7 deletions(-)

-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/3] spl: dfu: reduce spl-dfu MLO size

2017-04-26 Thread Ravi Babu
Since spl-dfu does not dfu-reset, there is no need
of run_command_cli, hence compiling out cli.c and
cli_hush.c to reduce the spl-dfu memory foot print.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/Makefile  | 3 +--
 drivers/dfu/Makefile | 4 +++-
 include/dfu.h| 8 
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 86225f1..8976cbc 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -11,6 +11,7 @@ obj-y += init/
 obj-y += main.o
 obj-y += exports.o
 obj-y += hash.o
+obj-y += cli.o
 obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
 
@@ -90,7 +91,6 @@ endif # !CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
-obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
@@ -171,7 +171,6 @@ endif
 # We always have this since drivers/ddr/fs/interactive.c needs it
 obj-$(CONFIG_CMDLINE) += cli_simple.o
 
-obj-y += cli.o
 obj-$(CONFIG_CMDLINE) += cli_readline.o
 obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
index 61f2b71..ef48f36 100644
--- a/drivers/dfu/Makefile
+++ b/drivers/dfu/Makefile
@@ -6,8 +6,10 @@
 #
 
 obj-$(CONFIG_USB_FUNCTION_DFU) += dfu.o
+ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_DFU_MMC) += dfu_mmc.o
 obj-$(CONFIG_DFU_NAND) += dfu_nand.o
-obj-$(CONFIG_DFU_RAM) += dfu_ram.o
 obj-$(CONFIG_DFU_SF) += dfu_sf.o
 obj-$(CONFIG_DFU_TFTP) += dfu_tftp.o
+endif
+obj-$(CONFIG_DFU_RAM) += dfu_ram.o
diff --git a/include/dfu.h b/include/dfu.h
index f39d3f1..b53ae80 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -203,7 +203,7 @@ static inline void dfu_set_defer_flush(struct dfu_entity 
*dfu)
 int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size);
 
 /* Device specific */
-#ifdef CONFIG_DFU_MMC
+#if defined(CONFIG_DFU_MMC) && !defined(CONFIG_SPL_BUILD)
 extern int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s);
 #else
 static inline int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr,
@@ -214,7 +214,7 @@ static inline int dfu_fill_entity_mmc(struct dfu_entity 
*dfu, char *devstr,
 }
 #endif
 
-#ifdef CONFIG_DFU_NAND
+#if defined(CONFIG_DFU_NAND) && !defined(CONFIG_SPL_BUILD)
 extern int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr, char *s);
 #else
 static inline int dfu_fill_entity_nand(struct dfu_entity *dfu, char *devstr,
@@ -236,7 +236,7 @@ static inline int dfu_fill_entity_ram(struct dfu_entity 
*dfu, char *devstr,
 }
 #endif
 
-#ifdef CONFIG_DFU_SF
+#if defined(CONFIG_DFU_SF) && !defined(CONFIG_SPL_BUILD)
 extern int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s);
 #else
 static inline int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr,
@@ -260,7 +260,7 @@ static inline int dfu_fill_entity_sf(struct dfu_entity 
*dfu, char *devstr,
  *
  * @return 0 on success, otherwise error code
  */
-#ifdef CONFIG_DFU_TFTP
+#if defined(CONFIG_DFU_TFTP) && !defined(CONFIG_SPL_BUILD)
 int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len,
   char *interface, char *devstring);
 #else
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] spl: dfu: compilation fixes for spl-dfu

2017-04-18 Thread Ravi Babu
This patch fixes the compilation error
common/cli_hush.c:3349: undefined reference to 'realloc_simple'

The dfu uses run_command(), it is part of cli_hush.c
but defining CONFIG_HUSH_PARSER for spl-dfu causes
this compilation error.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/cli.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/cli.c b/common/cli.c
index a433ef2..5e0869b 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -28,7 +28,7 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 int run_command(const char *cmd, int flag)
 {
-#ifndef CONFIG_HUSH_PARSER
+#if defined(CONFIG_SPL_DFU_SUPPORT) || !defined(CONFIG_HUSH_PARSER)
/*
 * cli_run_command can return 0 or 1 for success, so clean up
 * its result.
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 5/5] boot: fdt: fixup the memory dt nodes falcon boot

2017-04-18 Thread Ravi Babu
In single stage bootmode or falcon boot mode,
the SPL shall update the memory dt nodes
spl_fixup_fdt() based on DDR configuration for
specific platform.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/spl/spl.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index f11b370..b9b1331 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -56,6 +57,14 @@ __weak int spl_start_uboot(void)
return 1;
 }
 
+/* weak default platform specific function to initialize
+ * dram banks
+ */
+__weak int dram_init_banksize(void)
+{
+   return 0;
+}
+
 /*
  * Weak default function for arch specific zImage check. Return zero
  * and fill start and end address if image is recognized.
@@ -66,6 +75,33 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end)
 }
 #endif
 
+void spl_fixup_fdt(void)
+{
+#if defined(CONFIG_SPL_OF_LIBFDT) && defined(CONFIG_SYS_SPL_ARGS_ADDR)
+   void *fdt_blob = (void *)CONFIG_SYS_SPL_ARGS_ADDR;
+   int err;
+
+   err = fdt_check_header(fdt_blob);
+   if (err < 0) {
+   printf("fdt_root: %s\n", fdt_strerror(err));
+   return;
+   }
+
+   /* fixup the memory dt node */
+   err = fdt_shrink_to_minimum(fdt_blob, 0);
+   if (err == 0) {
+   printf("spl: fdt_shrink_to_minimum err - %d\n", err);
+   return;
+   }
+
+   err = arch_fixup_fdt(fdt_blob);
+   if (err) {
+   printf("spl: arch_fixup_fdt err - %d\n", err);
+   return;
+   }
+#endif
+}
+
 /*
  * Weak default function for board specific cleanup/preparation before
  * Linux boot. Some boards/platforms might not need it, so just provide
@@ -323,6 +359,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
debug(">>spl:board_init_r()\n");
gd->bd = 
+#ifdef CONFIG_SPL_OS_BOOT
+   dram_init_banksize();
+#endif
 
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
@@ -361,6 +400,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 #ifdef CONFIG_SPL_OS_BOOT
case IH_OS_LINUX:
debug("Jumping to Linux\n");
+   spl_fixup_fdt();
spl_board_prepare_for_linux();
jump_to_image_linux(_image,
(void *)CONFIG_SYS_SPL_ARGS_ADDR);
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/5] qspi: dra7xx: enable qspi-boot for dra7x paltform

2017-04-18 Thread Ravi Babu
Enables qspi boot configuration for dra7xx platform.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 configs/dra7xx_evm_defconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index 42f87b3..c510146 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -59,6 +59,12 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm"
 CONFIG_DM=y
 CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_REGMAP=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
+CONFIG_SPL_OF_TRANSLATE=y
 # CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 4/5] spl: fdt: support for fdt fixup for falcon boot

2017-04-18 Thread Ravi Babu
Adding support for fdt fixup to update the
memory node in device tree for falcon boot.

This is needed for single stage or falcon
bootmode, to pass memory configuration to
kernel through DT memory node.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 arch/arm/lib/Makefile| 1 +
 arch/arm/lib/bootm-fdt.c | 7 ++-
 common/Makefile  | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 6e96cfb..53d4ed2 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 else
 obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
 obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
+obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 obj-$(CONFIG_$(SPL_)USE_ARCH_MEMSET) += memset.o
 obj-$(CONFIG_$(SPL_)USE_ARCH_MEMCPY) += memcpy.o
diff --git a/arch/arm/lib/bootm-fdt.c b/arch/arm/lib/bootm-fdt.c
index d84789c..eaa817b 100644
--- a/arch/arm/lib/bootm-fdt.c
+++ b/arch/arm/lib/bootm-fdt.c
@@ -27,8 +27,10 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int arch_fixup_fdt(void *blob)
 {
+   int ret = 0;
+#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_OF_LIBFDT)
bd_t *bd = gd->bd;
-   int bank, ret;
+   int bank;
u64 start[CONFIG_NR_DRAM_BANKS];
u64 size[CONFIG_NR_DRAM_BANKS];
 
@@ -42,9 +44,11 @@ int arch_fixup_fdt(void *blob)
 #endif
}
 
+#ifdef CONFIG_OF_LIBFDT
ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
if (ret)
return ret;
+#endif
 
 #ifdef CONFIG_ARMV8_SPIN_TABLE
ret = spin_table_update_dt(blob);
@@ -58,6 +62,7 @@ int arch_fixup_fdt(void *blob)
if (ret)
return ret;
 #endif
+#endif
 
return 0;
 }
diff --git a/common/Makefile b/common/Makefile
index 86225f1..bcd2486 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -95,7 +95,7 @@ obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
-obj-$(CONFIG_SPL_OF_TRANSLATE) += fdt_support.o
+obj-$(CONFIG_SPL_OF_LIBFDT) += fdt_support.o
 ifdef CONFIG_SPL_USB_HOST_SUPPORT
 obj-$(CONFIG_SPL_USB_SUPPORT) += usb.o usb_hub.o
 obj-$(CONFIG_USB_STORAGE) += usb_storage.o
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/5] arch: arm: omap: Declare size of ddr very early

2017-04-18 Thread Ravi Babu
From: Lokesh Vutla <lokeshvu...@ti.com>

Declare the size of ddr very early in spl, so that this can be
used to enable cache.

Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 arch/arm/mach-omap2/am33xx/board.c  | 4 
 arch/arm/mach-omap2/hwinit-common.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/arch/arm/mach-omap2/am33xx/board.c 
b/arch/arm/mach-omap2/am33xx/board.c
index 2bfc864..568f36f 100644
--- a/arch/arm/mach-omap2/am33xx/board.c
+++ b/arch/arm/mach-omap2/am33xx/board.c
@@ -327,6 +327,10 @@ void board_init_f(ulong dummy)
early_system_init();
board_early_init_f();
sdram_init();
+   /* dram_init must store complete ramsize in gd->ram_size */
+   gd->ram_size = get_ram_size(
+   (void *)CONFIG_SYS_SDRAM_BASE,
+   CONFIG_MAX_RAM_BANK_SIZE);
 }
 #endif
 
diff --git a/arch/arm/mach-omap2/hwinit-common.c 
b/arch/arm/mach-omap2/hwinit-common.c
index f317293..cac3274 100644
--- a/arch/arm/mach-omap2/hwinit-common.c
+++ b/arch/arm/mach-omap2/hwinit-common.c
@@ -171,6 +171,7 @@ void board_init_f(ulong dummy)
 #endif
/* For regular u-boot sdram_init() is called from dram_init() */
sdram_init();
+   gd->ram_size = omap_sdram_size();
 }
 #endif
 
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/5] spl: reorder the assignment of board info to global data

2017-04-18 Thread Ravi Babu
From: Lokesh Vutla <lokeshvu...@ti.com>

Move the assignment of board info to global data a bit early which is
safe,
so that ram details can be used to enable caches.

Signed-off-by: Lokesh Vutla <lokeshvu...@ti.com>
Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/spl/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index a3e73b8..f11b370 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -322,6 +322,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
struct spl_image_info spl_image;
 
debug(">>spl:board_init_r()\n");
+   gd->bd = 
 
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
@@ -383,7 +384,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
  */
 void preloader_console_init(void)
 {
-   gd->bd = 
gd->baudrate = CONFIG_BAUDRATE;
 
serial_init();  /* serial communications setup */
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 0/5] QSPI: Falcon or single stage boot mode support

2017-04-18 Thread Ravi Babu
This patch series fixes the Falcon or single stage boot mode
for dra7xx platform.

FDT fixup is added to update the memory DT node based
DDR configuration for specific platform. 

Test verfied on dra7xx paltforms.

Lokesh Vutla (2):
  spl: reorder the assignment of board info to global data
  arch: arm: omap: Declare size of ddr very early

Ravi Babu (3):
  qspi: dra7xx: enable qspi-boot for dra7x paltform
  spl: fdt: support for fdt fixup for falcon boot
  boot: fdt: fixup the memory dt nodes falcon boot

 arch/arm/lib/Makefile   |  1 +
 arch/arm/lib/bootm-fdt.c|  7 ++-
 arch/arm/mach-omap2/am33xx/board.c  |  4 
 arch/arm/mach-omap2/hwinit-common.c |  1 +
 common/Makefile |  2 +-
 common/spl/spl.c| 42 -
 configs/dra7xx_evm_defconfig|  6 ++
 7 files changed, 60 insertions(+), 3 deletions(-)

-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v1] spl: saveenv: adding saveenv support in SPL

2016-09-28 Thread Ravi Babu
By default saveenv option is not supported for SPL. This patch
enable the support for save environment variable for SPL build.

Enable save environment support in SPL after setenv. By default
the saveenv option is not provided in SPL, but some boards need
this support in 'Falcon' boot, where SPL need to boot from
different images based on environment variable set by OS. For
example OS may set "reboot_image" environment variable to
"recovery" inorder to boot recovery image by SPL. The SPL read
"reboot_image" and act accordingly and change the reboot_image
to default mode using setenv and save the environemnt.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Simon Glass <s...@chromium.org>


change in v1:
- dropped SUPPORT, use CONFIG_SPL_SAVEENV
- updates the comments in mmc_private.h

---
 common/spl/Kconfig| 13 +
 drivers/mmc/Makefile  |  1 +
 drivers/mmc/mmc_private.h |  7 +++
 lib/Makefile  |  1 +
 lib/hashtable.c   |  2 +-
 5 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 2a8ddbc..605cf66 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -163,6 +163,19 @@ config SPL_ENV_SUPPORT
  starting U-Boot first. Enabling this option will make getenv()
  and setenv() available in SPL.
 
+config SPL_SAVEENV
+   bool "Support save environment"
+   depends on SPL && SPL_ENV_SUPPORT
+   help
+ Enable save environment support in SPL after setenv. By default
+ the saveenv option is not provided in SPL, but some boards need
+ this support in 'Falcon' boot, where SPL need to boot from
+ different images based on environment variable set by OS. For
+ example OS may set "reboot_image" environment variable to
+ "recovery" inorder to boot recovery image by SPL. The SPL read
+ "reboot_image" and act accordingly and change the reboot_image
+ to default mode using setenv and save the environemnt.
+
 config SPL_ETH_SUPPORT
bool "Support Ethernet"
depends on SPL_ENV_SUPPORT
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 18351fb..d850758 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_ROCKCHIP_SDHCI) += rockchip_sdhci.o
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
+obj-$(CONFIG_SPL_SAVEENV) += mmc_write.o
 else
 obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
 endif
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 49ec022..d8b399e 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -28,8 +28,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, 
lbaint_t blkcnt,
void *dst);
 #endif
 
-#ifndef CONFIG_SPL_BUILD
-
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
 unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
 lbaint_t blkcnt);
 
@@ -41,9 +40,9 @@ ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, 
lbaint_t blkcnt,
 const void *src);
 #endif
 
-#else /* CONFIG_SPL_BUILD */
+#else /* CONFIG_SPL_BUILD and CONFIG_SPL_SAVEENV is not defined */
 
-/* SPL will never write or erase, declare dummies to reduce code size. */
+/* declare dummies to reduce code size. */
 
 #ifdef CONFIG_BLK
 static inline unsigned long mmc_berase(struct udevice *dev,
diff --git a/lib/Makefile b/lib/Makefile
index c81bfeb..e3383f4 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_$(SPL_)RSA) += rsa/
 obj-$(CONFIG_$(SPL_)SHA1) += sha1.o
 obj-$(CONFIG_$(SPL_)SHA256) += sha256.o
 
+obj-$(CONFIG_SPL_SAVEENV) += qsort.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/
 ifneq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy)
 obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 4e52b36..07c437c 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -477,11 +477,11 @@ int hdelete_r(const char *key, struct hsearch_data *htab, 
int flag)
return 1;
 }
 
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
 /*
  * hexport()
  */
 
-#ifndef CONFIG_SPL_BUILD
 /*
  * Export the data stored in the hash table in linearized form.
  *
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] spl: saveenv: adding saveenv support in SPL

2016-09-28 Thread Ravi Babu
By default saveenv option is not supported for SPL. This patch
enable the support for save environment variable for SPL build.

Enable save environment support in SPL after setenv. By default
the saveenv option is not provided in SPL, but some boards need
this support in 'Falcon' boot, where SPL need to boot from
different images based on environment variable set by OS. For
example OS may set "reboot_image" environment variable to
"recovery" inorder to boot recovery image by SPL. The SPL read
"reboot_image" and act accordingly and change the reboot_image
to default mode using setenv and save the environemnt.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Simon Glass <s...@chromium.org>
---
 common/spl/Kconfig| 13 +
 drivers/mmc/Makefile  |  1 +
 drivers/mmc/mmc_private.h |  3 +--
 lib/Makefile  |  1 +
 lib/hashtable.c   |  2 +-
 5 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 2a8ddbc..605cf66 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -163,6 +163,19 @@ config SPL_ENV_SUPPORT
  starting U-Boot first. Enabling this option will make getenv()
  and setenv() available in SPL.
 
+config SPL_SAVEENV
+   bool "Support save environment"
+   depends on SPL && SPL_ENV_SUPPORT
+   help
+ Enable save environment support in SPL after setenv. By default
+ the saveenv option is not provided in SPL, but some boards need
+ this support in 'Falcon' boot, where SPL need to boot from
+ different images based on environment variable set by OS. For
+ example OS may set "reboot_image" environment variable to
+ "recovery" inorder to boot recovery image by SPL. The SPL read
+ "reboot_image" and act accordingly and change the reboot_image
+ to default mode using setenv and save the environemnt.
+
 config SPL_ETH_SUPPORT
bool "Support Ethernet"
depends on SPL_ENV_SUPPORT
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 18351fb..d850758 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_ROCKCHIP_SDHCI) += rockchip_sdhci.o
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
+obj-$(CONFIG_SPL_SAVEENV) += mmc_write.o
 else
 obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
 endif
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 49ec022..e0c9849 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -28,8 +28,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, 
lbaint_t blkcnt,
void *dst);
 #endif
 
-#ifndef CONFIG_SPL_BUILD
-
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
 unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
 lbaint_t blkcnt);
 
diff --git a/lib/Makefile b/lib/Makefile
index c81bfeb..e3383f4 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_$(SPL_)RSA) += rsa/
 obj-$(CONFIG_$(SPL_)SHA1) += sha1.o
 obj-$(CONFIG_$(SPL_)SHA256) += sha256.o
 
+obj-$(CONFIG_SPL_SAVEENV) += qsort.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/
 ifneq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy)
 obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 4e52b36..07c437c 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -477,11 +477,11 @@ int hdelete_r(const char *key, struct hsearch_data *htab, 
int flag)
return 1;
 }
 
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
 /*
  * hexport()
  */
 
-#ifndef CONFIG_SPL_BUILD
 /*
  * Export the data stored in the hash table in linearized form.
  *
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] spl: saveenv: adding saveenv support in SPL

2016-09-27 Thread Ravi Babu
By default saveenv option is not supported for SPL. This patch
enable the support for save environment variable for SPL build.

Enable save environment support in SPL after setenv. By default
the saveenv option is not provided in SPL, but some boards need
this support in 'Falcon' boot, where SPL need to boot from
different images based on environment variable set by OS. For
example OS may set "reboot_image" environment variable to
"recovery" inorder to boot recovery image by SPL. The SPL read
"reboot_image" and act accordingly and change the reboot_image
to default mode using setenv and save the environemnt.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Simon Glass <s...@chromium.org>
---
 common/spl/Kconfig| 13 +
 drivers/mmc/Makefile  |  1 +
 drivers/mmc/mmc_private.h |  3 +--
 lib/Makefile  |  1 +
 lib/hashtable.c   |  2 +-
 5 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 2a8ddbc..605cf66 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -163,6 +163,19 @@ config SPL_ENV_SUPPORT
  starting U-Boot first. Enabling this option will make getenv()
  and setenv() available in SPL.
 
+config SPL_SAVEENV
+   bool "Support save environment"
+   depends on SPL && SPL_ENV_SUPPORT
+   help
+ Enable save environment support in SPL after setenv. By default
+ the saveenv option is not provided in SPL, but some boards need
+ this support in 'Falcon' boot, where SPL need to boot from
+ different images based on environment variable set by OS. For
+ example OS may set "reboot_image" environment variable to
+ "recovery" inorder to boot recovery image by SPL. The SPL read
+ "reboot_image" and act accordingly and change the reboot_image
+ to default mode using setenv and save the environemnt.
+
 config SPL_ETH_SUPPORT
bool "Support Ethernet"
depends on SPL_ENV_SUPPORT
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 18351fb..d850758 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_ROCKCHIP_SDHCI) += rockchip_sdhci.o
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
+obj-$(CONFIG_SPL_SAVEENV) += mmc_write.o
 else
 obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
 endif
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 49ec022..e0c9849 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -28,8 +28,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, 
lbaint_t blkcnt,
void *dst);
 #endif
 
-#ifndef CONFIG_SPL_BUILD
-
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
 unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
 lbaint_t blkcnt);
 
diff --git a/lib/Makefile b/lib/Makefile
index c81bfeb..e3383f4 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_$(SPL_)RSA) += rsa/
 obj-$(CONFIG_$(SPL_)SHA1) += sha1.o
 obj-$(CONFIG_$(SPL_)SHA256) += sha256.o
 
+obj-$(CONFIG_SPL_SAVEENV) += qsort.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/
 ifneq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy)
 obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 4e52b36..07c437c 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -477,11 +477,11 @@ int hdelete_r(const char *key, struct hsearch_data *htab, 
int flag)
return 1;
 }
 
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV))
 /*
  * hexport()
  */
 
-#ifndef CONFIG_SPL_BUILD
 /*
  * Export the data stored in the hash table in linearized form.
  *
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] spl: saveenv: adding saveenv support in SPL

2016-09-26 Thread Ravi Babu
By default saveenv option is not supported for SPL. This patch
enable the support for save environment variable for SPL build.

Enable save environment support in SPL after setenv. By default
the saveenv option is not provided in SPL, but some boards need
this support in 'Falcon' boot, where SPL need to boot from
different images based on environment variable set by OS. For
example OS may set "reboot_image" environment variable to
"recovery" inorder to boot recovery image by SPL. The SPL read
"reboot_image" and act accordingly and change the reboot_image
to default mode using setenv and save the environemnt.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/spl/Kconfig| 13 +
 drivers/mmc/Makefile  |  1 +
 drivers/mmc/mmc_private.h |  3 +--
 lib/Makefile  |  1 +
 lib/hashtable.c   |  2 +-
 5 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 2a8ddbc..0daa835 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -163,6 +163,19 @@ config SPL_ENV_SUPPORT
  starting U-Boot first. Enabling this option will make getenv()
  and setenv() available in SPL.
 
+config SPL_SAVEENV_SUPPORT
+   bool "Support save environment"
+   depends on SPL && SPL_ENV_SUPPORT
+   help
+ Enable save environment support in SPL after setenv. By default
+ the saveenv option is not provided in SPL, but some boards need
+ this support in 'Falcon' boot, where SPL need to boot from
+ different images based on environment variable set by OS. For
+ example OS may set "reboot_image" environment variable to
+ "recovery" inorder to boot recovery image by SPL. The SPL read
+ "reboot_image" and act accordingly and change the reboot_image
+ to default mode using setenv and save the environemnt.
+
 config SPL_ETH_SUPPORT
bool "Support Ethernet"
depends on SPL_ENV_SUPPORT
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 18351fb..cedce0a 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_ROCKCHIP_SDHCI) += rockchip_sdhci.o
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
+obj-$(CONFIG_SPL_SAVEENV_SUPPORT) += mmc_write.o
 else
 obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
 endif
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
index 49ec022..1a881ad 100644
--- a/drivers/mmc/mmc_private.h
+++ b/drivers/mmc/mmc_private.h
@@ -28,8 +28,7 @@ ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, 
lbaint_t blkcnt,
void *dst);
 #endif
 
-#ifndef CONFIG_SPL_BUILD
-
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV_SUPPORT))
 unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
 lbaint_t blkcnt);
 
diff --git a/lib/Makefile b/lib/Makefile
index c81bfeb..1590704 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_$(SPL_)RSA) += rsa/
 obj-$(CONFIG_$(SPL_)SHA1) += sha1.o
 obj-$(CONFIG_$(SPL_)SHA256) += sha256.o
 
+obj-$(CONFIG_SPL_SAVEENV_SUPPORT) += qsort.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/
 ifneq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy)
 obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 4e52b36..bdb54ca 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -477,11 +477,11 @@ int hdelete_r(const char *key, struct hsearch_data *htab, 
int flag)
return 1;
 }
 
+#if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV_SUPPORT))
 /*
  * hexport()
  */
 
-#ifndef CONFIG_SPL_BUILD
 /*
  * Export the data stored in the hash table in linearized form.
  *
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] env: tool: add command line option to input lockfile path

2016-09-26 Thread Ravi Babu
The default lockname is set to /var/lock. This limits the
usage of this application where OS uses different lockfile
location parameter.
For example, In case of android, the default lock
path location is /data.
Hence by providing the command line option to input lockfile
path will be useful to reuse the tool across multiple
operating system.

usage: ./fw_printenv -l 

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 tools/env/fw_env.h  |  1 +
 tools/env/fw_env_main.c | 35 +--
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/tools/env/fw_env.h b/tools/env/fw_env.h
index 436eca9..05588ab 100644
--- a/tools/env/fw_env.h
+++ b/tools/env/fw_env.h
@@ -63,6 +63,7 @@ struct env_opts {
 #endif
int aes_flag; /* Is AES encryption used? */
uint8_t aes_key[AES_KEY_LENGTH];
+   char *lockname;
 };
 
 int parse_aes_key(char *key, uint8_t *bin_key);
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index 7a17b28..443de36 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -46,6 +46,7 @@ static struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"script", required_argument, NULL, 's'},
{"noheader", required_argument, NULL, 'n'},
+   {"lock", required_argument, NULL, 'l'},
{NULL, 0, NULL, 0}
 };
 
@@ -72,6 +73,7 @@ void usage_printenv(void)
" -c, --config configuration file, default:" 
CONFIG_FILE "\n"
 #endif
" -n, --noheader   do not repeat variable name in output\n"
+   " -l, --lock   lock node, default:/var/lock\n"
"\n");
 }
 
@@ -88,6 +90,7 @@ void usage_setenv(void)
 #ifdef CONFIG_FILE
" -c, --config configuration file, default:" 
CONFIG_FILE "\n"
 #endif
+   " -l, --lock   lock node, default:/var/lock\n"
" -s, --script batch mode to minimize writes\n"
"\n"
"Examples:\n"
@@ -119,7 +122,7 @@ static void parse_common_args(int argc, char *argv[])
env_opts.config_file = CONFIG_FILE;
 #endif
 
-   while ((c = getopt_long(argc, argv, ":a:c:h", long_options, NULL)) !=
+   while ((c = getopt_long(argc, argv, ":a:c:l:h", long_options, NULL)) !=
   EOF) {
switch (c) {
case 'a':
@@ -134,6 +137,9 @@ static void parse_common_args(int argc, char *argv[])
env_opts.config_file = optarg;
break;
 #endif
+   case 'l':
+   env_opts.lockname = optarg;
+   break;
case 'h':
do_printenv ? usage_printenv() : usage_setenv();
exit(EXIT_SUCCESS);
@@ -155,8 +161,8 @@ int parse_printenv_args(int argc, char *argv[])
 
parse_common_args(argc, argv);
 
-   while ((c = getopt_long(argc, argv, "a:c:ns:h", long_options, NULL)) !=
-  EOF) {
+   while ((c = getopt_long(argc, argv, "a:c:ns:l:h", long_options, NULL))
+   != EOF) {
switch (c) {
case 'n':
noheader = 1;
@@ -164,6 +170,7 @@ int parse_printenv_args(int argc, char *argv[])
case 'a':
case 'c':
case 'h':
+   case 'l':
/* ignore common options */
break;
default: /* '?' */
@@ -181,8 +188,8 @@ int parse_setenv_args(int argc, char *argv[])
 
parse_common_args(argc, argv);
 
-   while ((c = getopt_long(argc, argv, "a:c:ns:h", long_options, NULL)) !=
-  EOF) {
+   while ((c = getopt_long(argc, argv, "a:c:ns:l:h", long_options, NULL))
+   != EOF) {
switch (c) {
case 's':
script_file = optarg;
@@ -190,6 +197,7 @@ int parse_setenv_args(int argc, char *argv[])
case 'a':
case 'c':
case 'h':
+   case 'l':
/* ignore common options */
break;
default: /* '?' */
@@ -203,7 +211,7 @@ int parse_setenv_args(int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
-   const char *lockname = "/var/lock/" CMD_PRINTENV ".lock";
+   char *lockname = "/var/lock/" CMD_PRINTENV ".lock";
int lockfd = -1;
int retval = EXIT_SUCCESS;
char *_cmdname;
@@ -235,6 +243,18 @@ int main(int argc, char *argv[])
argc -= optind;
argv += optind;
 
+   if (env_opts.lockname) {
+   lockname = malloc(sizeof(env_opts.lockname) +
+

[U-Boot] [PATCH] dra7x: dfu: qspi: increase the qspi spl partition to 256K

2016-09-26 Thread Ravi Babu
The SPL size for dra7x platform increased beyond 64K,
increasing the size to 256K to cater for future enhancement.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 include/configs/dra7xx_evm.h | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index 72daddf..827c1df 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -105,10 +105,7 @@
 
 #define DFU_ALT_INFO_QSPI \
"dfu_alt_info_qspi=" \
-   "MLO raw 0x0 0x01;" \
-   "MLO.backup1 raw 0x01 0x01;" \
-   "MLO.backup2 raw 0x02 0x01;" \
-   "MLO.backup3 raw 0x03 0x01;" \
+   "MLO raw 0x0 0x04;" \
"u-boot.img raw 0x04 0x010;" \
"u-boot-spl-os raw 0x14 0x08;" \
"u-boot-env raw 0x1C 0x01;" \
@@ -183,10 +180,7 @@
 
 /*
  * Default to using SPI for environment, etc.
- * 0x00 - 0x01 : QSPI.SPL (64KiB)
- * 0x01 - 0x02 : QSPI.SPL.backup1 (64KiB)
- * 0x02 - 0x03 : QSPI.SPL.backup2 (64KiB)
- * 0x03 - 0x04 : QSPI.SPL.backup3 (64KiB)
+ * 0x00 - 0x04 : QSPI.SPL (256KiB)
  * 0x04 - 0x14 : QSPI.u-boot (1MiB)
  * 0x14 - 0x1C : QSPI.u-boot-spl-os (512KiB)
  * 0x1C - 0x1D : QSPI.u-boot-env (64KiB)
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] dra7x: dfu: qspi: increase the qspi spl partition to 256K

2016-09-26 Thread Ravi Babu
The SPL size for dra7x platform increased beyond 64K,
increasing the size to 256K to cater for future enhancement.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 include/configs/dra7xx_evm.h | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index 72daddf..827c1df 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -105,10 +105,7 @@
 
 #define DFU_ALT_INFO_QSPI \
"dfu_alt_info_qspi=" \
-   "MLO raw 0x0 0x01;" \
-   "MLO.backup1 raw 0x01 0x01;" \
-   "MLO.backup2 raw 0x02 0x01;" \
-   "MLO.backup3 raw 0x03 0x01;" \
+   "MLO raw 0x0 0x04;" \
"u-boot.img raw 0x04 0x010;" \
"u-boot-spl-os raw 0x14 0x08;" \
"u-boot-env raw 0x1C 0x01;" \
@@ -183,10 +180,7 @@
 
 /*
  * Default to using SPI for environment, etc.
- * 0x00 - 0x01 : QSPI.SPL (64KiB)
- * 0x01 - 0x02 : QSPI.SPL.backup1 (64KiB)
- * 0x02 - 0x03 : QSPI.SPL.backup2 (64KiB)
- * 0x03 - 0x04 : QSPI.SPL.backup3 (64KiB)
+ * 0x00 - 0x04 : QSPI.SPL (256KiB)
  * 0x04 - 0x14 : QSPI.u-boot (1MiB)
  * 0x14 - 0x1C : QSPI.u-boot-spl-os (512KiB)
  * 0x1C - 0x1D : QSPI.u-boot-env (64KiB)
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] dra7xx: config: cleanup: moved to kconfig for CONFIG_SPL_ENV_SUPPORT

2016-09-26 Thread Ravi Babu
removing CONFIG_SPL_ENV_SUPPORT defined in header files
due to moved to kconfig option for CONFIG_SPL_ENV_SUPPORT

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 include/configs/dra7xx_evm.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index 0726875..72daddf 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -136,7 +136,6 @@
 #undef CONFIG_CMD_BOOTD
 #ifdef CONFIG_SPL_DFU_SUPPORT
 #define CONFIG_SPL_LOAD_FIT_ADDRESS 0x8020
-#define CONFIG_SPL_ENV_SUPPORT
 #define CONFIG_SPL_HASH_SUPPORT
 #define DFU_ALT_INFO_RAM \
"dfu_alt_info_ram=" \
-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC v1 PATCH] ARM7: Kconfig: cache: fix cacheline size based on arm type

2016-08-25 Thread Ravi Babu
The CONFIG_SYS_CACHELINE_SIZE is not defined for
some of the platforms due to which buildman iill
fail for these platforms.

Fixing this issue in generic way in Kconfig by
selecting cacheline size based on arm processor type.

This patch is based on linux kernel commit 5637a126

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Lukasz Majewski <l.majew...@samsung.com>
---
 arch/arm/Kconfig |   11 +++
 arch/arm/include/asm/armv7.h |1 +
 arch/arm/include/asm/cache.h |5 +
 3 files changed, 17 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index aef901c..776d3b7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -42,6 +42,17 @@ config CPU_V7
 select HAS_VBAR
 select HAS_THUMB2
 
+config ARM_L1_CACHE_SHIFT_6
+bool
+default y if CPU_V7
+help
+  Setting ARM L1 cache line size to 64 Bytes.
+
+config ARM_L1_CACHE_SHIFT
+int
+default 6 if ARM_L1_CACHE_SHIFT_6
+default 5
+
 config CPU_V7M
bool
 select HAS_THUMB2
diff --git a/arch/arm/include/asm/armv7.h b/arch/arm/include/asm/armv7.h
index a20702e..fb3b59b 100644
--- a/arch/arm/include/asm/armv7.h
+++ b/arch/arm/include/asm/armv7.h
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * Workaround for ARM errata # 798870
diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
index 16e65c3..7c57422 100644
--- a/arch/arm/include/asm/cache.h
+++ b/arch/arm/include/asm/cache.h
@@ -47,6 +47,11 @@ void dram_bank_mmu_setup(int bank);
  * use that value for aligning DMA buffers unless the board config has 
specified
  * an alternate cache line size.
  */
+#define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
+#ifndef CONFIG_SYS_CACHELINE_SIZE
+#define CONFIG_SYS_CACHELINE_SIZE   (1 << L1_CACHE_SHIFT)
+#endif
+
 #ifdef CONFIG_SYS_CACHELINE_SIZE
 #define ARCH_DMA_MINALIGN  CONFIG_SYS_CACHELINE_SIZE
 #else
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v3 4/5] dra7x: boot: add dfu bootmode support

2016-07-28 Thread Ravi Babu
This patch enables the DFU boot mode support
for dra7x platform.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 arch/arm/cpu/armv7/omap-common/boot-common.c |5 +
 arch/arm/include/asm/arch-omap5/spl.h|2 +-
 common/spl/spl.c |   10 +-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c 
b/arch/arm/cpu/armv7/omap-common/boot-common.c
index 60c367a..385310b 100644
--- a/arch/arm/cpu/armv7/omap-common/boot-common.c
+++ b/arch/arm/cpu/armv7/omap-common/boot-common.c
@@ -91,6 +91,11 @@ void save_omap_boot_params(void)
sys_boot_device = 1;
break;
 #endif
+#if defined(BOOT_DEVICE_DFU) && !defined(CONFIG_SPL_DFU_SUPPORT)
+   case BOOT_DEVICE_DFU:
+   sys_boot_device = 1;
+   break;
+#endif
}
 
if (sys_boot_device) {
diff --git a/arch/arm/include/asm/arch-omap5/spl.h 
b/arch/arm/include/asm/arch-omap5/spl.h
index 468ff5a..3582880 100644
--- a/arch/arm/include/asm/arch-omap5/spl.h
+++ b/arch/arm/include/asm/arch-omap5/spl.h
@@ -20,7 +20,7 @@
 #define BOOT_DEVICE_QSPI_1 0x0A
 #define BOOT_DEVICE_QSPI_4 0x0B
 #define BOOT_DEVICE_UART   0x43
-#define BOOT_DEVICE_USB0x45
+#define BOOT_DEVICE_DFU0x45
 
 #define MMC_BOOT_DEVICES_START BOOT_DEVICE_MMC1
 #define MMC_BOOT_DEVICES_END   BOOT_DEVICE_MMC2_2
diff --git a/common/spl/spl.c b/common/spl/spl.c
index b7ec333..02e6abb 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -171,7 +171,7 @@ __weak void __noreturn jump_to_image_no_args(struct 
spl_image_info *spl_image)
 # define CONFIG_SPL_LOAD_FIT_ADDRESS   0
 #endif
 
-#ifdef CONFIG_SPL_RAM_DEVICE
+#if defined(CONFIG_SPL_RAM_DEVICE) || defined(CONFIG_SPL_DFU_SUPPORT)
 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
   ulong count, void *buf)
 {
@@ -309,6 +309,9 @@ struct boot_device_name boot_name_table[] = {
 #ifdef CONFIG_SPL_USB_SUPPORT
{ BOOT_DEVICE_USB, "USB" },
 #endif
+#ifdef CONFIG_SPL_DFU_SUPPORT
+   { BOOT_DEVICE_DFU, "USB DFU" },
+#endif
 #ifdef CONFIG_SPL_SATA_SUPPORT
{ BOOT_DEVICE_SATA, "SATA" },
 #endif
@@ -395,6 +398,11 @@ static int spl_load_image(u32 boot_device)
case BOOT_DEVICE_USB:
return spl_usb_load_image();
 #endif
+#ifdef CONFIG_SPL_DFU_SUPPORT
+   case BOOT_DEVICE_DFU:
+   spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
+   return spl_ram_load_image();
+#endif
 #ifdef CONFIG_SPL_SATA_SUPPORT
case BOOT_DEVICE_SATA:
return spl_sata_load_image();
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v3 5/5] dra7x: configs: enable SPL-DFU support

2016-07-28 Thread Ravi Babu
This patch enables the SPL-DFU support for
dra7x platform.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 include/configs/dra7xx_evm.h  |   20 +++-
 include/configs/ti_omap5_common.h |2 --
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index 0d51aeb..4f0f895 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -133,6 +133,23 @@
 #define CONFIG_FASTBOOT_FLASH_MMC_DEV   1
 #endif
 
+#ifdef CONFIG_SPL_BUILD
+#undef CONFIG_CMD_BOOTD
+#ifdef CONFIG_SPL_DFU_SUPPORT
+#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x8020
+#define CONFIG_SPL_ENV_SUPPORT
+#define CONFIG_SPL_HASH_SUPPORT
+#define DFU_ALT_INFO_RAM \
+   "dfu_alt_info_ram=" \
+   "kernel ram 0x8020 0x400;" \
+   "fdt ram 0x80f8 0x8;" \
+   "ramdisk ram 0x8100 0x400\0"
+#define DFUARGS \
+   "dfu_bufsiz=0x1\0" \
+   DFU_ALT_INFO_RAM
+#endif
+#endif
+
 #include 
 
 /* Enhance our eMMC support / experience. */
@@ -222,9 +239,10 @@
 #define CONFIG_USB_FUNCTION_DFU
 #define CONFIG_DFU_RAM
 
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_DFU_MMC
-#define CONFIG_DFU_RAM
 #define CONFIG_DFU_SF
+#endif
 
 /* SATA */
 #define CONFIG_BOARD_LATE_INIT
diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index 3589cdc..2079b9f 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 \
@@ -130,7 +129,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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v3 3/5] spl: dfu: adding dfu support functions for SPL-DFU

2016-07-28 Thread Ravi Babu
Adding support functions to run dfu spl commands.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 common/spl/Makefile  |1 +
 common/spl/spl_dfu.c |   57 ++
 include/spl.h|8 +++
 3 files changed, 66 insertions(+)
 create mode 100644 common/spl/spl_dfu.c

diff --git a/common/spl/Makefile b/common/spl/Makefile
index b15f0f6..5bd0b18 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -24,4 +24,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_SUPPORT) += spl_dfu.o
 endif
diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
new file mode 100644
index 000..e8d0ba1
--- /dev/null
+++ b/common/spl/spl_dfu.c
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2016
+ * Texas Instruments, 
+ *
+ * Ravi B <ravib...@ti.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int run_dfu(int usb_index, char *interface, char *devstring)
+{
+   int ret;
+
+   ret = dfu_init_env_entities(interface, devstring);
+   if (ret) {
+   dfu_free_entities();
+   goto exit;
+   }
+
+   run_usb_dnl_gadget(usb_index, "usb_dnl_dfu");
+exit:
+   dfu_free_entities();
+   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);
+}
diff --git a/include/spl.h b/include/spl.h
index 8afa085..30eda36 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -144,4 +144,12 @@ void spl_board_init(void);
  */
 bool spl_was_boot_source(void);
 
+/**
+ * spl_dfu_cmd- 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_cmd(int usbctrl, char *dfu_alt_info, char *interface, char 
*devstr);
 #endif
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v3 2/5] common: dfu: saperate the dfu common functionality

2016-07-28 Thread Ravi Babu
The cmd_dfu functionality is been used by both SPL and
u-boot, saperating the core dfu functionality moving
it to common/dfu.c.

Signed-off-by: Ravi Babu <ravib...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 cmd/dfu.c   |   61 ++
 common/Makefile |2 ++
 common/dfu.c|   87 +++
 include/g_dnl.h |1 +
 4 files changed, 92 insertions(+), 59 deletions(-)
 create mode 100644 common/dfu.c

diff --git a/cmd/dfu.c b/cmd/dfu.c
index d8aae26..04291f6 100644
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -21,7 +21,6 @@
 
 static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-   bool dfu_reset = false;
 
if (argc < 4)
return CMD_RET_USAGE;
@@ -30,7 +29,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
char *interface = argv[2];
char *devstring = argv[3];
 
-   int ret, i = 0;
+   int ret;
 #ifdef CONFIG_DFU_TFTP
unsigned long addr = 0;
if (!strcmp(argv[1], "tftp")) {
@@ -52,67 +51,11 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
}
 
int controller_index = simple_strtoul(usb_controller, NULL, 0);
-   board_usb_init(controller_index, USB_INIT_DEVICE);
-   g_dnl_clear_detach();
-   g_dnl_register("usb_dnl_dfu");
-   while (1) {
-   if (g_dnl_detach()) {
-   /*
-* Check if USB bus reset is performed after detach,
-* which indicates that -R switch has been passed to
-* dfu-util. In this case reboot the device
-*/
-   if (dfu_usb_get_reset()) {
-   dfu_reset = true;
-   goto exit;
-   }
 
-   /*
-* This extra number of usb_gadget_handle_interrupts()
-* calls is necessary to assure correct transmission
-* completion with dfu-util
-*/
-   if (++i == 1)
-   goto exit;
-   }
+   run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
 
-   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(controller_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(controller_index);
-   }
-exit:
-   g_dnl_unregister();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
 done:
dfu_free_entities();
-
-   if (dfu_reset)
-   run_command("reset", 0);
-
-   g_dnl_clear_detach();
-
return ret;
 }
 
diff --git a/common/Makefile b/common/Makefile
index 7a7a1b4..83bd3f4 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 endif # !CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
 obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
@@ -160,6 +161,7 @@ obj-$(CONFIG_CMDLINE) += cli_simple.o
 
 obj-y += cli.o
 obj-$(CONFIG_CMDLINE) += cli_readline.o
+obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o
diff --git a/common/dfu.c b/common/dfu.c
new file mode 100644
index 000..14b60f1
--- /dev/null
+++ b/common/dfu.c
@@ -0,0 +1,87 @@
+/*
+ * dfu.c -- dfu command
+ *
+ * Copyright (C) 2015
+ * Lukasz Majewski <l.majew...@majess.pl>
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * authors: Andrzej Pietrasiewicz <andrze...@samsung.com>
+ * Lukasz Majewski <l.majew...@samsung.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 

[U-Boot] [RFC PATCH v3 1/5] spl: dfu: add dfu support in SPL

2016-07-28 Thread Ravi Babu
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
does not have MMC/SD, ethernet boot mechanism
to boot the board and only has USB inteface.

This patch add DFU support in SPL with RAM
memory device support to load and execute u-boot.
And then leverage full functionality DFU in
u-boot 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 <ravib...@ti.com>
Reviewed-by: Tom Rini <tr...@konsulko.com>
---
 Kconfig  |   27 +++
 common/Makefile  |1 +
 scripts/Makefile.spl |4 
 3 files changed, 32 insertions(+)

diff --git a/Kconfig b/Kconfig
index ef12f9f..dce9800 100644
--- a/Kconfig
+++ b/Kconfig
@@ -336,6 +336,33 @@ config SPL_FIT_IMAGE_POST_PROCESS
  injected into the FIT creation (i.e. the blobs would have been pre-
  processed before being added to the FIT image).
 
+config SPL_DFU_SUPPORT
+   bool "Enable SPL with DFU to load binaries to memory device"
+   depends on USB
+   help
+ Currently the SPL does not have capability to load the
+ binaries or boot images to boot devices like ram,eMMC,SPI,etc.
+ This feature enables the DFU (Device Firmware Upgarde) in SPL with
+ RAM memory device support. The ROM code will load and execute
+ the SPL built with dfu. The user can load binaries (u-boot/kernel) to
+ selected 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 SPL_DFU_SUPPORT
+
+config SPL_DFU_RAM
+   bool "RAM device"
+   depends on SPL_DFU_SUPPORT
+   help
+select RAM/DDR memory device for loading binary images
+(u-boot/kernel) to the selected device partition using
+DFU and execute the u-boot/kernel from RAM.
+
+endchoice
+
 config SYS_CLK_FREQ
depends on ARC || ARCH_SUNXI
int "CPU clock frequency"
diff --git a/common/Makefile b/common/Makefile
index e08cd3e..7a7a1b4 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 endif # !CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 3ba9742..3b70c4d 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -57,6 +57,10 @@ libs-y += common/init/
 libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/
 libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
 libs-y += drivers/
+libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/dfu/
+libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/gadget/
+libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/gadget/udc/
+libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/dwc3/
 libs-y += dts/
 libs-y += fs/
 libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v3 0/5] SPL: DFU Support in SPL

2016-07-28 Thread Ravi Babu
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
does not have MMC/SD, ethernet boot mechanism
to boot the board and only has USB inteface.

This patch add DFU support in SPL with RAM
memory device support to load and execute u-boot
from PC over USB interface. And then leverage
full functional feature of DFU in u-boot to
flash boot inital binary images to factory or
bare-metal boards to memory devices like SPI,
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 to build SPL-DFU/RAM:
This SPL-DFU support can be enabled through
Menuconfig->Boot Images->Enable SPL-DFU support
1) Soc ROMcode loads the u-boot-spl.bin(+DFU) to IRAM 
from PC host via usb interface and execute DFU.
2) Then load u-boot.img to RAM using dfu-util from PC-host
with -R switch to boot u-boot.
#sudo dfu-util -c 1 -i 0 -a 0 -D u-boot.img -R

Note:
On latest mainline u-boot usb fails,
need patch [4],[5] to test dfu.

Tested on dra7xx SoCs family.
[1] is EVM console output with SPL-DFU/RAM enabled.
[2] is ubuntu host console output.

references:
[1] http://pastebin.ubuntu.com/21264490/
[2] http://pastebin.ubuntu.com/21264638/
[3] http://www.ti.com/lit/an/sprac33/sprac33.pdf
[4] https://patchwork.ozlabs.org/patch/651146/
[5] http://pastebin.ubuntu.com/21264233/

v3 changes:
- minor v2 review comments fixed.
- Kconfig SPL/DFU selection made generic.
- unselect CONFIG_CMD_BOOTD for SPL

v1/v2 changes : 
- support for DFU RAM device only .
- removed support for other SPI flash devices
- SPL+DFU loads and execute u-boot and leaverage
  u-boot dfu functionality to flash binaries to
  SPI, eMMC etc.
- saperated the common dfu code used by SPL and
  u-boot to common/dfu.c

Ravi Babu (5):
  spl: dfu: add dfu support in SPL
  common: dfu: saperate the dfu common functionality
  spl: dfu: adding dfu support functions for SPL-DFU
  dra7x: boot: add dfu bootmode support
  dra7x: configs: enable SPL-DFU support

 Kconfig  |   27 
 arch/arm/cpu/armv7/omap-common/boot-common.c |5 ++
 arch/arm/include/asm/arch-omap5/spl.h|2 +-
 cmd/dfu.c|   61 +-
 common/Makefile  |3 +
 common/dfu.c |   87 ++
 common/spl/Makefile  |1 +
 common/spl/spl.c |   10 ++-
 common/spl/spl_dfu.c |   57 +
 include/configs/dra7xx_evm.h |   20 +-
 include/configs/ti_omap5_common.h|2 -
 include/g_dnl.h  |1 +
 include/spl.h|8 +++
 scripts/Makefile.spl |4 ++
 14 files changed, 224 insertions(+), 64 deletions(-)
 create mode 100644 common/dfu.c
 create mode 100644 common/spl/spl_dfu.c

-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] Kconfig: dra7x: Kconfig based PHYS_64BIT select based on Soc type

2016-07-26 Thread Ravi Babu
Moving CONFIG_PHYS_64BIT selection to Kconfig based on
Soc/board type chosen.

This fixes the usb crash observed due to phy_addr_t size
mismatch which is causing the wrong offset calculation
for dwc3 structure members and leads to crash.

The phy_addr_t size is depends on CONFIG_PHYS_64BIT either
8bytes or 4 bytes. Due to non-inclusion of common.h or
config.h in some of dwc3 source files, the phy_addr_t size
was different, which leads wrong offset code generation
and leading to crash.

The issue is noticed due to commit [1]. But the right
fix would be select CONFIG_PHYS_64BIT based on Soc type
at Kconfig, so it will apply across all source files.

[1] commit 95ebc253e6d4a3370e3dab14743bfc99fcd9cf1b
types.h: move and redefine resource_size_t

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 arch/arm/cpu/armv7/omap5/Kconfig |1 +
 include/configs/dra7xx_evm.h |1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv7/omap5/Kconfig b/arch/arm/cpu/armv7/omap5/Kconfig
index 4fb5ef9..a8600b1 100644
--- a/arch/arm/cpu/armv7/omap5/Kconfig
+++ b/arch/arm/cpu/armv7/omap5/Kconfig
@@ -13,6 +13,7 @@ config TARGET_OMAP5_UEVM
 config TARGET_DRA7XX_EVM
bool "TI DRA7XX"
select TI_I2C_BOARD_DETECT
+   select PHYS_64BIT
 
 config TARGET_AM57XX_EVM
bool "AM57XX"
diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index a11a923..5114104 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -20,7 +20,6 @@
 #endif
 
 #define CONFIG_VERY_BIG_RAM
-#define CONFIG_PHYS_64BIT
 #define CONFIG_NR_DRAM_BANKS   2
 #define CONFIG_MAX_MEM_MAPPED  0x8000
 
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v2 0/5] SPL: DFU Support in SPL

2016-07-21 Thread Ravi Babu
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
does not have MMC/SD, ethernet boot mechanism
to boot the board and only has USB inteface.

This patch add DFU support in SPL with RAM
memory device support to load and execute u-boot 
from PC over USB interface. And then leverage
full functional feature of DFU in u-boot to
flash boot inital binary images to factory or
bare-metal boards to memory devices like SPI,
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 to build SPL-DFU/RAM:
This SPL-DFU support can be enabled through
Menuconfig->Boot Images->Enable SPL-DFU support
1) Soc ROMcode loads the u-boot-spl.bin(+DFU) to IRAM 
from PC host via usb interface and execute DFU.
2) Then load u-boot.img to RAM using dfu-util from PC-host
with -R switch to boot u-boot.
#sudo dfu-util -c 1 -i 0 -a 0 -D u-boot.img -R

Note: 
On latest u-boot usb fails, need patch [4] to test dfu.

Tested on dra7xx SoCs family.
[1] is EVM console output with SPL-DFU/RAM enabled.
[2] is ubuntu host console output.

references:
[1] http://pastebin.ubuntu.com/20312940/
[2] http://pastebin.ubuntu.com/20313150/
[3] http://www.ti.com/lit/an/sprac33/sprac33.pdf
[4] https://patchwork.ozlabs.org/patch/651146/

v1 changes : 
- support for DFU RAM device only .
- removed support for other SPI flash devices
- SPL+DFU loads and execute u-boot and leaverage
  u-boot dfu functionality to flash binaries to
  SPI, eMMC etc.
- saperated the common dfu code used by SPL and
  u-boot to common/dfu.c

Ravi Babu (5):
  spl: dfu: add dfu support in SPL
  common: dfu: saperate the dfu common functionality
  spl: dfu: adding dfu support functions for SPL-DFU
  dra7x: boot: add dfu bootmode support
  dra7x: configs: enable SPL-DFU support

 Kconfig  |   27 
 arch/arm/cpu/armv7/omap-common/boot-common.c |5 ++
 arch/arm/include/asm/arch-omap5/spl.h|2 +-
 cmd/dfu.c|   61 +-
 common/Makefile  |3 +
 common/command.c |2 +-
 common/dfu.c |   88 ++
 common/spl/Makefile  |1 +
 common/spl/spl.c |   10 ++-
 common/spl/spl_dfu.c |   57 +
 include/configs/dra7xx_evm.h |   19 +-
 include/configs/ti_omap5_common.h|2 -
 include/g_dnl.h  |1 +
 include/spl.h|8 +++
 scripts/Makefile.spl |4 ++
 15 files changed, 225 insertions(+), 65 deletions(-)
 create mode 100644 common/dfu.c
 create mode 100644 common/spl/spl_dfu.c

-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v2 4/5] dra7x: boot: add dfu bootmode support

2016-07-21 Thread Ravi Babu
This patch enables the DFU boot mode support
for dra7x platform.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 arch/arm/cpu/armv7/omap-common/boot-common.c |5 +
 arch/arm/include/asm/arch-omap5/spl.h|2 +-
 common/spl/spl.c |   10 +-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c 
b/arch/arm/cpu/armv7/omap-common/boot-common.c
index 60c367a..385310b 100644
--- a/arch/arm/cpu/armv7/omap-common/boot-common.c
+++ b/arch/arm/cpu/armv7/omap-common/boot-common.c
@@ -91,6 +91,11 @@ void save_omap_boot_params(void)
sys_boot_device = 1;
break;
 #endif
+#if defined(BOOT_DEVICE_DFU) && !defined(CONFIG_SPL_DFU_SUPPORT)
+   case BOOT_DEVICE_DFU:
+   sys_boot_device = 1;
+   break;
+#endif
}
 
if (sys_boot_device) {
diff --git a/arch/arm/include/asm/arch-omap5/spl.h 
b/arch/arm/include/asm/arch-omap5/spl.h
index 468ff5a..3582880 100644
--- a/arch/arm/include/asm/arch-omap5/spl.h
+++ b/arch/arm/include/asm/arch-omap5/spl.h
@@ -20,7 +20,7 @@
 #define BOOT_DEVICE_QSPI_1 0x0A
 #define BOOT_DEVICE_QSPI_4 0x0B
 #define BOOT_DEVICE_UART   0x43
-#define BOOT_DEVICE_USB0x45
+#define BOOT_DEVICE_DFU0x45
 
 #define MMC_BOOT_DEVICES_START BOOT_DEVICE_MMC1
 #define MMC_BOOT_DEVICES_END   BOOT_DEVICE_MMC2_2
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 14320fe..f82e848 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -148,7 +148,7 @@ __weak void __noreturn jump_to_image_no_args(struct 
spl_image_info *spl_image)
 # define CONFIG_SPL_LOAD_FIT_ADDRESS   0
 #endif
 
-#ifdef CONFIG_SPL_RAM_DEVICE
+#if defined(CONFIG_SPL_RAM_DEVICE) || defined(CONFIG_SPL_DFU_SUPPORT)
 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
   ulong count, void *buf)
 {
@@ -286,6 +286,9 @@ struct boot_device_name boot_name_table[] = {
 #ifdef CONFIG_SPL_USB_SUPPORT
{ BOOT_DEVICE_USB, "USB" },
 #endif
+#ifdef CONFIG_SPL_DFU_SUPPORT
+   { BOOT_DEVICE_DFU, "USB DFU" },
+#endif
 #ifdef CONFIG_SPL_SATA_SUPPORT
{ BOOT_DEVICE_SATA, "SATA" },
 #endif
@@ -366,6 +369,11 @@ static int spl_load_image(u32 boot_device)
case BOOT_DEVICE_USB:
return spl_usb_load_image();
 #endif
+#ifdef CONFIG_SPL_DFU_SUPPORT
+   case BOOT_DEVICE_DFU:
+   spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
+   return spl_ram_load_image();
+#endif
 #ifdef CONFIG_SPL_SATA_SUPPORT
case BOOT_DEVICE_SATA:
return spl_sata_load_image();
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v2 1/5] spl: dfu: add dfu support in SPL

2016-07-21 Thread Ravi Babu
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
does not have MMC/SD, ethernet boot mechanism
to boot the board and only has USB inteface.

This patch add DFU support in SPL with RAM
memory device support to load and execute u-boot.
And then leverage full functionality DFU in
u-boot 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 <ravib...@ti.com>
---
 Kconfig  |   27 +++
 common/Makefile  |1 +
 common/command.c |2 +-
 scripts/Makefile.spl |4 
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Kconfig b/Kconfig
index ef12f9f..ed3e295 100644
--- a/Kconfig
+++ b/Kconfig
@@ -336,6 +336,33 @@ config SPL_FIT_IMAGE_POST_PROCESS
  injected into the FIT creation (i.e. the blobs would have been pre-
  processed before being added to the FIT image).
 
+config SPL_DFU_SUPPORT
+   bool "Enable SPL with DFU to load binaries to memory device"
+   depends on USB && TARGET_DRA7XX_EVM
+   help
+ Currently the SPL does not have capability to load the
+ binaries or boot images to boot devices like ram,eMMC,SPI,etc.
+ This feature enables the DFU (Device Firmware Upgarde) in SPL with
+ RAM memory device support. The ROM code will load and execute
+ the SPL built with dfu. The user can load binaries (u-boot/kernel) to
+ selected 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 SPL_DFU_SUPPORT
+
+config SPL_DFU_RAM
+   bool "RAM device"
+   depends on SPL_DFU_SUPPORT
+   help
+select RAM/DDR memory device for loading binary images
+(u-boot/kernel) to the selected device partition using
+DFU and execute the u-boot/kernel from RAM.
+
+endchoice
+
 config SYS_CLK_FREQ
depends on ARC || ARCH_SUNXI
int "CPU clock frequency"
diff --git a/common/Makefile b/common/Makefile
index e08cd3e..7a7a1b4 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 endif # !CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.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 3ba9742..3b70c4d 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -57,6 +57,10 @@ libs-y += common/init/
 libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/
 libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
 libs-y += drivers/
+libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/dfu/
+libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/gadget/
+libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/gadget/udc/
+libs-$(CONFIG_SPL_DFU_SUPPORT) += drivers/usb/dwc3/
 libs-y += dts/
 libs-y += fs/
 libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v2 5/5] dra7x: configs: enable SPL-DFU support

2016-07-21 Thread Ravi Babu
This patch enables the SPL-DFU support for
dra7x platform.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 include/configs/dra7xx_evm.h  |   19 ++-
 include/configs/ti_omap5_common.h |2 --
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index 0d51aeb..a11a923 100644
--- a/include/configs/dra7xx_evm.h
+++ b/include/configs/dra7xx_evm.h
@@ -133,6 +133,22 @@
 #define CONFIG_FASTBOOT_FLASH_MMC_DEV   1
 #endif
 
+#ifdef CONFIG_SPL_BUILD
+#ifdef CONFIG_SPL_DFU_SUPPORT
+#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x8020
+#define CONFIG_SPL_ENV_SUPPORT
+#define CONFIG_SPL_HASH_SUPPORT
+#define DFU_ALT_INFO_RAM \
+   "dfu_alt_info_ram=" \
+   "kernel ram 0x8020 0x400;" \
+   "fdt ram 0x80f8 0x8;" \
+   "ramdisk ram 0x8100 0x400\0"
+#define DFUARGS \
+   "dfu_bufsiz=0x1\0" \
+   DFU_ALT_INFO_RAM
+#endif
+#endif
+
 #include 
 
 /* Enhance our eMMC support / experience. */
@@ -222,9 +238,10 @@
 #define CONFIG_USB_FUNCTION_DFU
 #define CONFIG_DFU_RAM
 
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_DFU_MMC
-#define CONFIG_DFU_RAM
 #define CONFIG_DFU_SF
+#endif
 
 /* SATA */
 #define CONFIG_BOARD_LATE_INIT
diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index 3589cdc..2079b9f 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 \
@@ -130,7 +129,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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v2 3/5] spl: dfu: adding dfu support functions for SPL-DFU

2016-07-21 Thread Ravi Babu
Adding support functions to run dfu spl commands.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 common/spl/Makefile  |1 +
 common/spl/spl_dfu.c |   57 ++
 include/spl.h|8 +++
 3 files changed, 66 insertions(+)
 create mode 100644 common/spl/spl_dfu.c

diff --git a/common/spl/Makefile b/common/spl/Makefile
index 2e0f695..0850da0 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_SUPPORT) += spl_dfu.o
 endif
diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
new file mode 100644
index 000..e8d0ba1
--- /dev/null
+++ b/common/spl/spl_dfu.c
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2016
+ * Texas Instruments, 
+ *
+ * Ravi B <ravib...@ti.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int run_dfu(int usb_index, char *interface, char *devstring)
+{
+   int ret;
+
+   ret = dfu_init_env_entities(interface, devstring);
+   if (ret) {
+   dfu_free_entities();
+   goto exit;
+   }
+
+   run_usb_dnl_gadget(usb_index, "usb_dnl_dfu");
+exit:
+   dfu_free_entities();
+   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);
+}
diff --git a/include/spl.h b/include/spl.h
index 2360466..1524e26 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -140,4 +140,12 @@ void spl_board_init(void);
  */
 bool spl_was_boot_source(void);
 
+/**
+ * spl_dfu_cmd- 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_cmd(int usbctrl, char *dfu_alt_info, char *interface, char 
*devstr);
 #endif
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v2 2/5] common: dfu: saperate the dfu common functionality

2016-07-21 Thread Ravi Babu
The cmd_dfu functionality is been used by both SPL and
u-boot, saperating the core dfu functionality moving
it to common/dfu.c.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 cmd/dfu.c   |   61 ++
 common/Makefile |2 ++
 common/dfu.c|   88 +++
 include/g_dnl.h |1 +
 4 files changed, 93 insertions(+), 59 deletions(-)
 create mode 100644 common/dfu.c

diff --git a/cmd/dfu.c b/cmd/dfu.c
index d8aae26..04291f6 100644
--- a/cmd/dfu.c
+++ b/cmd/dfu.c
@@ -21,7 +21,6 @@
 
 static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-   bool dfu_reset = false;
 
if (argc < 4)
return CMD_RET_USAGE;
@@ -30,7 +29,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
char *interface = argv[2];
char *devstring = argv[3];
 
-   int ret, i = 0;
+   int ret;
 #ifdef CONFIG_DFU_TFTP
unsigned long addr = 0;
if (!strcmp(argv[1], "tftp")) {
@@ -52,67 +51,11 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
}
 
int controller_index = simple_strtoul(usb_controller, NULL, 0);
-   board_usb_init(controller_index, USB_INIT_DEVICE);
-   g_dnl_clear_detach();
-   g_dnl_register("usb_dnl_dfu");
-   while (1) {
-   if (g_dnl_detach()) {
-   /*
-* Check if USB bus reset is performed after detach,
-* which indicates that -R switch has been passed to
-* dfu-util. In this case reboot the device
-*/
-   if (dfu_usb_get_reset()) {
-   dfu_reset = true;
-   goto exit;
-   }
 
-   /*
-* This extra number of usb_gadget_handle_interrupts()
-* calls is necessary to assure correct transmission
-* completion with dfu-util
-*/
-   if (++i == 1)
-   goto exit;
-   }
+   run_usb_dnl_gadget(controller_index, "usb_dnl_dfu");
 
-   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(controller_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(controller_index);
-   }
-exit:
-   g_dnl_unregister();
-   board_usb_cleanup(controller_index, USB_INIT_DEVICE);
 done:
dfu_free_entities();
-
-   if (dfu_reset)
-   run_command("reset", 0);
-
-   g_dnl_clear_detach();
-
return ret;
 }
 
diff --git a/common/Makefile b/common/Makefile
index 7a7a1b4..83bd3f4 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 endif # !CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
 obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
@@ -160,6 +161,7 @@ obj-$(CONFIG_CMDLINE) += cli_simple.o
 
 obj-y += cli.o
 obj-$(CONFIG_CMDLINE) += cli_readline.o
+obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o
diff --git a/common/dfu.c b/common/dfu.c
new file mode 100644
index 000..c6a7a58
--- /dev/null
+++ b/common/dfu.c
@@ -0,0 +1,88 @@
+/*
+ * dfu.c -- dfu command
+ *
+ * Copyright (C) 2015
+ * Lukasz Majewski <l.majew...@majess.pl>
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * authors: Andrzej Pietrasiewicz <andrze...@samsung.com>
+ * Lukasz Majewski <l.majew...@samsung.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int run_usb_dnl_gadg

[U-Boot] [PATCH] usb: dwc3: fixes crash in dwc3 driver due to types size mismatch

2016-07-21 Thread Ravi Babu
The crash at dwc3 driver observed due to offset misalignment
of structure members across files causing wrong code generation
and leads to crash, the issue is found during dfu test.

For instance, ther is is mismatch in code generation to
access the address of structure member dwc->dep[0] in
gadget.c and ep0.c. This leads to NULL pointer reference
casuing the crash. The inclusion of common.h fixes the issue.

The crash occurs due to below commit[1], revert of this patch
resolves the issue.

>>[1] commit 95ebc253e6d4a3370e3dab14743bfc99fcd9cf1b
>>Author: Masahiro Yamada <yamada.masah...@socionext.com>
>>Date:   Tue Jun 28 10:48:40 2016 +0900

types.h: move and redefine resource_size_t

Currently, this is only defined in arch/arm/include/asm/types.h,
so move it to include/linux/types.h to make it available for all
architectures.

I defined it with phys_addr_t as Linux does.  I needed to surround
the define with #ifdef __KERNEL__ ... #endif to avoid build errors
in tools building.  (Host tools should not include 
in the first place, but this is already messy in U-Boot...)

>>Signed-off-by: Masahiro Yamada <yamada.masah...@socionext.com>
>>Reviewed-by: Simon Glass <s...@chromium.org>

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 drivers/usb/dwc3/ep0.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 12b133f..f49a06e 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -14,6 +14,7 @@
  * SPDX-License-Identifier: GPL-2.0
  */
 
+#include 
 #include 
 #include 
 
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] driver: qspi: correct QSPI disable CS reset value

2016-06-21 Thread Ravi Babu
From: Praneeth Bajjuri <prane...@ti.com>

Correcting QSPI disable/unselect CS reset value.
CTRL_CORE_CONTROL_IO_2: QSPI_MEMMAPPED_CS[10:8]

This is not causing any issue, but its better
to untouch the reserved bits.

Praneeth Bajjuri <prane...@ti.com>
Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 drivers/spi/ti_qspi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index e69ec0d..9a372ad 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -45,7 +45,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define QSPI_XFER_DONE  QSPI_WC
 #define MM_SWITCH   0x01
 #define MEM_CS(cs)  ((cs + 1) << 8)
-#define MEM_CS_UNSELECT 0xf0ff
+#define MEM_CS_UNSELECT 0xf8ff
 #define MMAP_START_ADDR_DRA0x5c00
 #define MMAP_START_ADDR_AM43x  0x3000
 #define CORE_CTRL_IO0x4a002558
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x

2016-06-14 Thread Ravi Babu
enable the SPL-DFU support for am335x platform.

Signed-off-by: Ravi Babu <ravib...@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:2400: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(, (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   0x0700
+#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 0x8020 0xD8;" \
"fdt ram 0x80F8 0x8;" \
"ramdisk ram 0x8100 0x400\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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v1 0/6] SPL: DFU Support in SPL

2016-06-14 Thread Ravi Babu
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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu support for dra7x platform

2016-06-14 Thread Ravi Babu
Enable the SPL-DFU support for dra7x platform.

Signed-off-by: Ravi Babu <ravib...@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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v1 3/6] dfu: spl: add generic spl-dfu function in common-spl

2016-06-14 Thread Ravi Babu
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 <ravib...@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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform

2016-06-14 Thread Ravi Babu
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 
 #include 
 #include 
+#include 
 
 #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:6400: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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU

2016-06-14 Thread Ravi Babu
Adding support functions to run dfu commands

Signed-off-by: Ravi Babu <ravib...@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 000..8b8432b
--- /dev/null
+++ b/common/spl/spl_dfu.c
@@ -0,0 +1,153 @@
+/*
+ * (C) Copyright 2010
+ * Texas Instruments, 
+ *
+ * Ravi B <ravib...@ti.com>
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+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 = 
+   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 = 0x8020;
+   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;
+  

[U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support in SPL

2016-06-14 Thread Ravi Babu
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 <ravib...@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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1] ti_armv7_common: env: Fix hard coded mmc device for uuid

2016-06-03 Thread Ravi Babu
Avoid use of hard coded mmcdev value, use bootpart
instead, so finduuid works based on bootpart set 
for a specific platform.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 include/configs/ti_armv7_common.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/ti_armv7_common.h 
b/include/configs/ti_armv7_common.h
index 7db0881..ba7cf15 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -59,7 +59,7 @@
 #define DEFAULT_MMC_TI_ARGS \
"mmcdev=0\0" \
"mmcrootfstype=ext4 rootwait\0" \
-   "finduuid=part uuid mmc 0:2 uuid\0" \
+   "finduuid=part uuid mmc ${bootpart} uuid\0" \
"args_mmc=run finduuid;setenv bootargs console=${console} " \
"${optargs} " \
"root=PARTUUID=${uuid} rw " \
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ti_armv7_common: env: Fix hard coded mmc device for uuid

2016-06-02 Thread Ravi Babu
Avoid use of hard coded mmcdev value so finduuid works
based on current mmcdev selected.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 include/configs/ti_armv7_common.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/ti_armv7_common.h 
b/include/configs/ti_armv7_common.h
index 7db0881..bbff06b 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -59,7 +59,7 @@
 #define DEFAULT_MMC_TI_ARGS \
"mmcdev=0\0" \
"mmcrootfstype=ext4 rootwait\0" \
-   "finduuid=part uuid mmc 0:2 uuid\0" \
+   "finduuid=part uuid mmc ${mmcdev}:2 uuid\0" \
"args_mmc=run finduuid;setenv bootargs console=${console} " \
"${optargs} " \
"root=PARTUUID=${uuid} rw " \
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH 1/5] spl: dfu: add dfu support in SPL

2016-05-27 Thread Ravi Babu
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 <ravib...@ti.com>
---
 Kconfig   |   40 
 cmd/Makefile  |   11 ++-
 common/Makefile   |   28 
 common/command.c  |2 +-
 drivers/mmc/Makefile  |3 +--
 drivers/mmc/mmc_private.h |2 +-
 scripts/Makefile.spl  |   13 +
 7 files changed, 86 insertions(+), 13 deletions(-)

diff --git a/Kconfig b/Kconfig
index f53759a..8c033d0 100644
--- a/Kconfig
+++ b/Kconfig
@@ -285,6 +285,46 @@ 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
+   help
+ Normally with the SPL only image 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
+ eMMC 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_EMMC
+   bool "eMMC device"
+   depends on CMD_DFU && SPL_DFU
+   help
+select eMMC memory device for flashing binary images to
+the selection partition using DFU.
+
+config SPL_DFU_MMC
+   bool "MMC/SD device"
+   depends on CMD_DFU && SPL_DFU
+   help
+select MMC/SD memory device for flashing binary images to
+the selection 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 selection partition using DFU.
+
+endchoice
+
 config SYS_CLK_FREQ
depends on ARC || ARCH_SUNXI
int "CPU clock frequency"
diff --git a/cmd/Makefile b/cmd/Makefile
index f95759e..139189e 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -5,6 +5,13 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+CONFIG_INC_COMMON=y
+ifdef CONFIG_SPL_BUILD
+ifndef CONFIG_SPL_DFU
+CONFIG_INC_COMMON=n
+endif
+endif
+
 ifndef CONFIG_SPL_BUILD
 # core command
 obj-y += boot.o
@@ -146,7 +153,6 @@ obj-$(CONFIG_CMD_SPL) += spl.o
 obj-$(CONFIG_CMD_ZIP) += zip.o
 obj-$(CONFIG_CMD_ZFS) += zfs.o
 
-obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-$(CONFIG_CMD_GPT) += gpt.o
 obj-$(CONFIG_CMD_ETHSW) += ethsw.o
 
@@ -161,6 +167,9 @@ obj-$(CONFIG_CMD_SCSI) += scsi.o
 endif
 endif # CONFIG_SPL_BUILD
 
+ifeq ($(CONFIG_INC_COMMON),y)
+obj-$(CONFIG_CMD_DFU) += dfu.o
+endif
 obj-$(CONFIG_CMD_BLOB) += blob.o
 
 # core command
diff --git a/common/Makefile b/common/Makefile
index b23f312..3576fac 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -6,15 +6,31 @@
 #
 
 # core
-ifndef CONFIG_SPL_BUILD
-obj-y += init/
-obj-y += main.o
-obj-y += exports.o
+
+CONFIG_INC_COMMON=y
+ifdef CONFIG_SPL_BUILD
+ifndef CONFIG_SPL_DFU
+CONFIG_INC_COMMON=n
+endif
+endif
+
+ifeq ($(CONFIG_INC_COMMON),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
+obj-y += cli.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 +50,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
@@ -153,7 +166,6 @@ endif
 # We always have this since drivers/ddr/fs/interactive.c needs it
 obj-$(CONFIG_CMDLINE) += cli_simple.o
 
-obj-y += cli.o
 obj-$(CONFIG_CMDLINE) += cli_readline.o
 obj-y += command.o
 obj-y += s_record.o
diff --git a/common/command.c b/commo

[U-Boot] [RFC PATCH 0/5] SPL: DFU Support in SPL

2016-05-27 Thread Ravi Babu
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 adds DFU support in SPL to flash binary
images to factory or bare-metal boards to memory 
devices like SPI, 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.

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 (5):
  spl: dfu: add dfu support in SPL
  spl: dfu: fs: adding ext4/fat filesystem support for SPL-DFU
  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

 Kconfig   |   40 +
 board/ti/dra7xx/evm.c |   20 +++
 cmd/Makefile  |   20 ++-
 common/Makefile   |   32 -
 common/command.c  |2 +-
 common/spl/spl.c  |   11 ++
 drivers/dfu/dfu.c |   28 ++
 drivers/dfu/dfu_mmc.c |   28 ++
 drivers/mmc/Makefile  |3 +--
 drivers/mmc/mmc_private.h |2 +-
 fs/Makefile   |   12 ++-
 include/configs/dra7xx_evm.h  |3 +--
 include/configs/ti_omap5_common.h |2 --
 include/dfu.h |8 
 include/spl.h |1 +
 scripts/Makefile.spl  |   13 
 16 files changed, 206 insertions(+), 19 deletions(-)

-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH 4/5] dfu: spl: add generic spl-dfu function in common-spl

2016-05-27 Thread Ravi Babu
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 <ravib...@ti.com>
---
 common/spl/spl.c |   11 +++
 include/spl.h|1 +
 2 files changed, 12 insertions(+)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 82e7f58..ef6d2d1 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -273,6 +273,13 @@ static void announce_boot_device(u32 boot_device)
 static inline void announce_boot_device(u32 boot_device) { }
 #endif
 
+#ifdef CONFIG_SPL_DFU
+__weak int spl_run_dfu(void)
+{
+   return 0;
+}
+#endif
+
 static int spl_load_image(u32 boot_device)
 {
switch (boot_device) {
@@ -367,6 +374,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
spl_board_init();
 #endif
 
+#ifdef CONFIG_SPL_DFU
+   spl_run_dfu();
+#endif
+
board_boot_order(spl_boot_list);
for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
diff --git a/include/spl.h b/include/spl.h
index 5f0b0db..5794b05 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -158,4 +158,5 @@ void spl_board_init(void);
  */
 bool spl_was_boot_source(void);
 
+int spl_run_dfu(void);
 #endif
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH 5/5] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform

2016-05-27 Thread Ravi Babu
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.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 board/ti/dra7xx/evm.c |   20 
 include/configs/dra7xx_evm.h  |3 +--
 include/configs/ti_omap5_common.h |2 --
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index f194999..0ce0e97 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "mux_data.h"
 #include "../common/board_detect.h"
@@ -619,6 +620,25 @@ int spl_start_uboot(void)
 }
 #endif
 
+#ifdef CONFIG_SPL_DFU
+int spl_run_dfu(void)
+{
+#ifdef CONFIG_SPL_DFU_EMMC
+   return dfu_run_mmc(0, 1, "dfu_alt_info_emmc");
+#endif
+
+#ifdef CONFIG_SPL_DFU_MMC
+   return dfu_run_mmc(0, 0, "dfu_alt_info_mmc");
+#endif
+
+#ifdef CONFIG_SPL_DFU
+   return dfu_run_cmd("dfu_alt_info_qspi",
+   "dfu 0 sf 0:0:6400:0");
+#endif
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_DRIVER_TI_CPSW
 extern u32 *const omap_si_rev;
 
diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h
index da84f1c..ec10cd8 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 */ \
@@ -122,6 +121,7 @@
DFU_ALT_INFO_QSPI
 
 /* Fastboot */
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_USB_FUNCTION_FASTBOOT
 #define CONFIG_CMD_FASTBOOT
 #define CONFIG_ANDROID_BOOT_IMAGE
@@ -331,5 +331,4 @@
 /* pcf support */
 #define CONFIG_PCF8575
 #define CONFIG_SYS_I2C_PCF8575_CHIP { {0x21, 0xeaf7} }
-
 #endif /* __CONFIG_DRA7XX_EVM_H */
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

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH 3/5] spl: dfu: adding dfu support functions for SPL-DFU

2016-05-27 Thread Ravi Babu
Adding support functions to run dfu commands
with support for eMMC/MMC/SD memory device.

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 drivers/dfu/dfu.c |   28 
 drivers/dfu/dfu_mmc.c |   28 
 include/dfu.h |8 
 3 files changed, 64 insertions(+)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 20dfcbb..1d4690b 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static LIST_HEAD(dfu_list);
 static int dfu_alt_num;
@@ -596,3 +597,30 @@ int dfu_write_from_mem_addr(struct dfu_entity *dfu, void 
*buf, int size)
 
return ret;
 }
+
+int dfu_run_cmd(char *dfu_alt_info, char *dfu_cmd_str)
+{
+   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 */
+   ret = run_command(dfu_cmd_str, 0);
+   if (ret)
+   error("dfu: error = %d\n", ret);
+
+   return ret;
+}
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index faece88..28517e8 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static unsigned char *dfu_file_buf;
 static long dfu_file_buf_len;
@@ -401,3 +402,30 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char 
*devstr, char *s)
 
return 0;
 }
+
+int dfu_run_mmc(int usb_index, int mmc_dev, char *dfu_alt_info)
+{
+   char cmd_buf[DFU_CMD_BUF_SIZE];
+   struct mmc *mmcdev;
+   struct mmc **mmc = 
+   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;
+   }
+
+   sprintf(cmd_buf, "dfu %d mmc %d", usb_index, device);
+   return dfu_run_cmd(dfu_alt_info, cmd_buf);
+}
diff --git a/include/dfu.h b/include/dfu.h
index f39d3f1..0bc75bc 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -274,4 +274,12 @@ static inline int dfu_tftp_write(char *dfu_entity_name, 
unsigned int addr,
 #endif
 
 int dfu_add(struct usb_configuration *c);
+/* dfu_run_umc - 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 dfu_run_mmc(int usb_index, int mmc_dev, char *dfu_alt_info);
+int dfu_run_cmd(char *dfu_alt_info, char *dfu_cmd_str);
 #endif /* __DFU_ENTITY_H_ */
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH 2/5] spl: dfu: fs: adding ext4/fat filesystem support for SPL-DFU

2016-05-27 Thread Ravi Babu
Adding ext4/fat filesytem support for SPL-DFU to
write ext4/fat files to eMMC, MMC/SD device

Signed-off-by: Ravi Babu <ravib...@ti.com>
---
 cmd/Makefile|9 +
 common/Makefile |4 +++-
 fs/Makefile |   12 +++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/cmd/Makefile b/cmd/Makefile
index 139189e..ad89e09 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -12,6 +12,15 @@ CONFIG_INC_COMMON=n
 endif
 endif
 
+ifeq ($(CONFIG_INC_COMMON),y)
+obj-$(CONFIG_CMD_EXT4) += ext4.o
+obj-$(CONFIG_CMD_EXT2) += ext2.o
+obj-$(CONFIG_CMD_FAT) += fat.o
+obj-$(CONFIG_CMD_FDC) += fdc.o
+obj-$(CONFIG_CMD_FS_GENERIC) += fs.o
+obj-$(CONFIG_CMD_SCSI) += scsi.o
+endif
+
 ifndef CONFIG_SPL_BUILD
 # core command
 obj-y += boot.o
diff --git a/common/Makefile b/common/Makefile
index 3576fac..99de9e1 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -24,6 +24,9 @@ obj-y += env_attr.o
 obj-y += env_callback.o
 obj-y += env_flags.o
 obj-y += cli.o
+ifdef CONFIG_CMD_USB
+obj-$(CONFIG_USB_STORAGE) += usb_storage.o
+endif
 endif
 
 ifndef CONFIG_SPL_BUILD
@@ -78,7 +81,6 @@ obj-$(CONFIG_PHYLIB) += miiphyutil.o
 
 ifdef CONFIG_CMD_USB
 obj-y += usb.o usb_hub.o
-obj-$(CONFIG_USB_STORAGE) += usb_storage.o
 endif
 
 # others
diff --git a/fs/Makefile b/fs/Makefile
index 51d06fc..d4490a9 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -6,11 +6,21 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
+CONFIG_INC_COMMON=y
+ifdef CONFIG_SPL_BUILD
+ifndef CONFIG_SPL_DFU
+CONFIG_INC_COMMON=n
+endif
+endif
+
+ifeq ($(CONFIG_INC_COMMON),y)
+obj-y  += fs.o
+endif
+
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_FAT_SUPPORT) += fat/
 obj-$(CONFIG_SPL_EXT_SUPPORT) += ext4/
 else
-obj-y  += fs.o
 
 obj-$(CONFIG_CMD_CBFS) += cbfs/
 obj-$(CONFIG_CMD_CRAMFS) += cramfs/
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot