stm32: determine all cpu types and use common examine
[fw/openocd] / src / target / cortex_m.c
index 5ab120f272b13e0565462584e4894295bf3fe5cc..76e197c116d904fe8c2fb046138b818363986f12 100644 (file)
@@ -1756,7 +1756,7 @@ fail1:
         */
 }
 
-static int cortex_m3_examine(struct target *target)
+int cortex_m3_examine(struct target *target)
 {
        int retval;
        uint32_t cpuid, fpcr;
@@ -1776,9 +1776,11 @@ static int cortex_m3_examine(struct target *target)
                if (retval != ERROR_OK)
                        return retval;
 
-               if (((cpuid >> 4) & 0xc3f) == 0xc23)
-                       LOG_DEBUG("Cortex-M3 r%" PRId8 "p%" PRId8 " processor detected",
-                               (uint8_t)((cpuid >> 20) & 0xf), (uint8_t)((cpuid >> 0) & 0xf));
+               /* Get CPU Type */
+               i = (cpuid >> 4) & 0xf;
+
+               LOG_DEBUG("Cortex-M%d r%" PRId8 "p%" PRId8 " processor detected",
+                               i, (uint8_t)((cpuid >> 20) & 0xf), (uint8_t)((cpuid >> 0) & 0xf));
                LOG_DEBUG("cpuid: 0x%8.8" PRIx32 "", cpuid);
 
                /* NOTE: FPB and DWT are both optional. */