This is an automated email from Gerrit.

Spencer Oliver ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/352

-- gerrit

commit 09f45996fce952cf231300285f14ef147f042cda
Author: Spencer Oliver <[email protected]>
Date:   Mon Jan 9 12:42:31 2012 +0000

    flash: use correct device_id mask
    
    The stm32 drivers have been using 0x7ff as the DEV_ID mask, this should
    have been 0xfff.
    
    Change-Id: I232469620969d6dd1b9a2a2aa15ec18b947dbb05
    Signed-off-by: Spencer Oliver <[email protected]>

diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c
index 5d9da90..ab2d274 100644
--- a/src/flash/nor/stm32f1x.c
+++ b/src/flash/nor/stm32f1x.c
@@ -101,6 +101,9 @@
 #define KEY1                   0x45670123
 #define KEY2                   0xCDEF89AB
 
+/* DBGMCU_IDCODE mask bits */
+#define DEV_ID_MASK            0xFFF
+
 struct stm32x_options
 {
        uint16_t RDP;
@@ -977,8 +980,7 @@ static int stm32x_probe(struct flash_bank *bank)
                flash_size_in_kb = 0xffff;
        }
 
-       if ((device_id & 0x7ff) == 0x410)
-       {
+       if ((device_id & DEV_ID_MASK) == 0x410) {
                /* medium density - we have 1k pages
                 * 4 pages for a protection area */
                page_size = 1024;
@@ -991,9 +993,7 @@ static int stm32x_probe(struct flash_bank *bank)
                        LOG_WARNING("STM32 flash size failed, probe inaccurate 
- assuming 128k flash");
                        flash_size_in_kb = 128;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x412)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x412) {
                /* low density - we have 1k pages
                 * 4 pages for a protection area */
                page_size = 1024;
@@ -1006,9 +1006,7 @@ static int stm32x_probe(struct flash_bank *bank)
                        LOG_WARNING("STM32 flash size failed, probe inaccurate 
- assuming 32k flash");
                        flash_size_in_kb = 32;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x414)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x414) {
                /* high density - we have 2k pages
                 * 2 pages for a protection area */
                page_size = 2048;
@@ -1021,9 +1019,7 @@ static int stm32x_probe(struct flash_bank *bank)
                        LOG_WARNING("STM32 flash size failed, probe inaccurate 
- assuming 512k flash");
                        flash_size_in_kb = 512;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x418)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x418) {
                /* connectivity line density - we have 2k pages
                 * 2 pages for a protection area */
                page_size = 2048;
@@ -1036,9 +1032,7 @@ static int stm32x_probe(struct flash_bank *bank)
                        LOG_WARNING("STM32 flash size failed, probe inaccurate 
- assuming 256k flash");
                        flash_size_in_kb = 256;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x420)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x420) {
                /* value line density - we have 1k pages
                 * 4 pages for a protection area */
                page_size = 1024;
@@ -1051,9 +1045,7 @@ static int stm32x_probe(struct flash_bank *bank)
                        LOG_WARNING("STM32 flash size failed, probe inaccurate 
- assuming 128k flash");
                        flash_size_in_kb = 128;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x428)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x428) {
                /* value line High density - we have 2k pages
                 * 4 pages for a protection area */
                page_size = 2048;
@@ -1066,10 +1058,7 @@ static int stm32x_probe(struct flash_bank *bank)
                        LOG_WARNING("STM32 flash size failed, probe inaccurate 
- assuming 128k flash");
                        flash_size_in_kb = 128;
                }
-       }
-
-       else if ((device_id & 0x7ff) == 0x430)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x430) {
                /* xl line density - we have 2k pages
                 * 2 pages for a protection area */
                page_size = 2048;
@@ -1165,8 +1154,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
        if (retval != ERROR_OK)
                return retval;
 
-       if ((device_id & 0x7ff) == 0x410)
-       {
+       if ((device_id & DEV_ID_MASK) == 0x410) {
                printed = snprintf(buf, buf_size, "stm32x (Medium Density) - 
Rev: ");
                buf += printed;
                buf_size -= printed;
@@ -1193,9 +1181,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
                                snprintf(buf, buf_size, "unknown");
                                break;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x412)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x412) {
                printed = snprintf(buf, buf_size, "stm32x (Low Density) - Rev: 
");
                buf += printed;
                buf_size -= printed;
@@ -1210,9 +1196,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
                                snprintf(buf, buf_size, "unknown");
                                break;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x414)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x414) {
                printed = snprintf(buf, buf_size, "stm32x (High Density) - Rev: 
");
                buf += printed;
                buf_size -= printed;
@@ -1231,9 +1215,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
                                snprintf(buf, buf_size, "unknown");
                                break;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x418)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x418) {
                printed = snprintf(buf, buf_size, "stm32x (Connectivity) - Rev: 
");
                buf += printed;
                buf_size -= printed;
@@ -1252,9 +1234,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
                                snprintf(buf, buf_size, "unknown");
                                break;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x420)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x420) {
                printed = snprintf(buf, buf_size, "stm32x (Value) - Rev: ");
                buf += printed;
                buf_size -= printed;
@@ -1273,9 +1253,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
                                snprintf(buf, buf_size, "unknown");
                                break;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x428)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x428) {
                printed = snprintf(buf, buf_size, "stm32x (Value HD) - Rev: ");
                buf += printed;
                buf_size -= printed;
@@ -1294,9 +1272,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
                                snprintf(buf, buf_size, "unknown");
                                break;
                }
-       }
-       else if ((device_id & 0x7ff) == 0x430)
-       {
+       } else if ((device_id & DEV_ID_MASK) == 0x430) {
                printed = snprintf(buf, buf_size, "stm32x (XL) - Rev: ");
                buf += printed;
                buf_size -= printed;
diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c
index 479df8a..3a9438e 100644
--- a/src/flash/nor/stm32f2x.c
+++ b/src/flash/nor/stm32f2x.c
@@ -150,6 +150,9 @@
 #define KEY1                   0x45670123
 #define KEY2                   0xCDEF89AB
 
+/* DBGMCU_IDCODE mask bits */
+#define DEV_ID_MASK            0xFFF
+
 struct stm32x_flash_bank
 {
        struct working_area *write_algorithm;
@@ -595,14 +598,14 @@ static int stm32x_probe(struct flash_bank *bank)
                flash_size_in_kb = 0xffff;
        }
 
-       if ((device_id & 0x7ff) == 0x411) {
+       if ((device_id & DEV_ID_MASK) == 0x411) {
                /* check for early silicon */
                if (flash_size_in_kb == 0xffff) {
                        /* number of sectors may be incorrrect on early silicon 
*/
                        LOG_WARNING("STM32 flash size failed, probe inaccurate 
- assuming 512k flash");
                        flash_size_in_kb = 512;
                }
-       } else if ((device_id & 0x7ff) == 0x413) {
+       } else if ((device_id & DEV_ID_MASK) == 0x413) {
                /* check for early silicon */
                if (flash_size_in_kb == 0xffff) {
                        /* number of sectors may be incorrrect on early silicon 
*/
@@ -671,7 +674,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
        if (retval != ERROR_OK)
                return retval;
 
-       if ((device_id & 0x7ff) == 0x411) {
+       if ((device_id & DEV_ID_MASK) == 0x411) {
                printed = snprintf(buf, buf_size, "stm32f2x - Rev: ");
                buf += printed;
                buf_size -= printed;
@@ -697,7 +700,7 @@ static int get_stm32x_info(struct flash_bank *bank, char 
*buf, int buf_size)
                                snprintf(buf, buf_size, "unknown");
                                break;
                }
-       } else if ((device_id & 0x7ff) == 0x413) {
+       } else if ((device_id & DEV_ID_MASK) == 0x413) {
                printed = snprintf(buf, buf_size, "stm32f4x - Rev: ");
                buf += printed;
                buf_size -= printed;
diff --git a/src/flash/nor/stm32lx.c b/src/flash/nor/stm32lx.c
index 8a6ad7b..faf9a40 100644
--- a/src/flash/nor/stm32lx.c
+++ b/src/flash/nor/stm32lx.c
@@ -111,6 +111,9 @@
 /* RCC_ICSCR bits */
 #define RCC_ICSCR__MSIRANGE_MASK       (7<<13)
 
+/* DBGMCU_IDCODE mask bits */
+#define DEV_ID_MASK            0xFFF
+
 static int stm32lx_unlock_program_memory(struct flash_bank *bank);
 static int stm32lx_lock_program_memory(struct flash_bank *bank);
 static int stm32lx_enable_write_half_page(struct flash_bank *bank);
@@ -508,8 +511,7 @@ static int stm32lx_probe(struct flash_bank *bank)
 
        LOG_DEBUG("device id = 0x%08" PRIx32 "", device_id);
 
-       if ((device_id & 0x7ff) != 0x416)
-       {
+       if ((device_id & DEV_ID_MASK) != 0x416) {
                LOG_WARNING("Cannot identify target as a STM32L family.");
                return ERROR_FAIL;
        }
@@ -707,8 +709,7 @@ static int stm32lx_get_info(struct flash_bank *bank, char 
*buf, int buf_size)
        if (retval != ERROR_OK)
                return retval;
 
-       if ((device_id & 0x7ff) == 0x416)
-       {
+       if ((device_id & DEV_ID_MASK) == 0x416) {
                printed = snprintf(buf, buf_size, "stm32lx - Rev: ");
                buf += printed;
                buf_size -= printed;

-- 

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to