diff --git a/src/target/ch32f1.c b/src/target/ch32f1.c index e6bfe64..3fe7e24 100644 --- a/src/target/ch32f1.c +++ b/src/target/ch32f1.c @@ -159,8 +159,10 @@ static int ch32f1_flash_lock(target *t) */ bool ch32f1_probe(target *t) { - const uint32_t idcode = target_mem_read32(t, DBGMCU_IDCODE) & 0xfff; - if ((t->cpuid & CPUID_PARTNO_MASK) != CORTEX_M3 || idcode != 0x410) // only ch32f103 + if ((t->cpuid & CPUID_PARTNO_MASK) != CORTEX_M3) + return false; + const uint32_t idcode = target_mem_read32(t, DBGMCU_IDCODE) & 0x00000fffU; + if (idcode != 0x410) // only ch32f103 return false; // try to flock