- add missing files from previous commit (tms470 flash driver)
[openocd.git] / src / flash / flash.c
index efd16c34c9bb0d4c35a8dbbc56b993ddacc35cee..2e7cc4537e2f7e41421bbe6b8536d71d22ef5217 100644 (file)
@@ -63,6 +63,7 @@ extern flash_driver_t str9x_flash;
 extern flash_driver_t stellaris_flash;
 extern flash_driver_t str9xpec_flash;
 extern flash_driver_t stm32x_flash;
+extern flash_driver_t tms470_flash;
 
 flash_driver_t *flash_drivers[] =
 {
@@ -74,6 +75,7 @@ flash_driver_t *flash_drivers[] =
        &stellaris_flash,
        &str9xpec_flash,
        &stm32x_flash,
+       &tms470_flash,
        NULL,
 };
 
@@ -90,7 +92,7 @@ int flash_register_commands(struct command_context_s *cmd_ctx)
        return ERROR_OK;
 }
 
-int flash_init(struct command_context_s *cmd_ctx)
+int flash_init_drivers(struct command_context_s *cmd_ctx)
 {
        if (flash_banks)
        {
@@ -393,9 +395,12 @@ int handle_flash_erase_address_command(struct command_context_s *cmd_ctx, char *
                return ERROR_INVALID_ARGUMENTS;
        }
        
+       /* We can't know if we did a resume + halt, in which case we no longer know the erased state */
+       flash_set_dirty();
+       
        duration_start_measure(&duration);
        
-       if ((retval = flash_erase(target, address, length)) != ERROR_OK)
+       if ((retval = flash_erase_address_range(target, address, length)) != ERROR_OK)
        {
                switch (retval)
                {
@@ -766,6 +771,21 @@ int handle_flash_write_binary_command(struct command_context_s *cmd_ctx, char *c
        return ERROR_OK;
 }
 
+void flash_set_dirty(void)
+{
+       flash_bank_t *c;
+       int i;
+       
+       /* set all flash to require erasing */
+       for (c = flash_banks; c; c = c->next)
+       {
+               for (i = 0; i < c->num_sectors; i++)
+               {
+                       c->sectors[i].is_erased = 0; 
+               }
+       }
+}
+
 /* lookup flash bank by address */
 flash_bank_t *get_flash_bank_by_addr(target_t *target, u32 addr)
 {
@@ -783,7 +803,7 @@ flash_bank_t *get_flash_bank_by_addr(target_t *target, u32 addr)
 }
 
 /* erase given flash region, selects proper bank according to target and address */
-int flash_erase(target_t *target, u32 addr, u32 length)
+int flash_erase_address_range(target_t *target, u32 addr, u32 length)
 {
        flash_bank_t *c;
        int first = -1;
@@ -852,14 +872,8 @@ int flash_write(target_t *target, image_t *image, u32 *written, char **error_str
        {
                /* assume all sectors need erasing - stops any problems
                 * when flash_write is called multiple times */
-                
-               for (c = flash_banks; c; c = c->next)
-               {
-                       for (i = 0; i < c->num_sectors; i++)
-                       {
-                               c->sectors[i].is_erased = 0; 
-                       }
-               }
+               
+               flash_set_dirty();
        }
        
        /* loop until we reach end of the image */
@@ -965,7 +979,7 @@ int flash_write(target_t *target, image_t *image, u32 *written, char **error_str
                if (erase)
                {
                        /* calculate and erase sectors */
-                       retval = flash_erase( target, run_address, run_size );
+                       retval = flash_erase_address_range( target, run_address, run_size );
                }
                
                if (retval == ERROR_OK)

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)