All of these errors are various kinds of fatal memory overwrite
conditions and so should be handled by panic().  This fixes a bug in
which the error message might not get all the way out to the serial
console before the system reboots; panic() has a built-in delay after
doing a printf() before calling do_reset().

This will result in a change in behavior for the 27 board configuration
files which set CONFIG_PANIC_HANG (less than 5% of the total).  They
will now hang in those fatal error conditions instead of trying to
reboot.

Given that CONFIG_PANIC_HANG is intended to prevent the system from
rebooting after it has encountered an unrecoverable error, this seems to
be the desired behavior for those 27 board configurations.

Signed-off-by: Kyle Moffett <kyle.d.moff...@boeing.com>
Cc: Wolfgang Denk <w...@denx.de>
Cc: Mike Frysinger <vap...@gentoo.org>
Cc: Andy Fleming <aflem...@gmail.com>
Cc: Kumar Gala <kumar.g...@freescale.com>
---

This patch has been test-booted on my board and is checkpatch-clean.

---
 common/cmd_bootm.c |   43 +++++++++++++------------------------------
 1 files changed, 13 insertions(+), 30 deletions(-)

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index c2e8038..dea9093 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -300,7 +300,6 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[]
        return 0;
 }
 
-#define BOOTM_ERR_RESET                -1
 #define BOOTM_ERR_OVERLAP      -2
 #define BOOTM_ERR_UNIMPLEMENTED        -3
 static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
@@ -335,11 +334,9 @@ static int bootm_load_os(image_info_t os, ulong *load_end, 
int boot_progress)
                printf ("   Uncompressing %s ... ", type_name);
                if (gunzip ((void *)load, unc_len,
                                        (uchar *)image_start, &image_len) != 0) 
{
-                       puts ("GUNZIP: uncompress, out-of-mem or overwrite 
error "
-                               "- must RESET board to recover\n");
                        if (boot_progress)
-                               show_boot_progress (-6);
-                       return BOOTM_ERR_RESET;
+                               show_boot_progress(-6);
+                       panic("GUNZIP: uncompress or overwrite error");
                }
 
                *load_end = load + image_len;
@@ -357,11 +354,9 @@ static int bootm_load_os(image_info_t os, ulong *load_end, 
int boot_progress)
                                        &unc_len, (char *)image_start, 
image_len,
                                        CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 
0);
                if (i != BZ_OK) {
-                       printf ("BUNZIP2: uncompress or overwrite error %d "
-                               "- must RESET board to recover\n", i);
                        if (boot_progress)
-                               show_boot_progress (-6);
-                       return BOOTM_ERR_RESET;
+                               show_boot_progress(-6);
+                       panic("BUNZIP2: uncompress or overwrite error");
                }
 
                *load_end = load + unc_len;
@@ -377,10 +372,9 @@ static int bootm_load_os(image_info_t os, ulong *load_end, 
int boot_progress)
                        (unsigned char *)image_start, image_len);
                unc_len = lzma_len;
                if (ret != SZ_OK) {
-                       printf ("LZMA: uncompress or overwrite error %d "
-                               "- must RESET board to recover\n", ret);
-                       show_boot_progress (-6);
-                       return BOOTM_ERR_RESET;
+                       if (boot_progress)
+                               show_boot_progress(-6);
+                       panic("LZMA: uncompress or overwrite error");
                }
                *load_end = load + unc_len;
                break;
@@ -394,11 +388,9 @@ static int bootm_load_os(image_info_t os, ulong *load_end, 
int boot_progress)
                                          image_len, (unsigned char *)load,
                                          &unc_len);
                if (ret != LZO_E_OK) {
-                       printf ("LZO: uncompress or overwrite error %d "
-                             "- must RESET board to recover\n", ret);
                        if (boot_progress)
-                               show_boot_progress (-6);
-                       return BOOTM_ERR_RESET;
+                               show_boot_progress(-6);
+                       panic("LZO: uncompress or overwrite error");
                }
 
                *load_end = load + unc_len;
@@ -624,18 +616,14 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
        ret = bootm_load_os(images.os, &load_end, 1);
 
        if (ret < 0) {
-               if (ret == BOOTM_ERR_RESET)
-                       do_reset (cmdtp, flag, argc, argv);
                if (ret == BOOTM_ERR_OVERLAP) {
                        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(-113);
+                               panic("ERROR: new format image overwritten");
                        }
                }
                if (ret == BOOTM_ERR_UNIMPLEMENTED) {
@@ -678,13 +666,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
 
        boot_fn(0, argc, argv, &images);
 
-       show_boot_progress (-9);
-#ifdef DEBUG
-       puts ("\n## Control returned to monitor - resetting...\n");
-#endif
-       do_reset (cmdtp, flag, argc, argv);
-
-       return 1;
+       show_boot_progress(-9);
+       panic("Control returned to monitor!");
 }
 
 int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
-- 
1.7.2.5

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to