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_nand.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'common/cmd_nand.c') diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 8d6c959584..bfa39d7cce 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -514,16 +514,16 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, hdr = (image_header_t *) addr; - if (ntohl(hdr->ih_magic) != IH_MAGIC) { - printf("\n** Bad Magic Number 0x%x **\n", hdr->ih_magic); + 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); - print_image_hdr(hdr); + print_image_hdr (hdr); - cnt = (ntohl(hdr->ih_size) + sizeof (image_header_t)); + cnt = image_get_image_size (hdr); if (jffs2) { nand_read_options_t opts; memset(&opts, 0, sizeof(opts)); @@ -982,14 +982,14 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) hdr = (image_header_t *)addr; - if (ntohl(hdr->ih_magic) == IH_MAGIC) { + if (image_check_magic (hdr)) { print_image_hdr (hdr); - cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t)); + cnt = image_get_image_size (hdr); cnt -= SECTORSIZE; } else { - printf ("\n** Bad Magic Number 0x%x **\n", ntohl(hdr->ih_magic)); + printf ("\n** Bad Magic Number 0x%x **\n", image_get_magic (hdr)); show_boot_progress (-57); return 1; } -- cgit 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_nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/cmd_nand.c') diff --git a/common/cmd_nand.c b/common/cmd_nand.c index bfa39d7cce..7fd6667a7e 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -521,7 +521,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, } show_boot_progress (57); - print_image_hdr (hdr); + image_print_contents (hdr); cnt = image_get_image_size (hdr); if (jffs2) { @@ -984,7 +984,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (image_check_magic (hdr)) { - print_image_hdr (hdr); + image_print_contents (hdr); cnt = image_get_image_size (hdr); cnt -= SECTORSIZE; -- cgit 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_nand.c | 59 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 16 deletions(-) (limited to 'common/cmd_nand.c') diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 7fd6667a7e..b099afeca0 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -512,18 +512,32 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, } show_boot_progress (56); - 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 0x%x **\n", + image_get_magic (hdr)); + show_boot_progress (-57); + return 1; + } + show_boot_progress (57); + + image_print_contents (hdr); - if (!image_check_magic (hdr)) { - printf("\n** Bad Magic Number 0x%x **\n", image_get_magic (hdr)); - show_boot_progress (-57); + cnt = image_get_image_size (hdr); + break; +#if defined(CONFIG_FIT) + case IMAGE_FORMAT_FIT: + fit_unsupported ("nand_load_image"); + return 1; +#endif + default: + puts ("** Unknown image type\n"); return 1; } - show_boot_progress (57); - - image_print_contents (hdr); - cnt = image_get_image_size (hdr); if (jffs2) { nand_read_options_t opts; memset(&opts, 0, sizeof(opts)); @@ -980,17 +994,30 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } show_boot_progress (56); - 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)) { + if (image_check_magic (hdr)) { - image_print_contents (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); + 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; + } + break; +#if defined(CONFIG_FIT) + case IMAGE_FORMAT_FIT: + fit_unsupported ("nboot"); + return 1; +#endif + default: + puts ("** Unknown image type\n"); return 1; } show_boot_progress (57); -- cgit 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_nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/cmd_nand.c') diff --git a/common/cmd_nand.c b/common/cmd_nand.c index b099afeca0..86959dc2c0 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -512,7 +512,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, } show_boot_progress (56); - switch (gen_image_get_format ((void *)addr)) { + switch (genimg_get_format ((void *)addr)) { case IMAGE_FORMAT_LEGACY: hdr = (image_header_t *)addr; @@ -994,7 +994,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } show_boot_progress (56); - switch (gen_image_get_format ((void *)addr)) { + switch (genimg_get_format ((void *)addr)) { case IMAGE_FORMAT_LEGACY: hdr = (image_header_t *)addr; -- cgit 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_nand.c | 65 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 23 deletions(-) (limited to 'common/cmd_nand.c') diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 86959dc2c0..9a168eab2f 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; -- cgit From 1372cce2b9040fb640e5032b84e3a033a22d6ff0 Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Wed, 12 Mar 2008 10:33:01 +0100 Subject: [new uImage] Use show_boot_progress() for new uImage format 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 --- common/cmd_nand.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'common/cmd_nand.c') diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 9a168eab2f..7b1f830465 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); -- cgit