Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reprogramming PY32F002A #30

Open
ajaybhargav opened this issue Sep 9, 2023 · 8 comments
Open

reprogramming PY32F002A #30

ajaybhargav opened this issue Sep 9, 2023 · 8 comments

Comments

@ajaybhargav
Copy link

Hi, I have successfully build and flashed PY32F002AL15S, using puyocd and ST-LINK V2. However I am unable to get the IC detected again on SWD. I believe since pins are used inside the firmware (which is already flashed), How can I enable SWD again on this chip? as per reference manual, POR should enable those pins, but pyocd does not detect. I do not have any idea how to reprogram this chip.

@IOsetting
Copy link
Owner

Sorry I made a mistake. It is different part. You need to use Puya's ISP Tool download link
Please refer to this discussion https://www.eevblog.com/forum/microcontrollers/$0-11-py32f002a-m0-24mhz-320kb-actually-324kb-more-peripherals/

@ajaybhargav
Copy link
Author

There is no boot0 pin on this chip, its an 8 pin IC. I made NRST as GPIO. there is no way to invoke bootloader or enter into flash mode. I think I bricked it 😝 I will try ISP though but as per Puya PY32F002AL15S does not have ISP feature.

@IOsetting
Copy link
Owner

It seems only TSSOP-20 package has BOOT0 pin. I did some searching but didn't find any solution. I usually add one second delay before the pin remapping so the chip can still be programmed via SWD after reset.

@ajaybhargav
Copy link
Author

I did not realize I would run into such problem, I was just testing this chip. I am going to keep NRST as is without mapping it as full GPIO, I believe it can be used as GPIO (PF2) (as per manual) after 20 clock cycles have passed.

I usually add one second delay before the pin remapping so the chip can still be programmed via SWD after reset.

Option byte is a different story, its like transforming your pin to a different function permanently. so software delay has no effect. PF2 is changed to PA2 permanently.

@NoNamedCat
Copy link

Did you read this forum?
https://www.elektroda.com/rtvforum/topic3946116-30.html

"I accidently messed around with A13. Is there any way to 'unbrick'/erase a device before the firmware is loaded? Couldn't find anything in the documentation.

A manual reset quickly following by a erase does not help..
Thanks!

Thank you for your quick reply, I fixed it.

I should have mentioned this, it was the QFN (PY32F002AW15U6TR) giving me problems it has no BOOT0 pin. BOOT0 did help to erase the TSSOP20. Solution for the QFN is to do hardware RESET when powered on.

All very obvious. I made stupid mistake though, I had two projects with the same name but both with different MCU's. I had the wrong processor selected, ouch!"

@NoNamedCat
Copy link

If you have a button connected to the NRST pin, try to hold it at the same time that you power the board. That is what I understand from that forum.

@ajaybhargav
Copy link
Author

I already tried everything, I shorted NRST with GND, it doesnt work. Since I have written the option bytes to change NRST(PF2) to PA2.

PA13 is just SWD pin, if your NRST is intact you can keep CPU in reset by shorting it to GND. if you have Boot0 pin you can put CPU in bootloader. but this 8-bit part has only NRST and that too is now a GPIO, so unless I had some software logic implemented to revert back A2 to F2-NRST, which I did not thought of, since as per reference manual, I thought NRST will only switch once CPU is passes the POR state.

image

So yes, there is a possibility of bricking (only 8-pin) Puya.

However, as per Puya FAE; the only way to bring it back is using an offline programmer, looks like the NRST before 20uS filter can only be triggered using and an offline programmer.

@deividAlfa
Copy link
Contributor

deividAlfa commented Sep 12, 2023

Well, you know now! Consider yourself lucky, you only lost 10 cents LOL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants