cancel
Showing results for 
Search instead for 
Did you mean: 

STLink can not connect to Nucleo as ''Wrong device detected''

Takayoshi Ishii
Associate III
Posted on June 20, 2017 at 12:27

Hello,

I am a new for STM32.

I bought Nucreo-L053R8 board, and installed latest Systemworkbench and STLink USB driver stsw-link009 on my PC. My OS is windows 8.1. I made a very short program and it could be compiled.

When I connect Nucreo board to my PC, I can see it as 'USB BUS DEVICE-STM32 STLink'.

Then I did run on Systemworkbench, then a window is opend and said 'OpenOCD Problem Occured, Reason: Wrong device detedted'.

After few second, USB is disconnected and I can see it as unknown device.

When I made the project, I select the device as L053.

Console shows like following.

-----------------------------------------

Wrong device detected

Open On-Chip Debugger 0.10.0-dev-00278-ga53935e-dirty (2017-05-09-09:25)

Licensed under GNU GPL v2

For bug reports, read

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fopenocd.org%2Fdoc%2Fdoxygen%2Fbugs.html

srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD

adapter speed: 4000 kHz

adapter_nsrst_delay: 100

Info : clock speed 4000 kHz

Info : STLINK v2 JTAG v25 API v2 SWIM v14 VID 0x0483 PID 0x3748

Info : vid/pid are not identical: 0x0483/0x374B 0x0483/0x3748

Info : using stlink api v2

Error: init mode failed (unable to connect to the target)

in procedure 'program'

in procedure 'init' called at file 'embedded:startup.tcl', line 473

in procedure 'ocd_bouncer'

** OpenOCD init failed **

shutdown command invoked

-----------------------------------------

Let me know how should I do.

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on June 21, 2017 at 15:01

Right, almost every nucleo I bought had an old firmware version causing ST_LINK issues. I have not mentioned it.

View solution in original post

6 REPLIES 6
Posted on June 20, 2017 at 17:19

Maybe wrong configuration - you have ST-LINK v2 but you actually has v-1 in cfg file.

stlink-v2.cfg:

VID/PID 0x0483 0x3748 for ST-Link/V2

VID/PID 0x0483 0x374b for ST-Link/V2-1
Posted on June 21, 2017 at 04:31

Bogdan,

Thank you for your reply.

I changed the config file as ST-Link/v2, and the error massage of 

'

Info : vid/pid are not identical: 0x0483/0x374B 0x0483/0x3748'

is disappered. but the result is still same.

My board usb hardware infomation's PID is 0x3748, so my board is ST-Link/v2 for sure. 

And I noticed that, the log said,

'

Info : STLINK v2 JTAG v25 API v2 SWIM v14 VID 0x0483 PID 0x3748'

so it will connect as SWIM, but my project debug config has 

 'transport select 'hla_swd'

that mean I think the config setting is SWD but the hardware is SWIM.

If this is the problem, how can I change the config from SWD to SWIM? I tried to change the hla_swd to hla_swim, but when I build it, the swim character is change to swd automatically.  

Posted on June 21, 2017 at 08:18

Dear Takayoshi Ishii,

You said 'that mean I think the config setting is SWD but the hardware is SWIM.',

but ALL STLink/V2-1 in Nucleo uses SWD interface despite supporting JTAG/SWD/SWIM.

Currently OpenOCD cfg's default SWD clock settings for L0 is too fast,

so you need to reduce clock below 1000kHz.

I met same problem STM32L053C8-Discovery,and avoid the error to reduce SWD clock.

See my article for more information.

http://nemuisan.blog.bai.ne.jp/?eid=222175

Best Regards,

Nemui.
Posted on June 21, 2017 at 13:45

Nemui san,

Thank you for the infomation!

Finally, I could program it as following.

1) Update the ST-Link firmware. The Nucleo that I bought was old ST-Link firmware.

