Skip to main content
Associate II
April 3, 2026
Solved

Can't program/connect to STM32U031K4U6 over SWD

  • April 3, 2026
  • 4 replies
  • 377 views

Hi all, I have reached the point of desperation, and I am all out of ideas how to get my STM32U031 project working.

I designed a very simple PCB which has only a few components. I have attached the KiCad files in case it is helpful. I followed guidelines for decoupling capacitors and broke out the SWDIO and SWCLK pins. 

The issue I have is this: I can not program/connect to the chip over SWD. 

When I power the PCB from 3V, the first noticeable problem is GPIO PA3 goes high. You can notice that because that pin is connected to the gate of a mosfet which is used to switch some LEDs, so when it goes high, the LEDs turn on. It is especially strange because I put an external pulldown resistor on the pin, so the fresh unprogrammed MCU is driving it high for some reason. I also connected my ST Link to the PCB, but when I try to connect with any speed or reset settings, I see this error:

02:27:47 : UR connection mode is defined with the SWrst reset mode
02:27:47 : ST-LINK SN : 003B00243333511831363730
02:27:47 : ST-LINK FW : V3J16M7
02:27:47 : Board : STLINK-V3MINIE
02:27:47 : Voltage : 2.96V
02:27:47 : Error: Unable to get core ID
02:27:47 : Error: ST-LINK error (DEV_TARGET_CMD_ERR)

I initially thought the issue was a damaged MCU during soldering, so I ordered a new MCU and soldered it using low temperature paste to a new PCB with just the MCU and decoupling caps to eliminate the possibility of other things on the circuit causing issues. As far as I can tell the second assembled circuit has the exact same problems.

I also tried soldering a wire to the reset pin to allow me to manually reset the chip and add an external pull up resistor (even though the IC has a built in pullup on NRST), but that didn't make any difference either.

To further try to diagnose the issue, I have soldered another new chip to a DIP breakout PCB I had lying around. I soldered decoupling caps the best I could, but it is still not ideal how far away they are from the chip. I still think it should be a good way to test things though.

Sadly, even with the chip on a breakout I have the same problems! I can not program it, and some GPIO are at weird voltage levels. PA3 is high like my previous attempts. Some other pins are also weird like PB1 is at 2V for some reason, PA5 is at 1.3V, the list goes on. Also, I will mention that I have seen the chip draw between 1mA and 4mA from a 3V supply of my Nordic PPK 2. One time it drew 1mA and some time later after debugging things it randomly is seems to draw 4mA, so not sure what is causing the change.

The strange voltages make me feel like the chips are damaged, but I seriously doubt three chips in a row have been damaged. They were ordered form the ST E Store, kept in sealed ESD bags, and assembled with low temp paste.

I also thought perhaps I got the orientation wrong, but as far as I can tell I have it right. On my PCB and on my breakout board. I do find it weird that in CubeMX, the ST logo and MPN on the chip are in a different orientation than on the actual chip. However I have double checked the pin I marking on the underside of the MCU and it matches the pin 1 marking dot on the top of the MCU.

I am out of ideas now, so if anyone can suggest something, please do!
I have uploaded photos of things I think could be useful.

Thank you in advance!

 

Screenshot From 2026-04-03 02-41-12.png

IMG_20260403_023607.jpg

IMG_20260403_023614.jpg

IMG_20260403_023347.jpg

IMG_20260403_023403.jpg

IMG_20260403_025049.jpg

Screenshot From 2026-04-03 02-44-43.png

Screenshot From 2026-04-03 02-45-19.png

Best answer by EricNava

Since I could get the MCU on the dip breakout connecting, but not the one on the PCB, I decided to solder a new PCB with the known good chip from the DIP breakout. I also reduced the wire length from the PCB to the programmer, and now I can connect!

I do not need to have the NRST pin connected to the programmer for a successful connection. I also do not need the 100nF cap between NRST and ground, however I will add that in the next revision to be safe.

It seems to me the issue was caused by too long cable lengths from the ST link to the MCU and potentially a damaged chip on the PCB. Either way I am glad it is working, thank you for all the help everyone!

4 replies

TDK
Super User
April 3, 2026

You have pictures of two, as far as I can tell, unrelated setups. One is a heart shaped board and one is rectangular board on a breadboard. Which one are you trying to debug here?

I see, the heart shaped board is the target and the other one is the breakout to further help and debug.

The issue is likely wiring, or chip orientation, or soldering.

"If you feel a post has answered your question, please click ""Accept as Solution""."
EricNavaAuthor
Associate II
April 3, 2026

Yes that is correct, the heart is the target but I am also trying a breakout board to eliminate the possibility of mistakes in the PCB.

A soldering problem seems very unlikely to me. I used a stencil with a hot air station and low temperature 130° paste so they were definitely not over heated I also kept them in their dry anti static packaging until assembly. The solder joints look very good overall and can not find any shorts between pins.

As for chip orientation, I have verified orientation with the pin 1 marking on the top of the package and also by checking the pin 1 marking (chamfered part of exposed pad) on the underside of the chip. Unless the die inside is somehow oriented differently to how the package suggests, I have the orientation correct.

 

I have checked the schematic and breadboard wiring many times, it looks correct to me. Only thing I can think of is I will check the stlink signals on my scope when I try to connect to verify it is doing something.

 

AScha.3
Super User
April 3, 2026

I suppose it goes to bootloader...

you have PF3 open, that would possibly start the bootloader; connect PF3 to gnd and try connect again.

And maybe a 100nF cap on PF2 to gnd , to have longer reset at start.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Andrew Neil
Super User
April 3, 2026
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
EricNavaAuthorBest answer
Associate II
April 3, 2026

Since I could get the MCU on the dip breakout connecting, but not the one on the PCB, I decided to solder a new PCB with the known good chip from the DIP breakout. I also reduced the wire length from the PCB to the programmer, and now I can connect!

I do not need to have the NRST pin connected to the programmer for a successful connection. I also do not need the 100nF cap between NRST and ground, however I will add that in the next revision to be safe.

It seems to me the issue was caused by too long cable lengths from the ST link to the MCU and potentially a damaged chip on the PCB. Either way I am glad it is working, thank you for all the help everyone!

Andrew Neil
Super User
April 4, 2026

@EricNava wrote:

I do not need to have the NRST pin connected to the programmer 


But I strongly recommend that you do have that connection!

It can get you out of a few other "can't connect" situations ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Super User
April 4, 2026

If the bootloader starts you can still connect with STM32CubeProgrammer. Doesn't matter what state BOOT0 is at here.

Caps on NRST are also irrelevant here.

Had to be a wiring issue.

 

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