]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
automatic update from FIT image: add optional address parameter
authorAndreas Pretzsch <apr@cn-eng.de>
Sat, 16 Jul 2011 05:50:59 +0000 (05:50 +0000)
committerWolfgang Denk <wd@denx.de>
Tue, 26 Jul 2011 14:58:44 +0000 (16:58 +0200)
Current update_tftp() flow:
  1.) fetch "updatefile" from defined TFTP server
  2.) check if FIT format
  3.) flash contained images

Add an address parameter to update_tftp(). If this address is non-zero,
skip the TFTP transfer and use the image at this address.
Also extend update_tftp() to return success/fail.

Signed-off-by: Andreas Pretzsch <apr@cn-eng.de>
common/main.c
common/update.c

index 212452681939c163dc9a6010a6d2e858b2f8dfb2..1f221423a202866cd98eabb6b9763604a0490f5c 100644 (file)
@@ -51,7 +51,7 @@ void inline __show_boot_progress (int val) {}
 void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
 
 #if defined(CONFIG_UPDATE_TFTP)
-void update_tftp (void);
+int update_tftp (ulong addr);
 #endif /* CONFIG_UPDATE_TFTP */
 
 #define MAX_DELAY_STOP_STR 32
@@ -341,7 +341,7 @@ void main_loop (void)
 #endif /* CONFIG_PREBOOT */
 
 #if defined(CONFIG_UPDATE_TFTP)
-       update_tftp ();
+       update_tftp (0UL);
 #endif /* CONFIG_UPDATE_TFTP */
 
 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
index 75284748734e11961cea3fb6258d4149e389112d..a19f136647d083f38f567db0633b82217db8a1ef 100644 (file)
@@ -238,13 +238,17 @@ static int update_fit_getparams(const void *fit, int noffset, ulong *addr,
        return 0;
 }
 
-void update_tftp(void)
+int update_tftp(ulong addr)
 {
        char *filename, *env_addr;
        int images_noffset, ndepth, noffset;
        ulong update_addr, update_fladdr, update_size;
-       ulong addr;
        void *fit;
+       int ret = 0;
+
+       /* use already present image */
+       if (addr)
+               goto got_update_file;
 
        printf("Auto-update from TFTP: ");
 
@@ -253,7 +257,7 @@ void update_tftp(void)
        if (filename == NULL) {
                printf("failed, env. variable '%s' not found\n",
                                                        UPDATE_FILE_ENV);
-               return;
+               return 1;
        }
 
        printf("trying update file '%s'\n", filename);
@@ -268,15 +272,16 @@ void update_tftp(void)
        if (update_load(filename, CONFIG_UPDATE_TFTP_MSEC_MAX,
                                        CONFIG_UPDATE_TFTP_CNT_MAX, addr)) {
                printf("Can't load update file, aborting auto-update\n");
-               return;
+               return 1;
        }
 
+got_update_file:
        fit = (void *)addr;
 
        if (!fit_check_format((void *)fit)) {
                printf("Bad FIT format of the update file, aborting "
                                                        "auto-update\n");
-               return;
+               return 1;
        }
 
        /* process updates */
@@ -293,6 +298,7 @@ void update_tftp(void)
 
                if (!fit_image_check_hashes(fit, noffset)) {
                        printf("Error: invalid update hash, aborting\n");
+                       ret = 1;
                        goto next_node;
                }
 
@@ -301,15 +307,17 @@ void update_tftp(void)
                                        &update_fladdr, &update_size)) {
                        printf("Error: can't get update parameteres, "
                                                                "aborting\n");
+                       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;
                }
 next_node:
                noffset = fdt_next_node(fit, noffset, &ndepth);
        }
 
-       return;
+       return ret;
 }