STlink v2 doesn't connect

neixian

100 mW
Joined
Oct 29, 2023
Messages
46
Location
Victoria
It looks fine. All drivers installed and I can see it in the device management.

I have also made the cables very short. However it alwasy says so:

(API) ERROR : Cannot communicate with the device !
Check the SWIM cable connection and check all the needed pin connections on the SWIM connector.

If the application code uses Swim Disable and Reset pin as Output or has disabled SWIM Clock Divider:
Try Now to SWITCH OFF and ON the application Power Supply while NRST Reset pin is forced low.

Even I tried connecting RST port to the ground (to force it low), it still doesn't connect.

Do I have a faulty dongle?

Thanks in advance guys.

IMG_20231109_110930.jpg
 
It looks fine. All drivers installed and I can see it in the device management.

I have also made the cables very short. However it alwasy says so:

(API) ERROR : Cannot communicate with the device !
Check the SWIM cable connection and check all the needed pin connections on the SWIM connector.

If the application code uses Swim Disable and Reset pin as Output or has disabled SWIM Clock Divider:
Try Now to SWITCH OFF and ON the application Power Supply while NRST Reset pin is forced low.

Even I tried connecting RST port to the ground (to force it low), it still doesn't connect.

Do I have a faulty dongle?

Thanks in advance guys.

View attachment 342692

Hi!
I have the same problem. Did you find the solution?
Greetings,
G
 
new version of TSDZ2 controlers have different microcontrollers, so stlink won't connect. I bought an old version controller to run OSF.
Thank you!


I tried with an old TSDZ2 what I bought in 2021 october, and it can not communicate. The laptop can see the ST Link, but "Cannot communicate with the device"

Let me ask, where did you buy the old version? Can we find the difference by serial numbers?
 
Last edited:
Thank you!


I tried with an old TSDZ2 what I bought in 2021 october, and it can not communicate. The laptop can see the ST Link, but "Cannot communicate with the device"

Let me ask, where did you buy the old version? Can we find the difference by serial numbers?
search for it. Measure the voltage across ground and swim, I can't remember whether 5v or 0v means new controller.
 
new version of TSDZ2 controlers have different microcontrollers, so stlink won't connect. I bought an old version controller to run OSF.
Hi ,

I bought TSDZ2B and I can't connect. How to check if I have a new version of the controller?
 
Thank you!


I tried with an old TSDZ2 what I bought in 2021 october, and it can not communicate. The laptop can see the ST Link, but "Cannot communicate with the device"

Let me ask, where did you buy the old version? Can we find the difference by serial numbers?
Just saw your post. I had a similar problem and wired the ST Link to the 3.3V pin and that got it to communicate. See this post TSDZ2 OSF for all displays, VLCD5-VLCD6-XH18, LCD3, 860C-850C-SW102.
 
