This is an automated email from Gerrit.

Mathias Küster ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/554

-- gerrit

commit e5b649cc725754ab6c8d9aeecb3efbb0b78be5f4
Author: Mathias K <[email protected]>
Date:   Wed Apr 4 11:36:26 2012 +0200

    STM32L: Validate flash writes
    
    Read-back flash data and make sure it is byte-for-byte the same as the
    source data.
    
    Change-Id: I7ec4b49d87eed6806b11bafe48f9388d422f4c19
    Signed-off-by: Keith Packard <[email protected]>
    Signed-off-by: Mathias K <[email protected]>

diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c
index ca29e1c..de894f4 100644
--- a/src/flash/nor/stm32lx.c
+++ b/src/flash/nor/stm32lx.c
@@ -380,6 +380,12 @@ static int stm32lx_write(struct flash_bank *bank, uint8_t 
*buffer,
        uint32_t bytes_written = 0;
        int retval;
 
+       uint8_t  *start = buffer;
+       uint32_t start_address = address;
+       uint32_t start_count = count;
+       uint8_t  *validate;
+       uint32_t check;
+
        if (bank->target->state != TARGET_HALTED) {
                LOG_ERROR("Target not halted");
                return ERROR_TARGET_NOT_HALTED;
@@ -453,7 +459,26 @@ static int stm32lx_write(struct flash_bank *bank, uint8_t 
*buffer,
        if (retval != ERROR_OK)
                return retval;
 
-       return ERROR_OK;
+       validate = malloc (start_count);
+
+       retval = target_read_buffer(target, start_address, start_count, 
validate);
+       if (retval != ERROR_OK) {
+               free (validate);
+               return retval;
+       }
+
+       for (check = 0; check < start_count; check++) {
+               if (validate[check] != start[check]) {
+                       LOG_ERROR ("flash corrupted at 0x%08x (%02x != %02x)\n",
+                                  start_address + check, start[check], 
validate[check]);
+                       retval = ERROR_FAIL;
+                       break;
+               }
+       }
+
+       free (validate);
+
+       return retval;
 }
 
 static int stm32lx_probe(struct flash_bank *bank)

-- 

------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to