Committed.

This makes it possible for flash fill to modify part of a sector. Erase can
still be invoked seperately and explicitly.

### Eclipse Workspace Patch 1.0
#P openocd
Index: src/flash/flash.c
===================================================================
--- src/flash/flash.c   (revision 1059)
+++ src/flash/flash.c   (working copy)
@@ -206,7 +206,7 @@
                                                 "erase address range <address> 
<length>");

                register_command(cmd_ctx, flash_cmd, "fillw",
handle_flash_fill_command, COMMAND_EXEC,
-                                                "fill with pattern <address> 
<word_pattern> <count>");
+                                                "fill with pattern (no 
autoerase) <address> <word_pattern> <count>");
                register_command(cmd_ctx, flash_cmd, "fillh",
handle_flash_fill_command, COMMAND_EXEC,
                                                 "fill with pattern <address> 
<halfword_pattern> <count>");
                register_command(cmd_ctx, flash_cmd, "fillb",
handle_flash_fill_command, COMMAND_EXEC,
@@ -516,7 +516,6 @@
        {
                if ((retval = duration_stop_measure(&duration, &duration_text)) 
!= ERROR_OK)
                {
-                       free(duration_text);
                        return retval;
                }
                command_print(cmd_ctx, "erased address 0x%8.8x length %i in %s",
address, length, duration_text);
@@ -582,7 +581,6 @@
                {
                        if ((retval = duration_stop_measure(&duration, 
&duration_text)) != ERROR_OK)
                        {
-                               free(duration_text);
                                return retval;
                        }

@@ -707,7 +705,6 @@

        if ((retvaltemp = duration_stop_measure(&duration, &duration_text))
!= ERROR_OK)
        {
-               free(duration_text);
                image_close(&image);
                return retvaltemp;
        }
@@ -792,33 +789,27 @@

        duration_start_measure(&duration);

-       flash_set_dirty();
-       err = flash_erase_address_range( target, address, count*wordsize );
-       if (err == ERROR_OK)
+       for (wrote=0; wrote<(count*wordsize); wrote+=sizeof(chunk))
        {
-               for (wrote=0; wrote<(count*wordsize); wrote+=sizeof(chunk))
+               int cur_size = MIN( (count*wordsize - wrote) , 1024 );
+               if (err == ERROR_OK)
                {
-                       int cur_size = MIN( (count*wordsize - wrote) , 1024 );
-                       if (err == ERROR_OK)
+                       flash_bank_t *bank;
+                       bank = get_flash_bank_by_addr(target, address);
+                       if(bank == NULL)
                        {
-                               flash_bank_t *bank;
-                               bank = get_flash_bank_by_addr(target, address);
-                               if(bank == NULL)
-                               {
-                                       err = ERROR_FAIL;
-                                       break;
-                               }
-                               err = flash_driver_write(bank, chunk, address - 
bank->base +
wrote, cur_size);
-                               wrote += cur_size;
+                               err = ERROR_FAIL;
+                               break;
                        }
-                       if (err!=ERROR_OK)
-                               break;
+                       err = flash_driver_write(bank, chunk, address - 
bank->base +
wrote, cur_size);
+                       wrote += cur_size;
                }
+               if (err!=ERROR_OK)
+                       break;
        }

        if ((retval = duration_stop_measure(&duration, &duration_text)) != 
ERROR_OK)
        {
-               free(duration_text);
                return retval;
        }

@@ -885,7 +876,6 @@

        if ((retvaltemp = duration_stop_measure(&duration, &duration_text))
!= ERROR_OK)
        {
-               free(duration_text);
                fileio_close(&fileio);
                return retvaltemp;
        }


-- 
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer

Free eCos workshop in Oslo October 21!
http://www.zylin.com/workshop.html
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to