API: STLink detected but cannot be connected to.
I want to use the STM32CubeProgrammer C++ API to do high-speed real-time automated debugging (i.e. use it as an oscilloscope).
I used as a basis the Example_2 given in the API's documentation. The STLink is detected since I can get info from it which I confirmed with the CubeProgrammer. However, when I try to connect to it the connectStLink function returns the value -545 (see the screenshot). I have tried to change various parameters for the past two days with no effect, I am at a complete loss. Here is my very simple code:
Thank you for your help.
#include <DisplayManager.h>
#include <stdio.h>
#include <iostream>
#include <CubeProgrammer_API.h>
void initProgBar() {
std::cout << "initProgBar";
}
void MylogMessage(int msgType, const wchar_t* str) {}
void loadBar(int x, int n) {}
int main() {
debugConnectParameters *stLinkList;
debugConnectParameters debugParameters;
generalInf* genInfo;
displayCallBacks dc;
dc.initProgressBar = initProgBar;
dc.logMessage = MylogMessage;
dc.loadBar = loadBar;
setDisplayCallbacks(dc);
int getStlinkListNb = getStLinkList(&stLinkList, 0);
if (getStlinkListNb == 0)
{
logMessage(Error, "No STLINK available\n");
return 0;
}
else {
logMessage(Title, "\n-------- Connected ST-LINK Probes List --------");
for (int i = 0; i < getStlinkListNb; i++)
{
logMessage(Normal, "\nST-LINK Probe %d :\n", i);
logMessage(Info, " ST-LINK SN : %s \n", stLinkList[i].serialNumber);
logMessage(Info, " ST-LINK FW : %s \n", stLinkList[i].firmwareVersion);
}
logMessage(Title, "-----------------------------------------------\n\n");
}
for (int index = 0; index < getStlinkListNb; index++) {
logMessage(Title, "\n--------------------- ");
logMessage(Title, "\n ST-LINK Probe %d ", index);
logMessage(Title, "\n--------------------- \n\n");
debugParameters = stLinkList[index];
debugParameters.connectionMode = HOTPLUG_MODE;
debugParameters.resetMode = SOFTWARE_RESET;
/* Target connect */
int connectStlinkFlag = connectStLink(debugParameters);
if (connectStlinkFlag != 0) {
logMessage(Error, "Establishing connection with the device failed. Return value: %d\n", connectStlinkFlag);
disconnect();
continue;
}
else {
logMessage(GreenInfo, "\n--- Device %d Connected --- \n", index);
}
/* Display device informations */
genInfo = getDeviceGeneralInf();
logMessage(Normal, "\nDevice name : %s ", genInfo->name);
logMessage(Normal, "\nDevice type : %s ", genInfo->type);
logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
}
deleteInterfaceList();
return 1;
}
