Skip to main content
Visitor II
August 27, 2022
Solved

Which is Correct; 4-wire SWD without Reset OR 5-Wire SWD with Reset?

  • August 27, 2022
  • 15 replies
  • 13172 views

I see numerous examples of 4-wire SWD without a reset pin connection.

I come from the PIC world where there is always Data, Clock and Reset for a Pgm/Dbg interface.

I bought a Chinese STLink-V2 programmer/debugger and it has a reset pin as well as data, clock, GND and VSS.

Although, the Chinese STLink-V2 comes with a 4-conductor cable for attachment to my target.

Do I need to connect the Reset pin?

Also, anyone know of an Ap-Note that covers the electrical nature of the SWD interface.

Thank You

    This topic has been closed for replies.
    Best answer by eewiz

    Harvey

    I just successfully upgraded my Chinese debugger.

    Here's how I did it.

    Plug in the debugger.

    Start CubeIDE.

    Go to the Debug View.

    Select Run/Debug Configurations.

    Double-Click STM32 C/C++ Application.

    Select Debugger Tab.

    Select AutoStart GDB Local Server.

    Select Debug Probe = ST-LINK (ST-LINK GDB Server).

    Select SWD.

    Select ST-LINK S/N and click Scan button.

    If what looks like hex serial number fails to populate the box then STOP, your debugger is kaput.

    Mine populates with something like "121F14002E15374...."

    Click the DEBUG button which leads the upgrade prompt.

    Click to upgrade which starts the STLinkUpgrade dialog. Mine is v3.4.0.

    Mine had some bogus ST-Link ID like "3030303030303030301".

    If you click Refresh Device List, nothing happens.

    If you click Open in Update Mode, you get a failure message something like "The Debugger is not in DFU Mode".

    Simply unplug the debugger from it's USB port.

    Take a deep breath and plug it back in to the same port.

    Go back to STLinkUpgrade.

    Click Refresh Device List.

    It says that debugger "3030303030303030301" appears to be defective but I found debugger "121F14002E15374...." would you like to use it.

    Say yes.

    Click Open in Update Mode and the Upgrade button will light up.

    Click the Upgrade button.

    Here's the result:

    0693W00000SuGClQAN.jpgYou may wish to resurrect your door stop and see if this works.

    That's all for now

    15 replies

    Graduate II
    August 27, 2022

    >>Do I need to connect the Reset pin?

    If you expect "Connect Under Reset" modes to work, yes.

    If your device might go into standby or sleep modes, turning off the interfaces, yes.

    eewizAuthor
    Visitor II
    August 27, 2022

    Hello Tesla

    I am used to being able to reset the target from the debugger.

    Is this what "Connect Under Reset" mode means?

    I don't understand how the SWD interface could ever work without a reset connection.

    How does the debugger initiate downloading code to the target without being able to reset the target to get its attention?

    Can the SWD interface reset the target without a reset pin connection?

    Very confusing.

    Thank you

    Graduate II
    August 27, 2022

    Well it holds the device in reset whilst it attempts to connect. Bascially so code on the system doesn't interfere with the initial connection.

    The debug accesses mostly memory and registers within the device, so it can basically execute NVIC_SystemReset() type call, or directly change the NVIC registers to cause that to reset the processor. It would also start the watchdog, and ignore it

    I'm not sure why wiring up an extra pin is burdensome.

    On most of the non CM0(+) parts there's a communication channel method using PB3 / TDO / SWO pin

    https://www.silabs.com/documents/public/application-notes/an0062.pdf

    https://developer.arm.com/documentation/ihi0031/a/The-Serial-Wire-Debug-Port--SW-DP-

    https://research.kudelskisecurity.com/2019/05/16/swd-arms-alternative-to-jtag/

    Visitor II
    August 27, 2022

    If the running user code doesn't have stop modes, 3 wire swd is only needed. Reset control otherwise, unless your user code has a sw delay at startup to ensure enough time for the opportunity to enter debug mode without reset.

    SWD protocol is already a pin squeeze of jtag standard bus, and spec is in ARM cortex debug interface documents.

    Vdd sometime is used by debug prove as target voltage monitoring, and/or signal level shifting like in STLinkV3minie.

    Visitor II
    August 28, 2022

    Thank you Tesla.

    I would have been quite frustrated trying to find that type of technical documentation on the ST Micro site.

    This is the information I needed. I can now start a schematic.

    I've been a PIC guy for 20 years but, now I'm moving to ST because I can't get PICs for a cost less than ridiculous.

    Again, thank you.

    Visitor II
    August 28, 2022

    Hello .

    I see you mention a 3-wire SWD interface.

    I assume you mean Ground, Data and Clock with pull ups on the target.

    I've seen no examples that the leave out VCC yet.

    In PIC world the debugger's transmitter requires VCC supplied from the target board.

    You can't leave out the VCC connection.

    I will look at the docs linked by tesla keeping a 3-wire interface in mind.

    Thank You

    Graduate II
    August 28, 2022

    Minimum SWD is 3wire as you write,

    Optimal is 4 wire + RESET

    This two need own power for MCU for debug or prog.

    Next config i 5 wire + VCC , can be used to power MCU from debger.

    Advanced is 6 wire +SWO ... thats all folks

    Graduate II
    August 28, 2022

    GND, SWCLK, SWDIO - mandatory.

    VDD - almost mandatory, because the debugger probes need it.

    NRST - highly recommended. It is necessary for debugging stop/standby/shutdown modes and will allow erasing/flashing the MCU before running the code. If the code messes up the SWD pins or something else, which disables the debugging capability, pulling NRST low and doing "connect under reset" becomes a necessity.

    SWO - optional. It provides an UART-like Tx channel, which can be useful for logging or other purposes.

    Visitor II
    August 28, 2022

    Thank you MM and Piranha.

    My cheap Chinese STLINKv2 does not implement the SWO function.

    This does not hurt much since my target's STM32F030 also does not implement the SWO function.

    I foresee this target having no stop/sleep modes but I will add a reset connection anyway.

    I never did plan to leave out Reset and VCC but I saw so many examples without reset that I had to inquire.

    That's all for now.

    Thank You

    Graduate II
    August 29, 2022

    Little warning for you, cheap chinese dont implement too NRST for STM32.

    RST on pinout is for STM8.

    SWD part 3 – SWO and nRST – Kudelski Security Research

    Graduate II
    August 28, 2022

    Take a note that a code line as simple as GPIOA->MODER=0; will reconfigure the PA13 and PA14 pins and make debugging impossible. If the code does it at the startup, then the debugger will not be able to connect anymore. The only solution left is to "connect under reset". To do it, something has to pull down NRST. That can be done by the debugger, reset button or a screwdriver, wire or something like that. Obviously the first option is the safest, easiest and most reliable one.

    Take a look on the standard Cortex Debug connectors:

    https://developer.arm.com/documentation/ka001776/latest

    https://developer.arm.com/documentation/101453/0100/CoreSight-Technology/Connectors

    And on ST's UM2448 Rev 7, section "8.1.2 STDC14 (STM32 JTAG/SWD and VCP)", which is compatible with 10-pin Cortex Debug.

    And just in case... Read the AN4325.

    Graduate
    August 29, 2022

    I, too, bought a Chinese debugger. It could not be updated with newer drivers. I bought an STLink v2 for my boards, and since I had used the Chinese pinout as a standard for a 1:1 connection (10 pin to 10 pin), I had to design an adaptor for the standard 20 pin (now legacy) connector to the 10 pin I put on my boards. On the next revision, I went to a 7 pin connector, which had all the signals plus a jumpable VCC. I think that the STLinkV2 needed VCC to determine if the processor was there. Not a big deal to add it. If you go to 8 pins you could key the connector.

    I next bought an STLink V3, which needed a base cover (see thingiverse) printed. Since it has the legacy connector, it worked perfectly with another adaptor (leave out the 10 pin, put in the 7). Your choice of connector, of course. I also put in 22 ohm damping resistors in the lines from the processor to the debug connector. Note that the STLINK V3 prefers 0.050 spacing pin connectors rather than 0.010 inch.

    eewizAuthor
    Visitor II
    August 30, 2022

    Harvey

    The Amazon ad does say "Supporting for automatic firmware upgrades."

    So I will have to see if I bought a boat anchor or not.

    As for 22 ohm. I have implemented this programming interface in the PIC world for a couple of decades now. I've learned that the STM32 will not require the two 18K pull downs, their internal on the F030.

    Makes the interface pretty much indestructible to human body model surge.

    Thank You

    eewizAuthor
    Visitor II
    August 29, 2022

    Thank You MM

    I would have been tripped up by the reset thing.

    From what I can determine from the data sheet and the posted info here, I should be able to program/debug my STM32F030C8 target with the Chinese debugger.

    In my application PA13 and PA14 are dedicated to SWD only.

    Also, the datasheet/ref-man for the STM32F030C8 makes no mention of Connect Under Reset being required, unlike the STM32L011D3 cited in the Kudelski article.

    Many thanks to all for this invaluable enlightenment.

    That's all for now.