From patchwork Tue Jul 3 09:38:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 168753 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7BFFF2C00F5 for ; Tue, 3 Jul 2012 19:39:37 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 92C7D280F1; Tue, 3 Jul 2012 11:39:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8Dprszb9qVhd; Tue, 3 Jul 2012 11:39:14 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 582E1280F6; Tue, 3 Jul 2012 11:38:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 82571280E9 for ; Tue, 3 Jul 2012 11:38:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HdKhKLiqGcvw for ; Tue, 3 Jul 2012 11:38:51 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by theia.denx.de (Postfix) with ESMTP id 5FF0E280B5 for ; Tue, 3 Jul 2012 11:38:37 +0200 (CEST) Received: from epcpsbgm1.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M6K0006QW1MW3W0@mailout4.samsung.com> for u-boot@lists.denx.de; Tue, 03 Jul 2012 18:38:35 +0900 (KST) X-AuditID: cbfee61a-b7f086d000000e64-90-4ff2bd9b268b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 87.7A.03684.B9DB2FF4; Tue, 03 Jul 2012 18:38:35 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M6K0019TW3PXE40@mmp2.samsung.com> for u-boot@lists.denx.de; Tue, 03 Jul 2012 18:38:35 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Tue, 03 Jul 2012 11:38:09 +0200 Message-id: <1341308291-14663-6-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1341308291-14663-1-git-send-email-l.majewski@samsung.com> References: <1341308291-14663-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jQd3Zez/5G9z6Kmjxdm8nuwOjx9k7 OxgDGKO4bFJSczLLUov07RK4Muacuc9UcFSy4vKLA+wNjJdEuhg5OCQETCTO7gvrYuQEMsUk Ltxbz9bFyMUhJDCdUeJpw0EoZzGTxKfmrSwgVWwCehKf7z5lArFFBCQkfvVfZQSxmQXKJPZO ec0KYgsL2Eg8vPUdLM4ioCrRcr2HHcTmFXCTmHyhmw1im7zE0/t9YDangLvEve27wGwhoJor T2ezTWDkXcDIsIpRNLUguaA4KT3XUK84Mbe4NC9dLzk/dxMj2OfPpHYwrmywOMQowMGoxMNr uPmTvxBrYllxZe4hRgkOZiUR3qtbgEK8KYmVValF+fFFpTmpxYcYpTlYlMR5m6wv+AsJpCeW pGanphakFsFkmTg4pRoYmU30NNxXTr++WbPvICNbc2L+DDXRb7y9Ee3Of//ec1qfKyv6VM9k 5bw7MVOfb3JJ28G56MyLR57Jk9W5trzrs1CfxqOdWj9T+WBYffHeBQtmOmhGHTfTXPfqq9Ks 0o2iXo4zdi/nrReeLc3YW9cp7vpG54zSdLZDOoUMjbG8pkfaDods7G5XYinOSDTUYi4qTgQA hlFGO/UBAAA= X-TM-AS-MML: No Cc: Marek Vasut , Kyungmin Park Subject: [U-Boot] [PATCH 5/7] dfu:cmd: Support for DFU u-boot command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Support for u-boot's command line command "dfu [list]". Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Cc: Marek Vasut --- common/Makefile | 1 + common/cmd_dfu.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 0 deletions(-) create mode 100644 common/cmd_dfu.c diff --git a/common/Makefile b/common/Makefile index 6e23baa..de43ead 100644 --- a/common/Makefile +++ b/common/Makefile @@ -186,6 +186,7 @@ COBJS-$(CONFIG_MENU) += menu.o COBJS-$(CONFIG_MODEM_SUPPORT) += modem.o COBJS-$(CONFIG_UPDATE_TFTP) += update.o COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o +COBJS-$(CONFIG_CMD_DFU) += cmd_dfu.o endif ifdef CONFIG_SPL_BUILD diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c new file mode 100644 index 0000000..ceb0f54 --- /dev/null +++ b/common/cmd_dfu.c @@ -0,0 +1,81 @@ +/* + * cmd_dfu.c -- dfu command + * + * Copyright (C) 2012 Samsung Electronics + * authors: Andrzej Pietrasiewicz + * Lukasz Majewski + * + * 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 +#include +#include +#include +#include +#include + +int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + char *str_env = NULL, *env_bkp = NULL; + static char *s = "dfu"; + int ret = 0; + + if (argc < 3) + return CMD_RET_USAGE; + + str_env = getenv("dfu_alt_info"); + if (str_env == NULL) { + printf("%s: \"dfu_alt_info\" env variable not defined!\n", + __func__); + return CMD_RET_FAILURE; + } + + env_bkp = strdup(str_env); + ret = dfu_config_entities(env_bkp, argv[1], + (int)simple_strtoul(argv[2], NULL, 10)); + if (ret) + return CMD_RET_FAILURE; + + if (strcmp(argv[3], "list") == 0) { + dfu_show_entities(); + dfu_free_entities(); + free(env_bkp); + return CMD_RET_SUCCESS; + } + + board_usb_init(); + g_dnl_init(s); + while (1) { + if (ctrlc()) + goto exit; + + usb_gadget_handle_interrupts(); + } +exit: + g_dnl_cleanup(); + dfu_free_entities(); + free(env_bkp); + + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu, + "Device Firmware Upgrade", + " [list]\n" + " - device firmware upgrade on a device \n" + " attached to interface \n" + " [list] - list available alt settings" +);