public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Bartlomiej Sieka <tur@semihalf.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 11/20] [new uImage] Add new uImage format support to	autoscript routine
Date: Wed, 12 Mar 2008 21:11:35 +0100	[thread overview]
Message-ID: <20080312201135.6444.3414.stgit@pollux.denx.de> (raw)
In-Reply-To: <20080312201023.6444.52806.stgit@pollux.denx.de>

From: Marian Balakowicz <m8@semihalf.com>

autoscript() routine is updated to accept second argument, which
is only used for FIT images and provides a FIT subimage unit name.

autoscript() routine callers must now pass two arguments. For
non-interactive use (like in cmd_load.c, cmd_net.c), new environment
variable 'autoscript_uname' is introduced and used as a FIT
subimage unit name source.

autoscript command accepts extended syntax of the addr argument:
addr:<subimg_uname>

Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---

 board/pn62/cmd_pn62.c   |   11 +++++-
 common/cmd_autoscript.c |   84 +++++++++++++++++++++++++++++++++++++++--------
 common/cmd_load.c       |   11 +++++-
 common/cmd_net.c        |   11 +++++-
 include/common.h        |    2 +
 5 files changed, 97 insertions(+), 22 deletions(-)

diff --git a/board/pn62/cmd_pn62.c b/board/pn62/cmd_pn62.c
index ffa20cd..3f53e4b 100644
--- a/board/pn62/cmd_pn62.c
+++ b/board/pn62/cmd_pn62.c
@@ -157,8 +157,15 @@ int do_loadpci (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	char *s;
 
 	if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) {
-	    printf("Running autoscript at addr 0x%08lX ...\n", load_addr);
-	    rcode = autoscript (bd, load_addr);
+		printf ("Running autoscript at addr 0x%08lX", load_addr);
+
+		s = getenv ("autoscript_uname");
+		if (s)
+			printf (":%s ...\n", s);
+		else
+			puts (" ...\n");
+
+		rcode = autoscript (load_addr, s);
 	}
     }
 #endif
diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c
index 60ffc7d..5163d57 100644
--- a/common/cmd_autoscript.c
+++ b/common/cmd_autoscript.c
@@ -50,14 +50,20 @@
 #if defined(CONFIG_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT)
 
 int
-autoscript (ulong addr)
+autoscript (ulong addr, const char *fit_uname)
 {
-	ulong len;
-	image_header_t *hdr;
-	ulong *data;
-	char *cmd;
-	int rcode = 0;
-	int verify;
+	ulong 		len;
+	image_header_t	*hdr;
+	ulong		*data;
+	char		*cmd;
+	int		rcode = 0;
+	int		verify;
+#if defined(CONFIG_FIT)
+	const void*	fit_hdr;
+	int		noffset;
+	const void	*fit_data;
+	size_t		fit_len;
+#endif
 
 	verify = getenv_verify ();
 
@@ -97,8 +103,46 @@ autoscript (ulong addr)
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		fit_unsupported ("autoscript");
-		return 1;
+		if (fit_uname == NULL) {
+			puts ("No FIT subimage unit name\n");
+			return 1;
+		}
+
+		fit_hdr = (const void *)addr;
+		if (!fit_check_format (fit_hdr)) {
+			puts ("Bad FIT image format\n");
+			return 1;
+		}
+
+		/* get script component image node offset */
+		noffset = fit_image_get_node (fit_hdr, fit_uname);
+		if (noffset < 0) {
+			printf ("Can't find '%s' FIT subimage\n", fit_uname);
+			return 1;
+		}
+
+		if (!fit_image_check_type (fit_hdr, noffset, IH_TYPE_SCRIPT)) {
+			puts ("Not a image image\n");
+			return 1;
+		}
+
+		/* verify integrity */
+		if (verify) {
+			if (!fit_image_check_hashes (fit_hdr, noffset)) {
+				puts ("Bad Data Hash\n");
+				return 1;
+			}
+		}
+
+		/* get script subimage data address and length */
+		if (fit_image_get_data (fit_hdr, noffset, &fit_data, &fit_len)) {
+			puts ("Could not find script subimage data\n");
+			return 1;
+		}
+
+		data = (ulong *)fit_data;
+		len = (ulong)fit_len;
+		break;
 #endif
 	default:
 		puts ("Wrong image format for autoscript\n");
@@ -160,25 +204,35 @@ do_autoscript (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
 	ulong addr;
 	int rcode;
+	const char *fit_uname = NULL;
 
+	/* Find script image */
 	if (argc < 2) {
 		addr = CFG_LOAD_ADDR;
+		debug ("*  autoscr: default load address = 0x%08lx\n", addr);
+#if defined(CONFIG_FIT)
+	} else if (fit_parse_subimage (argv[1], load_addr, &addr, &fit_uname)) {
+		debug ("*  autoscr: subimage '%s' from FIT image at 0x%08lx\n",
+				fit_uname, addr);
+#endif
 	} else {
-		addr = simple_strtoul (argv[1],0,16);
+		addr = simple_strtoul(argv[1], NULL, 16);
+		debug ("*  autoscr: cmdline image address = 0x%08lx\n", addr);
 	}
 
-	printf ("## Executing script at %08lx\n",addr);
-	rcode = autoscript (addr);
+	printf ("## Executing script at %08lx\n", addr);
+	rcode = autoscript (addr, fit_uname);
 	return rcode;
 }
 
-#if defined(CONFIG_CMD_AUTOSCRIPT)
 U_BOOT_CMD(
 	autoscr, 2, 0,	do_autoscript,
 	"autoscr - run script from memory\n",
 	"[addr] - run script starting@addr"
 	" - A valid autoscr header must be present\n"
-);
+#if defined(CONFIG_FIT)
+	"For FIT format uImage addr must include subimage\n"
+	"unit name in the form of addr:<subimg_uname>\n"
 #endif
-
+);
 #endif
