To avoid bloating my HK32F030M thread, I'll be posting the PY32F002A bits here.
Links:
Puya gitee repo: Docs, libs, software...
Puya support pack: English reference manuals, datasheets, application notes... Edit: Puya link gone, added Drive link.
IOSetting's repo containing py32 template and libs.
MCU-Flash-Tools. Python-based ISP bootloader tool for WCH and PY32 mcus, removing the dependency of Puya-ISP.
Tested so far:
- Bootloader. Pulling PB6 (BOOT0) high before power-on (Or resetting afterwards) enters the embedded bootloader, just like in STM32.
Connect RX/TX to PA2/PA3, open Puya ISP, everything works.
Thread showing PuyaISP:
https://www.elektroda.pl/rtvforum/topic3951956.html- STM32 CubeIDE: The patch works, I was able to program & debug using JLink.
CubeIDE Patch adding support for several devices, including PY32.
PY32 folder with docs and CubeIDE PY32F030 sample project. Patch must be applied before attempting to open this project, otherwise CubeIDE will crash.
Jlink doesn't support this chip yet so you must manually add it. Place IOSetting's
PY32 folder following
this instructions:
OS Location
Windows C:\Users\<USER>\AppData\Roaming\SEGGER\JLinkDevices
Linux $HOME/.config/SEGGER/JLinkDevices
macOS $HOME/Library/Application Support/SEGGER/JLinkDevices
Alternatively, you can convert a ST-Link into JLinkEDU, but it will block any attempts to use non-ST devices.
The solution is to edit the XML file and change the vendor to ST (
ChipInfo Vendor="ST" ).
But if the device already exists in Jlink software, then you must change the device name, for example "_py32f002af15p6".
Then set this device name under Jlink configuration.
DO NOT do this for commercial purposes. Most people can't afford $100 programmers to just blink some leds.
So far this chip seems to contain the same die as the PY32F030x6, with the same 4/32KB. PLL, DMA, 2nd UART & SPI...
More info:
https://www.elektroda.com/rtvforum/topic3946116.htmlTested so far:
- 32KB flash
- 4KB RAM
- PLL (48MHz)
- 2xSPI, 2xUSART
- DMA
After setting RDP1, I could no longer program or erase it with J-Link, I had to use PUYA ISP, setting BOOT=1 to enter the serial bootloader and running "Clear chip".
Edit: Fix PCB:
- Missing GND trace for CH340E !!
- CH340E RTS/DTR not working as expected, removed them.
- Fix BOOT0 button, pull pin high instead low.
Basic BOM:
CH340E
PY32F002AF15P6TU
HK32F030MF4P6
SX3M32.000M20F30TNN
TYPE-C-31-M-12
ME6211A33PG-N
1N5819WT
HS91L02W2C01
XL-3216RGBC
CTS-3425J-V-TR
Rest are common parts easily sourced anywhere, 0402 resistors / capacitors, pin headers, 25xx/24xx memories...
The board doesn't need to be fully populated. Actually just the LDO and few caps and you'll have a working board.
You can add the rest of functionalities depending on your needs.
I also extracted the factory bootloader located at 0x1FFF0000, just in case anyone wants to tinker with it in Ghidra/IDA.