cancel
Showing results for 
Search instead for 
Did you mean: 

SWD Reset doesn't seem to work on ST-link

Eymeric_Chauchat
Associate II

Hello,

I am developping a custom board on stm32l031f6. I got my hand on a ST-link v2 (from what I searched today it seems to be clone dongle...). My application is tight on pin so I use SWclk as a GPIO pin. Before making this pin definition, I could freely  flash from STMCubeIDE. Now that I changed the definition for GPIO pin, when I flash, I kind of brick my MCU (expected).I thought that I would have been able to leverage the use of RST pin to automatically boot again my MCU, but even with trying "connect under reset", didn't do nothing.

Only way, I found is to manually push RESET, go on STMCubeProgrammer and full erase the chip, and after I can go back to STMCubeIDE to flash my chip. It is way too long in my workflow and I think a better solution exist since we only talk about pulling down a RST pin.

My hardware reset setup is as follow :

- NRST pin is tied to a button to ground (manual)

- NRST pin is tied to a header pin that is directly linked to ST-Link V2

- No pull up, pull down, cap...

 

So I have two questions, is my software/hardware setup correct (connect under reset is enough to automatically boot thanks to RST pin), is it normal that my MCU doesn't reset when I try to go on debug with connect under reset, active and Hardware reset on STMCubeProgrammer ? (I would have thought that even if it doesn't flash program at least my code would restart (I have visual clue when I manual reset))

Can my ST-link v2 dongle just broken ?? (It updated without issue, and since it has ST logo, I though it was legit...)

Eymeric_Chauchat_0-1718295206348.png

 

11 REPLIES 11
MM..1
Chief II

Clones dont have NRST signal for STM32. Google for howto add.

When you use GPIO you can only flash sw no debug.

Put a short delay or idle loop in Reset_Handler so that the debugger has a chance to connect, it's not an instantaneous connection. Give it a few hundred thousand machine cycles.

Perhaps look at the states of the SWDIO/SWCLK pins, or a button.

You're trying to delay it's arrival at main() and all the HAL_Init() and MX_FAFO() code that's breaking usability of the debugger pins.

Do you see NRST going low on the board, confirming the ST-LINK is driving it?

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AScha.3
Chief III

Hi,

1. if your  ST-link v2 looks like a USB-stick, its a clone. And has no working reset (for stm32).

2. You cannot define a debug port (swd, swc) as i/o port and expect it will still work with debug connection.

Decide, what you want: debug (st-link) connection or 2 more i/o ports , but no debug possible.

If you just want load your code from IDE, maybe try "connect under reset" setting and press and hold reset , when start "debug" or "run". (Or modify your clone, to have reset signal on "reset " named output. )

Or (as i would do) if you want use this ssop20 case, set debug pins for debug , connect setting "software reset" , and if tested your program and need no more debug, define the debug pins as i/o , as you like.

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Evangelist III

@Eymeric_Chauchat wrote:

I got my hand on a ST-link v2 (from what I searched today it seems to be clone dongle...).


If it looks like this, it's a clone:

AndrewNeil_0-1718299569608.png

Even if it does have an "ST" logo on it:

AndrewNeil_1-1718299640746.png

https://community.st.com/t5/stm32-mcus-products/blue-pill-stm32f1-board-gets-programmed-through-arduino-ide-but/td-p/667923/page/4

 


@Eymeric_Chauchat wrote:

since it has ST logo, I though it was legit...


unfortunately not.

Is it really possible to do this modification ? I found nothing. my RST seem already link to something

Okay maybe for the moment I will do some software adjustment in order to be able to program it... but since I want to deal with sleep state and so on I will need to solve my st link issue...

 

No Nrst is never going low... that's the issue


@AScha.3 wrote:

2. You cannot define a debug port (swd, swc) as i/o port and expect it will still work with debug connection.


I didn't expect this, but I expected that I was still able to flash under connect under reset

Eymeric_Chauchat
Associate II

Okay thanks to your answer, it was very helpful.

I managed to modify the hardware of my clone and use "Connect under reset" to be able to flash again from STMCubeIDE !

However, this project (and every other one that will follow) are aim at educational purpose, and I don't want to spread the use of conterfeit product (and St Link clone seems to be it). Legit St Link seems to be out of stock, but it look like that I could buy a Nucleo board (for example the one for L0 series) and it embed a (kind of) detachable St-link in it.

 

Am I right ? If so for nearly the same price of clone, I could have a test board AND St link :grimacing_face: (shame on Amazon...)

True NUCLEO board are found in Digikey isn't it ?

 

P.S. As a funny side note, I aim at doing cheap project, and my hardware was using PIC at first. Since MicroCHIP didn't answer my mail for student discount on PICkit (~100$ initially) and I am kind of poor student, I swapped my hardware for STM because I knew that their programmer was cheap (didn't know 90% were counterfeit though) but Nucleo board seems cheap enough and come with dev board :flushed_face:

Yes, the NUCLEO and DISCO boards have an integrated ST-LINK, most of the recent ones provide a USB VCP connection to a UART, and drag-n-drop of .BIN files.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..