2) Set the Clock lower than 1000KHz. On the Systemworkbench, Run->RunConfigurations->Debugger->Show generator options->Frequency tab->480KHz

Thank you very much for all your guys!

Posted on June 21, 2017 at 15:01

Right, almost every nucleo I bought had an old firmware version causing ST_LINK issues. I have not mentioned it.

Posted on November 06, 2017 at 01:06

Hey, I'm having a similar error (granted its a different chip, and not a development board, I'm using a custom board...) How do I change the stlink config file? I can't even find it in my project. I see it linked in the project.cfg file at the top like this:

source [find interface/stlink.cfg]

But I can't fin stlink.cfg... I've also attached the errors I'm having. They look similar to yours.

Open On-Chip Debugger 0.0-dev-00005-g4030e1c-dirty (2017-10-24-07:56)

Licensed under GNU GPL v2

For bug reports, read

/external-link.jspa?url=http%3A%2F%2Fopenocd.org%2Fdoc%2Fdoxygen%2Fbugs.html

srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD

adapter speed: 950 kHz

adapter_nsrst_delay: 100

Info : clock speed 950 kHz

Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748

Info : vid/pid are not identical: 0x0483/0x374B 0x0483/0x3748

Info : using stlink api v2

Info : Target voltage: 3.258614

Info : Stlink adapter speed set to 950 kHz

Info : STM32F030R8Tx.cpu: hardware has 4 breakpoints, 2 watchpoints

Info : Stlink adapter speed set to 950 kHz

adapter speed: 950 kHz

Error: timed out while waiting for target halted

TARGET: STM32F030R8Tx.cpu - Not halted

in procedure 'program'

in procedure 'reset' called at file 'embedded:startup.tcl', line 478

in procedure 'ocd_bouncer'

** Unable to reset target **

shutdown command invoked

Your help would be veryappreciated!

EDIT: I tried running it as Debug. This is what I got:

Open On-Chip Debugger 0.0-dev-00005-g4030e1c-dirty (2017-10-24-07:56)

Licensed under GNU GPL v2

For bug reports, read

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fopenocd.org%2Fdoc%2Fdoxygen%2Fbugs.html

srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD

adapter speed: 950 kHz

adapter_nsrst_delay: 100

Info : tcl server disabled

Info : telnet server disabled

Info : clock speed 950 kHz

Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748

Info : vid/pid are not identical: 0x0483/0x374B 0x0483/0x3748

Info : using stlink api v2

Info : Target voltage: 3.255445

Info : Stlink adapter speed set to 950 kHz

Info : STM32F030R8Tx.cpu: hardware has 4 breakpoints, 2 watchpoints

Info : accepting 'gdb' connection on tcp/3333

Info : Stlink adapter speed set to 950 kHz

adapter speed: 950 kHz

Error: timed out while waiting for target halted

TARGET: STM32F030R8Tx.cpu - Not halted

in procedure 'reset'

in procedure 'ocd_bouncer'

Info : device id = 0x20006440

Info : flash size = 64kbytes

Info : Stlink adapter speed set to 950 kHz

adapter speed: 950 kHz

Error: timed out while waiting for target halted

TARGET: STM32F030R8Tx.cpu - Not halted

in procedure 'reset'

in procedure 'ocd_bouncer'

Info : Stlink adapter speed set to 950 kHz

adapter speed: 950 kHz

Error: timed out while waiting for target halted

TARGET: STM32F030R8Tx.cpu - Not halted

in procedure 'reset'

in procedure 'ocd_bouncer'

Error: Target not halted

Error: failed erasing sectors 0 to 2

Error: flash_erase returned -304

shutdown command invoked

Error in final launch sequence

Failed to execute MI command:

load /Users/mahmudahmad/Desktop/Development/STM/testing/Debug/testing.elf

Error message from debugger back end:

Error erasing flash with vFlashErase packet

Error erasing flash with vFlashErase packet