This is an automated email from Gerrit.

Paul Fertser (fercer...@gmail.com) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/2491

-- gerrit

commit 6758d298c87f066d53fedf02d37d0424d370608d
Author: Paul Fertser <fercer...@gmail.com>
Date:   Fri Jan 23 12:40:58 2015 +0300

    flash/nor/stm32l: unify waiting for busy flag functions
    
    Change-Id: I5e6daff8232bb4807dd13a1951fbf335529661d4
    Signed-off-by: Paul Fertser <fercer...@gmail.com>

diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c
index bacf4a0..d8898be 100644
--- a/src/flash/nor/stm32lx.c
+++ b/src/flash/nor/stm32lx.c
@@ -104,7 +104,7 @@ static int stm32lx_enable_write_half_page(struct flash_bank 
*bank);
 static int stm32lx_erase_sector(struct flash_bank *bank, int sector);
 static int stm32lx_wait_until_bsy_clear(struct flash_bank *bank);
 static int stm32lx_mass_erase(struct flash_bank *bank);
-static int stm32lx_wait_status_busy(struct flash_bank *bank, int timeout);
+static int stm32lx_wait_until_bsy_clear_timeout(struct flash_bank *bank, int 
timeout);
 
 struct stm32lx_rev {
        uint16_t rev;
@@ -1105,38 +1105,7 @@ static inline int stm32lx_get_flash_status(struct 
flash_bank *bank, uint32_t *st
 
 static int stm32lx_wait_until_bsy_clear(struct flash_bank *bank)
 {
-       struct target *target = bank->target;
-       struct stm32lx_flash_bank *stm32lx_info = bank->driver_priv;
-       uint32_t status;
-       int retval = ERROR_OK;
-       int timeout = 100;
-
-       /* wait for busy to clear */
-       for (;;) {
-               retval = target_read_u32(target, stm32lx_info->flash_base + 
FLASH_SR, &status);
-               if (retval != ERROR_OK)
-                       return retval;
-
-               if ((status & FLASH_SR__BSY) == 0)
-                       break;
-               if (timeout-- <= 0) {
-                       LOG_ERROR("timed out waiting for flash");
-                       return ERROR_FAIL;
-               }
-               alive_sleep(1);
-       }
-
-       if (status & FLASH_SR__WRPERR) {
-               LOG_ERROR("access denied / write protected");
-               retval = ERROR_FAIL;
-       }
-
-       if (status & FLASH_SR__PGAERR) {
-               LOG_ERROR("invalid program address");
-               retval = ERROR_FAIL;
-       }
-
-       return retval;
+       return stm32lx_wait_until_bsy_clear_timeout(bank, 100);
 }
 
 static int stm32lx_unlock_options_bytes(struct flash_bank *bank)
@@ -1182,17 +1151,15 @@ static int stm32lx_unlock_options_bytes(struct 
flash_bank *bank)
        return ERROR_OK;
 }
 
-static int stm32lx_wait_status_busy(struct flash_bank *bank, int timeout)
+static int stm32lx_wait_until_bsy_clear_timeout(struct flash_bank *bank, int 
timeout)
 {
        struct target *target = bank->target;
+       struct stm32lx_flash_bank *stm32lx_info = bank->driver_priv;
        uint32_t status;
-
        int retval = ERROR_OK;
-       struct stm32lx_flash_bank *stm32lx_info = bank->driver_priv;
 
        /* wait for busy to clear */
        for (;;) {
-
                retval = stm32lx_get_flash_status(bank, &status);
                if (retval != ERROR_OK)
                        return retval;
@@ -1209,7 +1176,12 @@ static int stm32lx_wait_status_busy(struct flash_bank 
*bank, int timeout)
        }
 
        if (status & FLASH_SR__WRPERR) {
-               LOG_ERROR("stm32lx device protected");
+               LOG_ERROR("access denied / write protected");
+               retval = ERROR_FAIL;
+       }
+
+       if (status & FLASH_SR__PGAERR) {
+               LOG_ERROR("invalid program address");
                retval = ERROR_FAIL;
        }
 
@@ -1246,7 +1218,7 @@ static int stm32lx_mass_erase(struct flash_bank *bank)
        if (retval != ERROR_OK)
                return retval;
 
-       retval = stm32lx_wait_status_busy(bank, 30000);
+       retval = stm32lx_wait_until_bsy_clear_timeout(bank, 30000);
        if (retval != ERROR_OK)
                return retval;
 
@@ -1255,7 +1227,7 @@ static int stm32lx_mass_erase(struct flash_bank *bank)
        if (retval != ERROR_OK)
                return retval;
 
-       retval = stm32lx_wait_status_busy(bank, 30000);
+       retval = stm32lx_wait_until_bsy_clear_timeout(bank, 30000);
        if (retval != ERROR_OK)
                return retval;
 

-- 

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to