Skip to main content
JJRR
Associate III
January 9, 2024
Solved

STLink V3 Error

  • January 9, 2024
  • 6 replies
  • 3591 views
Hello, I use the original StLink V3 set, along with STM32CubeProgrammer via cmd. Sometimes I encounter an error where ST-Link jumps into Error: ST-LINK error (DEV_USB_COMM_ERR).I don't know how to resolve it. The only solution that works for me is to disconnect and reconnect the ST link to USB. However, this is problematic if I want it to function reliably in production. Is there any solution?
 
All output:
b' -------------------------------------------------------------------\\r\\n STM32CubeProgrammer v2.13.0 \\r\\n -------------------------------------------------------------------\\r\\n\\r\\n===== DFU Interface =====\\r\\n\\r\\nNo STM32 device in DFU mode connected\\r\\n\\r\\n===== STLink Interface =====\\r\\nST-LINK error (DEV_USB_COMM_ERR)\\r\\n\\r\\n-------- Connected ST-LINK Probes List --------\\r\\n\\r\\nST-Link Probe 0 :\\r\\n ST-LINK SN : \\xf0X\\xe5\\x02\\r\\n ST-LINK FW : \\r\\n Access Port Number : 7471203\\r\\n Board Name : \\r\\n-----------------------------------------------\\r\\n\\r\\n===== UART Interface =====\\r\\n\\r\\nTotal number of serial ports available: 2\\r\\n\\r\\nPort: COM4\\r\\nLocation: \\\\\\\\.\\\\COM4\\r\\nDescription: STMicroelectronics STLink Virtual COM Port\\r\\nManufacturer: STMicroelectronics\\r\\n\\r\\nPort: COM11\\r\\nLocation: \\\\\\\\.\\\\COM11\\r\\nDescription: USB-SERIAL CH340\\r\\nManufacturer: wch.cn\\r\\n\\r\\n
This topic has been closed for replies.
Best answer by JJRR

Solution: use Jlink instead of unreliable ST-Link. It solved this problem

6 replies

Peter BENSCH
Technical Moderator
January 9, 2024

In the meantime, there is already a much newer version of the STM32CubeProgr, which you should definitely install to possibly solve your problem. However, I would like to draw your attention to the Terms of Use for ST-LINK/V3SET, which do not permit use in production:

The Evaluation Board shall not be, in any case, directly or indirectly assembled as a part in any production of Yours as it is solely developed to serve evaluation an d testing purposes and has no direct function and is not a finished product. [...]
You shall not use, in whole or in part, the Evaluation Board in a production system.

Hope that helps anyway?

Regards
/Peter

JJRR
JJRRAuthor
Associate III
January 9, 2024

Hi,

But what else would you recommend for me to use as an alternative to STLink? I know I might use Segger, but I need to use a debugging tool, no components like Asix and such can be utilized in my case.

Thank you.

AScha.3
Super User
January 9, 2024

Hi,

Your problem might be hardware related, i had similar problems with st-link V3 .

It catches some glitch or spike over ground connection and gets error, need reconnect.

Try: from [ (mains)plug ->PC -> USB -> st-link -> target <- supply <- (mains)plug  ]

using same mains outlet (+ground) and keep cables for USB to target and mains(+gnd) to target close together,

to keep induced spikes at low level.

Since i did it this way, no more sporadic errors on st-link communication. Try it.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Uwe Bonnes
Chief
January 9, 2024

When debug does not work, tripple check wiring, keep wires short and provide sufficient short ground connection. hertz:~> tin -g netnews
Reading config file...

Uwe Bonnes
Chief
January 9, 2024

Consider also bad USB cables, hubs or connectors.

JR2963
Senior II
January 11, 2024

Thank you for all help, but problem remains. There is maybe problem in my code.
The problem almost never occurs when Erasing or Flashing MCU, but sometimes when I write or read from RAM mem. 
Code In Python for writeU32:

 

def writeU32ToMem(self,addr,u32,verify = True):
 with self.swdLock:
 tm = 0.2
 prcs = [self.cubeProgPath+'/STM32_Programmer_CLI.exe',
 '-c',
 'port=SWD',
 'mode=hotplug',
 'freq='+SWD_FREQ,
 #'speed=Reliable',
 '-w32',
 hex(addr),
 hex(u32)
 ]
 if verify == True:
 prcs.append('-v')

 try:
 out = str(subprocess.check_output(prcs, stderr=subprocess.STDOUT, timeout=tm,creationflags=subprocess.CREATE_NO_WINDOW))
 break
 except:
 out = ''

 

 

and Read U32:

 

 

def readU32Mem(self,addr):
 with self.swdLock:
 tm = 1
 
 prcs = [self.cubeProgPath+'/STM32_Programmer_CLI.exe',
 '-c',
 'port=SWD',
 'mode=UR',
 #'speed=Reliable',
 '-r32',
 hex(addr),
 '12',
 ]
 for _ in range(3):
 try:
 out = str(subprocess.check_output(prcs, stderr=subprocess.STDOUT, timeout=tm,creationflags=subprocess.CREATE_NO_WINDOW))
 break
 except:
 out = ''

 try:
 if 'Reading 32-bit memory content' in out:
 hexAddr = "0x{:08X}".format(addr)
 start=out.find(hexAddr+' : ')+len(hexAddr+' : ')
 end = start + 8
 res = out[start:end]
 res=int(res,16)
 
 return res
 except:
 pass

 

Whe try to connect via ST-Utility:

JR2963_0-1704961567618.png

and in STM32Propgramer:

JR2963_1-1704961608126.png

 

 

 

JJRR
JJRRAuthorBest answer
Associate III
January 16, 2024

Solution: use Jlink instead of unreliable ST-Link. It solved this problem