From c7c5f68a84ed34cf3b5e4a118d11d7108b54b21b Mon Sep 17 00:00:00 2001 From: dragonmux Date: Wed, 22 Jun 2022 16:49:32 -0400 Subject: [PATCH] ch32f1: Re-ordered a couple of the operation in ch32f1_probe so it plays nicer with the STM32 parts --- src/target/ch32f1.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/target/ch32f1.c b/src/target/ch32f1.c index 8feaa403..f79c02e5 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