diff --git a/common/cmd_load.c b/common/cmd_load.c
index 204c3eb..1b75a7b 100644
--- a/common/cmd_load.c
+++ b/common/cmd_load.c
@@ -521,8 +521,15 @@ int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		char *s;
 
 		if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) {
-			printf("Running autoscript at addr 0x%08lX ...\n", load_addr);
-			rcode = autoscript (load_addr);
+			printf ("Running autoscript at addr 0x%08lX", load_addr);
+
+			s = getenv ("autoscript_uname");
+			if (s)
+				printf (":%s ...\n", s);
+			else
+				puts (" ...\n");
+
+			rcode = autoscript (load_addr, s);
 		}
 	}
 #endif
diff --git a/common/cmd_net.c b/common/cmd_net.c
index dbf6b86..79e910c 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -220,9 +220,16 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
 
 #ifdef CONFIG_AUTOSCRIPT
 	if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) {
-		printf("Running autoscript at addr 0x%08lX ...\n", load_addr);
+		printf ("Running autoscript at addr 0x%08lX", load_addr);
+
+		s = getenv ("autoscript_uname");
+		if (s)
+			printf (":%s ...\n", s);
+		else
+			puts (" ...\n");
+
 		show_boot_progress (83);
-		rcode = autoscript (load_addr);
+		rcode = autoscript (load_addr, s);
 	}
 #endif
 	if (rcode < 0)
diff --git a/include/common.h b/include/common.h
index 3f05b5e..3351e2c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -222,7 +222,7 @@ int mac_read_from_eeprom(void);
 void flash_perror (int);
 
 /* common/cmd_autoscript.c */
-int	autoscript (ulong addr);
+int	autoscript (ulong addr, const char *fit_uname);
 
 extern ulong load_addr;		/* Default Load Address */
 

  parent reply	other threads:[~2008-03-12 20:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 01/20] [new uImage] Make node unit names const in struct bootm_headers Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 02/20] [new uImage] Add support for new uImage format to mkimage tool Bartlomiej Sieka
2008-03-14 14:54   ` Luigi 'Comio' Mantellini
2008-03-14 16:19     ` Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 03/20] [new uImage] Add new uImage format support for imls and iminfo commands Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 04/20] [new uImage] Add new uImage format support for kernel booting Bartlomiej Sieka
2008-03-12 20:10 ` [U-Boot-Users] [PATCH 05/20] [new uImage] Add new uImage format support for ramdisk handling Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 06/20] [new uImage] Remove unnecessary arguments passed to ramdisk routines Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 07/20] [new uImage] Re-enable interrupts for non automatic booting Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 08/20] [new uImage] ppc: Add new uImage format support to FDT handling routines Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 09/20] [new uImage] Add node offsets for FIT images listed in struct bootm_headers Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 10/20] [new uImage] Add new uImage format support to arch specific do_bootm_linux() routines Bartlomiej Sieka
2008-03-12 20:11 ` Bartlomiej Sieka [this message]
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 12/20] [new uImage] Add new uImage format support to imgextract command Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 13/20] [new uImage] Add new uImage format handling to other bootm related commands Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 14/20] [new uImage] Add new uImage fromat support to fpga command Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 15/20] [new uImage] Use show_boot_progress() for new uImage format Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 16/20] [new uImage] More verbose kernel image uncompress error message Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 17/20] [new uImage] Add proper ramdisk/FDT handling when FIT configuration is used Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 18/20] [new uImage] Fix build problems on trab board Bartlomiej Sieka
2008-03-12 20:55   ` Wolfgang Denk
2008-03-19  9:01     ` Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 19/20] [new uImage] Fix definition of common bootm_headers_t fields Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 20/20] [new uImage] Add new uImage format documentation and examples Bartlomiej Sieka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080312201135.6444.3414.stgit@pollux.denx.de \
    --to=tur@semihalf.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox