[U-Boot] [RFC PATCH v2 03/15] net: Add prototype for update_tftp, and use autoconf
Joe Hershberger
joe.hershberger at gmail.com
Sun Feb 24 21:02:14 CET 2013
Hi Simon,
On Sun, Feb 24, 2013 at 11:26 AM, Simon Glass <sjg at chromium.org> wrote:
> 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 <sjg at chromium.org>
> ---
> 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 <common.h>
> #include <command.h>
> +#include <net.h>
>
> #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())
Shouldn't you be using the _has version here?
> + 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)) {
Sneaky using autoconf_update_tftp_cnt_max() to default to 0.
> 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__ */
> --
> 1.8.1.3
Acked-by: Joe Hershberger <joe.hershberger at ni.com>
More information about the U-Boot
mailing list