Author Topic: $0.11 PY32F002A: Cortex-M0+ MCU, actually a PY32F030! 32/4KB, 48MHz, PLL, DMA...  (Read 30655 times)

0 Members and 3 Guests are viewing this topic.

Online DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5913
  • Country: es
Still, why can't it be erased by the button? Did you modify it?
Anyways, I can't think on a worse example to play with, make a mistake and it'll be gone!
Just play with a led like the rest of the world :-DD
« Last Edit: December 13, 2023, 02:47:18 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Still, why can't it be erased by the button? Did you modify it?
Yupp - The SO16 needed other pins

Anyways, I can't think on a worse example to play with, make a mistake and it'll be gone!
Just play with a led like the rest of the world :-DD
:-DD  :-+ :-+


But  :palm:   - I misred the "Pin1 - dot" on the package , when jumpering the "Button pin"  & leds :palm:
Magic ... Leds blinking - Program running & It's revived from the dead  :-DD  :phew:

I'mo now  11c richer ... And think i'll just play w leds   :popcorn:

/Bingo
« Last Edit: December 13, 2023, 05:14:07 pm by bingo600 »
 

Online DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5913
  • Country: es
You can now tell the wife you'll have food for Christmas! :)
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline eliocor

  • Supporter
  • ****
  • Posts: 519
  • Country: it
    • rhodiatoce
because the PY32F002A micro is the same as a PY32F030, except for the pinout, I have prepared a small document (extracted from the datasheets) which can be of some help when you are planning to use the 002A using all the "enhancements" of the 030.
I hope it can be of some use...
 
The following users thanked this post: Pixie dust

Offline Pixie dust

  • Newbie
  • Posts: 3
  • Country: nl
During a test on a PY32F003 current was fed via the onboard protection diodes into the bulk capacitors placed on the output of a 5V regulator powering a py32F003. As more current was pushed in than drawn by the processor the voltage started to rise to about 8V. I thought this was the end of that microcontroller but to my surprise nothing broke and the processor still runs fine. I thought this is quite remarkable and makes me think that these PYFxxx controllers have quite robust IO pins. 
 

Offline pappkopp

  • Contributor
  • Posts: 25
  • Country: no
For the 8 pin (SOP8) PY32F002AL15S6TU, how would i flash this device? using J-link, USART RX/TX and PA14 ?
This model does not have a boot0 mode, only reset/nrst button?
 

Online DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5913
  • Country: es
Jlink, dap...
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline pappkopp

  • Contributor
  • Posts: 25
  • Country: no
I'm trying to connect to the 8 pin (SOP8) PY32F002AL15S6TU via PuyaISP, but i cant really get it working, how should i enter the bootloader? I have tried pulling pin 6 (PA2/PF2-NRST) both high and low while power-cycling the MCU, but PuyaISP wont connect,

Is pulling NRST high the correct method to enter the bootloader? This package does not have a dedicated BOOT0 pin,

I have the option to try J-Link, does Puya have some tool to upload or read the mcu info via this? I have tried PuyaProgrammer but it can't find the USB device to use for SWD, For the J-link i'm using a nucleo board i have converted to J-link, but i belive Puya has its own programmer but it should be compatible ?
 

Online DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5913
  • Country: es
You already asked ths and were answered:
Jlink, dap...

No bootloader possible without Boot0, you need a programmer or buy a different package which has Boot0.
Read the thread, that matter has already been talked.
« Last Edit: February 29, 2024, 12:01:23 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 56
  • Country: cn
I have the option to try J-Link, does Puya have some tool to upload or read the mcu info via this? I have tried PuyaProgrammer but it can't find the USB device to use for SWD, For the J-link i'm using a nucleo board i have converted to J-link, but i belive Puya has its own programmer but it should be compatible ?
J-Link has its own software, which can be downloaded from https://www.segger.com/downloads/jlink/
 

Offline John Celo

  • Contributor
  • Posts: 20
  • Country: lt
I'm reading this thread and trying to piece together on how to programm the SOP8/SOP16 versions of the PY32F002 (those don't have the boot0 pin available)

