How to fix STM32 Stuck with error ST-LINK error (DEV_TARGET_NOT_HALTED)

errorst-linkstm32stm32cubeide

I have a custom board with a STM32H7A3ZIT mcu. I'm programming it with a ST-Link V2 via SWD.

I'm trying to get an external hyperbus ram working, and immediately after programming the mcu with some questionable code, it no longer is able to be re-programmed. I get the error ST-LINK error (DEV_TARGET_NOT_HALTED)

Power-cycling the PCB, ST-Link and even the PC does not fix it.

I can tell the MCU is operating because it draws garbage on the LCD on powerup (problem I was working on before).

I believe the circuit is correct, because I've programmed this board dozens of times prior to this without issue.

The programming header on the board is routed to the MCU with no additional circuitry besides a 100nF cap on the NRST line. The BOOT0 pin is connected to gnd with a 1k resistor.

Has anyone else encountered this error and found a way to fix it?

Best Answer

I didn't figure out what caused the problem, but I found a solution.

I used a probe connected to VDD, and forced BOOT0 high. I then powered up the PCB. With boot still tied high I ran the programming sequence, and it succeeded.

Forcing BOOT0 high only during the initial power up did not work.

Forcing NRST low at various points in the programming cycle also did not work. If I held it too long I would get TARGET_HELD_IN_RESET, and any time shorter I would get DEV_TARGET_NOT_HALTED.

Edit: I determined the cause of the hangup. I was working on initializing a hyperram IC. I had switched on memory mapped mode while the ram was still not work properly. This problem can be avoided by simply testing the ram in indirect-mode before entering memory mapped mode.