cortexm / pyswd

Python SWD Debugging library for ST-Link/V2
MIT License
61 stars 21 forks source link

IDCODE confusing #20

Open schneidersoft opened 2 years ago

schneidersoft commented 2 years ago

CortexM(sdw.Swd()).get_idcode() gets the Stlinks IDCODE(or some other value from it) rather than the target IDCODE. To get the target IDCODE you must use: sdw.Swd().get_mem32(0xE0042000)

Consider changing the function name?

example get_idcode() = 2BA01477 (corresponding to Cortex ®-M4 with FPU r0p1) STM32F446xx example swd.get_mem32(0xE0042000) = 10006430 (F103 XL REV.A)

makkarpov commented 1 year ago

These are two different IDCODEs, both are from target.

get_idcode returns debug port IDCODE, which is not present anywhere in the memory. On STM32F103 the value is 0x1BA01477, with most significant nibble being the revision (so you have 2 there).

image

schneidersoft commented 1 year ago

Thanks! That clears it up! I was scratching my head for ages on this one.