]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_dfu.c
Update from 2013.01 to 2013.07
[karo-tx-uboot.git] / common / cmd_dfu.c
index 01d6b3a2d66b6a4780f8a479ff41ffd2a5bd601b..793c42212369a85d11047d7315e0f386e77c0e05 100644 (file)
@@ -5,19 +5,7 @@
  * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
  *         Lukasz Majewski <l.majewski@samsung.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -31,8 +19,8 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        const char *str_env;
        char *s = "dfu";
+       int ret, i = 0;
        char *env_bkp;
-       int ret;
 
        if (argc < 3)
                return CMD_RET_USAGE;
@@ -50,14 +38,26 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        if (ret)
                return CMD_RET_FAILURE;
 
-       if (strcmp(argv[3], "list") == 0) {
+       if (argc > 3 && strcmp(argv[3], "list") == 0) {
                dfu_show_entities();
                goto done;
        }
 
+#ifdef CONFIG_TRATS
        board_usb_init();
+#endif
+
        g_dnl_register(s);
        while (1) {
+               if (dfu_reset())
+                       /*
+                        * This extra number of usb_gadget_handle_interrupts()
+                        * calls is necessary to assure correct transmission
+                        * completion with dfu-util
+                        */
+                       if (++i == 10)
+                               goto exit;
+
                if (ctrlc())
                        goto exit;
 
@@ -69,6 +69,9 @@ done:
        dfu_free_entities();
        free(env_bkp);
 
+       if (dfu_reset())
+               run_command("reset", 0);
+
        return CMD_RET_SUCCESS;
 }