* [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality
@ 2008-03-12 20:10 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
` (19 more replies)
0 siblings, 20 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:10 UTC (permalink / raw)
To: u-boot
Hello,
This patch series implements the core of the new uImage support functionality,
i.e., the actual booting of images in new format, as well as support in
auxiliary commands that operate on images. There are also few fixing patches
in the series.
The patchset concludes major development work on the new uImage format, with
one missing piece (MD5 support) to be posted in a day or two. Generally, the
new format supports everything that the old format does, with the exception of
XIP and standalone applications. Also, only booting of the Linux kernel is
supported. If there are people interested in contributing to these areas,
please step forward.
It's a good moment to thank everybody who helped with this effort by
commenting on requirements, etc., and those who helped by reviewing patches.
At the same time it's important that people help with testing. The patchset 7
code is already available in the new-image branch of the u-boot-testing
repository -- please pull the code and try it out on the boards that you care
about. Reading doc/uImage.FIT/howto.txt should be sufficient to get you
started. Note that adding support for the new image format increases the size
of U-Boot, so depending on your Flash sector layout, adjustments to
CFG_MONITOR_LEN might be necessary.
The code builds on all architectures, and has been tested on ppc, but more
thorough testing is needed. In particular, reports on test results of the
following areas not tested due to hardware unavailability will be greatly
appreciated:
- boards other that ppc
- booting from dataflash
- U-Boot commands:
- diskboot
- docboot
- fdcboot
- fpga
- nboot
- scsiboot
- usbboot
Regards,
Bartlomiej
Bartlomiej Sieka (1):
[new uImage] Add support for new uImage format to mkimage tool
Marian Balakowicz (19):
[new uImage] Add new uImage format documentation and examples
[new uImage] Fix definition of common bootm_headers_t fields
[new uImage] Fix build problems on trab board
[new uImage] Add proper ramdisk/FDT handling when FIT configuration is used
[new uImage] More verbose kernel image uncompress error message
[new uImage] Use show_boot_progress() for new uImage format
[new uImage] Add new uImage fromat support to fpga command
[new uImage] Add new uImage format handling to other bootm related commands
[new uImage] Add new uImage format support to imgextract command
[new uImage] Add new uImage format support to autoscript routine
[new uImage] Add new uImage format support to arch specific do_bootm_linux() routines
[new uImage] Add node offsets for FIT images listed in struct bootm_headers
[new uImage] ppc: Add new uImage format support to FDT handling routines
[new uImage] Re-enable interrupts for non automatic booting
[new uImage] Remove unnecessary arguments passed to ramdisk routines
[new uImage] Add new uImage format support for ramdisk handling
[new uImage] Add new uImage format support for kernel booting
[new uImage] Add new uImage format support for imls and iminfo commands
[new uImage] Make node unit names const in struct bootm_headers
^ permalink raw reply [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 01/20] [new uImage] Make node unit names const in struct bootm_headers
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
@ 2008-03-12 20:10 ` 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
` (18 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:10 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
include/image.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/image.h b/include/image.h
index 704a3b4..bbd481d 100644
--- a/include/image.h
+++ b/include/image.h
@@ -200,14 +200,14 @@ typedef struct bootm_headers {
#if defined(CONFIG_FIT)
void *fit_hdr_os; /* os FIT image header */
- char *fit_uname_os; /* os subimage node unit name */
+ const char *fit_uname_os; /* os subimage node unit name */
void *fit_hdr_rd; /* init ramdisk FIT image header */
- char *fit_uname_rd; /* init ramdisk node unit name */
+ const char *fit_uname_rd; /* init ramdisk node unit name */
#if defined(CONFIG_PPC)
void *fit_hdr_fdt; /* FDT blob FIT image header */
- char *fit_uname_fdt; /* FDT blob node unit name */
+ const char *fit_uname_fdt; /* FDT blob node unit name */
#endif
int verify; /* getenv("verify")[0] != 'n' */
int autostart; /* getenv("autostart")[0] != 'n' */
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 02/20] [new uImage] Add support for new uImage format to mkimage tool
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 ` Bartlomiej Sieka
2008-03-14 14:54 ` Luigi 'Comio' Mantellini
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
` (17 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:10 UTC (permalink / raw)
To: u-boot
Support for the new uImage format (FIT) is added to mkimage tool.
Commandline syntax is appropriately extended:
mkimage [-D dtc_options] -f fit-image.its fit-image
mkimage (together with dtc) takes fit-image.its and referenced therein
binaries (like vmlinux.bin.gz) as inputs, and produces fit-image file -- the
final image that can be transferred to the target (e.g., via tftp) and then
booted using the bootm command in U-Boot.
Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
---
include/image.h | 15 ++-
tools/mkimage.c | 257 ++++++++++++++++++++++++++++++++++++++++++++-----------
tools/mkimage.h | 6 +
3 files changed, 222 insertions(+), 56 deletions(-)
diff --git a/include/image.h b/include/image.h
index bbd481d..681c753 100644
--- a/include/image.h
+++ b/include/image.h
@@ -40,14 +40,21 @@
#include <lmb.h>
#include <linux/string.h>
#include <asm/u-boot.h>
-#endif /* USE_HOSTCC */
-/* new uImage format support enabled by default */
+/* new uImage format support enabled on target
+ * To be moved to board configuration file */
#define CONFIG_FIT 1
#define CONFIG_OF_LIBFDT 1
+#define CONFIG_FIT_VERBOSE 1 /* enable fit_format_{error,warning}() */
+
+#else
-/* enable fit_format_error(), fit_format_warning() */
-#define CONFIG_FIT_VERBOSE 1
+/* new uImage format support enabled on host */
+#define CONFIG_FIT 1
+#define CONFIG_OF_LIBFDT 1
+#define CONFIG_FIT_VERBOSE 1 /* enable fit_format_{error,warning}() */
+
+#endif /* USE_HOSTCC */
#if defined(CONFIG_FIT) && !defined(CONFIG_OF_LIBFDT)
#error "CONFIG_OF_LIBFDT not enabled, required by CONFIG_FIT!"
diff --git a/tools/mkimage.c b/tools/mkimage.c
index 5cb2bc7..6e1ff2b 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -1,4 +1,6 @@
/*
+ * (C) Copyright 2008 Semihalf
+ *
* (C) Copyright 2000-2004
* DENX Software Engineering
* Wolfgang Denk, wd at denx.de
@@ -32,6 +34,8 @@ extern int errno;
extern unsigned long crc32 (unsigned long crc, const char *buf, unsigned int len);
static void copy_file (int, const char *, int);
static void usage (void);
+static void image_verify_header (char *, int);
+static void fit_handle_file (void);
char *datafile;
char *imagefile;
@@ -39,6 +43,7 @@ char *cmdname;
int dflag = 0;
int eflag = 0;
+int fflag = 0;
int lflag = 0;
int vflag = 0;
int xflag = 0;
@@ -46,6 +51,7 @@ int opt_os = IH_OS_LINUX;
int opt_arch = IH_ARCH_PPC;
int opt_type = IH_TYPE_KERNEL;
int opt_comp = IH_COMP_GZIP;
+char *opt_dtc = MKIMAGE_DEFAULT_DTC_OPTIONS;
image_header_t header;
image_header_t *hdr = &header;
@@ -53,7 +59,7 @@ image_header_t *hdr = &header;
int
main (int argc, char **argv)
{
- int ifd;
+ int ifd = -1;
uint32_t checksum;
uint32_t addr;
uint32_t ep;
@@ -81,6 +87,12 @@ main (int argc, char **argv)
(opt_comp = genimg_get_comp_id (*++argv)) < 0)
usage ();
goto NXTARG;
+ case 'D':
+ if (--argc <= 0)
+ usage ();
+ opt_dtc = *++argv;
+ goto NXTARG;
+
case 'O':
if ((--argc <= 0) ||
(opt_os = genimg_get_os_id (*++argv)) < 0)
@@ -121,6 +133,12 @@ main (int argc, char **argv)
}
eflag = 1;
goto NXTARG;
+ case 'f':
+ if (--argc <= 0)
+ usage ();
+ datafile = *++argv;
+ fflag = 1;
+ goto NXTARG;
case 'n':
if (--argc <= 0)
usage ();
@@ -139,7 +157,10 @@ main (int argc, char **argv)
NXTARG: ;
}
- if ((argc != 1) || ((lflag ^ dflag) == 0))
+ if ((argc != 1) ||
+ (dflag && (fflag || lflag)) ||
+ (fflag && (dflag || lflag)) ||
+ (lflag && (dflag || fflag)))
usage();
if (!eflag) {
@@ -165,21 +186,22 @@ NXTARG: ;
imagefile = *argv;
- if (lflag) {
- ifd = open(imagefile, O_RDONLY|O_BINARY);
- } else {
- ifd = open(imagefile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
- }
+ if (!fflag){
+ if (lflag) {
+ ifd = open (imagefile, O_RDONLY|O_BINARY);
+ } else {
+ ifd = open (imagefile,
+ O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666);
+ }
- if (ifd < 0) {
- fprintf (stderr, "%s: Can't open %s: %s\n",
- cmdname, imagefile, strerror(errno));
- exit (EXIT_FAILURE);
+ if (ifd < 0) {
+ fprintf (stderr, "%s: Can't open %s: %s\n",
+ cmdname, imagefile, strerror(errno));
+ exit (EXIT_FAILURE);
+ }
}
if (lflag) {
- int len;
- char *data;
/*
* list header information of existing image
*/
@@ -204,44 +226,24 @@ NXTARG: ;
exit (EXIT_FAILURE);
}
- /*
- * image_check_hcrc() creates copy of header so that
- * we can blank out the checksum field for checking -
- * this can't be done on the PROT_READ mapped data.
- */
- hdr = (image_header_t *)ptr;
-
- if (!image_check_magic (hdr)) {
- fprintf (stderr,
- "%s: Bad Magic Number: \"%s\" is no valid image\n",
- cmdname, imagefile);
- exit (EXIT_FAILURE);
- }
-
- if (!image_check_hcrc (hdr)) {
- fprintf (stderr,
- "%s: ERROR: \"%s\" has bad header checksum!\n",
- cmdname, imagefile);
- exit (EXIT_FAILURE);
+ if (fdt_check_header (ptr)) {
+ /* old-style image */
+ image_verify_header ((char *)ptr, sbuf.st_size);
+ image_print_contents_noindent ((image_header_t *)ptr);
+ } else {
+ /* FIT image */
+ fit_print_contents_noindent (ptr);
}
- data = (char *)image_get_data (hdr);
- len = sbuf.st_size - image_get_header_size ();
-
- if (crc32(0, data, len) != image_get_dcrc (hdr)) {
- fprintf (stderr,
- "%s: ERROR: \"%s\" has corrupted data!\n",
- cmdname, imagefile);
- exit (EXIT_FAILURE);
- }
-
- /* for multi-file images we need the data part, too */
- image_print_contents_noindent ((image_header_t *)ptr);
-
(void) munmap((void *)ptr, sbuf.st_size);
(void) close (ifd);
exit (EXIT_SUCCESS);
+ } else if (fflag) {
+ /* Flattened Image Tree (FIT) format handling */
+ debug ("FIT format handling\n");
+ fit_handle_file ();
+ exit (EXIT_SUCCESS);
}
/*
@@ -467,11 +469,11 @@ void
usage ()
{
fprintf (stderr, "Usage: %s -l image\n"
- " -l ==> list image header information\n"
- " %s [-x] -A arch -O os -T type -C comp "
- "-a addr -e ep -n name -d data_file[:data_file...] image\n",
- cmdname, cmdname);
- fprintf (stderr, " -A ==> set architecture to 'arch'\n"
+ " -l ==> list image header information\n",
+ cmdname);
+ fprintf (stderr, " %s [-x] -A arch -O os -T type -C comp "
+ "-a addr -e ep -n name -d data_file[:data_file...] image\n"
+ " -A ==> set architecture to 'arch'\n"
" -O ==> set operating system to 'os'\n"
" -T ==> set image type to 'type'\n"
" -C ==> set compression type 'comp'\n"
@@ -479,7 +481,158 @@ usage ()
" -e ==> set entry point to 'ep' (hex)\n"
" -n ==> set image name to 'name'\n"
" -d ==> use image data from 'datafile'\n"
- " -x ==> set XIP (execute in place)\n"
- );
+ " -x ==> set XIP (execute in place)\n",
+ cmdname);
+ fprintf (stderr, " %s [-D dtc_options] -f fit-image.its fit-image\n",
+ cmdname);
+
exit (EXIT_FAILURE);
}
+
+static void
+image_verify_header (char *ptr, int image_size)
+{
+ int len;
+ char *data;
+ uint32_t checksum;
+ image_header_t header;
+ image_header_t *hdr = &header;
+
+ /*
+ * create copy of header so that we can blank out the
+ * checksum field for checking - this can't be done
+ * on the PROT_READ mapped data.
+ */
+ memcpy (hdr, ptr, sizeof(image_header_t));
+
+ if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+ fprintf (stderr,
+ "%s: Bad Magic Number: \"%s\" is no valid image\n",
+ cmdname, imagefile);
+ exit (EXIT_FAILURE);
+ }
+
+ data = (char *)hdr;
+ len = sizeof(image_header_t);
+
+ checksum = ntohl(hdr->ih_hcrc);
+ hdr->ih_hcrc = htonl(0); /* clear for re-calculation */
+
+ if (crc32 (0, data, len) != checksum) {
+ fprintf (stderr,
+ "%s: ERROR: \"%s\" has bad header checksum!\n",
+ cmdname, imagefile);
+ exit (EXIT_FAILURE);
+ }
+
+ data = ptr + sizeof(image_header_t);
+ len = image_size - sizeof(image_header_t) ;
+
+ if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) {
+ fprintf (stderr,
+ "%s: ERROR: \"%s\" has corrupted data!\n",
+ cmdname, imagefile);
+ exit (EXIT_FAILURE);
+ }
+}
+
+/**
+ * fit_handle_file - main FIT file processing function
+ *
+ * fit_handle_file() runs dtc to convert .its to .itb, includes
+ * binary data, updates timestamp property and calculates hashes.
+ *
+ * datafile - .its file
+ * imagefile - .itb file
+ *
+ * returns:
+ * only on success, otherwise calls exit (EXIT_FAILURE);
+ */
+static void fit_handle_file (void)
+{
+ char tmpfile[MKIMAGE_MAX_TMPFILE_LEN];
+ char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN];
+ int tfd;
+ struct stat sbuf;
+ unsigned char *ptr;
+
+ /* call dtc to include binary properties into the tmp file */
+ if (strlen (imagefile) + strlen (MKIMAGE_TMPFILE_SUFFIX) + 1 >
+ sizeof (tmpfile)) {
+ fprintf (stderr, "%s: Image file name (%s) too long, "
+ "can't create tmpfile",
+ imagefile, cmdname);
+ exit (EXIT_FAILURE);
+ }
+ sprintf (tmpfile, "%s%s", imagefile, MKIMAGE_TMPFILE_SUFFIX);
+
+ /* dtc -I dts -O -p 200 datafile > tmpfile */
+ sprintf (cmd, "%s %s %s > %s",
+ MKIMAGE_DTC, opt_dtc, datafile, tmpfile);
+ debug ("Trying to execute \"%s\"\n", cmd);
+ if (system (cmd) == -1) {
+ fprintf (stderr, "%s: system(%s) failed: %s\n",
+ cmdname, cmd, strerror(errno));
+ unlink (tmpfile);
+ exit (EXIT_FAILURE);
+ }
+
+ /* load FIT blob into memory */
+ tfd = open (tmpfile, O_RDWR|O_BINARY);
+
+ if (tfd < 0) {
+ fprintf (stderr, "%s: Can't open %s: %s\n",
+ cmdname, tmpfile, strerror(errno));
+ unlink (tmpfile);
+ exit (EXIT_FAILURE);
+ }
+
+ if (fstat (tfd, &sbuf) < 0) {
+ fprintf (stderr, "%s: Can't stat %s: %s\n",
+ cmdname, tmpfile, strerror(errno));
+ unlink (tmpfile);
+ exit (EXIT_FAILURE);
+ }
+
+ ptr = (unsigned char *)mmap (0, sbuf.st_size,
+ PROT_READ|PROT_WRITE, MAP_SHARED, tfd, 0);
+ if ((caddr_t)ptr == (caddr_t)-1) {
+ fprintf (stderr, "%s: Can't read %s: %s\n",
+ cmdname, tmpfile, strerror(errno));
+ unlink (tmpfile);
+ exit (EXIT_FAILURE);
+ }
+
+ /* check if ptr has a valid blob */
+ if (fdt_check_header (ptr)) {
+ fprintf (stderr, "%s: Invalid FIT blob\n", cmdname);
+ unlink (tmpfile);
+ exit (EXIT_FAILURE);
+ }
+
+ /* set hashes for images in the blob */
+ if (fit_set_hashes (ptr)) {
+ fprintf (stderr, "%s Can't add hashes to FIT blob", cmdname);
+ unlink (tmpfile);
+ exit (EXIT_FAILURE);
+ }
+
+ /* add a timestamp@offset 0 i.e., root */
+ if (fit_set_timestamp (ptr, 0, sbuf.st_mtime)) {
+ fprintf (stderr, "%s: Can't add image timestamp\n", cmdname);
+ unlink (tmpfile);
+ exit (EXIT_FAILURE);
+ }
+ debug ("Added timestamp successfully\n");
+
+ munmap ((void *)ptr, sbuf.st_size);
+ close (tfd);
+
+ if (rename (tmpfile, imagefile) == -1) {
+ fprintf (stderr, "%s: Can't rename %s to %s: %s\n",
+ cmdname, tmpfile, imagefile, strerror (errno));
+ unlink (tmpfile);
+ unlink (imagefile);
+ exit (EXIT_FAILURE);
+ }
+}
diff --git a/tools/mkimage.h b/tools/mkimage.h
index 41cd156..a2d5248 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -43,6 +43,12 @@
#define debug(fmt,args...)
#endif /* MKIMAGE_DEBUG */
+#define MKIMAGE_TMPFILE_SUFFIX ".tmp"
+#define MKIMAGE_MAX_TMPFILE_LEN 256
+#define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500"
+#define MKIMAGE_MAX_DTC_CMDLINE_LEN 512
+#define MKIMAGE_DTC "dtc" /* assume dtc is in $PATH */
+
#if defined(__BEOS__) || defined(__NetBSD__) || defined(__APPLE__)
#include <inttypes.h>
#endif
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 03/20] [new uImage] Add new uImage format support for imls and iminfo commands
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-12 20:10 ` 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
` (16 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:10 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
imls and iminfo can now recognize nad print out contents of the new (FIT)
format uImages.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/cmd_bootm.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 10403aa..daee7bf 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -556,7 +556,13 @@ static int image_info (ulong addr)
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
puts (" FIT image found\n");
- fit_unsupported ("iminfo");
+
+ if (!fit_check_format (hdr)) {
+ puts ("Bad FIT image format!\n");
+ return 1;
+ }
+
+ fit_print_contents (hdr);
return 0;
#endif
default:
@@ -601,9 +607,6 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
switch (genimg_get_format (hdr)) {
case IMAGE_FORMAT_LEGACY:
- if (!image_check_magic (hdr))
- goto next_sector;
-
if (!image_check_hcrc (hdr))
goto next_sector;
@@ -619,8 +622,11 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
+ if (!fit_check_format (hdr))
+ goto next_sector;
+
printf ("FIT Image at %08lX:\n", (ulong)hdr);
- fit_unsupported ("imls");
+ fit_print_contents (hdr);
break;
#endif
default:
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 04/20] [new uImage] Add new uImage format support for kernel booting
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (2 preceding siblings ...)
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 ` 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
` (15 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:10 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
New format uImages are recognized by the bootm command,
validity of specified kernel component image is checked and
its data section located and used for further processing
(uncompress, load, etc.)
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/cmd_bootm.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 144 insertions(+), 11 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index daee7bf..96d09e6 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -66,6 +66,11 @@ static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
static void fixup_silent_linux (void);
#endif
+static image_header_t *image_get_kernel (ulong img_addr, int verify);
+#if defined(CONFIG_FIT)
+static int fit_check_kernel (const void *fit, int os_noffset, int verify);
+#endif
+
static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char *argv[],
bootm_headers_t *images, ulong *os_data, ulong *os_len);
extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
@@ -125,6 +130,9 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong image_start, image_end;
ulong load_start, load_end;
ulong mem_start, mem_size;
+#if defined(CONFIG_FIT)
+ int os_noffset;
+#endif
struct lmb lmb;
@@ -145,8 +153,10 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* get kernel image header, start address and length */
os_hdr = boot_get_kernel (cmdtp, flag, argc, argv,
&images, &os_data, &os_len);
- if (os_len == 0)
+ if (os_len == 0) {
+ puts ("ERROR: can't get kernel image!\n");
return 1;
+ }
show_boot_progress (6);
@@ -162,8 +172,37 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("bootm");
- return 1;
+ os_noffset = fit_image_get_node (images.fit_hdr_os,
+ images.fit_uname_os);
+ if (os_noffset < 0) {
+ printf ("Can't get image node for '%s'!\n",
+ images.fit_uname_os);
+ return 1;
+ }
+
+ if (fit_image_get_type (images.fit_hdr_os, os_noffset, &type)) {
+ puts ("Can't get image type!\n");
+ return 1;
+ }
+
+ if (fit_image_get_comp (images.fit_hdr_os, os_noffset, &comp)) {
+ puts ("Can't get image compression!\n");
+ return 1;
+ }
+
+ if (fit_image_get_os (images.fit_hdr_os, os_noffset, &os)) {
+ puts ("Can't get image OS!\n");
+ return 1;
+ }
+
+ image_end = fit_get_end (images.fit_hdr_os);
+
+ if (fit_image_get_load (images.fit_hdr_os, os_noffset,
+ &load_start)) {
+ puts ("Can't get image load address!\n");
+ return 1;
+ }
+ break;
#endif
default:
puts ("ERROR: unknown image format type!\n");
@@ -360,6 +399,47 @@ static image_header_t *image_get_kernel (ulong img_addr, int verify)
}
/**
+ * fit_check_kernel - verify FIT format kernel subimage
+ * @fit_hdr: pointer to the FIT image header
+ * os_noffset: kernel subimage node offset within FIT image
+ * @verify: data CRC verification flag
+ *
+ * fit_check_kernel() verifies integrity of the kernel subimage and from
+ * specified FIT image.
+ *
+ * returns:
+ * 1, on success
+ * 0, on failure
+ */
+#if defined (CONFIG_FIT)
+static int fit_check_kernel (const void *fit, int os_noffset, int verify)
+{
+ fit_image_print (fit, os_noffset, " ");
+
+ if (verify) {
+ puts (" Verifying Hash Integrity ... ");
+ if (!fit_image_check_hashes (fit, os_noffset)) {
+ puts ("Bad Data Hash\n");
+ return 0;
+ }
+ puts ("OK\n");
+ }
+
+ if (!fit_image_check_target_arch (fit, os_noffset)) {
+ puts ("Unsupported Architecture\n");
+ return 0;
+ }
+
+ if (!fit_image_check_type (fit, os_noffset, IH_TYPE_KERNEL)) {
+ puts ("Not a kernel image\n");
+ return 0;
+ }
+
+ return 1;
+}
+#endif /* CONFIG_FIT */
+
+/**
* boot_get_kernel - find kernel image
* @os_data: pointer to a ulong variable, will hold os data start address
* @os_len: pointer to a ulong variable, will hold os data length
@@ -380,6 +460,10 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
void *fit_hdr;
const char *fit_uname_config = NULL;
const char *fit_uname_kernel = NULL;
+ const void *data;
+ size_t len;
+ int conf_noffset;
+ int os_noffset;
#endif
/* find out kernel image address */
@@ -403,21 +487,22 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
}
show_boot_progress (1);
- printf ("## Booting kernel image at %08lx ...\n", img_addr);
/* copy from dataflash if needed */
img_addr = genimg_get_image (img_addr);
/* check image type, for FIT images get FIT kernel node */
+ *os_data = *os_len = 0;
switch (genimg_get_format ((void *)img_addr)) {
case IMAGE_FORMAT_LEGACY:
-
- debug ("* kernel: legacy format image\n");
+ printf ("## Booting kernel from Legacy Image@%08lx ...\n",
+ img_addr);
hdr = image_get_kernel (img_addr, images->verify);
if (!hdr)
return NULL;
show_boot_progress (5);
+ /* get os_data and os_len */
switch (image_get_type (hdr)) {
case IH_TYPE_KERNEL:
*os_data = image_get_data (hdr);
@@ -438,17 +523,57 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
fit_hdr = (void *)img_addr;
- debug ("* kernel: FIT format image\n");
- fit_unsupported ("kernel");
- return NULL;
+ printf ("## Booting kernel from FIT Image at %08lx ...\n",
+ img_addr);
+
+ if (!fit_check_format (fit_hdr)) {
+ puts ("Bad FIT kernel image format!\n");
+ return NULL;
+ }
+
+ if (!fit_uname_kernel) {
+ /*
+ * no kernel image node unit name, try to get config
+ * node first. If config unit node name is NULL
+ * fit_conf_get_node() will try to find default config node
+ */
+ conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+ if (conf_noffset < 0)
+ return NULL;
+
+ os_noffset = fit_conf_get_kernel_node (fit_hdr, conf_noffset);
+ fit_uname_kernel = fit_get_name (fit_hdr, os_noffset, NULL);
+ } else {
+ /* get kernel component image node offset */
+ os_noffset = fit_image_get_node (fit_hdr, fit_uname_kernel);
+ }
+ if (os_noffset < 0)
+ return NULL;
+
+ printf (" Trying '%s' kernel subimage\n", fit_uname_kernel);
+
+ if (!fit_check_kernel (fit_hdr, os_noffset, images->verify))
+ return NULL;
+
+ /* get kernel image data address and length */
+ if (fit_image_get_data (fit_hdr, os_noffset, &data, &len)) {
+ puts ("Could not find kernel subimage data!\n");
+ return NULL;
+ }
+
+ *os_len = len;
+ *os_data = (ulong)data;
+ images->fit_hdr_os = fit_hdr;
+ images->fit_uname_os = fit_uname_kernel;
+ break;
#endif
default:
printf ("Wrong Image Format for %s command\n", cmdtp->name);
return NULL;
}
- debug (" kernel data at 0x%08lx, end = 0x%08lx\n",
- *os_data, *os_data + *os_len);
+ debug (" kernel data at 0x%08lx, len = 0x%08lx (%d)\n",
+ *os_data, *os_len, *os_len);
return (void *)img_addr;
}
@@ -466,6 +591,14 @@ U_BOOT_CMD(
"\tuse a '-' for the second argument. If you do not pass a third\n"
"\ta bd_info struct will be passed instead\n"
#endif
+#if defined(CONFIG_FIT)
+ "\t\nFor the new multi component uImage format (FIT) addresses\n"
+ "\tmust be extened to include component or configuration unit name:\n"
+ "\taddr:<subimg_uname> - direct component image specification\n"
+ "\taddr#<conf_uname> - configuration specification\n"
+ "\tUse iminfo command to get the list of existing component\n"
+ "\timages and configurations.\n"
+#endif
);
/*******************************************************************/
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 05/20] [new uImage] Add new uImage format support for ramdisk handling
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (3 preceding siblings ...)
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 ` Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 06/20] [new uImage] Remove unnecessary arguments passed to ramdisk routines Bartlomiej Sieka
` (14 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:10 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
This patch updates boot_get_ramdisk() routine adding format
verification and handling for new (FIT) uImages.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/image.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 108 insertions(+), 16 deletions(-)
diff --git a/common/image.c b/common/image.c
index 9278ea9..3b15853 100644
--- a/common/image.c
+++ b/common/image.c
@@ -47,11 +47,17 @@
#include <image.h>
-#if defined(CONFIG_FIT)
+#if defined(CONFIG_FIT) || defined (CONFIG_OF_LIBFDT)
#include <fdt.h>
#include <libfdt.h>
#include <fdt_support.h>
+#endif
+
+#if defined(CONFIG_FIT)
#include <sha1.h>
+
+static int fit_check_ramdisk (const void *fit, int os_noffset,
+ uint8_t arch, int verify);
#endif
#ifdef CONFIG_CMD_BDI
@@ -774,8 +780,15 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
const char *fit_uname_config = NULL;
const char *fit_uname_ramdisk = NULL;
ulong default_addr;
+ int rd_noffset;
+ int conf_noffset;
+ const void *data;
+ size_t size;
#endif
+ *rd_start = 0;
+ *rd_end = 0;
+
/*
* Look for a '-' which indicates to ignore the
* ramdisk argument
@@ -812,8 +825,6 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
}
/* copy from dataflash if needed */
- printf ("## Loading init Ramdisk Image at %08lx ...\n",
- rd_addr);
rd_addr = genimg_get_image (rd_addr);
/*
@@ -823,17 +834,14 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
*/
switch (genimg_get_format ((void *)rd_addr)) {
case IMAGE_FORMAT_LEGACY:
-
- debug ("* ramdisk: legacy format image\n");
+ printf ("## Loading init Ramdisk from Legacy "
+ "Image at %08lx ...\n", rd_addr);
rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
rd_addr, arch, images->verify);
- if (rd_hdr == NULL) {
- *rd_start = 0;
- *rd_end = 0;
+ if (rd_hdr == NULL)
return 1;
- }
rd_data = image_get_data (rd_hdr);
rd_len = image_get_data_size (rd_hdr);
@@ -842,14 +850,60 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
fit_hdr = (void *)rd_addr;
- debug ("* ramdisk: FIT format image\n");
- fit_unsupported_reset ("ramdisk");
- return 1;
+ printf ("## Loading init Ramdisk from FIT "
+ "Image at %08lx ...\n", rd_addr);
+
+ if (!fit_check_format (fit_hdr)) {
+ puts ("Bad FIT ramdisk image format!\n");
+ return 0;
+ }
+
+ if (!fit_uname_ramdisk) {
+ /*
+ * no ramdisk image node unit name, try to get config
+ * node first. If config unit node name is NULL
+ * fit_conf_get_node() will try to find default config node
+ */
+ conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+ if (conf_noffset < 0)
+ return 0;
+
+ rd_noffset = fit_conf_get_ramdisk_node (fit_hdr, conf_noffset);
+ fit_uname_ramdisk = fit_get_name (fit_hdr, rd_noffset, NULL);
+ } else {
+ /* get ramdisk component image node offset */
+ rd_noffset = fit_image_get_node (fit_hdr, fit_uname_ramdisk);
+ }
+ if (rd_noffset < 0)
+ return 0;
+
+ printf (" Trying '%s' ramdisk subimage\n", fit_uname_ramdisk);
+
+ if (!fit_check_ramdisk (fit_hdr, rd_noffset, arch, images->verify))
+ return 0;
+
+ /* get ramdisk image data address and length */
+ if (fit_image_get_data (fit_hdr, rd_noffset, &data, &size)) {
+ puts ("Could not find ramdisk subimage data!\n");
+ return 0;
+ }
+
+ rd_data = (ulong)data;
+ rd_len = size;
+
+ if (fit_image_get_load (fit_hdr, rd_noffset, &rd_load)) {
+ puts ("Can't get ramdisk subimage load address!\n");
+ return 0;
+ }
+
+ images->fit_hdr_rd = fit_hdr;
+ images->fit_uname_rd = fit_uname_ramdisk;
+ break;
#endif
default:
printf ("Wrong Image Format for %s command\n",
cmdtp->name);
- rd_data = rd_len = 0;
+ rd_data = rd_len = rd_load = 0;
}
#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO)
@@ -870,7 +924,7 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
*/
show_boot_progress (13);
printf ("## Loading init Ramdisk from multi component "
- "Image at %08lx ...\n",
+ "Legacy Image at %08lx ...\n",
(ulong)images->legacy_hdr_os);
image_multi_getimg (images->legacy_hdr_os, 1, &rd_data, &rd_len);
@@ -884,8 +938,6 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if (!rd_data) {
debug ("## No init Ramdisk\n");
- *rd_start = 0;
- *rd_end = 0;
} else {
*rd_start = rd_data;
*rd_end = rd_data + rd_len;
@@ -2376,4 +2428,44 @@ void fit_conf_print (const void *fit, int noffset, const char *p)
if (uname)
printf ("%s FDT: %s\n", p, uname);
}
+
+/**
+ * fit_check_ramdisk - verify FIT format ramdisk subimage
+ * @fit_hdr: pointer to the FIT ramdisk header
+ * @rd_noffset: ramdisk subimage node offset within FIT image
+ * @arch: requested ramdisk image architecture type
+ * @verify: data CRC verification flag
+ *
+ * fit_check_ramdisk() verifies integrity of the ramdisk subimage and from
+ * specified FIT image.
+ *
+ * returns:
+ * 1, on success
+ * 0, on failure
+ */
+#ifndef USE_HOSTCC
+static int fit_check_ramdisk (const void *fit, int rd_noffset, uint8_t arch, int verify)
+{
+ fit_image_print (fit, rd_noffset, " ");
+
+ if (verify) {
+ puts (" Verifying Hash Integrity ... ");
+ if (!fit_image_check_hashes (fit, rd_noffset)) {
+ puts ("Bad Data Hash\n");
+ return 0;
+ }
+ puts ("OK\n");
+ }
+
+ if (!fit_image_check_os (fit, rd_noffset, IH_OS_LINUX) ||
+ !fit_image_check_arch (fit, rd_noffset, arch) ||
+ !fit_image_check_type (fit, rd_noffset, IH_TYPE_RAMDISK)) {
+ printf ("No Linux %s Ramdisk Image\n",
+ genimg_get_arch_name(arch));
+ return 0;
+ }
+
+ return 1;
+}
+#endif /* USE_HOSTCC */
#endif /* CONFIG_FIT */
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 06/20] [new uImage] Remove unnecessary arguments passed to ramdisk routines
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (4 preceding siblings ...)
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 ` Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 07/20] [new uImage] Re-enable interrupts for non automatic booting Bartlomiej Sieka
` (13 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
boot_get_ramdisk() and image_get_ramdisk() do not need all
cmdtp, flag, argc and argv arguments. Simplify routines definition.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/image.c | 32 ++++++++++++--------------------
include/image.h | 5 ++---
lib_arm/bootm.c | 6 ++++--
lib_avr32/bootm.c | 6 ++++--
lib_i386/bootm.c | 7 +++++--
lib_m68k/bootm.c | 5 ++---
lib_mips/bootm.c | 7 +++++--
lib_ppc/bootm.c | 5 ++---
8 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/common/image.c b/common/image.c
index 3b15853..6458fb1 100644
--- a/common/image.c
+++ b/common/image.c
@@ -66,9 +66,8 @@ extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
DECLARE_GLOBAL_DATA_PTR;
-static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
- ulong rd_addr, uint8_t arch, int verify);
+static image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
+ int verify);
#else
#include "mkimage.h"
#include <time.h>
@@ -379,10 +378,6 @@ inline void image_print_contents_noindent (image_header_t *hdr)
#ifndef USE_HOSTCC
/**
* image_get_ramdisk - get and verify ramdisk image
- * @cmdtp: command table pointer
- * @flag: command flag
- * @argc: command argument count
- * @argv: command argument list
* @rd_addr: ramdisk image start address
* @arch: expected ramdisk architecture
* @verify: checksum verification flag
@@ -399,9 +394,8 @@ inline void image_print_contents_noindent (image_header_t *hdr)
* pointer to a ramdisk image header, if image was found and valid
* otherwise, return NULL
*/
-static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
- ulong rd_addr, uint8_t arch, int verify)
+static image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
+ int verify)
{
image_header_t *rd_hdr;
@@ -748,8 +742,6 @@ ulong genimg_get_image (ulong img_addr)
/**
* boot_get_ramdisk - main ramdisk handling routine
- * @cmdtp: command table pointer
- * @flag: command flag
* @argc: command argument count
* @argv: command argument list
* @images: pointer to the bootm images structure
@@ -763,14 +755,15 @@ ulong genimg_get_image (ulong img_addr)
* - commandline provided address of decicated ramdisk image.
*
* returns:
+ * 0, if ramdisk image was found and valid, or skiped
* rd_start and rd_end are set to ramdisk start/end addresses if
* ramdisk image is found and valid
+ *
+ * 1, if ramdisk image is found but corrupted
* rd_start and rd_end are set to 0 if no ramdisk exists
- * return 1 if ramdisk image is found but corrupted
*/
-int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
- bootm_headers_t *images, uint8_t arch,
- ulong *rd_start, ulong *rd_end)
+int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
+ uint8_t arch, ulong *rd_start, ulong *rd_end)
{
ulong rd_addr, rd_load;
ulong rd_data, rd_len;
@@ -837,8 +830,8 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
printf ("## Loading init Ramdisk from Legacy "
"Image at %08lx ...\n", rd_addr);
- rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
- rd_addr, arch, images->verify);
+ rd_hdr = image_get_ramdisk (rd_addr, arch,
+ images->verify);
if (rd_hdr == NULL)
return 1;
@@ -901,8 +894,7 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
break;
#endif
default:
- printf ("Wrong Image Format for %s command\n",
- cmdtp->name);
+ puts ("Wrong Ramdisk Image Format\n");
rd_data = rd_len = rd_load = 0;
}
diff --git a/include/image.h b/include/image.h
index 681c753..6fca6f4 100644
--- a/include/image.h
+++ b/include/image.h
@@ -250,9 +250,8 @@ int genimg_get_comp_id (const char *name);
int genimg_get_format (void *img_addr);
ulong genimg_get_image (ulong img_addr);
-int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
- bootm_headers_t *images, uint8_t arch,
- ulong *rd_start, ulong *rd_end);
+int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
+ uint8_t arch, ulong *rd_start, ulong *rd_end);
#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c
index 865e711..08eef0b 100644
--- a/lib_arm/bootm.c
+++ b/lib_arm/bootm.c
@@ -95,8 +95,10 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
printf ("Using machid 0x%x from environment\n", machid);
}
- boot_get_ramdisk (cmdtp, flag, argc, argv, images,
- IH_ARCH_ARM, &initrd_start, &initrd_end);
+ ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_ARM,
+ &initrd_start, &initrd_end);
+ if (ret)
+ do_reset (cmdtp, flag, argc, argv);
show_boot_progress (15);
diff --git a/lib_avr32/bootm.c b/lib_avr32/bootm.c
index e8e537a..c9a0190 100644
--- a/lib_avr32/bootm.c
+++ b/lib_avr32/bootm.c
@@ -196,8 +196,10 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
}
theKernel = (void *)ep;
- boot_get_ramdisk (cmdtp, flag, argc, argv, images,
- IH_ARCH_AVR32, &initrd_start, &initrd_end);
+ ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_AVR32,
+ &initrd_start, &initrd_end);
+ if (ret)
+ do_reset (cmdtp, flag, argc, argv);
show_boot_progress (15);
diff --git a/lib_i386/bootm.c b/lib_i386/bootm.c
index 76bcf6c..b4a52fa 100644
--- a/lib_i386/bootm.c
+++ b/lib_i386/bootm.c
@@ -39,9 +39,12 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ulong initrd_start, initrd_end;
ulong ep;
image_header_t *hdr;
+ int ret;
- boot_get_ramdisk (cmdtp, flag, argc, argv, images,
- IH_ARCH_I386, &initrd_start, &initrd_end);
+ ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_I386,
+ &initrd_start, &initrd_end);
+ if (ret)
+ do_reset (cmdtp, flag, argc, argv);
if (images->legacy_hdr_valid) {
hdr = images->legacy_hdr_os;
diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c
index fba7499..f185bea 100644
--- a/lib_m68k/bootm.c
+++ b/lib_m68k/bootm.c
@@ -111,9 +111,8 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
/* find ramdisk */
- ret = boot_get_ramdisk (cmdtp, flag, argc, argv, images,
- IH_ARCH_M68K, &rd_data_start, &rd_data_end);
-
+ ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_M68K,
+ &rd_data_start, &rd_data_end);
if (ret)
goto error;
diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c
index b336a36..5e7a460 100644
--- a/lib_mips/bootm.c
+++ b/lib_mips/bootm.c
@@ -53,6 +53,7 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
void (*theKernel) (int, char **, char **, int *);
char *commandline = getenv ("bootargs");
char env_buf[12];
+ int ret;
/* find kernel entry point */
if (images->legacy_hdr_valid) {
@@ -68,8 +69,10 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
}
theKernel = (void (*)(int, char **, char **, int *))ep;
- boot_get_ramdisk (cmdtp, flag, argc, argv, images,
- IH_ARCH_MIPS, &initrd_start, &initrd_end);
+ ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_MIPS,
+ &initrd_start, &initrd_end);
+ if (ret)
+ do_reset (cmdtp, flag, argc, argv);
show_boot_progress (15);
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index 7977157..ac06b26 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -160,9 +160,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
/* find ramdisk */
- ret = boot_get_ramdisk (cmdtp, flag, argc, argv, images,
- IH_ARCH_PPC, &rd_data_start, &rd_data_end);
-
+ ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_PPC,
+ &rd_data_start, &rd_data_end);
if (ret)
goto error;
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 07/20] [new uImage] Re-enable interrupts for non automatic booting
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (5 preceding siblings ...)
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 ` 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
` (12 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Re-enable interrupts if we return from do_bootm_<os> and 'autostart'
environment variable is not set to 'yes'.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/cmd_bootm.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 96d09e6..aca54b5 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -342,8 +342,12 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
show_boot_progress (-9);
#ifdef DEBUG
puts ("\n## Control returned to monitor - resetting...\n");
- do_reset (cmdtp, flag, argc, argv);
+ if (images.autostart)
+ do_reset (cmdtp, flag, argc, argv);
#endif
+ if (!images.autostart && iflag)
+ enable_interrupts();
+
return 1;
}
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 08/20] [new uImage] ppc: Add new uImage format support to FDT handling routines
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (6 preceding siblings ...)
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 ` 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
` (11 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Support for new (FIT) format uImages is added to powerpc specific
boot_get_fdt() routine which now recognizes, sanity checks FIT image
and is able to access data sections of the requested component image.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
lib_ppc/bootm.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 151 insertions(+), 23 deletions(-)
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index ac06b26..60bc04b 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -254,20 +254,24 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
* r6: NULL
* r7: NULL
*/
+ debug (" Booting using OF flat tree...\n");
(*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0);
/* does not return */
- }
+ } else
#endif
- /*
- * Linux Kernel Parameters (passing board info data):
- * r3: ptr to board info data
- * r4: initrd_start or 0 if no initrd
- * r5: initrd_end - unused if r4 is 0
- * r6: Start of command line string
- * r7: End of command line string
- */
- (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
- /* does not return */
+ {
+ /*
+ * Linux Kernel Parameters (passing board info data):
+ * r3: ptr to board info data
+ * r4: initrd_start or 0 if no initrd
+ * r5: initrd_end - unused if r4 is 0
+ * r6: Start of command line string
+ * r7: End of command line string
+ */
+ debug (" Booting using board info...\n");
+ (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
+ /* does not return */
+ }
return ;
error:
@@ -353,6 +357,47 @@ static image_header_t *image_get_fdt (ulong fdt_addr)
return fdt_hdr;
}
+/**
+ * fit_check_fdt - verify FIT format FDT subimage
+ * @fit_hdr: pointer to the FIT header
+ * fdt_noffset: FDT subimage node offset within FIT image
+ * @verify: data CRC verification flag
+ *
+ * fit_check_fdt() verifies integrity of the FDT subimage and from
+ * specified FIT image.
+ *
+ * returns:
+ * 1, on success
+ * 0, on failure
+ */
+#if defined(CONFIG_FIT)
+static int fit_check_fdt (const void *fit, int fdt_noffset, int verify)
+{
+ fit_image_print (fit, fdt_noffset, " ");
+
+ if (verify) {
+ puts (" Verifying Hash Integrity ... ");
+ if (!fit_image_check_hashes (fit, fdt_noffset)) {
+ fdt_error ("Bad Data Hash");
+ return 0;
+ }
+ puts ("OK\n");
+ }
+
+ if (!fit_image_check_type (fit, fdt_noffset, IH_TYPE_FLATDT)) {
+ fdt_error ("Not a FDT image");
+ return 0;
+ }
+
+ if (!fit_image_check_comp (fit, fdt_noffset, IH_COMP_NONE)) {
+ fdt_error ("FDT image is compressed");
+ return 0;
+ }
+
+ return 1;
+}
+#endif /* CONFIG_FIT */
+
static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
{
@@ -366,8 +411,15 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
const char *fit_uname_config = NULL;
const char *fit_uname_fdt = NULL;
ulong default_addr;
+ int conf_noffset;
+ int fdt_noffset;
+ const void *data;
+ size_t size;
#endif
+ *of_flat_tree = NULL;
+ *of_size = 0;
+
if (argc > 3) {
#if defined(CONFIG_FIT)
/*
@@ -398,7 +450,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
fdt_addr);
}
- debug ("## Checking for 'FDT'/'FDT image' at %08lx\n",
+ debug ("## Checking for 'FDT'/'FDT Image' at %08lx\n",
fdt_addr);
/* copy from dataflash if needed */
@@ -411,10 +463,8 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
*/
switch (genimg_get_format ((void *)fdt_addr)) {
case IMAGE_FORMAT_LEGACY:
- debug ("* fdt: legacy format image\n");
-
/* verify fdt_addr points to a valid image header */
- printf ("## Flattened Device Tree Legacy Image at %08lx\n",
+ printf ("## Flattened Device Tree from Legacy Image at %08lx\n",
fdt_addr);
fdt_hdr = image_get_fdt (fdt_addr);
if (!fdt_hdr)
@@ -434,11 +484,15 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
fdt_error ("fdt overwritten");
goto error;
}
- memmove ((void *)image_get_load (fdt_hdr),
+
+ debug (" Loading FDT from 0x%08lx to 0x%08lx\n",
+ image_get_data (fdt_hdr), load_start);
+
+ memmove ((void *)load_start,
(void *)image_get_data (fdt_hdr),
image_get_data_size (fdt_hdr));
- fdt_blob = (char *)image_get_load (fdt_hdr);
+ fdt_blob = (char *)load_start;
break;
case IMAGE_FORMAT_FIT:
/*
@@ -448,14 +502,90 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
*/
#if defined(CONFIG_FIT)
/* check FDT blob vs FIT blob */
- if (0) { /* FIXME: call FIT format verification */
+ if (fit_check_format ((const void *)fdt_addr)) {
/*
* FIT image
*/
fit_hdr = (void *)fdt_addr;
- debug ("* fdt: FIT format image\n");
- fit_unsupported_reset ("PPC fdt");
- goto error;
+ printf ("## Flattened Device Tree from FIT Image at %08lx\n",
+ fdt_addr);
+
+ if (!fit_uname_fdt) {
+ /*
+ * no FDT blob image node unit name,
+ * try to get config node first. If
+ * config unit node name is NULL
+ * fit_conf_get_node() will try to
+ * find default config node
+ */
+ conf_noffset = fit_conf_get_node (fit_hdr,
+ fit_uname_config);
+ if (conf_noffset < 0)
+ goto error;
+
+ fdt_noffset = fit_conf_get_fdt_node (fit_hdr,
+ conf_noffset);
+ fit_uname_fdt = fit_get_name (fit_hdr,
+ fdt_noffset, NULL);
+ } else {
+ /* get FDT component image node offset */
+ fdt_noffset = fit_image_get_node (fit_hdr,
+ fit_uname_fdt);
+ }
+ if (fdt_noffset < 0)
+ goto error;
+
+ printf (" Trying '%s' FDT blob subimage\n",
+ fit_uname_fdt);
+
+ if (!fit_check_fdt (fit_hdr, fdt_noffset,
+ images->verify))
+ goto error;
+
+ /* get ramdisk image data address and length */
+ if (fit_image_get_data (fit_hdr, fdt_noffset,
+ &data, &size)) {
+ fdt_error ("Could not find FDT subimage data");
+ goto error;
+ }
+
+ /* verift that image data is a proper FDT blob */
+ if (fdt_check_header ((char *)data) != 0) {
+ fdt_error ("Subimage data is not a FTD");
+ goto error;
+ }
+
+ /*
+ * move image data to the load address,
+ * make sure we don't overwrite initial image
+ */
+ image_start = (ulong)fit_hdr;
+ image_end = fit_get_end (fit_hdr);
+
+ if (fit_image_get_load (fit_hdr, fdt_noffset,
+ &load_start) == 0) {
+ load_end = load_start + size;
+
+ if ((load_start < image_end) &&
+ (load_end > image_start)) {
+ fdt_error ("FDT overwritten");
+ goto error;
+ }
+
+ printf (" Loading FDT from 0x%08lx to 0x%08lx\n",
+ (ulong)data, load_start);
+
+ memmove ((void *)load_start,
+ (void *)data, size);
+
+ fdt_blob = (char *)load_start;
+ } else {
+ fdt_blob = (char *)data;
+ }
+
+ images->fit_hdr_fdt = fit_hdr;
+ images->fit_uname_fdt = fit_uname_fdt;
+ break;
} else
#endif
{
@@ -509,8 +639,6 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
}
} else {
debug ("## No Flattened Device Tree\n");
- *of_flat_tree = NULL;
- *of_size = 0;
return 0;
}
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 09/20] [new uImage] Add node offsets for FIT images listed in struct bootm_headers
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (7 preceding siblings ...)
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 ` 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
` (10 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
This patch adds new node offset fields to struct bootm_headers
and updates bootm_headers processing code to make use of them.
Saved node offsets allow to avoid repeating fit_image_get_node() calls.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/cmd_bootm.c | 23 ++++++++---------------
common/image.c | 1 +
include/image.h | 7 +++++--
lib_ppc/bootm.c | 1 +
4 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index aca54b5..11c476e 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -130,9 +130,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong image_start, image_end;
ulong load_start, load_end;
ulong mem_start, mem_size;
-#if defined(CONFIG_FIT)
- int os_noffset;
-#endif
struct lmb lmb;
@@ -172,32 +169,27 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- os_noffset = fit_image_get_node (images.fit_hdr_os,
- images.fit_uname_os);
- if (os_noffset < 0) {
- printf ("Can't get image node for '%s'!\n",
- images.fit_uname_os);
- return 1;
- }
-
- if (fit_image_get_type (images.fit_hdr_os, os_noffset, &type)) {
+ if (fit_image_get_type (images.fit_hdr_os,
+ images.fit_noffset_os, &type)) {
puts ("Can't get image type!\n");
return 1;
}
- if (fit_image_get_comp (images.fit_hdr_os, os_noffset, &comp)) {
+ if (fit_image_get_comp (images.fit_hdr_os,
+ images.fit_noffset_os, &comp)) {
puts ("Can't get image compression!\n");
return 1;
}
- if (fit_image_get_os (images.fit_hdr_os, os_noffset, &os)) {
+ if (fit_image_get_os (images.fit_hdr_os,
+ images.fit_noffset_os, &os)) {
puts ("Can't get image OS!\n");
return 1;
}
image_end = fit_get_end (images.fit_hdr_os);
- if (fit_image_get_load (images.fit_hdr_os, os_noffset,
+ if (fit_image_get_load (images.fit_hdr_os, images.fit_noffset_os,
&load_start)) {
puts ("Can't get image load address!\n");
return 1;
@@ -569,6 +561,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
*os_data = (ulong)data;
images->fit_hdr_os = fit_hdr;
images->fit_uname_os = fit_uname_kernel;
+ images->fit_noffset_os = os_noffset;
break;
#endif
default:
diff --git a/common/image.c b/common/image.c
index 6458fb1..e838f65 100644
--- a/common/image.c
+++ b/common/image.c
@@ -891,6 +891,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
images->fit_hdr_rd = fit_hdr;
images->fit_uname_rd = fit_uname_ramdisk;
+ images->fit_noffset_rd = rd_noffset;
break;
#endif
default:
diff --git a/include/image.h b/include/image.h
index 6fca6f4..51c0c89 100644
--- a/include/image.h
+++ b/include/image.h
@@ -208,13 +208,16 @@ typedef struct bootm_headers {
#if defined(CONFIG_FIT)
void *fit_hdr_os; /* os FIT image header */
const char *fit_uname_os; /* os subimage node unit name */
+ int fit_noffset_os; /* os subimage node offset */
void *fit_hdr_rd; /* init ramdisk FIT image header */
- const char *fit_uname_rd; /* init ramdisk node unit name */
+ const char *fit_uname_rd; /* init ramdisk subimage node unit name */
+ int fit_noffset_rd; /* init ramdisk subimage node offset */
#if defined(CONFIG_PPC)
void *fit_hdr_fdt; /* FDT blob FIT image header */
- const char *fit_uname_fdt; /* FDT blob node unit name */
+ const char *fit_uname_fdt; /* FDT blob subimage node unit name */
+ int fit_noffset_fdt;/* FDT blob subimage node offset */
#endif
int verify; /* getenv("verify")[0] != 'n' */
int autostart; /* getenv("autostart")[0] != 'n' */
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index 60bc04b..4d8ef35 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -585,6 +585,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
images->fit_hdr_fdt = fit_hdr;
images->fit_uname_fdt = fit_uname_fdt;
+ images->fit_noffset_fdt = fdt_noffset;
break;
} else
#endif
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 10/20] [new uImage] Add new uImage format support to arch specific do_bootm_linux() routines
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (8 preceding siblings ...)
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 ` Bartlomiej Sieka
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 11/20] [new uImage] Add new uImage format support to autoscript routine Bartlomiej Sieka
` (9 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
This patch updates architecture specific implementations of
do_bootm_linux() adding new uImage format handling for
operations like get kernel entry point address, get kernel
image data start address.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
lib_arm/bootm.c | 20 ++++++++++++++++----
lib_avr32/bootm.c | 20 ++++++++++++++++----
lib_blackfin/bootm.c | 17 ++++++++++++++---
lib_i386/bootm.c | 26 +++++++++++++++++++++-----
lib_m68k/bootm.c | 12 +++++++-----
lib_microblaze/bootm.c | 17 ++++++++++++++---
lib_mips/bootm.c | 19 +++++++++++++++----
lib_nios2/bootm.c | 17 ++++++++++++++---
lib_ppc/bootm.c | 8 ++++++--
lib_sh/bootm.c | 17 ++++++++++++++---
10 files changed, 137 insertions(+), 36 deletions(-)
diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c
index 08eef0b..c5e8cb3 100644
--- a/lib_arm/bootm.c
+++ b/lib_arm/bootm.c
@@ -70,6 +70,7 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
char *s;
int machid = bd->bi_arch_number;
void (*theKernel)(int zero, int arch, uint params);
+ int ret;
#ifdef CONFIG_CMDLINE_TAG
char *commandline = getenv ("bootargs");
@@ -80,12 +81,16 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("ARM linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
theKernel = (void (*)(int, int, uint))ep;
@@ -98,7 +103,7 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_ARM,
&initrd_start, &initrd_end);
if (ret)
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
show_boot_progress (15);
@@ -151,6 +156,13 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
cleanup_before_linux ();
theKernel (0, machid, bd->bi_boot_params);
+ /* does not return */
+ return;
+
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
}
diff --git a/lib_avr32/bootm.c b/lib_avr32/bootm.c
index c9a0190..b1c651a 100644
--- a/lib_avr32/bootm.c
+++ b/lib_avr32/bootm.c
@@ -181,25 +181,30 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
void (*theKernel)(int magic, void *tagtable);
struct tag *params, *params_start;
char *commandline = getenv("bootargs");
+ int ret;
/* find kernel entry point */
if (images->legacy_hdr_valid) {
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("AVR32 linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
theKernel = (void *)ep;
ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_AVR32,
&initrd_start, &initrd_end);
if (ret)
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
show_boot_progress (15);
@@ -225,4 +230,11 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
prepare_to_boot();
theKernel(ATAG_MAGIC, params_start);
+ /* does not return */
+ return;
+
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
}
diff --git a/lib_blackfin/bootm.c b/lib_blackfin/bootm.c
index 33979a9..1ea80f4 100644
--- a/lib_blackfin/bootm.c
+++ b/lib_blackfin/bootm.c
@@ -65,12 +65,16 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("AVR32 linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ int ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
appl = (int (*)(char *))ep;
@@ -85,6 +89,13 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
dcache_disable();
}
(*appl) (cmdline);
+ /* does not return */
+ return;
+
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
}
char *make_command_line(void)
diff --git a/lib_i386/bootm.c b/lib_i386/bootm.c
index b4a52fa..107ebaa 100644
--- a/lib_i386/bootm.c
+++ b/lib_i386/bootm.c
@@ -40,11 +40,15 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ulong ep;
image_header_t *hdr;
int ret;
+#if defined(CONFIG_FIT)
+ const void *data;
+ size_t len;
+#endif
ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_I386,
&initrd_start, &initrd_end);
if (ret)
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
if (images->legacy_hdr_valid) {
hdr = images->legacy_hdr_os;
@@ -58,12 +62,18 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
}
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("I386 linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ ret = fit_image_get_data (images->fit_hdr_os,
+ images->fit_noffset_os, &data, &len);
+ if (ret) {
+ puts ("Can't get image data/size!\n");
+ goto error;
+ }
+ os_data = (ulong)data;
+ os_len = (ulong)len;
#endif
} else {
puts ("Could not find kernel image!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
base_ptr = load_zimage ((void*)os_data, os_len,
@@ -71,7 +81,7 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
if (NULL == base_ptr) {
printf ("## Kernel loading failed ...\n");
- do_reset(cmdtp, flag, argc, argv);
+ goto error;
}
@@ -87,5 +97,11 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
printf("\nStarting kernel ...\n\n");
boot_zimage(base_ptr);
+ /* does not return */
+ return;
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
}
diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c
index f185bea..6f49c31 100644
--- a/lib_m68k/bootm.c
+++ b/lib_m68k/bootm.c
@@ -35,8 +35,6 @@
DECLARE_GLOBAL_DATA_PTR;
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-
#define PHYSADDR(x) x
#define LINUX_MAX_ENVS 256
@@ -101,12 +99,16 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("M68K linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
diff --git a/lib_microblaze/bootm.c b/lib_microblaze/bootm.c
index 99c4533..fab4a54 100644
--- a/lib_microblaze/bootm.c
+++ b/lib_microblaze/bootm.c
@@ -47,12 +47,16 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("MICROBLAZE linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ int ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
theKernel = (void (*)(char *))ep;
@@ -67,4 +71,11 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
return ;
theKernel (commandline);
+ /* does not return */
+ return;
+
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
}
diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c
index 5e7a460..e4c139e 100644
--- a/lib_mips/bootm.c
+++ b/lib_mips/bootm.c
@@ -60,19 +60,23 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("MIPS linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
theKernel = (void (*)(int, char **, char **, int *))ep;
ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_MIPS,
&initrd_start, &initrd_end);
if (ret)
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
show_boot_progress (15);
@@ -116,6 +120,13 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
printf ("\nStarting kernel ...\n\n");
theKernel (linux_argc, linux_argv, linux_env, 0);
+ /* does not return */
+ return;
+
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
}
static void linux_params_init (ulong start, char *line)
diff --git a/lib_nios2/bootm.c b/lib_nios2/bootm.c
index 4b940cb..0c89e96 100644
--- a/lib_nios2/bootm.c
+++ b/lib_nios2/bootm.c
@@ -37,12 +37,16 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("NIOS2 linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ int ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
void (*kernel)(void) = (void (*)(void))ep;
@@ -53,4 +57,11 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
* needs to be called ;-)
*/
kernel ();
+ /* does not return */
+ return;
+
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
}
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index 4d8ef35..86e104c 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -150,8 +150,12 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("PPC linux bootm");
- goto error;
+ ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
diff --git a/lib_sh/bootm.c b/lib_sh/bootm.c
index 8055841..49462c8 100644
--- a/lib_sh/bootm.c
+++ b/lib_sh/bootm.c
@@ -70,12 +70,16 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
ep = image_get_ep (images->legacy_hdr_os);
#if defined(CONFIG_FIT)
} else if (images->fit_uname_os) {
- fit_unsupported_reset ("SH linux bootm");
- do_reset (cmdtp, flag, argc, argv);
+ int ret = fit_image_get_entry (images->fit_hdr_os,
+ images->fit_noffset_os, &ep);
+ if (ret) {
+ puts ("Can't get entry point property!\n");
+ goto error;
+ }
#endif
} else {
puts ("Could not find kernel entry point!\n");
- do_reset (cmdtp, flag, argc, argv);
+ goto error;
}
void (*kernel) (void) = (void (*)(void))ep;
@@ -87,4 +91,11 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
strcpy(COMMAND_LINE, bootargs);
kernel();
+ /* does not return */
+ return;
+
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
}
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 11/20] [new uImage] Add new uImage format support to autoscript routine
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (9 preceding siblings ...)
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
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 12/20] [new uImage] Add new uImage format support to imgextract command Bartlomiej Sieka
` (8 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
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 */
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 12/20] [new uImage] Add new uImage format support to imgextract command
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (10 preceding siblings ...)
2008-03-12 20:11 ` [U-Boot-Users] [PATCH 11/20] [new uImage] Add new uImage format support to autoscript routine Bartlomiej Sieka
@ 2008-03-12 20:11 ` 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
` (7 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/cmd_ximg.c | 109 ++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 78 insertions(+), 31 deletions(-)
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index 360b05e..77f68c4 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -37,12 +37,21 @@
int
do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
- ulong addr = load_addr, dest = 0;
- ulong data, len;
- ulong *len_ptr;
- int i, verify, part = 0;
- char pbuf[10], *s;
- image_header_t *hdr;
+ ulong addr = load_addr;
+ ulong dest = 0;
+ ulong data, len, count;
+ int i, verify;
+ int part = 0;
+ char pbuf[10];
+ char *s;
+ image_header_t *hdr;
+#if defined(CONFIG_FIT)
+ const char *uname;
+ const void* fit_hdr;
+ int noffset;
+ const void *fit_data;
+ size_t fit_len;
+#endif
verify = getenv_verify ();
@@ -51,16 +60,20 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
}
if (argc > 2) {
part = simple_strtoul(argv[2], NULL, 16);
+#if defined(CONFIG_FIT)
+ uname = argv[2];
+#endif
}
if (argc > 3) {
dest = simple_strtoul(argv[3], NULL, 16);
}
-
switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
- printf("## Copying from legacy image at %08lx ...\n", addr);
+ printf("## Copying part %d from legacy image "
+ "at %08lx ...\n", part, addr);
+
hdr = (image_header_t *)addr;
if (!image_check_magic (hdr)) {
printf("Bad Magic Number\n");
@@ -71,9 +84,9 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
printf("Bad Header Checksum\n");
return 1;
}
- #ifdef DEBUG
+#ifdef DEBUG
image_print_contents (hdr);
- #endif
+#endif
if (!image_check_type (hdr, IH_TYPE_MULTI)) {
printf("Wrong Image Type for %s command\n",
@@ -96,31 +109,60 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
printf("OK\n");
}
- data = image_get_data (hdr);
- len_ptr = (ulong *) data;
-
- data += 4; /* terminator */
- for (i = 0; len_ptr[i]; ++i) {
- data += 4;
- if (argc > 2 && part > i) {
- u_long tail;
- len = uimage_to_cpu (len_ptr[i]);
- tail = len % 4;
- data += len;
- if (tail) {
- data += 4 - tail;
- }
- }
- }
- if (argc > 2 && part >= i) {
+ count = image_multi_count (hdr);
+ if (part >= count) {
printf("Bad Image Part\n");
return 1;
}
- len = uimage_to_cpu (len_ptr[part]);
+
+ image_multi_getimg (hdr, part, &data, &len);
+ break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("imxtract");
- return 1;
+ if (uname == NULL) {
+ puts ("No FIT subimage unit name\n");
+ return 1;
+ }
+
+ printf("## Copying '%s' subimage from FIT image "
+ "at %08lx ...\n", uname, addr);
+
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("Bad FIT image format\n");
+ return 1;
+ }
+
+ /* get subimage node offset */
+ noffset = fit_image_get_node (fit_hdr, fit_uname);
+ if (noffset < 0) {
+ printf ("Can't find '%s' FIT subimage\n", uname);
+ return 1;
+ }
+
+ if (fit_image_check_comp (fit_hdr, noffset, IH_COMP_NONE)) {
+ printf("Wrong Compression Type for %s command\n",
+ cmdtp->name);
+ return 1;
+ }
+
+ /* verify integrity */
+ if (verify) {
+ if (!fit_image_check_hashes (fit_hdr, noffset)) {
+ puts ("Bad Data Hash\n");
+ return 1;
+ }
+ }
+
+ /* get 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 ("Invalid image type for imxtract\n");
@@ -142,6 +184,11 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
U_BOOT_CMD(imxtract, 4, 1, do_imgextract,
"imxtract- extract a part of a multi-image\n",
"addr part [dest]\n"
- " - extract <part> from image at <addr> and copy to <dest>\n");
+ " - extract <part> from legacy image at <addr> and copy to <dest>\n"
+#if defined(CONFIG_FIT)
+ "addr uname [dest]\n"
+ " - extract <uname> subimage from FIT image at <addr> and copy to <dest>\n"
+#endif
+);
#endif
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 13/20] [new uImage] Add new uImage format handling to other bootm related commands
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (11 preceding siblings ...)
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 ` 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
` (6 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Updated commands:
docboot - cmd_doc.c
fdcboot - cmd_fdc.c
diskboot - cmd_ide.c
nboot - cmd_nand.c
scsiboot - cmd_scsi.c
usbboot - cmd_usb.c
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/cmd_doc.c | 34 ++++++++++++++++++----------
common/cmd_fdc.c | 27 ++++++++++++++++------
common/cmd_ide.c | 25 +++++++++++++++-----
common/cmd_nand.c | 65 ++++++++++++++++++++++++++++++++++-------------------
common/cmd_scsi.c | 26 +++++++++++++++------
common/cmd_usb.c | 27 +++++++++++++++-------
6 files changed, 140 insertions(+), 64 deletions(-)
diff --git a/common/cmd_doc.c b/common/cmd_doc.c
index 293b1aa..bf2f0a9 100644
--- a/common/cmd_doc.c
+++ b/common/cmd_doc.c
@@ -205,6 +205,9 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong offset = 0;
image_header_t *hdr;
int rcode = 0;
+#if defined(CONFIG_FIT)
+ const void *fit_hdr;
+#endif
show_boot_progress (34);
switch (argc) {
@@ -265,29 +268,30 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
- if (image_check_magic (hdr)) {
+ image_print_contents (hdr);
- image_print_contents (hdr);
-
- cnt = image_get_image_size (hdr);
- cnt -= SECTORSIZE;
- } else {
- puts ("\n** Bad Magic Number **\n");
- show_boot_progress (-39);
- return 1;
- }
+ cnt = image_get_image_size (hdr);
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("docboot");
- return 1;
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("** Bad FIT image format\n");
+ return 1;
+ }
+ puts ("Fit image detected...\n");
+
+ cnt = fit_get_size (fit_hdr);
+ break;
#endif
default:
+ show_boot_progress (-39);
puts ("** Unknown image type\n");
return 1;
}
show_boot_progress (39);
+ cnt -= SECTORSIZE;
if (doc_rw (doc_dev_desc + dev, 1, offset + SECTORSIZE, cnt,
NULL, (u_char *)(addr+SECTORSIZE))) {
printf ("** Read error on %d\n", dev);
@@ -296,6 +300,12 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
show_boot_progress (40);
+#if defined(CONFIG_FIT)
+ /* This cannot be done earlier, we need complete FIT image in RAM first */
+ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+ fit_print_contents ((const void *)addr);
+#endif
+
/* Loading ok, update default load address */
load_addr = addr;
diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c
index 80301b9..bf28370 100644
--- a/common/cmd_fdc.c
+++ b/common/cmd_fdc.c
@@ -788,6 +788,9 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
int i,nrofblk;
char *ep;
int rcode = 0;
+#if defined(CONFIG_FIT)
+ const void *fit_hdr;
+#endif
switch (argc) {
case 1:
@@ -839,18 +842,21 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
- if (!image_check_magic (hdr)) {
- printf ("Bad Magic Number\n");
- return 1;
- }
image_print_contents (hdr);
imsize = image_get_image_size (hdr);
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("fdcboot");
- return 1;
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("** Bad FIT image format\n");
+ return 1;
+ }
+ puts ("Fit image detected...\n");
+
+ imsize = fit_get_size (fit_hdr);
+ break;
#endif
default:
puts ("** Unknown image type\n");
@@ -872,9 +878,16 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
printf("OK %ld Bytes loaded.\n",imsize);
flush_cache (addr, imsize);
- /* Loading ok, update default load address */
+#if defined(CONFIG_FIT)
+ /* This cannot be done earlier, we need complete FIT image in RAM first */
+ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+ fit_print_contents ((const void *)addr);
+#endif
+
+ /* Loading ok, update default load address */
load_addr = addr;
+
/* Check if we should attempt an auto-start */
if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
char *local_args[2];
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 79b7dfb..6a67dd6 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -370,6 +370,9 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
disk_partition_t info;
image_header_t *hdr;
int rcode = 0;
+#if defined(CONFIG_FIT)
+ const void *fit_hdr;
+#endif
show_boot_progress (41);
switch (argc) {
@@ -450,11 +453,6 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
- if (!image_check_magic (hdr)) {
- printf("\n** Bad Magic Number **\n");
- show_boot_progress (-49);
- return 1;
- }
show_boot_progress (49);
if (!image_check_hcrc (hdr)) {
@@ -470,10 +468,18 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("diskboot");
- return 1;
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("** Bad FIT image format\n");
+ return 1;
+ }
+ puts ("Fit image detected...\n");
+
+ cnt = fit_get_size (fit_hdr);
+ break;
#endif
default:
+ show_boot_progress (-49);
puts ("** Unknown image type\n");
return 1;
}
@@ -490,6 +496,11 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
show_boot_progress (51);
+#if defined(CONFIG_FIT)
+ /* This cannot be done earlier, we need complete FIT image in RAM first */
+ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+ fit_print_contents ((const void *)addr);
+#endif
/* Loading ok, update default load address */
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 86959dc..9a168ea 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -484,6 +484,9 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
ulong cnt;
image_header_t *hdr;
int jffs2 = 0;
+#if defined(CONFIG_FIT)
+ const void *fit_hdr;
+#endif
s = strchr(cmd, '.');
if (s != NULL &&
@@ -516,24 +519,25 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
- if (!image_check_magic (hdr)) {
- printf("\n** Bad Magic Number 0x%x **\n",
- image_get_magic (hdr));
- show_boot_progress (-57);
- return 1;
- }
show_boot_progress (57);
-
image_print_contents (hdr);
cnt = image_get_image_size (hdr);
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("nand_load_image");
- return 1;
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("** Bad FIT image format\n");
+ return 1;
+ }
+ puts ("Fit image detected...\n");
+
+ cnt = fit_get_size (fit_hdr);
+ break;
#endif
default:
+ show_boot_progress (-57);
puts ("** Unknown image type\n");
return 1;
}
@@ -557,6 +561,12 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
}
show_boot_progress (58);
+#if defined(CONFIG_FIT)
+ /* This cannot be done earlier, we need complete FIT image in RAM first */
+ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+ fit_print_contents ((const void *)addr);
+#endif
+
/* Loading ok, update default load address */
load_addr = addr;
@@ -939,6 +949,10 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong offset = 0;
image_header_t *hdr;
int rcode = 0;
+#if defined(CONFIG_FIT)
+ const void *fit_hdr;
+#endif
+
show_boot_progress (52);
switch (argc) {
case 1:
@@ -997,26 +1011,25 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
+ image_print_contents (hdr);
- if (image_check_magic (hdr)) {
-
- image_print_contents (hdr);
-
- cnt = image_get_image_size (hdr);
- cnt -= SECTORSIZE;
- } else {
- printf ("\n** Bad Magic Number 0x%x **\n",
- image_get_magic (hdr));
- show_boot_progress (-57);
- return 1;
- }
+ cnt = image_get_image_size (hdr);
+ cnt -= SECTORSIZE;
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("nboot");
- return 1;
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("** Bad FIT image format\n");
+ return 1;
+ }
+ puts ("Fit image detected...\n");
+
+ cnt = fit_get_size (fit_hdr);
+ break;
#endif
default:
+ show_boot_progress (-57);
puts ("** Unknown image type\n");
return 1;
}
@@ -1031,6 +1044,12 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
show_boot_progress (58);
+#if defined(CONFIG_FIT)
+ /* This cannot be done earlier, we need complete FIT image in RAM first */
+ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+ fit_print_contents ((const void *)addr);
+#endif
+
/* Loading ok, update default load address */
load_addr = addr;
diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index 7868805..f49531e 100644
--- a/common/cmd_scsi.c
+++ b/common/cmd_scsi.c
@@ -211,6 +211,9 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
disk_partition_t info;
image_header_t *hdr;
int rcode = 0;
+#if defined(CONFIG_FIT)
+ const void *fit_hdr;
+#endif
switch (argc) {
case 1:
@@ -277,11 +280,6 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
- if (!image_check_magic (hdr)) {
- printf("\n** Bad Magic Number **\n");
- return 1;
- }
-
if (!image_check_hcrc (hdr)) {
puts ("\n** Bad Header Checksum **\n");
return 1;
@@ -292,8 +290,15 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("scsi");
- return 1;
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("** Bad FIT image format\n");
+ return 1;
+ }
+ puts ("Fit image detected...\n");
+
+ cnt = fit_get_size (fit_hdr);
+ break;
#endif
default:
puts ("** Unknown image type\n");
@@ -309,6 +314,13 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
printf ("** Read error on %d:%d\n", dev, part);
return 1;
}
+
+#if defined(CONFIG_FIT)
+ /* This cannot be done earlier, we need complete FIT image in RAM first */
+ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+ fit_print_contents ((const void *)addr);
+#endif
+
/* Loading ok, update default load address */
load_addr = addr;
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 8ee7d27..bf56c6a 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -315,7 +315,9 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
disk_partition_t info;
image_header_t *hdr;
block_dev_desc_t *stor_dev;
-
+#if defined(CONFIG_FIT)
+ const void *fit_hdr;
+#endif
switch (argc) {
case 1:
@@ -390,11 +392,6 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
- if (!image_check_magic (hdr)) {
- printf("\n** Bad Magic Number **\n");
- return 1;
- }
-
if (!image_check_hcrc (hdr)) {
puts ("\n** Bad Header Checksum **\n");
return 1;
@@ -406,8 +403,15 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("usbboot");
- return 1;
+ fit_hdr = (const void *)addr;
+ if (!fit_check_format (fit_hdr)) {
+ puts ("** Bad FIT image format\n");
+ return 1;
+ }
+ puts ("Fit image detected...\n");
+
+ cnt = fit_get_size (fit_hdr);
+ break;
#endif
default:
puts ("** Unknown image type\n");
@@ -423,6 +427,13 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
printf ("\n** Read error on %d:%d\n", dev, part);
return 1;
}
+
+#if defined(CONFIG_FIT)
+ /* This cannot be done earlier, we need complete FIT image in RAM first */
+ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+ fit_print_contents ((const void *)addr);
+#endif
+
/* Loading ok, update default load address */
load_addr = addr;
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 14/20] [new uImage] Add new uImage fromat support to fpga command
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (12 preceding siblings ...)
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 ` 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
` (5 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:11 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/cmd_fpga.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 76 insertions(+), 9 deletions(-)
diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c
index 0bb82f6..9141dcc 100644
--- a/common/cmd_fpga.c
+++ b/common/cmd_fpga.c
@@ -164,6 +164,10 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
char *devstr = getenv ("fpga");
char *datastr = getenv ("fpgadata");
int rc = FPGA_FAIL;
+#if defined (CONFIG_FIT)
+ const char *fit_uname = NULL;
+ ulong fit_addr;
+#endif
if (devstr)
dev = (int) simple_strtoul (devstr, NULL, 16);
@@ -173,9 +177,22 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
switch (argc) {
case 5: /* fpga <op> <dev> <data> <datasize> */
data_size = simple_strtoul (argv[4], NULL, 16);
+
case 4: /* fpga <op> <dev> <data> */
- fpga_data = (void *) simple_strtoul (argv[3], NULL, 16);
+#if defined(CONFIG_FIT)
+ if (fit_parse_subimage (argv[3], (ulong)fpga_data,
+ &fit_addr, &fit_uname)) {
+ fpga_data = (void *)fit_addr;
+ debug ("* fpga: subimage '%s' from FIT image at 0x%08lx\n",
+ fit_uname, fit_addr);
+ } else
+#endif
+ {
+ fpga_data = (void *) simple_strtoul (argv[3], NULL, 16);
+ debug ("* fpga: cmdline image address = 0x%08lx\n", (ulong)fpga_data);
+ }
PRINTF ("%s: fpga_data = 0x%x\n", __FUNCTION__, (uint) fpga_data);
+
case 3: /* fpga <op> <dev | data addr> */
dev = (int) simple_strtoul (argv[2], NULL, 16);
PRINTF ("%s: device = %d\n", __FUNCTION__, dev);
@@ -183,14 +200,29 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
if ((argc == 3) && (dev > fpga_count ())) { /* must be buffer ptr */
PRINTF ("%s: Assuming buffer pointer in arg 3\n",
__FUNCTION__);
- fpga_data = (void *) dev;
+
+#if defined(CONFIG_FIT)
+ if (fit_parse_subimage (argv[2], (ulong)fpga_data,
+ &fit_addr, &fit_uname)) {
+ fpga_data = (void *)fit_addr;
+ debug ("* fpga: subimage '%s' from FIT image at 0x%08lx\n",
+ fit_uname, fit_addr);
+ } else
+#endif
+ {
+ fpga_data = (void *) dev;
+ debug ("* fpga: cmdline image address = 0x%08lx\n", (ulong)fpga_data);
+ }
+
PRINTF ("%s: fpga_data = 0x%x\n",
__FUNCTION__, (uint) fpga_data);
dev = FPGA_INVALID_DEVICE; /* reset device num */
}
+
case 2: /* fpga <op> */
op = (int) fpga_get_op (argv[1]);
break;
+
default:
PRINTF ("%s: Too many or too few args (%d)\n",
__FUNCTION__, argc);
@@ -222,10 +254,6 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
image_header_t *hdr = (image_header_t *)fpga_data;
ulong data;
- if (!image_check_magic (hdr)) {
- puts ("Bad Magic Number\n");
- return 1;
- }
data = (ulong)image_get_data (hdr);
data_size = image_get_data_size (hdr);
rc = fpga_load (dev, (void *)data, data_size);
@@ -233,8 +261,42 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
- fit_unsupported ("fpga");
- rc = FPGA_FAIL;
+ {
+ const void *fit_hdr = (const void *)fpga_data;
+ int noffset;
+ void *fit_data;
+
+ if (fit_uname == NULL) {
+ puts ("No FIT subimage unit name\n");
+ return 1;
+ }
+
+ if (!fit_check_format (fit_hdr)) {
+ puts ("Bad FIT image format\n");
+ return 1;
+ }
+
+ /* get fpga 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;
+ }
+
+ /* verify integrity */
+ if (!fit_image_check_hashes (fit_hdr, noffset)) {
+ puts ("Bad Data Hash\n");
+ return 1;
+ }
+
+ /* get fpga subimage data address and length */
+ if (fit_image_get_data (fit_hdr, noffset, &fit_data, &data_size)) {
+ puts ("Could not find fpga subimage data\n");
+ return 1;
+ }
+
+ rc = fpga_load (dev, fit_data, data_size);
+ }
break;
#endif
default:
@@ -295,4 +357,9 @@ U_BOOT_CMD (fpga, 6, 1, do_fpga,
"\tload\tLoad device from memory buffer\n"
"\tloadb\tLoad device from bitstream buffer (Xilinx devices only)\n"
"\tloadmk\tLoad device generated with mkimage\n"
- "\tdump\tLoad device to memory buffer\n");
+ "\tdump\tLoad device to memory buffer\n"
+#if defined(CONFIG_FIT)
+ "\tFor loadmk operating on FIT format uImage address must include\n"
+ "\tsubimage unit name in the form of addr:<subimg_uname>\n"
+#endif
+);
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 15/20] [new uImage] Use show_boot_progress() for new uImage format
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (13 preceding siblings ...)
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 ` Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 16/20] [new uImage] More verbose kernel image uncompress error message Bartlomiej Sieka
` (4 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:12 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
This patch allocates a set of show_boot_progress() IDs for new uImage format
and adds show_boot_progress() calls in new uImage format handling code.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
README | 83 +++++++++++++++++++++++++++++++++++++++++++---------
common/cmd_bootm.c | 30 ++++++++++++++++---
common/cmd_doc.c | 2 +
common/cmd_ide.c | 2 +
common/cmd_nand.c | 4 +++
common/image.c | 28 ++++++++++++++----
6 files changed, 125 insertions(+), 24 deletions(-)
diff --git a/README b/README
index 491397a..183246e 100644
--- a/README
+++ b/README
@@ -1659,6 +1659,8 @@ The following options need to be configured:
example, some LED's) on your board. At the moment,
the following checkpoints are implemented:
+Legacy uImage format:
+
Arg Where When
1 common/cmd_bootm.c before attempting to boot an image
-1 common/cmd_bootm.c Image header has bad magic number
@@ -1669,25 +1671,26 @@ The following options need to be configured:
4 common/cmd_bootm.c Image data has correct checksum
-4 common/cmd_bootm.c Image is for unsupported architecture
5 common/cmd_bootm.c Architecture check OK
- -5 common/cmd_bootm.c Wrong Image Type (not kernel, multi, standalone)
+ -5 common/cmd_bootm.c Wrong Image Type (not kernel, multi)
6 common/cmd_bootm.c Image Type check OK
-6 common/cmd_bootm.c gunzip uncompression error
-7 common/cmd_bootm.c Unimplemented compression type
7 common/cmd_bootm.c Uncompression OK
- -8 common/cmd_bootm.c Wrong Image Type (not kernel, multi, standalone)
- 8 common/cmd_bootm.c Image Type check OK
+ 8 common/cmd_bootm.c No uncompress/copy overwrite error
-9 common/cmd_bootm.c Unsupported OS (not Linux, BSD, VxWorks, QNX)
- 9 common/cmd_bootm.c Start initial ramdisk verification
- -10 common/cmd_bootm.c Ramdisk header has bad magic number
- -11 common/cmd_bootm.c Ramdisk header has bad checksum
- 10 common/cmd_bootm.c Ramdisk header is OK
- -12 common/cmd_bootm.c Ramdisk data has bad checksum
- 11 common/cmd_bootm.c Ramdisk data has correct checksum
- 12 common/cmd_bootm.c Ramdisk verification complete, start loading
- -13 common/cmd_bootm.c Wrong Image Type (not PPC Linux Ramdisk)
- 13 common/cmd_bootm.c Start multifile image verification
- 14 common/cmd_bootm.c No initial ramdisk, no multifile, continue.
- 15 common/cmd_bootm.c All preparation done, transferring control to OS
+
+ 9 common/image.c Start initial ramdisk verification
+ -10 common/image.c Ramdisk header has bad magic number
+ -11 common/image.c Ramdisk header has bad checksum
+ 10 common/image.c Ramdisk header is OK
+ -12 common/image.c Ramdisk data has bad checksum
+ 11 common/image.c Ramdisk data has correct checksum
+ 12 common/image.c Ramdisk verification complete, start loading
+ -13 common/image.c Wrong Image Type (not PPC Linux Ramdisk)
+ 13 common/image.c Start multifile image verification
+ 14 common/image.c No initial ramdisk, no multifile, continue.
+
+ 15 lib_<arch>/bootm.c All preparation done, transferring control to OS
-30 lib_ppc/board.c Fatal error, hang the system
-31 post/post.c POST test failed, detected by post_output_backlog()
@@ -1757,6 +1760,58 @@ The following options need to be configured:
-83 common/cmd_net.c some error in automatic boot or autoscript
84 common/cmd_net.c end without errors
+FIT uImage format:
+
+ Arg Where When
+ 100 common/cmd_bootm.c Kernel FIT Image has correct format
+ -100 common/cmd_bootm.c Kernel FIT Image has incorrect format
+ 101 common/cmd_bootm.c No Kernel subimage unit name, using configuration
+ -101 common/cmd_bootm.c Can't get configuration for kernel subimage
+ 102 common/cmd_bootm.c Kernel unit name specified
+ -103 common/cmd_bootm.c Can't get kernel subimage node offset
+ 104 common/cmd_bootm.c Got kernel subimage node offset
+ -104 common/cmd_bootm.c Kernel subimage hash verification failed
+ 105 common/cmd_bootm.c Kernel subimage hash verification OK
+ -105 common/cmd_bootm.c Kernel subimage is for unsupported architecture
+ 106 common/cmd_bootm.c Architecture check OK
+ -106 common/cmd_bootm.c Kernel subimage has wrong typea
+ 107 common/cmd_bootm.c Kernel subimge type OK
+ -107 common/cmd_bootm.c Can't get kernel subimage data/size
+ 108 common/cmd_bootm.c Got kernel subimage data/size
+ -108 common/cmd_bootm.c Wrong image type (not legacy, FIT)
+ -109 common/cmd_bootm.c Can't get kernel subimage type
+ -110 common/cmd_bootm.c Can't get kernel subimage comp
+ -111 common/cmd_bootm.c Can't get kernel subimage os
+ -112 common/cmd_bootm.c Can't get kernel subimage load address
+ -113 common/cmd_bootm.c Image uncompress/copy overwrite error
+
+ 120 common/image.c Start initial ramdisk verification
+ -120 common/image.c Ramdisk FIT image has incorrect format
+ 121 common/image.c Ramdisk FIT image has correct format
+ 122 common/image.c No Ramdisk subimage unit name, using configuration
+ -122 common/image.c Can't get configuration for ramdisk subimage
+ 123 common/image.c Ramdisk unit name specified
+ -124 common/image.c Can't get ramdisk subimage node offset
+ 125 common/image.c Got ramdisk subimage node offset
+ -125 common/image.c Ramdisk subimage hash verification failed
+ 126 common/image.c Ramdisk subimage hash verification OK
+ -126 common/image.c Ramdisk subimage for unsupported architecture
+ 127 common/image.c Architecture check OK
+ -127 common/image.c Can't get ramdisk subimage data/size
+ 128 common/image.c Got ramdisk subimage data/size
+ 129 common/image.c Can't get ramdisk load address
+ -129 common/image.c Got ramdisk load address
+
+ -130 common/cmd_doc.c Icorrect FIT image format
+ 131 common/cmd_doc.c FIT image format OK
+
+ -140 common/cmd_ide.c Icorrect FIT image format
+ 141 common/cmd_ide.c FIT image format OK
+
+ -150 common/cmd_nand.c Icorrect FIT image format
+ 151 common/cmd_nand.c FIT image format OK
+
+
Modem Support:
--------------
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 11c476e..6591e61 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -155,8 +155,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
- show_boot_progress (6);
-
/* get image parameters */
switch (genimg_get_format (os_hdr)) {
case IMAGE_FORMAT_LEGACY:
@@ -172,18 +170,21 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (fit_image_get_type (images.fit_hdr_os,
images.fit_noffset_os, &type)) {
puts ("Can't get image type!\n");
+ show_boot_progress (-109);
return 1;
}
if (fit_image_get_comp (images.fit_hdr_os,
images.fit_noffset_os, &comp)) {
puts ("Can't get image compression!\n");
+ show_boot_progress (-110);
return 1;
}
if (fit_image_get_os (images.fit_hdr_os,
images.fit_noffset_os, &os)) {
puts ("Can't get image OS!\n");
+ show_boot_progress (-111);
return 1;
}
@@ -192,6 +193,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (fit_image_get_load (images.fit_hdr_os, images.fit_noffset_os,
&load_start)) {
puts ("Can't get image load address!\n");
+ show_boot_progress (-112);
return 1;
}
break;
@@ -284,6 +286,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
debug ("load_start = 0x%lx, load_end = 0x%lx\n", load_start, load_end);
puts ("ERROR: image overwritten - must RESET the board to recover.\n");
+ show_boot_progress (-113);
do_reset (cmdtp, flag, argc, argv);
}
@@ -416,21 +419,27 @@ static int fit_check_kernel (const void *fit, int os_noffset, int verify)
puts (" Verifying Hash Integrity ... ");
if (!fit_image_check_hashes (fit, os_noffset)) {
puts ("Bad Data Hash\n");
+ show_boot_progress (-104);
return 0;
}
puts ("OK\n");
}
+ show_boot_progress (105);
if (!fit_image_check_target_arch (fit, os_noffset)) {
puts ("Unsupported Architecture\n");
+ show_boot_progress (-105);
return 0;
}
+ show_boot_progress (106);
if (!fit_image_check_type (fit, os_noffset, IH_TYPE_KERNEL)) {
puts ("Not a kernel image\n");
+ show_boot_progress (-106);
return 0;
}
+ show_boot_progress (107);
return 1;
}
#endif /* CONFIG_FIT */
@@ -515,6 +524,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
images->legacy_hdr_os = hdr;
images->legacy_hdr_valid = 1;
+ show_boot_progress (6);
break;
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
@@ -524,8 +534,10 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
if (!fit_check_format (fit_hdr)) {
puts ("Bad FIT kernel image format!\n");
+ show_boot_progress (-100);
return NULL;
}
+ show_boot_progress (100);
if (!fit_uname_kernel) {
/*
@@ -533,29 +545,38 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
* node first. If config unit node name is NULL
* fit_conf_get_node() will try to find default config node
*/
+ show_boot_progress (101);
conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
- if (conf_noffset < 0)
+ if (conf_noffset < 0) {
+ show_boot_progress (-101);
return NULL;
+ }
os_noffset = fit_conf_get_kernel_node (fit_hdr, conf_noffset);
fit_uname_kernel = fit_get_name (fit_hdr, os_noffset, NULL);
} else {
/* get kernel component image node offset */
+ show_boot_progress (102);
os_noffset = fit_image_get_node (fit_hdr, fit_uname_kernel);
}
- if (os_noffset < 0)
+ if (os_noffset < 0) {
+ show_boot_progress (-103);
return NULL;
+ }
printf (" Trying '%s' kernel subimage\n", fit_uname_kernel);
+ show_boot_progress (104);
if (!fit_check_kernel (fit_hdr, os_noffset, images->verify))
return NULL;
/* get kernel image data address and length */
if (fit_image_get_data (fit_hdr, os_noffset, &data, &len)) {
puts ("Could not find kernel subimage data!\n");
+ show_boot_progress (-107);
return NULL;
}
+ show_boot_progress (108);
*os_len = len;
*os_data = (ulong)data;
@@ -566,6 +587,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
#endif
default:
printf ("Wrong Image Format for %s command\n", cmdtp->name);
+ show_boot_progress (-108);
return NULL;
}
diff --git a/common/cmd_doc.c b/common/cmd_doc.c
index bf2f0a9..83aba37 100644
--- a/common/cmd_doc.c
+++ b/common/cmd_doc.c
@@ -276,9 +276,11 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
case IMAGE_FORMAT_FIT:
fit_hdr = (const void *)addr;
if (!fit_check_format (fit_hdr)) {
+ show_boot_progress (-130);
puts ("** Bad FIT image format\n");
return 1;
}
+ show_boot_progress (131);
puts ("Fit image detected...\n");
cnt = fit_get_size (fit_hdr);
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 6a67dd6..8ace970 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -470,9 +470,11 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
case IMAGE_FORMAT_FIT:
fit_hdr = (const void *)addr;
if (!fit_check_format (fit_hdr)) {
+ show_boot_progress (-140);
puts ("** Bad FIT image format\n");
return 1;
}
+ show_boot_progress (141);
puts ("Fit image detected...\n");
cnt = fit_get_size (fit_hdr);
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 9a168ea..7b1f830 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -528,9 +528,11 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
case IMAGE_FORMAT_FIT:
fit_hdr = (const void *)addr;
if (!fit_check_format (fit_hdr)) {
+ show_boot_progress (-150);
puts ("** Bad FIT image format\n");
return 1;
}
+ show_boot_progress (151);
puts ("Fit image detected...\n");
cnt = fit_get_size (fit_hdr);
@@ -1020,9 +1022,11 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
case IMAGE_FORMAT_FIT:
fit_hdr = (const void *)addr;
if (!fit_check_format (fit_hdr)) {
+ show_boot_progress (-150);
puts ("** Bad FIT image format\n");
return 1;
}
+ show_boot_progress (151);
puts ("Fit image detected...\n");
cnt = fit_get_size (fit_hdr);
diff --git a/common/image.c b/common/image.c
index e838f65..f29614b 100644
--- a/common/image.c
+++ b/common/image.c
@@ -397,10 +397,7 @@ inline void image_print_contents_noindent (image_header_t *hdr)
static image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
int verify)
{
- image_header_t *rd_hdr;
-
- show_boot_progress (9);
- rd_hdr = (image_header_t *)rd_addr;
+ image_header_t *rd_hdr = (image_header_t *)rd_addr;
if (!image_check_magic (rd_hdr)) {
puts ("Bad Magic Number\n");
@@ -830,6 +827,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
printf ("## Loading init Ramdisk from Legacy "
"Image at %08lx ...\n", rd_addr);
+ show_boot_progress (9);
rd_hdr = image_get_ramdisk (rd_addr, arch,
images->verify);
@@ -846,10 +844,13 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
printf ("## Loading init Ramdisk from FIT "
"Image at %08lx ...\n", rd_addr);
+ show_boot_progress (120);
if (!fit_check_format (fit_hdr)) {
puts ("Bad FIT ramdisk image format!\n");
+ show_boot_progress (-120);
return 0;
}
+ show_boot_progress (121);
if (!fit_uname_ramdisk) {
/*
@@ -857,37 +858,48 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
* node first. If config unit node name is NULL
* fit_conf_get_node() will try to find default config node
*/
+ show_boot_progress (122);
conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
- if (conf_noffset < 0)
+ if (conf_noffset < 0) {
+ show_boot_progress (-122);
return 0;
+ }
rd_noffset = fit_conf_get_ramdisk_node (fit_hdr, conf_noffset);
fit_uname_ramdisk = fit_get_name (fit_hdr, rd_noffset, NULL);
} else {
/* get ramdisk component image node offset */
+ show_boot_progress (123);
rd_noffset = fit_image_get_node (fit_hdr, fit_uname_ramdisk);
}
- if (rd_noffset < 0)
+ if (rd_noffset < 0) {
+ show_boot_progress (-124);
return 0;
+ }
printf (" Trying '%s' ramdisk subimage\n", fit_uname_ramdisk);
+ show_boot_progress (125);
if (!fit_check_ramdisk (fit_hdr, rd_noffset, arch, images->verify))
return 0;
/* get ramdisk image data address and length */
if (fit_image_get_data (fit_hdr, rd_noffset, &data, &size)) {
puts ("Could not find ramdisk subimage data!\n");
+ show_boot_progress (-127);
return 0;
}
+ show_boot_progress (128);
rd_data = (ulong)data;
rd_len = size;
if (fit_image_get_load (fit_hdr, rd_noffset, &rd_load)) {
puts ("Can't get ramdisk subimage load address!\n");
+ show_boot_progress (-129);
return 0;
}
+ show_boot_progress (129);
images->fit_hdr_rd = fit_hdr;
images->fit_uname_rd = fit_uname_ramdisk;
@@ -2445,19 +2457,23 @@ static int fit_check_ramdisk (const void *fit, int rd_noffset, uint8_t arch, int
puts (" Verifying Hash Integrity ... ");
if (!fit_image_check_hashes (fit, rd_noffset)) {
puts ("Bad Data Hash\n");
+ show_boot_progress (-125);
return 0;
}
puts ("OK\n");
}
+ show_boot_progress (126);
if (!fit_image_check_os (fit, rd_noffset, IH_OS_LINUX) ||
!fit_image_check_arch (fit, rd_noffset, arch) ||
!fit_image_check_type (fit, rd_noffset, IH_TYPE_RAMDISK)) {
printf ("No Linux %s Ramdisk Image\n",
genimg_get_arch_name(arch));
+ show_boot_progress (-126);
return 0;
}
+ show_boot_progress (127);
return 1;
}
#endif /* USE_HOSTCC */
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 16/20] [new uImage] More verbose kernel image uncompress error message
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (14 preceding siblings ...)
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 ` 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
` (3 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:12 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/cmd_bootm.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 6591e61..e95c5dd 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -243,7 +243,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
printf (" Uncompressing %s ... ", type_name);
if (gunzip ((void *)load_start, unc_len,
(uchar *)os_data, &os_len) != 0) {
- puts ("GUNZIP ERROR - must RESET board to recover\n");
+ puts ("GUNZIP: uncompress or overwrite error "
+ "- must RESET board to recover\n");
show_boot_progress (-6);
do_reset (cmdtp, flag, argc, argv);
}
@@ -262,7 +263,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
&unc_len, (char *)os_data, os_len,
CFG_MALLOC_LEN < (4096 * 1024), 0);
if (i != BZ_OK) {
- printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i);
+ printf ("BUNZIP2: uncompress or overwrite error %d "
+ "- must RESET board to recover\n", i);
show_boot_progress (-6);
do_reset (cmdtp, flag, argc, argv);
}
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 17/20] [new uImage] Add proper ramdisk/FDT handling when FIT configuration is used
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (15 preceding siblings ...)
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 ` Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 18/20] [new uImage] Fix build problems on trab board Bartlomiej Sieka
` (2 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:12 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Save FIT configuration provied in the first bootm argument and use it
when to get ramdisk/FDT subimages when second and third (ramdisk/FDT)
arguments are not specified.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
README | 1
common/cmd_bootm.c | 14 +++++--
common/image.c | 112 +++++++++++++++++++++++++++++++++++++++-------------
include/image.h | 3 +
lib_ppc/bootm.c | 104 ++++++++++++++++++++++++++++++++++--------------
5 files changed, 170 insertions(+), 64 deletions(-)
diff --git a/README b/README
index 183246e..0ed47f0 100644
--- a/README
+++ b/README
@@ -1769,6 +1769,7 @@ FIT uImage format:
-101 common/cmd_bootm.c Can't get configuration for kernel subimage
102 common/cmd_bootm.c Kernel unit name specified
-103 common/cmd_bootm.c Can't get kernel subimage node offset
+ 103 common/cmd_bootm.c Found configuration node
104 common/cmd_bootm.c Got kernel subimage node offset
-104 common/cmd_bootm.c Kernel subimage hash verification failed
105 common/cmd_bootm.c Kernel subimage hash verification OK
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index e95c5dd..2f232e7 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -469,7 +469,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
const char *fit_uname_kernel = NULL;
const void *data;
size_t len;
- int conf_noffset;
+ int cfg_noffset;
int os_noffset;
#endif
@@ -548,13 +548,19 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
* fit_conf_get_node() will try to find default config node
*/
show_boot_progress (101);
- conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
- if (conf_noffset < 0) {
+ cfg_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+ if (cfg_noffset < 0) {
show_boot_progress (-101);
return NULL;
}
+ /* save configuration uname provided in the first
+ * bootm argument
+ */
+ images->fit_uname_cfg = fdt_get_name (fit_hdr, cfg_noffset, NULL);
+ printf (" Using '%s' configuration\n", images->fit_uname_cfg);
+ show_boot_progress (103);
- os_noffset = fit_conf_get_kernel_node (fit_hdr, conf_noffset);
+ os_noffset = fit_conf_get_kernel_node (fit_hdr, cfg_noffset);
fit_uname_kernel = fit_get_name (fit_hdr, os_noffset, NULL);
} else {
/* get kernel component image node offset */
diff --git a/common/image.c b/common/image.c
index f29614b..bb57d6d 100644
--- a/common/image.c
+++ b/common/image.c
@@ -738,6 +738,26 @@ ulong genimg_get_image (ulong img_addr)
}
/**
+ * fit_has_config - check if there is a valid FIT configuration
+ * @images: pointer to the bootm command headers structure
+ *
+ * fit_has_config() checks if there is a FIT configuration in use
+ * (if FTI support is present).
+ *
+ * returns:
+ * 0, no FIT support or no configuration found
+ * 1, configuration found
+ */
+int genimg_has_config (bootm_headers_t *images)
+{
+#if defined(CONFIG_FIT)
+ if (images->fit_uname_cfg)
+ return 1;
+#endif
+ return 0;
+}
+
+/**
* boot_get_ramdisk - main ramdisk handling routine
* @argc: command argument count
* @argv: command argument list
@@ -771,7 +791,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
const char *fit_uname_ramdisk = NULL;
ulong default_addr;
int rd_noffset;
- int conf_noffset;
+ int cfg_noffset;
const void *data;
size_t size;
#endif
@@ -786,33 +806,63 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
if ((argc >= 3) && (strcmp(argv[2], "-") == 0)) {
debug ("## Skipping init Ramdisk\n");
rd_len = rd_data = 0;
- } else if (argc >= 3) {
+ } else if (argc >= 3 || genimg_has_config (images)) {
#if defined(CONFIG_FIT)
- /*
- * If the init ramdisk comes from the FIT image and the FIT image
- * address is omitted in the command line argument, try to use
- * os FIT image address or default load address.
- */
- if (images->fit_uname_os)
- default_addr = (ulong)images->fit_hdr_os;
- else
- default_addr = load_addr;
-
- if (fit_parse_conf (argv[2], default_addr,
- &rd_addr, &fit_uname_config)) {
- debug ("* ramdisk: config '%s' from image at 0x%08lx\n",
- fit_uname_config, rd_addr);
- } else if (fit_parse_subimage (argv[2], default_addr,
- &rd_addr, &fit_uname_ramdisk)) {
- debug ("* ramdisk: subimage '%s' from image at 0x%08lx\n",
- fit_uname_ramdisk, rd_addr);
- } else
+ if (argc >= 3) {
+ /*
+ * If the init ramdisk comes from the FIT image and
+ * the FIT image address is omitted in the command
+ * line argument, try to use os FIT image address or
+ * default load address.
+ */
+ if (images->fit_uname_os)
+ default_addr = (ulong)images->fit_hdr_os;
+ else
+ default_addr = load_addr;
+
+ if (fit_parse_conf (argv[2], default_addr,
+ &rd_addr, &fit_uname_config)) {
+ debug ("* ramdisk: config '%s' from image at 0x%08lx\n",
+ fit_uname_config, rd_addr);
+ } else if (fit_parse_subimage (argv[2], default_addr,
+ &rd_addr, &fit_uname_ramdisk)) {
+ debug ("* ramdisk: subimage '%s' from image at 0x%08lx\n",
+ fit_uname_ramdisk, rd_addr);
+ } else
#endif
- {
- rd_addr = simple_strtoul(argv[2], NULL, 16);
- debug ("* ramdisk: cmdline image address = 0x%08lx\n",
- rd_addr);
+ {
+ rd_addr = simple_strtoul(argv[2], NULL, 16);
+ debug ("* ramdisk: cmdline image address = 0x%08lx\n",
+ rd_addr);
+ }
+#if defined(CONFIG_FIT)
+ } else {
+ /* use FIT configuration provided in first bootm
+ * command argument
+ */
+ rd_addr = (ulong)images->fit_hdr_os;
+ fit_uname_config = images->fit_uname_cfg;
+ debug ("* ramdisk: using config '%s' from image at 0x%08lx\n",
+ fit_uname_config, rd_addr);
+
+ /*
+ * Check whether configuration has ramdisk defined,
+ * if not, don't try to use it, quit silently.
+ */
+ fit_hdr = (void *)rd_addr;
+ cfg_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+ if (cfg_noffset < 0) {
+ debug ("* ramdisk: no such config\n");
+ return 0;
+ }
+
+ rd_noffset = fit_conf_get_ramdisk_node (fit_hdr, cfg_noffset);
+ if (rd_noffset < 0) {
+ debug ("* ramdisk: no ramdisk in config\n");
+ return 0;
+ }
}
+#endif
/* copy from dataflash if needed */
rd_addr = genimg_get_image (rd_addr);
@@ -859,13 +909,16 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
* fit_conf_get_node() will try to find default config node
*/
show_boot_progress (122);
- conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
- if (conf_noffset < 0) {
+ cfg_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+ if (cfg_noffset < 0) {
+ puts ("Could not find configuration node\n");
show_boot_progress (-122);
return 0;
}
+ fit_uname_config = fdt_get_name (fit_hdr, cfg_noffset, NULL);
+ printf (" Using '%s' configuration\n", fit_uname_config);
- rd_noffset = fit_conf_get_ramdisk_node (fit_hdr, conf_noffset);
+ rd_noffset = fit_conf_get_ramdisk_node (fit_hdr, cfg_noffset);
fit_uname_ramdisk = fit_get_name (fit_hdr, rd_noffset, NULL);
} else {
/* get ramdisk component image node offset */
@@ -873,6 +926,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
rd_noffset = fit_image_get_node (fit_hdr, fit_uname_ramdisk);
}
if (rd_noffset < 0) {
+ puts ("Could not find subimage node\n");
show_boot_progress (-124);
return 0;
}
@@ -2394,7 +2448,7 @@ int fit_conf_get_fdt_node (const void *fit, int noffset)
/**
* fit_conf_print - prints out the FIT configuration details
* @fit: pointer to the FIT format image header
- * @conf_noffset: offset of the configuration node
+ * @noffset: offset of the configuration node
* @p: pointer to prefix string
*
* fit_conf_print() lists all mandatory properies for the processed
diff --git a/include/image.h b/include/image.h
index 51c0c89..0109560 100644
--- a/include/image.h
+++ b/include/image.h
@@ -206,6 +206,8 @@ typedef struct bootm_headers {
ulong legacy_hdr_valid;
#if defined(CONFIG_FIT)
+ const char *fit_uname_cfg; /* configuration node unit name */
+
void *fit_hdr_os; /* os FIT image header */
const char *fit_uname_os; /* os subimage node unit name */
int fit_noffset_os; /* os subimage node offset */
@@ -251,6 +253,7 @@ int genimg_get_comp_id (const char *name);
#define IMAGE_FORMAT_FIT 0x02 /* new, libfdt based format */
int genimg_get_format (void *img_addr);
+int genimg_has_config (bootm_headers_t *images);
ulong genimg_get_image (ulong img_addr);
int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c
index 86e104c..8cdace2 100644
--- a/lib_ppc/bootm.c
+++ b/lib_ppc/bootm.c
@@ -415,7 +415,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
const char *fit_uname_config = NULL;
const char *fit_uname_fdt = NULL;
ulong default_addr;
- int conf_noffset;
+ int cfg_noffset;
int fdt_noffset;
const void *data;
size_t size;
@@ -424,35 +424,67 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
*of_flat_tree = NULL;
*of_size = 0;
- if (argc > 3) {
+ if (argc > 3 || genimg_has_config (images)) {
#if defined(CONFIG_FIT)
- /*
- * If the FDT blob comes from the FIT image and the FIT image
- * address is omitted in the command line argument, try to use
- * ramdisk or os FIT image address or default load address.
- */
- if (images->fit_uname_rd)
- default_addr = (ulong)images->fit_hdr_rd;
- else if (images->fit_uname_os)
- default_addr = (ulong)images->fit_hdr_os;
- else
- default_addr = load_addr;
-
- if (fit_parse_conf (argv[3], default_addr,
- &fdt_addr, &fit_uname_config)) {
- debug ("* fdt: config '%s' from image at 0x%08lx\n",
- fit_uname_config, fdt_addr);
- } else if (fit_parse_subimage (argv[3], default_addr,
- &fdt_addr, &fit_uname_fdt)) {
- debug ("* fdt: subimage '%s' from image at 0x%08lx\n",
- fit_uname_fdt, fdt_addr);
- } else
+ if (argc > 3) {
+ /*
+ * If the FDT blob comes from the FIT image and the
+ * FIT image address is omitted in the command line
+ * argument, try to use ramdisk or os FIT image
+ * address or default load address.
+ */
+ if (images->fit_uname_rd)
+ default_addr = (ulong)images->fit_hdr_rd;
+ else if (images->fit_uname_os)
+ default_addr = (ulong)images->fit_hdr_os;
+ else
+ default_addr = load_addr;
+
+ if (fit_parse_conf (argv[3], default_addr,
+ &fdt_addr, &fit_uname_config)) {
+ debug ("* fdt: config '%s' from image at 0x%08lx\n",
+ fit_uname_config, fdt_addr);
+ } else if (fit_parse_subimage (argv[3], default_addr,
+ &fdt_addr, &fit_uname_fdt)) {
+ debug ("* fdt: subimage '%s' from image at 0x%08lx\n",
+ fit_uname_fdt, fdt_addr);
+ } else
#endif
- {
- fdt_addr = simple_strtoul(argv[3], NULL, 16);
- debug ("* fdt: cmdline image address = 0x%08lx\n",
- fdt_addr);
+ {
+ fdt_addr = simple_strtoul(argv[3], NULL, 16);
+ debug ("* fdt: cmdline image address = 0x%08lx\n",
+ fdt_addr);
+ }
+#if defined(CONFIG_FIT)
+ } else {
+ /* use FIT configuration provided in first bootm
+ * command argument
+ */
+ fdt_addr = (ulong)images->fit_hdr_os;
+ fit_uname_config = images->fit_uname_cfg;
+ debug ("* fdt: using config '%s' from image at 0x%08lx\n",
+ fit_uname_config, fdt_addr);
+
+ /*
+ * Check whether configuration has FDT blob defined,
+ * if not quit silently.
+ */
+ fit_hdr = (void *)fdt_addr;
+ cfg_noffset = fit_conf_get_node (fit_hdr,
+ fit_uname_config);
+ if (cfg_noffset < 0) {
+ debug ("* fdt: no such config\n");
+ return 0;
+ }
+
+ fdt_noffset = fit_conf_get_fdt_node (fit_hdr,
+ cfg_noffset);
+ if (fdt_noffset < 0) {
+ debug ("* fdt: no fdt in config\n");
+ return 0;
+ }
}
+#endif
debug ("## Checking for 'FDT'/'FDT Image'@%08lx\n",
fdt_addr);
@@ -522,13 +554,21 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
* fit_conf_get_node() will try to
* find default config node
*/
- conf_noffset = fit_conf_get_node (fit_hdr,
+ cfg_noffset = fit_conf_get_node (fit_hdr,
fit_uname_config);
- if (conf_noffset < 0)
+
+ if (cfg_noffset < 0) {
+ fdt_error ("Could not find configuration node\n");
goto error;
+ }
+
+ fit_uname_config = fdt_get_name (fit_hdr,
+ cfg_noffset, NULL);
+ printf (" Using '%s' configuration\n",
+ fit_uname_config);
fdt_noffset = fit_conf_get_fdt_node (fit_hdr,
- conf_noffset);
+ cfg_noffset);
fit_uname_fdt = fit_get_name (fit_hdr,
fdt_noffset, NULL);
} else {
@@ -536,8 +576,10 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
fdt_noffset = fit_image_get_node (fit_hdr,
fit_uname_fdt);
}
- if (fdt_noffset < 0)
+ if (fdt_noffset < 0) {
+ fdt_error ("Could not find subimage node\n");
goto error;
+ }
printf (" Trying '%s' FDT blob subimage\n",
fit_uname_fdt);
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 18/20] [new uImage] Fix build problems on trab board
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (16 preceding siblings ...)
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 ` Bartlomiej Sieka
2008-03-12 20:55 ` Wolfgang Denk
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
19 siblings, 1 reply; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:12 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
board/trab/auto_update.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/board/trab/auto_update.c b/board/trab/auto_update.c
index fa08bff..5311e12 100644
--- a/board/trab/auto_update.c
+++ b/board/trab/auto_update.c
@@ -224,7 +224,7 @@ au_check_cksum_valid(int idx, long nbytes)
return -1;
}
/* check the data CRC */
- if (!image_check_dcrc (hdr)) {
+ if (!image_check_dcrc (hdr))
{
printf ("Image %s bad data checksum\n", aufile[idx]);
return -1;
@@ -284,7 +284,7 @@ au_check_header_valid(int idx, long nbytes)
return -1;
}
if ((idx == IDX_APP) && !image_check_type (hdr, IH_TYPE_RAMDISK)
- && !image_check_type (hdr, FILESYSTEM)) {
+ && !image_check_type (hdr, IH_TYPE_FILESYSTEM)) {
printf ("Image %s wrong type\n", aufile[idx]);
return -1;
}
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 19/20] [new uImage] Fix definition of common bootm_headers_t fields
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (17 preceding siblings ...)
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:12 ` Bartlomiej Sieka
2008-03-12 20:12 ` [U-Boot-Users] [PATCH 20/20] [new uImage] Add new uImage format documentation and examples Bartlomiej Sieka
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:12 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
verify, autostart and lmb fields are used regardless of CONFIG_FIT
setting, move their definitions to common section.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
include/image.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/image.h b/include/image.h
index 0109560..fbd8c30 100644
--- a/include/image.h
+++ b/include/image.h
@@ -221,10 +221,11 @@ typedef struct bootm_headers {
const char *fit_uname_fdt; /* FDT blob subimage node unit name */
int fit_noffset_fdt;/* FDT blob subimage node offset */
#endif
+#endif
+
int verify; /* getenv("verify")[0] != 'n' */
int autostart; /* getenv("autostart")[0] != 'n' */
struct lmb *lmb; /* for memory mgmt */
-#endif
} bootm_headers_t;
/*
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 20/20] [new uImage] Add new uImage format documentation and examples
2008-03-12 20:10 [U-Boot-Users] [PATCH 00/20] [new uImage] patchset 7 - core functionality Bartlomiej Sieka
` (18 preceding siblings ...)
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 ` Bartlomiej Sieka
19 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-12 20:12 UTC (permalink / raw)
To: u-boot
From: Marian Balakowicz <m8@semihalf.com>
Create doc/uImage.FIT documentation directory with the following files:
- command_syntax_extensions.txt : extended command syntax description
- howto.txt : short usage howto
- source_file_format.txt : internal new uImage format description
Add example image source files:
- kernel.its
- kernel_fdt.its
- multi.its
Update README appropriately.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
---
README | 30 ++-
doc/uImage.FIT/command_syntax_extensions.txt | 191 +++++++++++++++++
doc/uImage.FIT/howto.txt | 296 ++++++++++++++++++++++++++
doc/uImage.FIT/kernel.its | 34 +++
doc/uImage.FIT/kernel_fdt.its | 48 ++++
doc/uImage.FIT/multi.its | 124 +++++++++++
doc/uImage.FIT/source_file_format.txt | 262 +++++++++++++++++++++++
7 files changed, 981 insertions(+), 4 deletions(-)
create mode 100644 doc/uImage.FIT/command_syntax_extensions.txt
create mode 100644 doc/uImage.FIT/howto.txt
create mode 100644 doc/uImage.FIT/kernel.its
create mode 100644 doc/uImage.FIT/kernel_fdt.its
create mode 100644 doc/uImage.FIT/multi.its
create mode 100644 doc/uImage.FIT/source_file_format.txt
diff --git a/README b/README
index 0ed47f0..26bd0cf 100644
--- a/README
+++ b/README
@@ -2684,6 +2684,14 @@ Some configuration options can be set using Environment Variables:
configuration from the BOOTP server, but not try to
load any image using TFTP
+ autoscript - if set to "yes" commands like "loadb", "loady",
+ "bootp", "tftpb", "rarpboot" and "nfs" will attempt
+ to automatically run script images (by internally
+ calling "autoscript").
+
+ autoscript_uname - if script image is in a format (FIT) this
+ variable is used to get script subimage unit name.
+
autostart - if set to "yes", an image loaded using the "bootp",
"rarpboot", "tftpboot" or "diskboot" commands will
be automatically started (by internally calling
@@ -2898,10 +2906,24 @@ o If neither SROM nor the environment contain a MAC address, an error
Image Formats:
==============
-The "boot" commands of this monitor operate on "image" files which
-can be basicly anything, preceeded by a special header; see the
-definitions in include/image.h for details; basicly, the header
-defines the following image properties:
+U-Boot is capable of booting (and performing other auxiliary operations on)
+images in two formats:
+
+New uImage format (FIT)
+-----------------------
+
+Flexible and powerful format based on Flattened Image Tree -- FIT (similar
+to Flattened Device Tree). It allows the use of images with multiple
+components (several kernels, ramdisks, etc.), with contents protected by
+SHA1, MD5 or CRC32. More details are found in the doc/uImage.FIT directory.
+
+
+Old uImage format
+-----------------
+
+Old image format is based on binary files which can be basically anything,
+preceded by a special header; see the definitions in include/image.h for
+details; basically, the header defines the following image properties:
* Target Operating System (Provisions for OpenBSD, NetBSD, FreeBSD,
4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO, Dell, NCR, VxWorks,
diff --git a/doc/uImage.FIT/command_syntax_extensions.txt b/doc/uImage.FIT/command_syntax_extensions.txt
new file mode 100644
index 0000000..b8b50ff
--- /dev/null
+++ b/doc/uImage.FIT/command_syntax_extensions.txt
@@ -0,0 +1,191 @@
+Command syntax extensions for the new uImage format
+===================================================
+
+Author: Bartlomiej Sieka <tur@semihalf.com>
+
+With the introduction of the new uImage format, bootm command (and other
+commands as well) have to understand new syntax of the arguments. This is
+necessary in order to specify objects contained in the new uImage, on which
+bootm has to operate. This note attempts to first summarize bootm usage
+scenarios, and then introduces new argument syntax.
+
+
+bootm usage scenarios
+---------------------
+
+Below is a summary of bootm usage scenarios, focused on booting a PowerPC
+Linux kernel. The purpose of the following list is to document a complete list
+of supported bootm usages.
+
+Note: U-Boot supports two methods of booting a PowerPC Linux kernel: old way,
+i.e., without passing the Flattened Device Tree (FDT), and new way, where the
+kernel is passed a pointer to the FDT. The boot method is indicated for each
+scenario.
+
+
+1. bootm boot image at the current address, equivalent to 2,3,8
+
+Old uImage:
+2. bootm <addr1> /* single image at <addr1> */
+3. bootm <addr1> /* multi-image at <addr1> */
+4. bootm <addr1> - /* multi-image at <addr1> */
+5. bootm <addr1> <addr2> /* single image at <addr1> */
+6. bootm <addr1> <addr2> <addr3> /* single image at <addr1> */
+7. bootm <addr1> - <addr3> /* single image at <addr1> */
+
+New uImage:
+8. bootm <addr1>
+9. bootm [<addr1>]:<subimg1>
+10. bootm [<addr1>]#<conf>
+11. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2>
+12. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> [<addr3>]:<subimg3>
+13. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> <addr3>
+14. bootm [<addr1>]:<subimg1> - [<addr3>]:<subimg3>
+15. bootm [<addr1>]:<subimg1> - <addr3>
+
+
+Ad. 1. This is equivalent to cases 2,3,8, depending on the type of image at
+the current image address.
+- boot method: see cases 2,3,8
+
+Ad. 2. Boot kernel image located at <addr1>.
+- boot method: non-FDT
+
+Ad. 3. First and second components of the image at <addr1> are assumed to be a
+kernel and a ramdisk, respectively. The kernel is booted with initrd loaded
+with the ramdisk from the image.
+- boot method: depends on the number of components at <addr1>, and on whether
+ U-Boot is compiled with OF support:
+
+ | 2 components | 3 components |
+ | (kernel, initrd) | (kernel, initrd, fdt) |
+---------------------------------------------------------------------
+#ifdef CONFIG_OF_* | non-FDT | FDT |
+#ifndef CONFIG_OF_* | non-FDT | non-FDT |
+
+Ad. 4. Similar to case 3, but the kernel is booted without initrd. Second
+component of the multi-image is irrelevant (it can be a dummy, 1-byte file).
+- boot method: see case 3
+
+Ad. 5. Boot kernel image located at <addr1> with initrd loaded with ramdisk
+from the image at <addr2>.
+- boot method: non-FDT
+
+Ad. 6. <addr1> is the address of a kernel image, <addr2> is the address of a
+ramdisk image, and <addr3> is the address of a FDT binary blob. Kernel is
+booted with initrd loaded with ramdisk from the image at <addr2>.
+- boot method: FDT
+
+Ad. 7. <addr1> is the address of a kernel image and <addr3> is the address of
+a FDT binary blob. Kernel is booted without initrd.
+- boot method: FDT
+
+Ad. 8. Image at <addr1> is assumed to contain a default configuration, which
+is booted.
+- boot method: FDT or non-FDT, depending on whether the default configuration
+ defines FDT
+
+Ad. 9. Similar to case 2: boot kernel stored in <subimg1> from the image at
+address <addr1>.
+- boot method: non-FDT
+
+Ad. 10. Boot configuration <conf> from the image at <addr1>.
+- boot method: FDT or non-FDT, depending on whether the configuration given
+ defines FDT
+
+Ad. 11. Equivalent to case 5: boot kernel stored in <subimg1> from the image
+at <addr1> with initrd loaded with ramdisk <subimg2> from the image at
+<addr2>.
+- boot method: non-FDT
+
+Ad. 12. Equivalent to case 6: boot kernel stored in <subimg1> from the image
+at <addr1> with initrd loaded with ramdisk <subimg2> from the image at
+<addr2>, and pass FDT blob <subimg3> from the image at <addr3>.
+- boot method: FDT
+
+Ad. 13. Similar to case 12, the difference being that <addr3> is the address
+of FDT binary blob that is to be passed to the kernel.
+- boot method: FDT
+
+Ad. 14. Equivalent to case 7: boot kernel stored in <subimg1> from the image
+at <addr1>, without initrd, and pass FDT blob <subimg3> from the image at
+<addr3>.
+- boot method: FDT
+
+Ad. 15. Similar to case 14, the difference being that <addr3> is the address
+of the FDT binary blob that is to be passed to the kernel.
+- boot method: FDT
+
+
+New uImage argument syntax
+--------------------------
+
+New uImage support introduces two new forms for bootm arguments, with the
+following syntax:
+
+- new uImage sub-image specification
+<addr>:<sub-image unit_name>
+
+- new uImage configuration specification
+<addr>#<configuration unit_name>
+
+
+Examples:
+
+- boot kernel "kernel at 1" stored in a new uImage located at 200000:
+bootm 200000:kernel at 1
+
+- boot configuration "cfg at 1" from a new uImage located at 200000:
+bootm 200000#cfg at 1
+
+- boot "kernel at 1" from a new uImage at 200000 with initrd "ramdisk at 2" found in
+ some other new uImage stored at address 800000:
+bootm 200000:kernel at 1 800000:ramdisk at 2
+
+- boot "kernel at 2" from a new uImage at 200000, with initrd "ramdisk at 1" and FDT
+ "fdt at 1", both stored in some other new uImage located at 800000:
+bootm 200000:kernel at 1 800000:ramdisk at 1 800000:fdt at 1
+
+- boot kernel "kernel at 2" with initrd "ramdisk at 2", both stored in a new uImage
+ at address 200000, with a raw FDT blob stored at address 600000:
+bootm 200000:kernel at 2 200000:ramdisk at 2 600000
+
+- boot kernel "kernel at 2" from new uImage at 200000 with FDT "fdt at 1" from the
+ same new uImage:
+bootm 200000:kernel at 2 - 200000:fdt at 1
+
+
+Note on current image address
+-----------------------------
+
+When bootm is called without arguments, the image at current image address is
+booted. The current image address is the address set most recently by a load
+command, etc, and is by default equal to CFG_LOAD_ADDR. For example, consider
+the following commands:
+
+tftp 200000 /tftpboot/kernel
+bootm
+Last command is equivalent to:
+bootm 200000
+
+In case of the new uImage argument syntax, the address portion of any argument
+can be omitted. If <addr3> is omitted, then it is assumed that image at
+<addr2> should be used. Similarly, when <addr2> is omitted, is is assumed that
+image at <addr1> should be used. If <addr1> is omitted, it is assumed that the
+current image address is to be used. For example, consider the following
+commands:
+
+tftp 200000 /tftpboot/uImage
+bootm :kernel at 1
+Last command is equivalent to:
+bootm 200000:kernel at 1
+
+tftp 200000 /tftpboot/uImage
+bootm 400000:kernel at 1 :ramdisk at 1
+Last command is equivalent to:
+bootm 400000:kernel at 1 400000:ramdisk at 1
+
+tftp 200000 /tftpboot/uImage
+bootm :kernel at 1 400000:ramdisk at 1 :fdt at 1
+Last command is equivalent to:
+bootm 200000:kernel at 1 400000:ramdisk at 1 400000:fdt at 1
diff --git a/doc/uImage.FIT/howto.txt b/doc/uImage.FIT/howto.txt
new file mode 100644
index 0000000..35ab97d
--- /dev/null
+++ b/doc/uImage.FIT/howto.txt
@@ -0,0 +1,296 @@
+How to use images in the new image format
+=========================================
+
+Author: Bartlomiej Sieka <tur@semihalf.com>
+
+
+Overview
+--------
+
+The new uImage format allows more flexibility in handling images of various
+types (kernel, ramdisk, etc.), it also enhances integrity protection of images
+with sha1 and md5 checksums.
+
+Two auxiliary tools are needed on the development host system in order to
+create an uImage in the new format: mkimage and dtc, although only one
+(mkimage) is invoked directly. dtc is called from within mkimage and operates
+behind the scenes, but needs to be present in the $PATH nevertheless. It is
+important that the dtc used has support for binary includes -- refer to
+www.jdl.com for its latest version. mkimage (together with dtc) takes as input
+an image source file, which describes the contents of the image and defines
+its various properties used during booting. By convention, image source file
+has the ".its" extension, also, the details of its format are given in
+doc/source_file_format.txt. The actual data that is to be included in the
+uImage (kernel, ramdisk, etc.) is specified in the image source file in the
+form of paths to appropriate data files. The outcome of the image creation
+process is a binary file (by convention with the ".itb" extension) that
+contains all the referenced data (kernel, ramdisk, etc.) and other information
+needed by U-Boot to handle the uImage properly. The uImage file is then
+transferred to the target (e.g., via tftp) and booted using the bootm command.
+
+To summarize the prerequisites needed for new uImage creation:
+- mkimage
+- dtc (with support for binary includes)
+- image source file (*.its)
+- image data file(s)
+
+
+Here's a graphical overview of the image creation and booting process:
+
+image source file mkimage + dtc transfer to target
+ + ---------------> image file --------------------> bootm
+image data files(s)
+
+
+Example 1 -- old-style (non-FDT) kernel booting
+-----------------------------------------------
+
+Consider a simple scenario, where a PPC Linux kernel built from sources on the
+development host is to be booted old-style (non-FDT) by U-Boot on an embedded
+target. Assume that the outcome of the build is vmlinux.bin.gz, a file which
+contains a gzip-compressed PPC Linux kernel (the only data file in this case).
+The uImage can be produced using the image source file examples/kernel.its
+(note that kernel.its assumes that vmlinux.bin.gz is in the current working
+directory; if desired, an alternative path can be specified in the kernel.its
+file). Here's how to create the image and inspect its contents:
+
+[on the host system]
+$ mkimage -f kernel.its kernel.itb
+DTC: dts->dtb on file "kernel.its"
+$
+$ mkimage -l kernel.itb
+FIT description: Simple image with single Linux kernel
+Created: Tue Mar 11 17:26:15 2008
+ Image 0 (kernel at 1)
+ Description: Vanilla Linux kernel
+ Type: Kernel Image
+ Compression: gzip compressed
+ Data Size: 943347 Bytes = 921.24 kB = 0.90 MB
+ Architecture: PowerPC
+ OS: Linux
+ Load Address: 0x00000000
+ Entry Point: 0x00000000
+ Hash algo: crc32
+ Hash value: 2ae2bb40
+ Hash algo: sha1
+ Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
+ Default Configuration: 'config at 1'
+ Configuration 0 (config at 1)
+ Description: Boot Linux kernel
+ Kernel: kernel at 1
+
+
+The resulting image file kernel.itb can be now transferred to the target,
+inspected and booted (note that first three U-Boot commands below are shown
+for completeness -- they are part of the standard booting procedure and not
+specific to the new image format).
+
+[on the target system]
+=> print nfsargs
+nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}
+=> print addip
+addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off panic=1
+=> run nfsargs addip
+=> tftp 900000 /path/to/tftp/location/kernel.itb
+Using FEC ETHERNET device
+TFTP from server 192.168.1.1; our IP address is 192.168.160.5
+Filename '/path/to/tftp/location/kernel.itb'.
+Load address: 0x900000
+Loading: #################################################################
+done
+Bytes transferred = 944464 (e6950 hex)
+=> iminfo
+
+## Checking Image at 00900000 ...
+ FIT image found
+ FIT description: Simple image with single Linux kernel
+ Created: 2008-03-11 16:26:15 UTC
+ Image 0 (kernel at 1)
+ Description: Vanilla Linux kernel
+ Type: Kernel Image
+ Compression: gzip compressed
+ Data Start: 0x009000e0
+ Data Size: 943347 Bytes = 921.2 kB
+ Architecture: PowerPC
+ OS: Linux
+ Load Address: 0x00000000
+ Entry Point: 0x00000000
+ Hash algo: crc32
+ Hash value: 2ae2bb40
+ Hash algo: sha1
+ Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
+ Default Configuration: 'config at 1'
+ Configuration 0 (config at 1)
+ Description: Boot Linux kernel
+ Kernel: kernel at 1
+
+=> bootm
+## Booting kernel from FIT Image at 00900000 ...
+ Using 'config at 1' configuration
+ Trying 'kernel at 1' kernel subimage
+ Description: Vanilla Linux kernel
+ Type: Kernel Image
+ Compression: gzip compressed
+ Data Start: 0x009000e0
+ Data Size: 943347 Bytes = 921.2 kB
+ Architecture: PowerPC
+ OS: Linux
+ Load Address: 0x00000000
+ Entry Point: 0x00000000
+ Hash algo: crc32
+ Hash value: 2ae2bb40
+ Hash algo: sha1
+ Hash value: 3c200f34e2c226ddc789240cca0c59fc54a67cf4
+ Verifying Hash Integrity ... crc32+ sha1+ OK
+ Uncompressing Kernel Image ... OK
+Memory BAT mapping: BAT2=256Mb, BAT3=0Mb, residual: 0Mb
+Linux version 2.4.25 (m8 at hekate) (gcc version 4.0.0 (DENX ELDK 4.0 4.0.0)) #2 czw lip 5 17:56:18 CEST 2007
+On node 0 totalpages: 65536
+zone(0): 65536 pages.
+zone(1): 0 pages.
+zone(2): 0 pages.
+Kernel command line: root=/dev/nfs rw nfsroot=192.168.1.1:/opt/eldk-4.1/ppc_6xx ip=192.168.160.5:192.168.1.1::255.255.0.0:lite5200b:eth0:off panic=1
+Calibrating delay loop... 307.20 BogoMIPS
+
+
+Example 2 -- new-style (FDT) kernel booting
+-------------------------------------------
+
+Consider another simple scenario, where a PPC Linux kernel is to be booted
+new-style, i.e., with a FDT blob. In this case there are two prerequisite data
+files: vmlinux.bin.gz (Linux kernel) and target.dtb (FDT blob). The uImage can
+be produced using image source file examples/kernel_fdt.its like this (note
+again, that both prerequisite data files are assumed to be present in the
+current working directory -- image source file kernel_fdt.its can be modified
+to take the files from some other location if needed):
+
+[on the host system]
+$ mkimage -f kernel_fdt.its kernel_fdt.itb
+DTC: dts->dtb on file "kernel_fdt.its"
+$
+$ mkimage -l kernel_fdt.itb
+FIT description: Simple image with single Linux kernel and FDT blob
+Created: Tue Mar 11 16:29:22 2008
+ Image 0 (kernel at 1)
+ Description: Vanilla Linux kernel
+ Type: Kernel Image
+ Compression: gzip compressed
+ Data Size: 1092037 Bytes = 1066.44 kB = 1.04 MB
+ Architecture: PowerPC
+ OS: Linux
+ Load Address: 0x00000000
+ Entry Point: 0x00000000
+ Hash algo: crc32
+ Hash value: 2c0cc807
+ Hash algo: sha1
+ Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
+ Image 1 (fdt at 1)
+ Description: Flattened Device Tree blob
+ Type: Flat Device Tree
+ Compression: uncompressed
+ Data Size: 16384 Bytes = 16.00 kB = 0.02 MB
+ Architecture: PowerPC
+ Hash algo: crc32
+ Hash value: 0d655d71
+ Hash algo: sha1
+ Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
+ Default Configuration: 'conf at 1'
+ Configuration 0 (conf at 1)
+ Description: Boot Linux kernel with FDT blob
+ Kernel: kernel at 1
+ FDT: fdt at 1
+
+
+The resulting image file kernel_fdt.itb can be now transferred to the target,
+inspected and booted:
+
+[on the target system]
+=> tftp 900000 /path/to/tftp/location/kernel_fdt.itb
+Using FEC ETHERNET device
+TFTP from server 192.168.1.1; our IP address is 192.168.160.5
+Filename '/path/to/tftp/location/kernel_fdt.itb'.
+Load address: 0x900000
+Loading: #################################################################
+ ###########
+done
+Bytes transferred = 1109776 (10ef10 hex)
+=> iminfo
+
+## Checking Image at 00900000 ...
+ FIT image found
+ FIT description: Simple image with single Linux kernel and FDT blob
+ Created: 2008-03-11 15:29:22 UTC
+ Image 0 (kernel at 1)
+ Description: Vanilla Linux kernel
+ Type: Kernel Image
+ Compression: gzip compressed
+ Data Start: 0x009000ec
+ Data Size: 1092037 Bytes = 1 MB
+ Architecture: PowerPC
+ OS: Linux
+ Load Address: 0x00000000
+ Entry Point: 0x00000000
+ Hash algo: crc32
+ Hash value: 2c0cc807
+ Hash algo: sha1
+ Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
+ Image 1 (fdt at 1)
+ Description: Flattened Device Tree blob
+ Type: Flat Device Tree
+ Compression: uncompressed
+ Data Start: 0x00a0abdc
+ Data Size: 16384 Bytes = 16 kB
+ Architecture: PowerPC
+ Hash algo: crc32
+ Hash value: 0d655d71
+ Hash algo: sha1
+ Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
+ Default Configuration: 'conf at 1'
+ Configuration 0 (conf at 1)
+ Description: Boot Linux kernel with FDT blob
+ Kernel: kernel at 1
+ FDT: fdt at 1
+=> bootm
+## Booting kernel from FIT Image at 00900000 ...
+ Using 'conf at 1' configuration
+ Trying 'kernel at 1' kernel subimage
+ Description: Vanilla Linux kernel
+ Type: Kernel Image
+ Compression: gzip compressed
+ Data Start: 0x009000ec
+ Data Size: 1092037 Bytes = 1 MB
+ Architecture: PowerPC
+ OS: Linux
+ Load Address: 0x00000000
+ Entry Point: 0x00000000
+ Hash algo: crc32
+ Hash value: 2c0cc807
+ Hash algo: sha1
+ Hash value: 264b59935470e42c418744f83935d44cdf59a3bb
+ Verifying Hash Integrity ... crc32+ sha1+ OK
+ Uncompressing Kernel Image ... OK
+## Flattened Device Tree from FIT Image at 00900000
+ Using 'conf at 1' configuration
+ Trying 'fdt at 1' FDT blob subimage
+ Description: Flattened Device Tree blob
+ Type: Flat Device Tree
+ Compression: uncompressed
+ Data Start: 0x00a0abdc
+ Data Size: 16384 Bytes = 16 kB
+ Architecture: PowerPC
+ Hash algo: crc32
+ Hash value: 0d655d71
+ Hash algo: sha1
+ Hash value: 25ab4e15cd4b8a5144610394560d9c318ce52def
+ Verifying Hash Integrity ... crc32+ sha1+ OK
+ Booting using the fdt blob at 0xa0abdc
+ Loading Device Tree to 007fc000, end 007fffff ... OK
+[ 0.000000] Using lite5200 machine description
+[ 0.000000] Linux version 2.6.24-rc6-gaebecdfc (m8 at hekate) (gcc version 4.0.0 (DENX ELDK 4.1 4.0.0)) #1 Sat Jan 12 15:38:48 CET 2008
+
+
+Example 3 -- advanced booting
+-----------------------------
+
+Refer to examples/multi.its for an image source file that allows more
+sophisticated booting scenarios (multiple kernels, ramdisks and fdt blobs).
diff --git a/doc/uImage.FIT/kernel.its b/doc/uImage.FIT/kernel.its
new file mode 100644
index 0000000..d1a5939
--- /dev/null
+++ b/doc/uImage.FIT/kernel.its
@@ -0,0 +1,34 @@
+/*
+ * Simple U-boot uImage source file containing a single kernel
+ */
+/ {
+ description = "Simple image with single Linux kernel";
+ #address-cells = <1>;
+
+ images {
+ kernel at 1 {
+ description = "Vanilla Linux kernel";
+ data = /incbin/("./vmlinux.bin.gz");
+ type = "kernel";
+ arch = "ppc";
+ os = "linux";
+ compression = "gzip";
+ load = <00000000>;
+ entry = <00000000>;
+ hash at 1 {
+ algo = "crc32";
+ };
+ hash at 2 {
+ algo = "sha1";
+ };
+ };
+ };
+
+ configurations {
+ default = "config at 1";
+ config at 1 {
+ description = "Boot Linux kernel";
+ kernel = "kernel at 1";
+ };
+ };
+};
diff --git a/doc/uImage.FIT/kernel_fdt.its b/doc/uImage.FIT/kernel_fdt.its
new file mode 100644
index 0000000..fd6dee2
--- /dev/null
+++ b/doc/uImage.FIT/kernel_fdt.its
@@ -0,0 +1,48 @@
+/*
+ * Simple U-boot uImage source file containing a single kernel and FDT blob
+ */
+/ {
+ description = "Simple image with single Linux kernel and FDT blob";
+ #address-cells = <1>;
+
+ images {
+ kernel at 1 {
+ description = "Vanilla Linux kernel";
+ data = /incbin/("./vmlinux.bin.gz");
+ type = "kernel";
+ arch = "ppc";
+ os = "linux";
+ compression = "gzip";
+ load = <00000000>;
+ entry = <00000000>;
+ hash at 1 {
+ algo = "crc32";
+ };
+ hash at 2 {
+ algo = "sha1";
+ };
+ };
+ fdt at 1 {
+ description = "Flattened Device Tree blob";
+ data = /incbin/("./target.dtb");
+ type = "flat_dt";
+ arch = "ppc";
+ compression = "none";
+ hash at 1 {
+ algo = "crc32";
+ };
+ hash at 2 {
+ algo = "sha1";
+ };
+ };
+ };
+
+ configurations {
+ default = "conf at 1";
+ conf at 1 {
+ description = "Boot Linux kernel with FDT blob";
+ kernel = "kernel at 1";
+ fdt = "fdt at 1";
+ };
+ };
+};
diff --git a/doc/uImage.FIT/multi.its b/doc/uImage.FIT/multi.its
new file mode 100644
index 0000000..b992962
--- /dev/null
+++ b/doc/uImage.FIT/multi.its
@@ -0,0 +1,124 @@
+/*
+ * U-boot uImage source file with multiple kernels, ramdisks and FDT blobs
+ */
+/ {
+ description = "Various kernels, ramdisks and FDT blobs";
+ #address-cells = <1>;
+
+ images {
+ kernel at 1 {
+ description = "vanilla-2.6.23";
+ data = /incbin/("./vmlinux.bin.gz");
+ type = "kernel";
+ arch = "ppc";
+ os = "linux";
+ compression = "gzip";
+ load = <00000000>;
+ entry = <00000000>;
+ hash at 1 {
+ algo = "md5";
+ };
+ hash at 2 {
+ algo = "sha1";
+ };
+ };
+
+ kernel at 2 {
+ description = "2.6.23-denx";
+ data = /incbin/("./2.6.23-denx.bin.gz");
+ type = "kernel";
+ arch = "ppc";
+ os = "linux";
+ compression = "gzip";
+ load = <00000000>;
+ entry = <00000000>;
+ hash at 1 {
+ algo = "sha1";
+ };
+ };
+
+ kernel at 3 {
+ description = "2.4.25-denx";
+ data = /incbin/("./2.4.25-denx.bin.gz");
+ type = "kernel";
+ arch = "ppc";
+ os = "linux";
+ compression = "gzip";
+ load = <00000000>;
+ entry = <00000000>;
+ hash at 1 {
+ algo = "md5";
+ };
+ };
+
+ ramdisk at 1 {
+ description = "eldk-4.2-ramdisk";
+ data = /incbin/("./eldk-4.2-ramdisk");
+ type = "ramdisk";
+ arch = "ppc";
+ compression = "gzip";
+ hash at 1 {
+ algo = "sha1";
+ };
+ };
+
+ ramdisk at 2 {
+ description = "eldk-3.1-ramdisk";
+ data = /incbin/("./eldk-3.1-ramdisk");
+ type = "ramdisk";
+ arch = "ppc";
+ compression = "gzip";
+ hash at 1 {
+ algo = "crc32";
+ };
+ };
+
+ fdt at 1 {
+ description = "tqm5200-fdt";
+ data = /incbin/("./tqm5200.dtb");
+ type = "flat_dt";
+ arch = "ppc";
+ compression = "none";
+ hash at 1 {
+ algo = "crc32";
+ };
+ };
+
+ fdt at 2 {
+ description = "tqm5200s-fdt";
+ data = /incbin/("./tqm5200s.dtb");
+ type = "flat_dt";
+ arch = "ppc";
+ compression = "none";
+ load = <00700000>;
+ hash at 1 {
+ algo = "sha1";
+ };
+ };
+
+ };
+
+ configurations {
+ default = "config at 1";
+
+ config at 1 {
+ description = "tqm5200 vanilla-2.6.23 configuration";
+ kernel = "kernel at 1";
+ ramdisk = "ramdisk at 1";
+ fdt = "fdt at 1";
+ };
+
+ config at 2 {
+ description = "tqm5200s denx-2.6.23 configuration";
+ kernel = "kernel at 2";
+ ramdisk = "ramdisk at 1";
+ fdt = "fdt at 2";
+ };
+
+ config at 3 {
+ description = "tqm5200s denx-2.4.25 configuration";
+ kernel = "kernel at 3";
+ ramdisk = "ramdisk at 2";
+ };
+ };
+};
diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt
new file mode 100644
index 0000000..3f7104f
--- /dev/null
+++ b/doc/uImage.FIT/source_file_format.txt
@@ -0,0 +1,262 @@
+U-boot new uImage source file format (bindings definition)
+==========================================================
+
+Author: Marian Balakowicz <m8@semihalf.com>
+
+1) Introduction
+---------------
+
+Evolution of the 2.6 Linux kernel for embedded PowerPC systems introduced new
+booting method which requires that hardware description is available to the
+kernel in the form of Flattened Device Tree.
+
+Booting with a Flattened Device Tree is much more flexible and is intended to
+replace direct passing of 'struct bd_info' which was used to boot pre-FDT
+kernels.
+
+However, U-boot needs to support both techniques to provide backward
+compatibility for platforms which are not FDT ready. Number of elements
+playing role in the booting process has increased and now includes the FDT
+blob. Kernel image, FDT blob and possibly ramdisk image - all must be placed
+in the system memory and passed to bootm as a arguments. Some of them may be
+missing: FDT is not present for legacy platforms, ramdisk is always optional.
+Additionally, old uImage format has been extended to support multi sub-images
+but the support is limited by simple format of the legacy uImage structure.
+Single binary header 'struct image_header' is not flexible enough to cover all
+possible scenarios.
+
+All those factors combined clearly show that there is a need for new, more
+flexible, multi component uImage format.
+
+
+2) New uImage format assumptions
+--------------------------------
+
+a) Implementation
+
+Libfdt has been selected for the new uImage format implementation as (1) it
+provides needed functionality, (2) is actively maintained and developed and
+(3) increases code reuse as it is already part of the U-boot source tree.
+
+b) Terminology
+
+This document defines new uImage structure by providing FDT bindings for new
+uImage internals. Bindings are defined from U-boot perspective, i.e. describe
+final form of the uImage at the moment when it reaches U-boot. User
+perspective may be simpler, as some of the properties (like timestamps and
+hashes) will need to be filled in automatically by the U-boot mkimage tool.
+
+To avoid confusion with the kernel FDT the following naming convention is
+proposed for the new uImage format related terms:
+
+FIT - Flattened uImage Tree
+
+FIT is formally a flattened device tree (in the libfdt meaning), which
+conforms to bindings defined in this document.
+
+.its - image tree source
+.itb - image tree blob
+
+c) Image building procedure
+
+The following picture shows how the new uImage is prepared. Input consists of
+image source file (.its) and a set of data files. Image is created with the
+help of standard U-boot mkimage tool which in turn uses dtc (device tree
+compiler) to produce image tree blob (.itb). Resulting .itb file is is the
+actual binary of a new uImage.
+
+
+tqm5200.its
++
+vmlinux.bin.gz mkimage + dtc xfer to target
+eldk-4.2-ramdisk --------------> tqm5200.itb --------------> bootm
+tqm5200.dtb /|\
+... |
+ 'new uImage'
+
+ - create .its file, automatically filled-in properties are omitted
+ - call mkimage tool on a .its file
+ - mkimage calls dtc to create .itb image and assures that
+ missing properties are added
+ - .itb (new uImage) is uploaded onto the target and used therein
+
+
+d) Unique identifiers
+
+To identify FIT sub-nodes representing images, hashes, configurations (which
+are defined in the following sections), the "unit name" of the given sub-node
+is used as it's identifier as it assures uniqueness without additional
+checking required.
+
+
+3) Root node properties
+-----------------------
+
+Root node of the uImage Tree should have the following layout:
+
+/ o image-tree
+ |- description = "image description"
+ |- timestamp = <12399321>
+ |- #address-cells = <1>
+ |
+ o images
+ | |
+ | o img at 1 {...}
+ | o img at 2 {...}
+ | ...
+ |
+ o configurations
+ |- default = "cfg at 1"
+ |
+ o cfg at 1 {...}
+ o cfg at 2 {...}
+ ...
+
+
+ Optional property:
+ - description : Textual description of the uImage
+
+ Mandatory property:
+ - timestamp : Last image modification time being counted in seconds since
+ 1970-01-01 00:00:00 - to be automatically calculated by mkimage tool.
+
+ Conditionally mandatory property:
+ - #address-cells : Number of 32bit cells required to represent entry and
+ load addresses supplied within sub-image nodes. May be omitted when no
+ entry or load addresses are used.
+
+ Mandatory node:
+ - images : This node contains a set of sub-nodes, each of them representing
+ single component sub-image (like kernel, ramdisk, etc.). At least one
+ sub-image is required.
+
+ Optional node:
+ - configurations : Contains a set of available configuration nodes and
+ defines a default configuration.
+
+
+4) '/images' node
+-----------------
+
+This node is a container node for component sub-image nodes. Each sub-node of
+the '/images' node should have the following layout:
+
+ o image at 1
+ |- description = "component sub-image description"
+ |- data = /incbin/("path/to/data/file.bin")
+ |- type = "sub-image type name"
+ |- arch = "ARCH name"
+ |- os = "OS name"
+ |- compression = "compression name"
+ |- load = <00000000>
+ |- entry = <00000000>
+ |
+ o hash at 1 {...}
+ o hash at 2 {...}
+ ...
+
+ Mandatory properties:
+ - description : Textual description of the component sub-image
+ - type : Name of component sub-image type, supported types are:
+ "standalone", "kernel", "ramdisk", "firmware", "script", "filesystem",
+ "fdt".
+ - data : Path to the external file which contains this node's binary data.
+ - compression : Compression used by included data. Supported compressions
+ are "gzip" and "bzip2". If no compression is used compression property
+ should be set to "none".
+
+ Conditionally mandatory property:
+ - os : OS name, mandatory for type="kernel", valid OS names are: "openbsd",
+ "netbsd", "freebsd", "4_4bsd", "linux", "svr4", "esix", "solaris", "irix",
+ "sco", "dell", "ncr", "lynxos", "vxworks", "psos", "qnx", "u_boot",
+ "rtems", "artos", "unity".
+ - arch : Architecture name, mandatory for types: "standalone", "kernel",
+ "firmware", "ramdisk" and "fdt". Valid architecture names are: "alpha",
+ "arm", "i386", "ia64", "mips", "mips64", "ppc", "s390", "sh", "sparc",
+ "sparc64", "m68k", "nios", "microblaze", "nios2", "blackfin", "avr32",
+ "st200".
+ - entry : entry point address, address size is determined by
+ '#address-cells' property of the root node. Mandatory for for types:
+ "standalone" and "kernel".
+ - load : load address, address size is determined by '#address-cells'
+ property of the root node. Mandatory for types: "standalone" and "kernel".
+
+ Optional nodes:
+ - hash at 1 : Each hash sub-node represents separate hash or checksum
+ calculated for node's data according to specified algorithm.
+
+
+5) Hash nodes
+-------------
+
+o hash at 1
+ |- algo = "hash or checksum algorithm name"
+ |- value = [hash or checksum value]
+
+ Mandatory properties:
+ - algo : Algorithm name, supported are "crc32", "md5" and "sha1".
+ - value : Actual checksum or hash value, correspondingly 4, 16 or 20 bytes
+ long.
+
+
+6) '/configurations' node
+-------------------------
+
+The 'configurations' node is optional. If present, it allows to create a
+convenient, labeled boot configurations, which combine together kernel images
+with their ramdisks and fdt blobs.
+
+The 'configurations' node has has the following structure:
+
+o configurations
+ |- default = "default configuration sub-node unit name"
+ |
+ o config at 1 {...}
+ o config at 2 {...}
+ ...
+
+
+ Optional property:
+ - default : Selects one of the configuration sub-nodes as a default
+ configuration.
+
+ Mandatory nodes:
+ - configuration-sub-node-unit-name : At least one of the configuration
+ sub-nodes is required.
+
+
+7) Configuration nodes
+----------------------
+
+Each configuration has the following structure:
+
+o config at 1
+ |- description = "configuration description"
+ |- kernel = "kernel sub-node unit name"
+ |- ramdisk = "ramdisk sub-node unit name"
+ |- fdt = "fdt sub-node unit-name"
+
+
+ Mandatory properties:
+ - description : Textual configuration description.
+ - kernel : Unit name of the corresponding kernel image (image sub-node of a
+ "kernel" type).
+
+ Optional properties:
+ - ramdisk : Unit name of the corresponding ramdisk image (component image
+ node of a "ramdisk" type).
+ - fdt : Unit name of the corresponding fdt blob (component image node of a
+ "fdt type").
+
+The FDT blob is required to properly boot FDT based kernel, so the minimal
+configuration for 2.6 FDT kernel is (kernel, fdt) pair.
+
+Older, 2.4 kernel and 2.6 non-FDT kernel do not use FDT blob, in such cases
+'struct bd_info' must be passed instead of FDT blob, thus fdt property *must
+not* be specified in a configuration node.
+
+
+8) Examples
+-----------
+
+Please see examples/*.its for actual image source files.
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 18/20] [new uImage] Fix build problems on trab board
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
0 siblings, 1 reply; 25+ messages in thread
From: Wolfgang Denk @ 2008-03-12 20:55 UTC (permalink / raw)
To: u-boot
In message <20080312201219.6444.56306.stgit@pollux.denx.de> you wrote:
>
> diff --git a/board/trab/auto_update.c b/board/trab/auto_update.c
> index fa08bff..5311e12 100644
> --- a/board/trab/auto_update.c
> +++ b/board/trab/auto_update.c
> @@ -224,7 +224,7 @@ au_check_cksum_valid(int idx, long nbytes)
> return -1;
> }
> /* check the data CRC */
> - if (!image_check_dcrc (hdr)) {
> + if (!image_check_dcrc (hdr))
> {
This patch looks broken to me. You should keep the brace on the same
line with the if, and rather delete the next line with the single
brace.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Too many people are ready to carry the stool when the piano needs to
be moved.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 02/20] [new uImage] Add support for new uImage format to mkimage tool
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
0 siblings, 1 reply; 25+ messages in thread
From: Luigi 'Comio' Mantellini @ 2008-03-14 14:54 UTC (permalink / raw)
To: u-boot
Hi A,
I'm trying to use the newimage patches but I cannot compile the mkimage
tool because the uint8_t uint16_t, ... types are not defined into the
fdt.h include file (that uses them).
I just patched the fdt.h source adding the following code in the head:
#ifndef __KERNEL__
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
#else
#include <linux/types.h>
#endif
This is just a dirty approach... but it can be useful for who have the
same problem. Anyway, can you correct the include/fdt.h source (or the
tool/mkimage.c) to avoid this issue?
Thanks a lot,
luigi
On mer, 2008-03-12 at 21:10 +0100, Bartlomiej Sieka wrote:
> Support for the new uImage format (FIT) is added to mkimage tool.
> Commandline syntax is appropriately extended:
>
> mkimage [-D dtc_options] -f fit-image.its fit-image
>
> mkimage (together with dtc) takes fit-image.its and referenced therein
> binaries (like vmlinux.bin.gz) as inputs, and produces fit-image file -- the
> final image that can be transferred to the target (e.g., via tftp) and then
> booted using the bootm command in U-Boot.
>
--
______ Luigi Mantellini
.'______'. R&D - Software
(.' '.) Industrie Dial Face S.p.A.
( :=----=: ) Via Canzo, 4
('.______.') 20068 Peschiera Borromeo (MI), Italy
'.______.' Tel.: +39 02 5167 2813
Fax: +39 02 5167 2459
Ind. Dial Face Email: luigi.mantellini at idf-hit.com
www.idf-hit.com GPG fingerprint: 3DD1 7B71 FBDF 6376 1B4A
B003 175F E979 907E 1650
^ permalink raw reply [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 02/20] [new uImage] Add support for new uImage format to mkimage tool
2008-03-14 14:54 ` Luigi 'Comio' Mantellini
@ 2008-03-14 16:19 ` Bartlomiej Sieka
0 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-14 16:19 UTC (permalink / raw)
To: u-boot
Luigi 'Comio' Mantellini wrote:
> Hi A,
Hi Luigi,
>
> I'm trying to use the newimage patches but I cannot compile the mkimage
> tool because the uint8_t uint16_t, ... types are not defined into the
> fdt.h include file (that uses them).
Hmm, I've not seen this. How are you trying to compile mkimage? What
system are you on?
I usually compile mkimage by configuring the build for any board, and
then compiling just the tools directory. Could you try this:
make TQM5200_config
make tools
BTW: "make tools" without prior make *_config says "make: Nothing to be
done for `tools'." -- can somebody offer a suggestions on how to fix this?
Regards,
Bartlomiej
^ permalink raw reply [flat|nested] 25+ messages in thread
* [U-Boot-Users] [PATCH 18/20] [new uImage] Fix build problems on trab board
2008-03-12 20:55 ` Wolfgang Denk
@ 2008-03-19 9:01 ` Bartlomiej Sieka
0 siblings, 0 replies; 25+ messages in thread
From: Bartlomiej Sieka @ 2008-03-19 9:01 UTC (permalink / raw)
To: u-boot
Wolfgang Denk wrote:
> In message <20080312201219.6444.56306.stgit@pollux.denx.de> you wrote:
>> diff --git a/board/trab/auto_update.c b/board/trab/auto_update.c
>> index fa08bff..5311e12 100644
>> --- a/board/trab/auto_update.c
>> +++ b/board/trab/auto_update.c
>> @@ -224,7 +224,7 @@ au_check_cksum_valid(int idx, long nbytes)
>> return -1;
>> }
>> /* check the data CRC */
>> - if (!image_check_dcrc (hdr)) {
>> + if (!image_check_dcrc (hdr))
>> {
>
> This patch looks broken to me. You should keep the brace on the same
> line with the if, and rather delete the next line with the single
> brace.
Will fix.
Regards,
Bartlomiej
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2008-03-19 9:01 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [U-Boot-Users] [PATCH 11/20] [new uImage] Add new uImage format support to autoscript routine Bartlomiej Sieka
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox