Finally, using WCH LINKE as a programmer in ARM mode, in Keil Uvision, I managed to unlock all 6 blocked PY32F002b MCUs. I couldn't do it with the original ST LINK V2 or clone. The secret is to make all connections clearly (GND,VCC,SWD,SWC,NRST) and connect a button between NRST and GND. Then, hold down the button, press LOAD on Keil, and immediately release the button. It's a matter of timing, try several times and don't get discouraged, because it works in case of blockage.
Finally, using WCH LINKE as a programmer in ARM mode, in Keil Uvision, I managed to unlock all 6 blocked PY32F002b MCUs. I couldn't do it with the original ST LINK V2 or clone. The secret is to make all connections clearly (GND,VCC,SWD,SWC,NRST) and connect a button between NRST and GND. Then, hold down the button, press LOAD on Keil, and immediately release the button. It's a matter of timing, try several times and don't get discouraged, because it works in case of blockage.
The WCH-LinkE has an RST output, which is controlled programmatically.
And no need to make buttons on NRST.
Only select the reset mode "pre-reset" or "under-reset".
If this doesn't work in Keil, then using pyOCD it definitely worked.
JLink OB v2 (f072) also has an RST output, for example.
There is a surprising moment for the PY32F002A(F003,F030) models
- programming on 3 wires - SWD,SWC,GND.
And there must be a capacitor between Vcc and Gnd.
Power is obtained through the SWD interface
and pull-up resistors inside the chip.
Since the chip is powered by 1.7V, it works.
In this method, we just get a "reset on power"
For PY32F002B, this method does not work.
Finally, using WCH LINKE as a programmer in ARM mode, in Keil Uvision, I managed to unlock all 6 blocked PY32F002b MCUs. I couldn't do it with the original ST LINK V2 or clone. The secret is to make all connections clearly (GND,VCC,SWD,SWC,NRST) and connect a button between NRST and GND. Then, hold down the button, press LOAD on Keil, and immediately release the button. It's a matter of timing, try several times and don't get discouraged, because it works in case of blockage.
I did also unlock a py32f002bw5 with SWD/SWC turned to GPIO via firmware, with a DAP probe made of a ST-Link V2 clone (the ones that do not work with the STM32CubeProgrammer because of the MCU UUID number) and pyOCD. Plug the probe but don't power the chip (leave Vcc unconnected), just connect GND, SWD, SWC. Run pyOCD mass Erase command. The pyOCD will be waiting for any SWD response... Connect Vcc, and the chip gets erased.
I've been studying the PY32 junior models a bit lately. There are also interesting CW32, N32, HC32 and many other miscellaneous items.
Here are some studies on PY32F002A(F003,F030) and PY32F002B(L020) chips
https://github.com/Xiamatsu/py32f002a_003_030
https://github.com/Xiamatsu/py32f002b
(I apologize that it is not in English.)
I need to add some more recent research data, I haven't updated my github pages for a long time.
I also collect summary data on microcontrollers.
I am conducting Coremark tests on my own for some controllers,
as well as comparing compilers with different settings.
All this is in a table in the cloud.
https://docs.google.com/spreadsheets/d/1Efv9o9Q0RhQnE3t0KpEYy8XxTBr_Hkxc-rqZPL5IJyA/edit?usp=sharing
PY32F0xx microcontrollers are characterized by very low current consumption, even at high frequencies, as well as at startup.
Didn't DavidAlpha once say that you could erase the PY32xx , using Puya's Programmer (Windows exe) , even if you had disabled SWD ?
I have no idea if that goes for the B' versions too though.
I can't remember what "Jtag" HW they required.
But i think DA mostly used a Jlink (clone), when playing w. the PY's
/Bingo
22.3. ID codes and locking mechanism
Here are several ID codes inside the MCU. It is recommended that Keil, IAR and other tools use
this ID Code (located at 0x4001 5800 ) locks debugging.
After the chip is powered on, the hardware reads the 0x1FFF 0FF8 address of the flash 's factory
config. byte and loads it into the DBG _IDCODE register.