ch32f1: Fixed the probe routine distrubing state for other parts wrt t->idcode
The CH32F1 routine now reads the IDCode into a local. If the part number matches and appears to be the chip (based on Flash locking), it only then writes the IDCode into `t->idcode`, which is at the point we can only `return true` from the probe routine anyway.
This commit is contained in:
parent
7e91c401d3
commit
eb8bb01c57
@ -157,9 +157,8 @@ static int ch32f1_flash_lock(target *t)
|
|||||||
*/
|
*/
|
||||||
bool ch32f1_probe(target *t)
|
bool ch32f1_probe(target *t)
|
||||||
{
|
{
|
||||||
t->idcode = target_mem_read32(t, DBGMCU_IDCODE) & 0xfff;
|
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 || t->idcode != 0x410) // only ch32f103
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// try to flock
|
// try to flock
|
||||||
@ -168,6 +167,7 @@ bool ch32f1_probe(target *t)
|
|||||||
if (ch32f1_flash_unlock(t))
|
if (ch32f1_flash_unlock(t))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
t->idcode = idcode;
|
||||||
uint32_t signature = target_mem_read32(t, FLASHSIZE);
|
uint32_t signature = target_mem_read32(t, FLASHSIZE);
|
||||||
uint32_t flashSize = signature & 0xFFFF;
|
uint32_t flashSize = signature & 0xFFFF;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user