diff mbox

[U-Boot,1/2] automatic update from FIT image: add optional address parameter

Message ID 1303246918-19921-2-git-send-email-apr@cn-eng.de
State Changes Requested
Delegated to: Wolfgang Denk
Headers show

Commit Message

Andreas Pretzsch April 19, 2011, 9:01 p.m. UTC
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.

Signed-off-by: Andreas Pretzsch <apr@cn-eng.de>
---
 common/main.c   |    4 ++--
 common/update.c |    8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/common/main.c b/common/main.c
index dcbacc9..9b86934 100644
--- a/common/main.c
+++ b/common/main.c
@@ -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);
+void update_tftp (ulong addr);
 #endif /* CONFIG_UPDATE_TFTP */
 
 #define MAX_DELAY_STOP_STR 32
@@ -356,7 +356,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)
diff --git a/common/update.c b/common/update.c
index 7528474..531c7d6 100644
--- a/common/update.c
+++ b/common/update.c
@@ -238,14 +238,17 @@  static int update_fit_getparams(const void *fit, int noffset, ulong *addr,
 	return 0;
 }
 
-void update_tftp(void)
+void update_tftp(ulong addr)
 {
 	char *filename, *env_addr;
 	int images_noffset, ndepth, noffset;
 	ulong update_addr, update_fladdr, update_size;
-	ulong addr;
 	void *fit;
 
+	/* use already present image */
+	if (addr)
+		goto got_update_file;
+
 	printf("Auto-update from TFTP: ");
 
 	/* get the file name of the update file */
@@ -271,6 +274,7 @@  void update_tftp(void)
 		return;
 	}
 
+got_update_file:
 	fit = (void *)addr;
 
 	if (!fit_check_format((void *)fit)) {