[U-Boot] [PATCH 3/4] dfu: command implementation

Andrzej Pietrasiewicz andrzej.p at samsung.com
Wed Nov 9 10:52:22 CET 2011


Signed-off-by: Andrzej Pietrasiewicz <andrzej.p at samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
---
 common/Makefile  |    1 +
 common/cmd_dfu.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
 create mode 100644 common/cmd_dfu.c

diff --git a/common/Makefile b/common/Makefile
index 1b672ad..3322b97 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -162,6 +162,7 @@ COBJS-y += cmd_usb.o
 COBJS-y += usb.o
 COBJS-$(CONFIG_USB_STORAGE) += usb_storage.o
 endif
+COBJS-$(CONFIG_CMD_DEVICE_FIRMWARE_UPGRADE) += cmd_dfu.o
 COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o
 COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o
 
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
new file mode 100644
index 0000000..93d8918
--- /dev/null
+++ b/common/cmd_dfu.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Samsung Electrnoics
+ * author: Andrzej Pietrasiewicz <andrzej.p at 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
+ */
+
+#include <common.h>
+#include <command.h>
+#include <dfu.h>
+#include <dfu_backend.h>
+#include <flash_entity.h>
+
+static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	board_dfu_init();
+	dfu_init();
+	while (1) {
+		int irq_res;
+		/* Handle control-c and timeouts */
+		if (ctrlc()) {
+			printf("The remote end did not respond in time.\n");
+			goto fail;
+		}
+
+		irq_res = usb_gadget_handle_interrupts();
+	}
+fail:
+	dfu_cleanup();
+	board_dfu_cleanup();
+	return -1;
+}
+
+U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
+	"Use the DFU [Device Firmware Upgrade]",
+	"dfu - device firmware upgrade"
+);
+
-- 
1.7.0.4



More information about the U-Boot mailing list