From patchwork Sun Feb 24 17:26:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 222779 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 14D522C0297 for ; Mon, 25 Feb 2013 04:30:12 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5ACCA4A13F; Sun, 24 Feb 2013 18:30:10 +0100 (CET) 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 fIjmUpmDrWvC; Sun, 24 Feb 2013 18:30:10 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 35CFE4A143; Sun, 24 Feb 2013 18:30:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A694C4A14F for ; Sun, 24 Feb 2013 18:30:04 +0100 (CET) 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 G+KDfzTz9XmY for ; Sun, 24 Feb 2013 18:30:03 +0100 (CET) X-Greylist: delayed 47693 seconds by postgrey-1.27 at theia; Sun, 24 Feb 2013 18:30:02 CET 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 mail-ye0-f201.google.com (mail-ye0-f201.google.com [209.85.213.201]) by theia.denx.de (Postfix) with ESMTPS id 366BB4A117 for ; Sun, 24 Feb 2013 18:30:01 +0100 (CET) Received: by mail-ye0-f201.google.com with SMTP id m12so17323yen.4 for ; Sun, 24 Feb 2013 09:30:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=9MwPZdb8uAm7ogA66YP4xoNb36TPhFq0nXHqWpjtqBo=; b=bfytLmRV2soTn/tU14hpCNm/ov+qijo9UXYgwXUbAqzJbhWP5ivZtg8/f/xkikHzE4 CJRVQETEqikpkF6uBp5HfM7M/cdmWvNxPSqC8lqxHMTfDD6qBvTKAtYoNtzw6h3sOzq5 pJAhx13BbRrUgdgKgbVGBe21xf7owhLx7zclvqK+4cf4jS2Z6xOmui+bIFJp71fBDvmw +cBp9/udpwx1OhbWjizDmf3e5wUbQi2hRAhmhqGXtK5JxNusYBugJwO4Gb1RjVFdbUA9 hG3VCElzLW3hIlZPh8QbofnwsUz3wEo3Fz47iCVfdmasufuxu2PgQy/hUQ0lvbYEt5I7 kR4w== X-Received: by 10.236.132.104 with SMTP id n68mr4994458yhi.37.1361727000157; Sun, 24 Feb 2013 09:30:00 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id u28si747232yhm.1.2013.02.24.09.30.00 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Sun, 24 Feb 2013 09:30:00 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id D63045A40A5; Sun, 24 Feb 2013 09:29:59 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 8356F16032C; Sun, 24 Feb 2013 09:29:59 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Sun, 24 Feb 2013 09:26:01 -0800 Message-Id: <1361726773-18639-4-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1361726773-18639-1-git-send-email-sjg@chromium.org> References: <1361726773-18639-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQl4BVIEip8++JqL0Q0jRQB424ZYNbsIsbIsaZJJVVTExyiveAA2rafKvAMvtV7lKoj9DIq9A1j1R5iOJCu5CA33hEj/NuysmL46oTsTL5WjJfkwj7w8VatvgmOaXmTt0R5GGUwQYFIS+INVsOpB7UVb37b37LooTOIZcd+HoisM2ltptD1XLMGMf7rHIA1UMUF0MCTJ Cc: David Hendrix , Graeme Russ , Joe Hershberger , Tom Rini , Vadim Bendebury Subject: [U-Boot] [RFC PATCH v2 03/15] net: Add prototype for update_tftp, and use autoconf 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 This function should be declared in net.h. At the same time, let's use autoconf insteaf of #ifdef for its inclusion. Signed-off-by: Simon Glass Acked-by: Joe Hershberger --- Changes in v2: None common/cmd_fitupd.c | 3 +-- common/main.c | 9 ++------- common/update.c | 24 ++++++++---------------- include/net.h | 3 +++ 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/common/cmd_fitupd.c b/common/cmd_fitupd.c index 7a3789e..618ff7c 100644 --- a/common/cmd_fitupd.c +++ b/common/cmd_fitupd.c @@ -8,13 +8,12 @@ #include #include +#include #if !defined(CONFIG_UPDATE_TFTP) #error "CONFIG_UPDATE_TFTP required" #endif -extern int update_tftp(ulong addr); - static int do_fitupd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong addr = 0UL; diff --git a/common/main.c b/common/main.c index e2d2e09..2b8af2c 100644 --- a/common/main.c +++ b/common/main.c @@ -61,10 +61,6 @@ DECLARE_GLOBAL_DATA_PTR; void inline __show_boot_progress (int val) {} void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress"))); -#if defined(CONFIG_UPDATE_TFTP) -int update_tftp (ulong addr); -#endif /* CONFIG_UPDATE_TFTP */ - #define MAX_DELAY_STOP_STR 32 #undef DEBUG_PARSER @@ -427,9 +423,8 @@ void main_loop (void) } #endif /* CONFIG_PREBOOT */ -#if defined(CONFIG_UPDATE_TFTP) - update_tftp (0UL); -#endif /* CONFIG_UPDATE_TFTP */ + if (autoconf_update_tftp()) + update_tftp(0UL); #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) s = getenv ("bootdelay"); diff --git a/common/update.c b/common/update.c index 94d6a82..9cd9ca2 100644 --- a/common/update.c +++ b/common/update.c @@ -43,19 +43,6 @@ /* env variable holding the location of the update file */ #define UPDATE_FILE_ENV "updatefile" -/* set configuration defaults if needed */ -#ifndef CONFIG_UPDATE_LOAD_ADDR -#define CONFIG_UPDATE_LOAD_ADDR 0x100000 -#endif - -#ifndef CONFIG_UPDATE_TFTP_MSEC_MAX -#define CONFIG_UPDATE_TFTP_MSEC_MAX 100 -#endif - -#ifndef CONFIG_UPDATE_TFTP_CNT_MAX -#define CONFIG_UPDATE_TFTP_CNT_MAX 0 -#endif - extern ulong TftpRRQTimeoutMSecs; extern int TftpRRQTimeoutCountMax; extern flash_info_t flash_info[]; @@ -244,6 +231,7 @@ int update_tftp(ulong addr) char *filename, *env_addr; int images_noffset, ndepth, noffset; ulong update_addr, update_fladdr, update_size; + int msec_max; void *fit; int ret = 0; @@ -266,12 +254,16 @@ int update_tftp(ulong addr) /* get load address of downloaded update file */ if ((env_addr = getenv("loadaddr")) != NULL) addr = simple_strtoul(env_addr, NULL, 16); + else if (autoconf_has_update_load_addr()) + addr = autoconf_update_load_addr(); else - addr = CONFIG_UPDATE_LOAD_ADDR; + addr = 0x100000; + msec_max = autoconf_has_update_tftp_msec_max() ? + autoconf_update_tftp_msec_max() : 100; - if (update_load(filename, CONFIG_UPDATE_TFTP_MSEC_MAX, - CONFIG_UPDATE_TFTP_CNT_MAX, addr)) { + if (update_load(filename, msec_max, autoconf_update_tftp_cnt_max(), + addr)) { printf("Can't load update file, aborting auto-update\n"); return 1; } diff --git a/include/net.h b/include/net.h index 970d4d1..23fb947 100644 --- a/include/net.h +++ b/include/net.h @@ -695,6 +695,9 @@ extern void copy_filename(char *dst, const char *src, int size); /* get a random source port */ extern unsigned int random_port(void); +/* Update U-Boot over TFTP */ +extern int update_tftp(ulong addr); + /**********************************************************************/ #endif /* __NET_H__ */