Hi2all...
The same issue(
I made diy cable from HERE(empoweredpeople)
Tried on Windows via Java(mbrusa) and directly on Android:

1737904283732.png

1737906284116.png

ST Visual Programmer also shows the error after the1st attempt (reading),
1737904436133.png

but after 1-2 attempts it can read the memory:
1737904477844.png

I found the info on the forum that some controllers aren't flashable...((
but I checked the pins and got 4.9V in my case (TSDZ2B from GreenEnergy store).

1737904249767.png
(st-link connected in the same way - red 5V, white Swim and black Gnd)
Any ideas colleagues? Bad ST-Link v2 dongle? spent more than 8 hours with this sh.. already
 

Attachments

  • 1737904304371.png
    1737904304371.png
    134.3 KB · Views: 5
Last edited:
I found that intermittent connection issues for me mostly was a wiring issue, the st-link's I got which didn't work just didn't work at all and the one's which worked 'intermittently' just worked after both fixing any wiring issues, and flashing new firmware for the St-Link ( posted in the mbrusa thread somewhere in the last page(s)).

Since yours does work ( or you wouldn't be able to read from your controller ), you could try flashing after getting a successful read ( that is what I do anyway, connect st-link open st visual programmer, read program tab and only after it read I hit 'compile and flash' ). Or I even run the java configurator, exit out before it tries to flash ( but it does compile the hex file ) and flash that manually.

To get rid of the intermittent access errors, I would double check your wiring see if there maybe is a loose connection which might not always make good contact. If that isn't the issue, try flashing the newer firmware on the st-link. If that also doesn't help, get another st-link luckily they are dirt cheap.
 
s a loose connection which might not always make good contact. If that isn't the issue, try flashing the newer firmware on the st-link. If that also doesn't help, get another st-link luckily they are dirt cheap.
Yes, all my connections are soldered... I tried updating the ST-Link 1737906599197.pnga something did get updated there.


and flash that manually.
Here I understood, but what I didn’t understand is that when reading via ST Visual Programmer, we have 3 tabs and can save 3 .hex files.

1737906996450.png

But Mbrusaa’s Java generates only 1 file...

1737907025335.png
(which is different by it's name in logs from java-cmd generator (TSDZ2-20.1C.2-3-PROGRAM.hex))
 
Program tab holds your firmware, other tabs hold configuration data ect. You should be able to confirm this easily by comparing a readout of the program tab after a successful flash and the content of the generated hex file.

If you soldered everything, and checked with multimeter, what's left if either st-link itself or having to long an usb 'extension' ( which would lower the +5v needed to power the controller for flashing/reading, so maybe check you have enough voltage? ).
 
Program tab holds your firmware, other tabs hold configuration data ect.
I took a "risk") and tried to flash the TSDZ2-20.1C.2-3.hex file using ST Visual Programmer, and it seems to have worked. Now the EKD-01 shows an error on startup (as it should), but it seems to be functioning.
I haven’t ridden it yet, but I’ve noticed some changes the 'walking assist' starts very smoothly, and the motor no longer reacts to pedals when they’re pressed while stationary.
 
I took a "risk") and tried to flash the TSDZ2-20.1C.2-3.hex file using ST Visual Programmer, and it seems to have worked.

----------------------------------------------------------
new log session
date: 01/18/25
time: 11:48:36
----------------------------------------------------------
STVP_CmdLine version 1.6

Verbose ON
Log activity ON
Display Progress OFF
Message box warning if protect option byte OFF
Loop mode OFF
Erase device OFF
Blank check device OFF
Verify device ON

Configuration:
BoardName=ST-LINK ST-LINK_ID=0 Device=STM8S105x6 Port=USB ProgMode=SWIM

>>> Filling PROGRAM MEMORY image in computer with Blank Value
<<< Filling PROGRAM MEMORY image in computer succeeds

>>> Loading file ../bin/main.hex in PROGRAM MEMORY image in computer
<<< Loading file succeeds

>>> Filling DATA MEMORY image in computer with Blank Value
<<< Filling DATA MEMORY image in computer succeeds

>>> Loading file data_empty.hex in DATA MEMORY image in computer
<<< Loading file succeeds

>>> Programming PROGRAM MEMORY
<<< Programming PROGRAM MEMORY succeeds

>>> Verifying PROGRAM MEMORY
<<< Verifying PROGRAM MEMORY succeeds

>>> Programming DATA MEMORY
<<< Programming DATA MEMORY succeeds

>>> Verifying DATA MEMORY
<<< Verifying DATA MEMORY succeeds

I usually do not say things which could pose a risk without mentioning it specifically. I did not say there was a risk flashing manually to program memory because it is what your scripts been trying to do anyway.
 
I usually do not say things which could pose a risk without mentioning it specifically. I did not say there was a risk flashing manually to program memory because it is what your scripts been trying to do anyway.
emm...(excuse me, English is one of the five languages I know a bit, so I didn't quite understand what you meant. :) )
I just generate a configuration file (TSDZ2-20.1C.2-3.hex) using Java, and then I "manually"(ST Visual Programmer) write it to the motor controller's memory (because the .bat script doesn't work for me for some reason).
But, if I buy a display, for example, the SW102 (+also reflash it), will I be able to change most of those settings "on the fly", directly from the handlebar?
 
because the .bat script doesn't work for me for some reason

dependencies or path issue

But, if I buy a display, for example, the SW102 (+also reflash it), will I be able to change most of those settings "on the fly", directly from the handlebar?

Using xh18 I can change settings on the display through the 'set parameters on startup' option ( though I really only use it to enable/disable street mode ).

emm...(excuse me, English is one of the five languages I know a bit, so I didn't quite understand what you meant. :) )

While all flashing is inherently 'risky', the way you wrote it gave me the feeling I was giving 'risky advice'. I don't think it was, hence my reply.
 
the way you wrote it gave me the feeling I was giving 'risky advice'.
nono, not at all ☺️it's just translation difficulties) I'm generally happy for any advice and I like to experiment, if I "burn" the controller, I'll buy a new one) $40 it's not a big deal
 
Last edited:
If it is 100% consistent -> no connection -> 3x failed attempt -> always 4th attempt you get a connection

.. it's almost as if the application decides to use alternate options, but I am not familiar with ST Visual programmer enough to say if it does this. But it's the only logical explanation if your connection issues are 100% repeatable every time.
 
I have a similar problem and hope someone can help. 🙏

Background: This is the third time in 2.5 years that my TSZD2b/860c/OSF setup has crashed. Like the prior two times, the screen will start but get stuck on the startup screen with a message "error brakes or coms." The prior two times, the solution was to reflash the option byte file via STVP by connecting the computer to the motor via the speed sensor cable with an ST-Link cable.

Problem: This time, when I set it up exactly as I have before, the STVP won't connect to the motor. It gives me the following error message over and over (not just once or twice)--the same error I get if I try to run the "read" function (or any other) when there's nothing at all plugged into the cable.

Cannot communicate with the device !

Check the SWIM cable connection and check all the needed pin connections on the SWIM connector.

If the application code uses Swim Disable and Reset pin as Output or has disabled SWIM Clock Divider: Try Now to SWITCH OFF and ON the application Power Supply while NRST Reset pin is forced low.


What I have tried/discovered:
*I uninstalled, redownloaded, and reinstalled the latest version of STVP.
*The ST-Link cable appeared fine. In case it was bad or got fried or something, I bought a new one and connected it to the wires in the 6-pin connector I have. Each of the three wires is conducting (tested by multimeter) from the pin in the bike connector to the end of the cable.
*There is a light on the ST-Link dongle that turns on when I plug it into the computer and the computer recognizes the USB device.
*The cable coming from the motor appears fine. I checked the pins in the cable with a multimeter. Using this image from above as reference--I think mine is wired the same way: red 5V, white Swim and black Gnd. The readings are 4.9V between the black and white; 4.9V or -4.9V, depending on the polarity of the leads, between the red and black; and 0V between the white and red.

1742522075683.png
*I have tried connecting the wire leads/connectors onto the pins on the ST-Link in every combination--trying both the 5V and the 3.3V pins, trying the RST, etc. I either get the same error as originally or this error:

Error : Cannot communicate with the tool.
Wrong tool selection or check tool power supply or check that a previous session is closed.


I am at a loss. Do you have any advice or what I could try next? Is there anything else I can do short of opening the motor casing and checking the interior components? (which is going to require some bike disassembly) And, I guess, even if I do that, what am I looking for?

Or even any ideas of what kind of professional I need to find to help me out? (none of the bike mechanics I know work on electrical aspects of ebikes at all, and this doesn't even seem to be an electrical wiring problem so much as a computer circuitry problem)

Thanks!
 
Since you're getting an error message on the motor/display system itself that could be a comm error, *and* the STlink can't connect to it, I would guess that the comm line itself (rx into the controller, probably) has failed.

It could be mechanical (broken wire, cold solder, broken PCB trace, etc) or electrical (failed comm transceiver component or MCU pin, etc).
 
Since you're getting an error message on the motor/display system itself that could be a comm error, *and* the STlink can't connect to it, I would guess that the comm line itself (rx into the controller, probably) has failed.

It could be mechanical (broken wire, cold solder, broken PCB trace, etc) or electrical (failed comm transceiver component or MCU pin, etc).
Thanks. FWIW, the error on the display is the same one I've gotten two times in the past when I was able to connect the STlink to it and reflash the option byte file and fix it.

The controller (which is inside the motor housing, yes?) is replaceable, right?
 
Back
Top