This is an automated email from Gerrit.

Szymon Modzelewski (szmodzelew...@gmail.com) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/479

-- gerrit

commit 8a3bfb66e22a81d03d6cc6483cf41994c2a8f143
Author: Szymon Modzelewski <szmodzelew...@gmail.com>
Date:   Thu Feb 23 06:09:28 2012 +0100

    flash: don't write to FLASH_CR in stm32x_write_block
    
    It's unnecessary and prevents reusing this function to fix
    option byte writes
    
    Change-Id: Ib5a7b768a1523e6b8da1555126fef4c1e60ab083
    Signed-off-by: Szymon Modzelewski <szmodzelew...@gmail.com>

diff --git a/contrib/loaders/flash/stm32f1x.S b/contrib/loaders/flash/stm32f1x.S
index e83d8c1..6b6aa09 100644
--- a/contrib/loaders/flash/stm32f1x.S
+++ b/contrib/loaders/flash/stm32f1x.S
@@ -37,7 +37,6 @@
         * r7 - tmp
         */
 
-#define STM32_FLASH_CR_OFFSET 0x10 /* offset of CR register from flash reg 
base */
 #define STM32_FLASH_SR_OFFSET 0x0c /* offset of SR register from flash reg 
base */
 
 wait_fifo:
@@ -47,8 +46,6 @@ wait_fifo:
        ldr     r5, [r2, #4]    /* read rp */
        cmp     r5, r6                  /* wait until rp != wp */
        beq     wait_fifo
-       movs    r6, #1                  /* set PG flag to enable flash 
programming */
-       str     r6, [r0, #STM32_FLASH_CR_OFFSET]
        ldrh    r6, [r5]        /* "*target_address++ = *rp++" */
        strh    r6, [r4]
        adds    r5, #2
diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c
index 8ec8d27..ceefcb3 100644
--- a/src/flash/nor/stm32f1x.c
+++ b/src/flash/nor/stm32f1x.c
@@ -604,17 +604,14 @@ static int stm32x_write_block(struct flash_bank *bank, 
uint8_t *buffer,
        /* see contrib/loaders/flash/stm32f1x.S for src */
 
        static const uint8_t stm32x_flash_write_code[] = {
-               /* #define STM32_FLASH_CR_OFFSET 0x10 */
                /* #define STM32_FLASH_SR_OFFSET 0x0C */
                /* wait_fifo: */
                        0x16, 0x68,   /* ldr   r6, [r2, #0] */
                        0x00, 0x2e,   /* cmp   r6, #0 */
-                       0x1a, 0xd0,   /* beq   exit */
+                       0x18, 0xd0,   /* beq   exit */
                        0x55, 0x68,   /* ldr   r5, [r2, #4] */
                        0xb5, 0x42,   /* cmp   r5, r6 */
                        0xf9, 0xd0,   /* beq   wait_fifo */
-                       0x01, 0x26,   /* movs  r6, #1 */
-                       0x06, 0x61,   /* str   r6, [r0, #STM32_FLASH_CR_OFFSET] 
*/
                        0x2e, 0x88,   /* ldrh  r6, [r5, #0] */
                        0x26, 0x80,   /* strh  r6, [r4, #0] */
                        0x02, 0x35,   /* adds  r5, #2 */
@@ -636,7 +633,7 @@ static int stm32x_write_block(struct flash_bank *bank, 
uint8_t *buffer,
                        0x01, 0x39,   /* subs  r1, r1, #1 */
                        0x00, 0x29,   /* cmp   r1, #0 */
                        0x02, 0xd0,   /* beq   exit */
-                       0xe3, 0xe7,   /* b     wait_fifo */
+                       0xe5, 0xe7,   /* b     wait_fifo */
                /* error: */
                        0x00, 0x20,   /* movs  r0, #0 */
                        0x50, 0x60,   /* str   r0, [r2, #4] */
@@ -846,6 +843,10 @@ static int stm32x_write(struct flash_bank *bank, uint8_t 
*buffer,
        if (retval != ERROR_OK)
                return retval;
 
+       retval = target_write_u32(target, stm32x_get_flash_reg(bank, 
STM32_FLASH_CR), FLASH_PG);
+       if (retval != ERROR_OK)
+               return retval;
+
        /* multiple half words (2-byte) to be programmed? */
        if (words_remaining > 0) {
                /* try using a block write */
@@ -870,9 +871,6 @@ static int stm32x_write(struct flash_bank *bank, uint8_t 
*buffer,
                uint16_t value;
                memcpy(&value, buffer + bytes_written, sizeof(uint16_t));
 
-               retval = target_write_u32(target, stm32x_get_flash_reg(bank, 
STM32_FLASH_CR), FLASH_PG);
-               if (retval != ERROR_OK)
-                       return retval;
                retval = target_write_u16(target, address, value);
                if (retval != ERROR_OK)
                        return retval;
@@ -890,9 +888,6 @@ static int stm32x_write(struct flash_bank *bank, uint8_t 
*buffer,
                uint16_t value = 0xffff;
                memcpy(&value, buffer + bytes_written, bytes_remaining);
 
-               retval = target_write_u32(target, stm32x_get_flash_reg(bank, 
STM32_FLASH_CR), FLASH_PG);
-               if (retval != ERROR_OK)
-                       return retval;
                retval = target_write_u16(target, address, value);
                if (retval != ERROR_OK)
                        return retval;

-- 

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to