cancel
Showing results for 
Search instead for 
Did you mean: 

Error in initializing ST-LINK device. Reason: (18) Could not verify ST device! Abort connection.

Fixer
Associate II

I'm having an issue using STM32CubeIDE to program my blue pill boards. I get the below error each time.

0690X00000AqZHVQA3.png

Error in final launch sequence:

Error in initializing ST-LINK device.

Reason: (18) Could not verify ST device! Abort connection.

Error in initializing ST-LINK device.

Reason: (18) Could not verify ST device! Abort connection.

The strange thing is I have no issue programming my boards using ST-Link Utility. I thought that maybe the chips on my boards were counterfeit but I've tried boards from multiple venders now.

I've looked around online and while I found some people getting the "Error in initializing ST-LINK device." message I haven't seen anyone getting "Reason: (18)".

Any help would be appreciated.

23 REPLIES 23

Thanks for your reply. The option in debugger setting "Type: Software system reset/ connect under reset/ non" is disappeared when I select the ST-Link (Open OCD) option.

But now I am getting this problem-->

Error in final launch sequence:

Failed to execute MI command:

target remote localhost:3333

Error message from debugger back end:

localhost:3333: The system tried to join a drive to a directory on a joined drive.

Failed to execute MI command:

target remote localhost:3333

Error message from debugger back end:

localhost:3333: The system tried to join a drive to a directory on a joined drive.

localhost:3333: The system tried to join a drive to a directory on a joined drive.

This error has to do with the ST-LINK interface that is not working. There are 2 reasons (that I know of) that can cause this:

1.      Your connections between the ST-LINK and Blue Pill board are not correct.

Have a look at the attached image and check the connections.

Note: Your Blue Pill will now be powered with the 3.3V from the ST-LINK.

Warning: Never power the Blue Pill from more than one source. Example; do not plug in the USB on the Blue Pill when 3.3V from the ST-LINK is connected. If you do want to power from the USB, then first disconnect the 3.3V from the ST-LINK. The YouTube video below is done like that.

2.      You have flashed a program to the Blue Pill that does not have the SWDIO and SWCLK pins on the MCU enabled. (Did not select Serial Wire – Debug).

If you do this your program will run only once. The second time you will be locked out.

Then the only way to get past that is to select Serial Wire – Debug in your program and then flash it by going the BOOT0 – route. 

Look at the 2 Answers in the following >>

https://stackoverflow.com/questions/60827602/stm32cubeide-can-only-flash-once-no-swd-debugging/62368704#62368704

Also look at the following YouTube video that shows the standard setup of a new project.

https://www.youtube.com/watch?v=e_NSqz5P8Qk&t=617s

Note: If your STM32CubeIDE is already installed you can skip to 5min and start watching from there.

Summary of the items (in the video) to pay attention to:

·        In the Target Selector, select STM32F103C8 as the MCU.

·        In the Device Configuration Tool >>

·        RCC > High Speed Clock = Crystal/Ceramic Resonator (Check that RCC pins go green {PD0 and PD1}).

·        SYS > Debug = Serial Wire (Check that SWDIO and SWCLK pins go green {PA13 and PA14}).

·        If you want to use the user LED, set PC13 to GPIO_Output.

·        Clock Configuration: Set the path that will use the external HSE- clock and set the frequency to 72 MHz for best performance.

·        Debug Configuration: Debug probe = ST-LINK (OpenOCD) ; Reset Mode = Software system reset.

Wow, I have written a book!

Hopefully that will give you enough information to successfully get started in the STM32CubeIDE.0693W000003BuVFQA0.jpg

0693W000007CS4wQAG.jpghi Over their,

I am also same error and as u mentioned about Clone MCU's

I opened my STLINKV2 red case and it has ST32F103C6 IC only.

But still getting this GDB error issue.

So when u are saying about CKS32F103, u mean the IC which is used by STLINKV2?

between i am not able to figure out how did u check your id code for your MCU

No, it does not matter what MCU is used in your ST-Link.

The issue is with a clone MCU on your “Blue- pill�?- board.

When using STM32CubeIDE to compile your program, it will not work.

Then you have to follow the steps in my original post to fix the problem.

Thanks it was useful

Nice of you to say thanks, megan-89.

I did put in a lot of effort to share all I know of how to get started in the STM32CubeIDE, so it is great when someone appreciates it.   :)

Kepo
Associate II

Same issue.

Both STM32Cubeprogrammer and stm32 st-link utility did not check the counterfeit chip. but the STM32CubeIDE did and aborted the connection.

Make sure it is a genuine STM chip!

Hi, I'm getting started on this and I get the following error after selecting the CFG File (already modified the file):

Cannot run program "[Omitting_it]\STM32CubeIDE_1.6.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.debug.openocd_1.6.0.202102111023\resources\openocd\st_scripts\target\stm32f1x.cfg" (in directory "[Omitting_it]"): CreateProcess error=193, %1 is not a valid Win32 application

Any idea on how to work around this? Thanks.

It looks like you are trying to run the “stm32f1x.cfg�?- file?

It is not a program (exe) - file, it is a configuration file for the OpenOCD- debugger.

Just edit the file (adding the “set CPUTAPID 0�? line at the top) as you would a normal text file, then save it, then leave it alone…

Then proceed with building and running your program (the “main.c�? in your project) in the IDE…

Done, it worked just fine. Thank you so much for taking your time on this :beaming_face_with_smiling_eyes: I really appreciate it.