From patchwork Sun Jul 12 15:30:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 494157 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 381EE1401E7 for ; Mon, 13 Jul 2015 03:18:39 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EC7414B61F; Sun, 12 Jul 2015 19:18:34 +0200 (CEST) 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 xRVQrj_8Imy3; Sun, 12 Jul 2015 19:18:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3EF1B4A03A; Sun, 12 Jul 2015 19:18:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7D0A54A03A for ; Sun, 12 Jul 2015 19:00:57 +0200 (CEST) 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 hnnP0C6nfvpy for ; Sun, 12 Jul 2015 19:00:57 +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 10.mo4.mail-out.ovh.net (10.mo4.mail-out.ovh.net [188.165.33.109]) by theia.denx.de (Postfix) with ESMTPS id 20E904A039 for ; Sun, 12 Jul 2015 19:00:54 +0200 (CEST) Received: from mail631.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo4.mail-out.ovh.net (Postfix) with SMTP id 7769CFFA900 for ; Sun, 12 Jul 2015 17:41:38 +0200 (CEST) Received: from localhost (HELO queueout) (127.0.0.1) by localhost with SMTP; 12 Jul 2015 17:41:38 +0200 Received: from 109241105088.warszawa.vectranet.pl (HELO localhost.localdomain) (l.majewski%majess.pl@109.241.105.88) by ns0.ovh.net with SMTP; 12 Jul 2015 17:41:36 +0200 From: Lukasz Majewski To: u-boot@lists.denx.de, Tom Rini Date: Sun, 12 Jul 2015 17:30:42 +0200 Message-Id: <1436715044-18706-7-git-send-email-l.majewski@majess.pl> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436715044-18706-1-git-send-email-l.majewski@majess.pl> References: <1436715044-18706-1-git-send-email-l.majewski@majess.pl> X-Ovh-Tracer-Id: 9967873351614644768 X-Ovh-Remote: 109.241.105.88 (109241105088.warszawa.vectranet.pl) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekvddrheefucetufdoteggucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekvddrheefucetufdoteggucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-Mailman-Approved-At: Sun, 12 Jul 2015 19:18:32 +0200 Cc: Marek Vasut , Steve Rae , Stephen Warren , Egli Samuel , Pantelis Antoniou , Rafal Czubak , Joe Hershberger , Bartlomiej Sieka , Przemyslaw Marczak , Tormod Volden Subject: [U-Boot] [PATCH 6/8] update: tftp: dfu: Extend update_tftp() function to support DFU X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This code allows using DFU defined mediums for storing data received via TFTP protocol. It reuses legacy code at common/update.c. To run update_tftp() during boot one needs to define "update_tftp_exec_at_boot=true". Signed-off-by: Lukasz Majewski --- common/update.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/common/update.c b/common/update.c index 75c6d62..f3ed036 100644 --- a/common/update.c +++ b/common/update.c @@ -18,6 +18,7 @@ #include #include #include +#include /* env variable holding the location of the update file */ #define UPDATE_FILE_ENV "updatefile" @@ -224,11 +225,18 @@ static int update_fit_getparams(const void *fit, int noffset, ulong *addr, int update_tftp(ulong addr) { - char *filename, *env_addr; - int images_noffset, ndepth, noffset; + char *filename, *env_addr, *fit_image_name; ulong update_addr, update_fladdr, update_size; - void *fit; + int images_noffset, ndepth, noffset; + bool update_tftp_dfu = false; int ret = 0; + void *fit; + + if (!getenv("update_tftp_exec_at_boot")) + return 0; + + if (getenv("update_tftp_dfu")) + update_tftp_dfu = true; /* use already present image */ if (addr) @@ -277,8 +285,8 @@ got_update_file: if (ndepth != 1) goto next_node; - printf("Processing update '%s' :", - fit_get_name(fit, noffset, NULL)); + fit_image_name = (char *)fit_get_name(fit, noffset, NULL); + printf("Processing update '%s' :", fit_image_name); if (!fit_image_verify(fit, noffset)) { printf("Error: invalid update hash, aborting\n"); @@ -294,10 +302,21 @@ got_update_file: ret = 1; goto next_node; } - if (update_flash(update_addr, update_fladdr, update_size)) { - printf("Error: can't flash update, aborting\n"); - ret = 1; - goto next_node; + + if (!update_tftp_dfu) { + if (update_flash(update_addr, update_fladdr, + update_size)) { + printf("Error: can't flash update, aborting\n"); + ret = 1; + goto next_node; + } + } else if (fit_image_check_type(fit, noffset, + IH_TYPE_FIRMWARE)) { + if (dfu_tftp_write(fit_image_name, + update_addr, update_size)) { + ret = 1; + goto next_node; + } } next_node: noffset = fdt_next_node(fit, noffset, &ndepth);