ST-Link cannot software reset the STM32 MCUs over SWD

gdbopenocdst-linkstm32swd

I've been working on a problem with two different boards (one using an STM32F7 and the other using STM32F3). When attempting to program the boards (using an ST-Link provided on Nucleo/Discovery boards) i get various errors revolving around resetting.

Basically, when trying to "run" a program from STM32CubeIDE, with "Software system reset" selected, depending on the debugger I use, I get:

  • for ST-Link GDB:

    STM32_AppReset(), failure reset target.

  • for OpenOCD:

    undefined debug reason 8 – target needs reset
    Info : accepting 'gdb' connection on tcp/3333
    undefined debug reason 8 – target needs reset
    Error: timed out while waiting for target halted
    Error executing event gdb-flash-erase-start on target STM32F373CCTx.cpu:
    TARGET: STM32F373CCTx.cpu – Not halted
    Error: Target not halted
    Error: failed erasing sectors 0 to 10
    Error: flash_erase returned -304

The only way to program the MCUs is to use ST-Link Utility, set it to Hardware Reset (because it won't even connect to the MCU when using Software System Reset), program the MCU and then manually power cycle it. If there is already a program in MCU memory, the ST-Link Utility will fail. The failures are different for the F3 and F7. On F7 it will just say that it cannot reset target, and on F3 the output is:

13:06:09 : Device ID:0x432
13:06:09 : Device flash Size : 256KBytes
13:06:09 : Device family :STM32F37xx
13:06:26 : The elf loader Program function fails.
13:06:28 : The elf loader Program function fails.
13:06:28 : Memory-Loader error
13:06:28 : Error occured during program operation!
13:06:28 : Programming error @ 0x08000188!

I am not sure whether it's a software problem or a hardware one. Regarding my connections, on both boards I'm only using SWDIO, SWCLK and GND. The MCU is getting stable 3.3V on both boards. There is no reset button, on both boards the NRST pin is connected directly to 3.3V. I've tried adding a 100nF capacitor between NRST and GND to make sure there won't be a drop from 3.3V but that didn't change anything.

As input protection there are 100 ohm resistors on SWDIO and SWCLK lines, there were also TVS diodes but I have removed them while trying to find a solution (and it didn't change anything). I've also tried several different ST-Link devices, but it did not have any impact.

I hope I have provided all the necessary details, cause I've been pulling my hair out over it for hours and could not find a solution. I have designed several other boards with the exact same connection scheme (only SWDIO and SWCLK, 100 ohm resistors etc.) and had no problem programming and debugging them. At first I thought that one F7 board was faulty, but the same problem persists on different PCB with a different MCU which suggests that I might be making a bigger mistake.

Thank you very much in advance.

Best Answer

Direct connection of NRST to 3.3V VCC is wrong. Disconnect it.