cancel
Showing results for 
Search instead for 
Did you mean: 

STLink V3 Error

JJRR
Senior
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
1 ACCEPTED SOLUTION

Accepted Solutions
JJRR
Senior

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

View solution in original post

8 REPLIES 8
Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
AScha.3
Chief III

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".

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.

Uwe Bonnes
Principal III

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

New version didn't help at all, it's the same. The issue is that it works but often malfunctions and disconnects. Maybe it's caused by some interference on the SWD pins, but why does the entire STlink need to freeze because of that?

Uwe Bonnes
Principal III

Consider also bad USB cables, hubs or connectors.

JR2963
Senior II

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
Senior

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