2024-06-13 09:14 AM
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...)
2024-06-13 09:18 AM - edited 2024-06-13 09:20 AM
Clones dont have NRST signal for STM32. Google for howto add.
When you use GPIO you can only flash sw no debug.
2024-06-13 09:26 AM
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?
2024-06-13 09:48 AM
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.
2024-06-13 10:29 AM
@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:
Even if it does have an "ST" logo on it:
@Eymeric_Chauchat wrote:since it has ST logo, I though it was legit...
unfortunately not.
2024-06-13 06:20 PM
Is it really possible to do this modification ? I found nothing. my RST seem already link to something
2024-06-13 06:23 PM
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
2024-06-13 07:08 PM
@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
2024-06-13 07:14 PM - edited 2024-06-13 07:22 PM
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:
2024-06-13 07:35 PM
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.