I don't have any dedicated programming device at the moment, and up to this point I have only programmed dev-boards that can be flashed via USB port (like arduino nano with it's onboard CH340 usb-to-serial chip and similar)

Which programming device should I get to program SOP8/SOP16 versions of those chips?
I've seen JLink mentioned, and on the first glance those cost 1000 euro or more.

For example, STM32 chips seem to have cheap ST-Link V2 programmers available on ali and else where.
Similarly, WCH CH32V003 chips have cheap WCH-LinkE on ali.

Are there any affordable beginner options to program SOP8/SOP16 versions of these chips?
 

Offline prosper

  • Regular Contributor
  • *
  • Posts: 79
  • Country: ca
you might already have parts on hand to build a daplink.

see https://github.com/IOsetting/py32f0-template/issues/6 for a discussion on probes. most DAP probes work, if only at 3.3V
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Are there any affordable beginner options to program SOP8/SOP16 versions of these chips?

A Jlink-OB or a Dap-Link from Ali will do ....
They're like $5 .. $8

1:
I've used this daplink
https://www.aliexpress.com/item/1005005303809188.html

2:
And this Jlink-OB
https://www.aliexpress.com/item/1005003620592002.html

3:
And this diy daplink
https://www.aliexpress.com/item/1005004635091721.html
https://www.eevblog.com/forum/microcontrollers/$0-11-py32f002a-m0-24mhz-320kb-actually-324kb-more-peripherals/msg5029996/#msg5029996

I'd prob get : One of #1 , and one of #2
 

Offline prosper

  • Regular Contributor
  • *
  • Posts: 79
  • Country: ca
this also works (same AIR32 as previous poster, just a smaller form factor):

https://www.aliexpress.com/item/1005005966658428.html
« Last Edit: March 13, 2024, 08:21:00 pm by prosper »
 

Online DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5913
  • Country: es
Puya has modded OpenOCD adding support por their chips:

https://gitee.com/puya-semiconductor/tools-and-software/blob/master/PY32_GCC/openocd-0.12.0.zip

Example cfg file for this DAP:
Code: [Select]
source [find interface/cmsis-dap.cfg]
source [find target/py32f030.cfg]
cmsis_dap_backend hid
transport select "swd"
set CLOCK_FREQ 1000
reset_config none
set CONNECT_UNDER_RESET 0
set CORE_RESET 0

Unfortunately CubeIDE complains about non genuine device. Haven't looked over it.
« Last Edit: March 13, 2024, 09:58:55 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline prosper

  • Regular Contributor
  • *
  • Posts: 79
  • Country: ca
I saw that. Unfortunately, it's windows-only and doesn't provide the source, so it's not useful for me.


probe-rs does support the py32, though, so that's my go-to OCD
 

Offline John Celo

  • Contributor
  • Posts: 20
  • Country: lt
Thank you for advice!

Sop8 version has following pins:
1. VCC
2. PA4/PA10
3. PA3
4. PA14-SWC/PB3
5. PA13-SWD
6. PA2/PF2-NRST
7. PA1
8. GND

The pins that have to be connected when programming are (5) SWC (6) SWD and (1) VCC (2) GND, correct?

Can SWC/SWD pins be shared and reused for different purposes?

And if the pins can be reused/shared, how does the device know that is being flashed instead of being used as in normal operation?

Is there some sort of special startup sequence?
 

Offline prosper

  • Regular Contributor
  • *
  • Posts: 79
  • Country: ca
I generally reserve SWC and SWD for debugging only, and don't re-assign them. It's easy enough to use a TSSOP-20 or something with more pins if IO is that tight.


If you do want to re-assign them, it'd be wise to implement a boot delay in your code before doing so, so that you have a moment when you can flash it on bootup before the SWD interface becomes unavailable to you. Otherwise, you'd essentially get a one-time-programmable device (which is not necessarily a problem if you're a manufacturer, but is less than ideal for a hobbyist)


Also be aware that in some cases, the 'multiplexing' is just the way the die is bonded - i.e. they just short together the points to the same pin. So you might have trouble if you try to drive PA14 high and PB3 low at the same time. Not sure if this is the case with the py32 or not, you'd need to carefully examine the datasheet (or experiment) and make your own inferences.
 

Online DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5913
  • Country: es
If you reasign swd pins, then you must also connect nRST to enter programming mode, otherwise it'll be impossible.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Online DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5913
  • Country: es
I was able to run puya OpenOCD under CubeIDE.

- Replace bin/dlls in plugins\com.st.stm32cube.ide.mcu.externaltools.openocd.win32_xxx\tools\bin.
- Add script files to plugins\com.st.stm32cube.ide.mcu.debug.openocd_xxx\resources\openocd\st_scripts

But the IDE had other genuine checks I missed out in the previous patch, so it didn't work.

I analyzed com.st.stm32cube.ide.mcu.debug.launch_xxx.jar and found a better aproach to entirely bypasss the checks.
Now it works great either with Jlink or openocd+stlink.

Updated the 1.12.1 patch, also added the patching guide so anyone can do it for any IDE version.
« Last Edit: March 14, 2024, 11:36:54 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline John Celo

  • Contributor
  • Posts: 20
  • Country: lt
It's all very confusing, for example PY32F002BW15S sop16 B version of the chip doesn't even seem to have NRST pin. (or is it a bug in the datasheet?)
How does writing to the flash memory of the device gets started/initiated when connected just to VCC/GND/SWC/SWD pins?

From what I could understand from reading the reference manual is:
1. Once powered on device resets pin functions to their default state
2. Since the SOP14/16 devices don't have a BOOT0 pin, CPU fetches top-of-stack value from 0x0000 00000
and starts executing code from 0x0000 0004 from the main flash memory (20kbytes)
3. Now in code, functions of GPIO pins will be set via Alternate Function Registers called GPIOx_AFRH and GPIOx_AFRL and accessed via peripheral registers (those are memory mapped in linear address space (32bit, 4gb))

For PF2-NRST pin specifically, their function is set through so called "Option bytes"
Option bytes (128bytes, one page of flash memory) are stored in flash memory.

Is that correct?
« Last Edit: March 15, 2024, 08:57:24 am by John Celo »
 

Offline IOsetting

  • Regular Contributor
  • *
  • Posts: 56
  • Country: cn
It's all very confusing, for example PY32F002BW15S sop16 B version of the chip doesn't even seem to have NRST pin. (or is it a bug in the datasheet?)
PIN13 is NRST, multiplexed with PC0, PA7
EN datasheet v0.3 is not the latest, please refer to the pin map in CN datasheet v0.9, page 17


How does writing to the flash memory of the device gets started/initiated when connected just to VCC/GND/SWC/SWD pins?
SWD transfer doesn't need a reset
 

Offline trimarco232

  • Newbie
  • Posts: 6
  • Country: fr
Hi , there is something maybe new at aliexpress : TW32F003  ???https://fr.aliexpress.com/item/1005006207267714.html
it is showed as a CH32V003 equivalent , but it is ARM , so rather a new PY32 ?
some thoughts ?

 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Hi , there is something maybe new at aliexpress : TW32F003  ???https://fr.aliexpress.com/item/1005006207267714.html
it is showed as a CH32V003 equivalent , but it is ARM , so rather a new PY32 ?
some thoughts ?

Don't ....

I think i have 3 of these , but : Absolutely no DOC is to be found ....

/Bingo
 

Offline prosper

  • Regular Contributor
  • *
  • Posts: 79
  • Country: ca
looks like it's a 'tianwen51' product, possibly the same as the mm32f003? https://www.micros.com.pl/mediaserver/UIMM32f003tw_0001.pdf

Some stuff comes up on a web search, like http://www.haohaodada.com/new/Arduino_example.php?href=TW32F003


...can probably say that it's *not* a py32, at least. I'd avoid it until/unless a datasheet and code examples from the vendor (as well as toolchain support) is provided

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf