]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Restore the ability to continue booting after legacy image overwrite
authorMarian Balakowicz <m8@semihalf.com>
Fri, 11 Apr 2008 09:07:49 +0000 (11:07 +0200)
committerWolfgang Denk <wd@denx.de>
Fri, 18 Apr 2008 06:59:05 +0000 (23:59 -0700)
Before new uImage code was merged, bootm code allowed for the kernel image to
get overwritten during decompresion. new uImage introduced a check for image
overwrites and refused to boot the image that got overwritten. This patch
restores the old behavior. It also adds a warning when the image overwriten is
a multi-image file, because in such case accessing componentes other than the
first one will fail.

Signed-off-by: Marian Balakowicz <m8@semihalf.com>
12 files changed:
common/cmd_bootm.c
common/image.c
include/image.h
lib_arm/bootm.c
lib_avr32/bootm.c
lib_blackfin/bootm.c
lib_m68k/bootm.c
lib_microblaze/bootm.c
lib_mips/bootm.c
lib_nios2/bootm.c
lib_ppc/bootm.c
lib_sh/bootm.c

index 9e5ce4b38fc96228a942e968c020679e15c53aeb..3a0c83d2d805c8ce1fb8edbfa09881f3a0539ef9 100644 (file)
@@ -286,9 +286,16 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                debug ("image_start = 0x%lX, image_end = 0x%lx\n", image_start, image_end);
                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);
+               if (images.legacy_hdr_valid) {
+                       if (image_get_type (&images.legacy_hdr_os_copy) == IH_TYPE_MULTI)
+                               puts ("WARNING: legacy format multi component "
+                                       "image overwritten\n");
+               } else {
+                       puts ("ERROR: new format image overwritten - "
+                               "must RESET the board to recover\n");
+                       show_boot_progress (-113);
+                       do_reset (cmdtp, flag, argc, argv);
+               }
        }
 
        show_boot_progress (8);
@@ -533,9 +540,17 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
                        show_boot_progress (-5);
                        return NULL;
                }
+
+               /*
+                * copy image header to allow for image overwrites during kernel
+                * decompression.
+                */
+               memmove (&images->legacy_hdr_os_copy, hdr, sizeof(image_header_t));
+
+               /* save pointer to image header */
                images->legacy_hdr_os = hdr;
-               images->legacy_hdr_valid = 1;
 
+               images->legacy_hdr_valid = 1;
                show_boot_progress (6);
                break;
 #if defined(CONFIG_FIT)
@@ -890,7 +905,7 @@ static void do_bootm_netbsd (cmd_tbl_t *cmdtp, int flag,
         * address of the original image header.
         */
        os_hdr = NULL;
-       if (image_check_type (hdr, IH_TYPE_MULTI)) {
+       if (image_check_type (&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
                image_multi_getimg (hdr, 1, &kernel_data, &kernel_len);
                if (kernel_len)
                        os_hdr = hdr;
@@ -947,7 +962,7 @@ static void do_bootm_lynxkdi (cmd_tbl_t *cmdtp, int flag,
                             int argc, char *argv[],
                             bootm_headers_t *images)
 {
-       image_header_t *hdr = images->legacy_hdr_os;
+       image_header_t *hdr = &images->legacy_hdr_os_copy;
 
 #if defined(CONFIG_FIT)
        if (!images->legacy_hdr_valid) {
@@ -964,7 +979,7 @@ static void do_bootm_rtems (cmd_tbl_t *cmdtp, int flag,
                           int argc, char *argv[],
                           bootm_headers_t *images)
 {
-       image_header_t *hdr = images->legacy_hdr_os;
+       image_header_t *hdr = &images->legacy_hdr_os_copy;
        void (*entry_point)(bd_t *);
 
 #if defined(CONFIG_FIT)
@@ -994,10 +1009,10 @@ static void do_bootm_vxworks (cmd_tbl_t *cmdtp, int flag,
                             bootm_headers_t *images)
 {
        char str[80];
-       image_header_t *hdr = images->legacy_hdr_os;
+       image_header_t *hdr = &images->legacy_hdr_os_copy;
 
 #if defined(CONFIG_FIT)
-       if (hdr == NULL) {
+       if (!images->legacy_hdr_valid) {
                fit_unsupported_reset ("VxWorks");
                do_reset (cmdtp, flag, argc, argv);
        }
@@ -1014,7 +1029,7 @@ static void do_bootm_qnxelf(cmd_tbl_t *cmdtp, int flag,
 {
        char *local_args[2];
        char str[16];
-       image_header_t *hdr = images->legacy_hdr_os;
+       image_header_t *hdr = &images->legacy_hdr_os_copy;
 
 #if defined(CONFIG_FIT)
        if (!images->legacy_hdr_valid) {
@@ -1041,7 +1056,7 @@ static void do_bootm_artos (cmd_tbl_t *cmdtp, int flag,
        int i, j, nxt, len, envno, envsz;
        bd_t *kbd;
        void (*entry)(bd_t *bd, char *cmdline, char **fwenv, ulong top);
-       image_header_t *hdr = images->legacy_hdr_os;
+       image_header_t *hdr = &images->legacy_hdr_os_copy;
 
 #if defined(CONFIG_FIT)
        if (!images->legacy_hdr_valid) {
index 9e63432007b88384c618f1d351489e69f2700439..d218f2f88ba77397fd69b24e8e6f17cd9dde1954 100644 (file)
@@ -983,7 +983,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
 #endif /* CONFIG_B2 || CONFIG_EVB4510 || CONFIG_ARMADILLO */
 
        } else if (images->legacy_hdr_valid &&
-                       image_check_type (images->legacy_hdr_os, IH_TYPE_MULTI)) {
+                       image_check_type (&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
                /*
                 * Now check if we have a legacy mult-component image,
                 * get second entry data start address and len.
index c1a6cbb481e05eac54c2205a9948aa8119a544af..60fdb2bea36a930122b7cb690cc42a9fbfb5b16d 100644 (file)
@@ -197,7 +197,8 @@ typedef struct bootm_headers {
         * then boot_get_ramdisk() and get_fdt() will attempt to get
         * data from second and third component accordingly.
         */
-       image_header_t  *legacy_hdr_os;
+       image_header_t  *legacy_hdr_os;         /* image header pointer */
+       image_header_t  legacy_hdr_os_copy;     /* header copy */
        ulong           legacy_hdr_valid;
 
 #if defined(CONFIG_FIT)
index c5e8cb3eb6625b821ce6b0b7a633fc68d5a0f9c7..6b4a80723ff4bfce0ab331b9d52e08a64a032622 100644 (file)
@@ -78,7 +78,7 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                ret = fit_image_get_entry (images->fit_hdr_os,
index b1c651ab2cdd15ab22e147032d2fb0c484071aba..5ff8c79e9b550c4d6297cdcb9c83116b1d46e5e1 100644 (file)
@@ -185,7 +185,7 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                ret = fit_image_get_entry (images->fit_hdr_os,
index bea11ed6dd36f997aa55bffb0c38d2258e79e693..ef4b1127fcf51811939522a96eac41fea89e4ddd 100644 (file)
@@ -49,7 +49,7 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                int ret = fit_image_get_entry (images->fit_hdr_os,
index 6f49c31616f478d2d811aaf641edb35cf1e2ddde..61f1a3648a9f8b40075c9c7b6f9eb57397c5bf7a 100644 (file)
@@ -96,7 +96,7 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                ret = fit_image_get_entry (images->fit_hdr_os,
index fab4a54418c35c0ccccfbb86b52b18fb5ded532c..30a03ef35908b2c31000d9c4eeb9dd7166947aa7 100644 (file)
@@ -44,7 +44,7 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                int ret = fit_image_get_entry (images->fit_hdr_os,
index e4c139efab1914616a69ec84c47ce1a876de8976..f813fc583100a9a15a3e1dc6fe1cea21a8d8ef2d 100644 (file)
@@ -57,7 +57,7 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                ret = fit_image_get_entry (images->fit_hdr_os,
index 0c89e963582087535b9c15c09c27fff8ea26fdf0..01f4e87cb43f94db8bd89a7b9cff778cde3c78ba 100644 (file)
@@ -34,7 +34,7 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                int ret = fit_image_get_entry (images->fit_hdr_os,
index b24a0640c775d4f29d534688e7b71bb0e63d24cf..0328baddcaa3610bb260b73eda4437474994a7d2 100644 (file)
@@ -146,7 +146,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                ret = fit_image_get_entry (images->fit_hdr_os,
@@ -639,7 +639,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
                printf ("   Booting using the fdt blob at 0x%x\n", fdt_blob);
 
        } else if (images->legacy_hdr_valid &&
-                       image_check_type (images->legacy_hdr_os, IH_TYPE_MULTI)) {
+                       image_check_type (&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
 
                ulong fdt_data, fdt_len;
 
index 3d5c3bbc959cd15231a67a450157c97d3207eab2..dd32a3ed845cfa4cbe459ee38af32b314ba5c344 100644 (file)
@@ -67,7 +67,7 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
        /* find kernel entry point */
        if (images->legacy_hdr_valid) {
-               ep = image_get_ep (images->legacy_hdr_os);
+               ep = image_get_ep (&images->legacy_hdr_os_copy);
 #if defined(CONFIG_FIT)
        } else if (images->fit_uname_os) {
                int ret = fit_image_get_entry (images->fit_hdr_os,