From b97a2a0a21f279d66de8a9bdbfe21920968bcb1c Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Tue, 8 Jan 2008 18:14:09 +0100 Subject: [new uImage] Define a API for image handling operations - Add inline helper macros for basic header processing - Move common non inline code common/image.c - Replace direct header access with the API routines - Rename IH_CPU_* to IH_ARCH_* Signed-off-by: Marian Balakowicz --- common/cmd_usb.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'common/cmd_usb.c') diff --git a/common/cmd_usb.c b/common/cmd_usb.c index c6b17c2..db2e754 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -311,7 +311,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) char *boot_device = NULL; char *ep; int dev, part=1, rcode; - ulong addr, cnt, checksum; + ulong addr, cnt; disk_partition_t info; image_header_t *hdr; block_dev_desc_t *stor_dev; @@ -388,23 +388,19 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) hdr = (image_header_t *)addr; - if (ntohl(hdr->ih_magic) != IH_MAGIC) { + if (!image_get_magic (hdr)) { printf("\n** Bad Magic Number **\n"); return 1; } - checksum = ntohl(hdr->ih_hcrc); - hdr->ih_hcrc = 0; - - if (crc32 (0, (uchar *)hdr, sizeof(image_header_t)) != checksum) { + if (!image_check_hcrc (hdr)) { puts ("\n** Bad Header Checksum **\n"); return 1; } - hdr->ih_hcrc = htonl(checksum); /* restore checksum for later use */ print_image_hdr (hdr); - cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t)); + cnt = image_get_image_size (hdr); cnt += info.blksz - 1; cnt /= info.blksz; cnt -= 1; -- cgit v1.1 From 2242f5369822bc7780db95c47985bb408ea9157b Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Thu, 21 Feb 2008 17:27:41 +0100 Subject: [new uImage] Rename and move print_image_hdr() routine Signed-off-by: Marian Balakowicz --- common/cmd_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/cmd_usb.c') diff --git a/common/cmd_usb.c b/common/cmd_usb.c index db2e754..2d7a85a 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -398,7 +398,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } - print_image_hdr (hdr); + image_print_contents (hdr); cnt = image_get_image_size (hdr); cnt += info.blksz - 1; -- cgit v1.1 From 5583cbf736474ef754e128a54fb78632f57b48fd Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Thu, 21 Feb 2008 17:27:49 +0100 Subject: [new uImage] Fix erroneous use of image_get_magic() in fdc/usb cmds Signed-off-by: Marian Balakowicz --- common/cmd_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/cmd_usb.c') diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 2d7a85a..3f1aa7d 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -388,7 +388,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) hdr = (image_header_t *)addr; - if (!image_get_magic (hdr)) { + if (!image_check_magic (hdr)) { printf("\n** Bad Magic Number **\n"); return 1; } -- cgit v1.1 From d5934ad7756f038a393a9cfab76a4fe306d9d930 Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Mon, 4 Feb 2008 08:28:09 +0100 Subject: [new uImage] Add dual format uImage support framework This patch adds framework for dual format images. Format detection is added and the bootm controll flow is updated to include cases for new FIT format uImages. When the legacy (image_header based) format is detected appropriate legacy specific handling is invoked. For the new (FIT based) format uImages dual boot framework has a minial support, that will only print out a corresponding debug messages. Implementation of the FIT specific handling will be added in following patches. Signed-off-by: Marian Balakowicz --- common/cmd_usb.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'common/cmd_usb.c') diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 3f1aa7d..ad3873c 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -386,21 +386,34 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } - hdr = (image_header_t *)addr; + switch (gen_image_get_format ((void *)addr)) { + 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_magic (hdr)) { + printf("\n** Bad Magic Number **\n"); + return 1; + } + + if (!image_check_hcrc (hdr)) { + puts ("\n** Bad Header Checksum **\n"); + return 1; + } - if (!image_check_hcrc (hdr)) { - puts ("\n** Bad Header Checksum **\n"); + image_print_contents (hdr); + + cnt = image_get_image_size (hdr); + break; +#if defined(CONFIG_FIT) + case IMAGE_FORMAT_FIT: + fit_unsupported ("usbboot"); + return 1; +#endif + default: + puts ("** Unknown image type\n"); return 1; } - image_print_contents (hdr); - - cnt = image_get_image_size (hdr); cnt += info.blksz - 1; cnt /= info.blksz; cnt -= 1; -- cgit v1.1 From 9a4daad0a35eb5143037eea9f786a3e9d672bdd6 Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Fri, 29 Feb 2008 14:58:34 +0100 Subject: [new uImage] Update naming convention for bootm/uImage related code This patch introduces the following prefix convention for the image format handling and bootm related code: genimg_ - dual format shared code image_ - legacy uImage format specific code fit_ - new uImage format specific code boot_ - booting process related code Related routines are renamed and a few pieces of code are moved around and re-grouped. Signed-off-by: Marian Balakowicz --- common/cmd_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/cmd_usb.c') diff --git a/common/cmd_usb.c b/common/cmd_usb.c index ad3873c..8ee7d27 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -386,7 +386,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } - switch (gen_image_get_format ((void *)addr)) { + switch (genimg_get_format ((void *)addr)) { case IMAGE_FORMAT_LEGACY: hdr = (image_header_t *)addr; -- cgit v1.1 From 09475f7527460e426c0e0628fc5b8f3754fbaa23 Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Wed, 12 Mar 2008 10:33:01 +0100 Subject: [new uImage] Add new uImage format handling to other bootm related commands 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 --- common/cmd_usb.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'common/cmd_usb.c') 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; -- cgit v1.1