lpc2000: Add LPC407x/8x flash size auto detection
[fw/openocd] / src / flash / nor / mdr.c
index 650abfd62d650e6c313ad4d8a0e5d3e7fa83d270..ed76aab097cb78b0ee45bbfbefd187188eb71b1b 100644 (file)
@@ -223,7 +223,7 @@ static int mdr_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int mdr_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int mdr_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -314,7 +314,7 @@ static int mdr_write_block(struct flash_bank *bank, uint8_t *buffer,
        return retval;
 }
 
-static int mdr_write(struct flash_bank *bank, uint8_t *buffer,
+static int mdr_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -345,7 +345,7 @@ static int mdr_write(struct flash_bank *bank, uint8_t *buffer,
                LOG_INFO("odd number of bytes to write, padding with 0xff");
                buffer = memcpy(new_buffer, buffer, count);
                while (rem--)
-                       buffer[count++] = 0xff;
+                       new_buffer[count++] = 0xff;
        }
 
        uint32_t flash_cmd, cur_per_clock;