cancel
Showing results for 
Search instead for 
Did you mean: 

STMCubeProgrammer API "int connectStLink(debugConnectParameters debugParameters);" issue

rtl
Associate II

Hello!

I am using STM32 Cube Programmer API to flash a device with ST-LINK. I am using ST-LINK example 1. When I use connectStLink(debugParameters) it returns the value '-545'. Doxygen comments say that if it returns 0 the connection was successful, otherwise an error occurred. I can't find any more documentation about it. Surely the value '-545' indicates to some specific error. After using the getStLinkList() function, the debugConnectParameters look okay, so it means it gets a connection with the device.

I can flash (debug) the device through VS Code (using the official STM32 VS Code Extension) and through the STM32CubeProgrammer app with no problems. During one runtime, after a couple of unsuccessful tries it actually flashed the device for a few times and then stopped working again (returnind -545). I haven't made any changes to the code or the connections.

I am using mikroProg for STM32 with the ST-LINK V2 adapter. I tried different USB ports with no luck.

There isn't much information about the API and seems like not a lot of people use it also. I'm still hopeful that someone can help me.

1 ACCEPTED SOLUTION

Accepted Solutions

I just found the solution. One must set the path to the parent folder of the FlashLoader and ExternalLoader folders with the setLoadersPath() function before calling other API functions. Those folders are located at /api/lib by default. If that folder also is the working directory, which is the case in the Visual Studio examples, one can simply set the path to "./.".

const char* loaderPath = "./.";
/* Set device loaders path that contains FlashLoader and ExternalLoader folders */
setLoadersPath(loaderPath);

 

View solution in original post

3 REPLIES 3
roman1
Associate III

I also get the error code -545 from the connectStLink() function when I call it in my LabView application.However, the Visual Studio examples provided with the STM32 Cube Programmer API work. Does anyone know what the error code -545 means?

I just found the solution. One must set the path to the parent folder of the FlashLoader and ExternalLoader folders with the setLoadersPath() function before calling other API functions. Those folders are located at /api/lib by default. If that folder also is the working directory, which is the case in the Visual Studio examples, one can simply set the path to "./.".

const char* loaderPath = "./.";
/* Set device loaders path that contains FlashLoader and ExternalLoader folders */
setLoadersPath(loaderPath);

 

rtl
Associate II

Yup. I had removed them for some reason and when I added them back everything worked. I forgot to reply with the solution in this thread tho.