]> git.sur5r.net Git - openocd/commitdiff
flash: fix bug in error propagation of flash write_image
authorØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 14 Jun 2010 10:08:46 +0000 (12:08 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Mon, 14 Jun 2010 10:27:58 +0000 (12:27 +0200)
when a write/unlock/erase failed during write_image, then
an error was not propagated back up so e.g. flash write
image from tcl scripts would not throw an exception.

Also flash filling speed was printed even when the
operation failed. Output is now less confusing.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/flash/nor/cfi.c
src/flash/nor/core.c
src/flash/nor/tcl.c

index 714cbe451e711b5f63a480da3ff8b851ebf933e3..c1343175c27dee8f676c9b04ce41864dd7012ba3 100644 (file)
@@ -2383,8 +2383,6 @@ static int cfi_probe(struct flash_bank *bank)
         */
        if (cfi_info->not_cfi == 0)
        {
-               int retval;
-
                /* enter CFI query mode
                 * according to JEDEC Standard No. 68.01,
                 * a single bus sequence with address = 0x55, data = 0x98 should put
@@ -2716,7 +2714,7 @@ static int cfi_protect_check(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int cfi_info(struct flash_bank *bank, char *buf, int buf_size)
+static int get_cfi_info(struct flash_bank *bank, char *buf, int buf_size)
 {
        int printed;
        struct cfi_flash_bank *cfi_info = bank->driver_priv;
@@ -2806,5 +2804,5 @@ struct flash_driver cfi_flash = {
        /* FIXME: access flash at bus_width size */
        .erase_check = default_flash_blank_check,
        .protect_check = cfi_protect_check,
-       .info = cfi_info,
+       .info = get_cfi_info,
 };
index d2f2754d67ce714b94605f8211b7b50bd491cbb9..84408e6a62d6da33bd1fd66de302c585ebfe8d7a 100644 (file)
@@ -599,7 +599,6 @@ int flash_write_unlock(struct target *target, struct image *image,
                }
 
                /* find the corresponding flash bank */
-               int retval;
                retval = get_flash_bank_by_addr(target, run_address, false, &c);
                if (retval != ERROR_OK)
                        return retval;
index 3d67327fd3ca771145354eecd6b5530831891c8f..28a504e701bfaf42f0b2fa4b74fc96f2075c8b66 100644 (file)
@@ -576,7 +576,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
                }
        }
 
-       if (duration_measure(&bench) == ERROR_OK)
+       if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK))
        {
                command_print(CMD_CTX, "wrote %" PRIu32 " bytes to 0x%8.8" PRIx32
                                " in %fs (%0.3f KiB/s)", wrote, address,