- Flash auto-erase is disabled by default
[openocd.git] / src / flash / flash.c
index 9607725834692a6702e8ef7eebd6f0b3cba8cc2a..0be0afc57c538a1eb6dc6a338e539b830c15fd8a 100644 (file)
@@ -88,6 +88,8 @@ flash_driver_t *flash_drivers[] =
 
 flash_bank_t *flash_banks;
 static         command_t *flash_cmd;
+
+/* flash auto-erase is disabled by default*/
 static int auto_erase = 0;
 
 /* wafer thin wrapper for invoking the flash driver */
@@ -618,13 +620,12 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm
        if (argc < 1)
        {
                return ERROR_COMMAND_SYNTAX_ERROR;
-
        }
 
        if (!target)
        {
                LOG_ERROR("no target selected");
-               return ERROR_OK;
+               return ERROR_FAIL;
        }
 
        duration_start_measure(&duration);
@@ -649,7 +650,6 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm
        }
 
        retval = flash_write(target, &image, &written, auto_erase);
-
        if (retval != ERROR_OK)
        {
                image_close(&image);
@@ -659,9 +659,9 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm
        duration_stop_measure(&duration, &duration_text);
        if (retval == ERROR_OK)
        {
-       command_print(cmd_ctx, "wrote %u byte from file %s in %s (%f kb/s)",
-               written, args[0], duration_text,
-               (float)written / 1024.0 / ((float)duration.duration.tv_sec + ((float)duration.duration.tv_usec / 1000000.0)));
+               command_print(cmd_ctx, "wrote %u byte from file %s in %s (%f kb/s)",
+                               written, args[0], duration_text,
+                               (float)written / 1024.0 / ((float)duration.duration.tv_sec + ((float)duration.duration.tv_usec / 1000000.0)));
        }
        free(duration_text);
 
@@ -886,7 +886,10 @@ int flash_erase_address_range(target_t *target, u32 addr, u32 length)
                return ERROR_FLASH_DST_OUT_OF_BANK; /* no corresponding bank found */
 
        if (c->size == 0 || c->num_sectors == 0)
+       {
+               LOG_ERROR("Bank is invalid");
                return ERROR_FLASH_BANK_INVALID;
+       }
 
        if (length == 0)
        {
@@ -923,7 +926,7 @@ int flash_erase_address_range(target_t *target, u32 addr, u32 length)
 /* write (optional verify) an image to flash memory of the given target */
 int flash_write(target_t *target, image_t *image, u32 *written, int erase)
 {
-       int retval;
+       int retval=ERROR_OK;
 
        int section;
        u32 section_offset;
@@ -1039,14 +1042,14 @@ int flash_write(target_t *target, image_t *image, u32 *written, int erase)
 
                if (retval != ERROR_OK)
                {
-                               return retval; /* abort operation */
-                       }
+                       return retval; /* abort operation */
+               }
 
                if (written != NULL)
                        *written += run_size; /* add run size to total written counter */
        }
 
-       return ERROR_OK;
+       return retval;
 }
 
 int handle_flash_auto_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)