ST意法半导体
直播中

张建国

7年用户 150经验值
私信 关注
[问答]

请问STVP无法加载TOOLS.CNF是为什么?如何解决?

嗨,
我一直试图通过ST-LINK连接我的应用程序
http://www.st.com/content/ccc/resource/technical/document/user_manual/90/cb/42/ef/2e/53/46/75/CD00060186.pdf/files/CD00060186.pdf/jcr:内容/翻译/ en.CD00060186.pdf
,但是当我调用时
ESelectHard('ST-LINK','SWIM',FALSE)
它返回0,并且
CGetLastError
提供以下消息:
File  TOOLS.CNF:没有这样的文件或目录
文件TOOLS.CNF显然与我成功管理加载的.dll文件存在于同一目录中(eprcore60.dll,dbca60.dll,lef60.dll和file60.dll)。
s的政策是什么?

以上来自于谷歌翻译


以下为原文




Hi,
I've been trying to connect my application through ST-LINK according to the
http://www.st.com/content/ccc/resource/technical/document/user_manual/90/cb/42/ef/2e/53/46/75/CD00060186.pdf/files/CD00060186.pdf/jcr:content/translations/en.CD00060186.pdf
, but when I invoke
ESelectHard('ST-LINK', 'SWIM', FALSE)
it returns 0, and
CGetLastError
provides the following message:
File TOOLS.CNF : No such file or directory
The file TOOLS.CNF is clearly present in the same directory as the .dll files that I successfully manage to load (eprcore60.dll, dbca60.dll, lef60.dll and file60.dll).
What is the policy of s

回帖(2)

张建国

2018-10-31 16:12:15
我不小心发了不完整的问题,找不到编辑方法。
我想问一下,在file60.dll中搜索.cnf文件的策略是什么 - 是硬编码的路径,还是它们相对于dll文件,还是可以以某种方式设置它们的路径?
我附上以下尝试的完整源代码:
#include'stdafx.h'
 
#include< windows.h>
 
#include< conio.h>
 
#ifndef MAX_PATH
 
#define MAX_PATH 260
 
#endif // MAX_PATH
使用命名空间std;
#define WARN(msg,...)fprintf(stderr,msg' n',## __ VA_ARGS__)
 
#define WWARN(wmsg,...)fwprintf(stderr,wmsg L' n',## __ VA_ARGS__)
typedef int(* EAllAccess_t)(DWORD dwAreaId);
 
typedef int(* EAreaAccess_t)(DWORD dwAreaId,long FirstAddr,long LastAddr);
int(* ESelectDevice)(const char * szDevice);
 
int(* ESelectHard)(const char * szCard,const char * szProtocol,BOOL bDemo);
 
int(* ESelectPort)(const char * szPort);
 
int(* ESetPreferences)(int iPreference,BOOL bState);
 
int(* ESetProtection)(const char * szProtectMode,BOOL bState);
 
int(* ECheckSum)(DWORD dwAreaId,long * FileCheckSum,long * MemoryCheckSum);
 
int(* EGetId)(const char * szName,DWORD * pdwId);
 
char *(* EGetImagePtr)(DWORD dwAreaId,long * MemSize);
 
INT(* ECloseComm)();
char *(* CGetLastError)()= NULL;
char * LastErrorMessage()
 
{
 
 if(CGetLastError)
 
 {
 
 return CGetLastError();
 
 }
 
 返回'未知错误';
 
}
#define TRY(action)if(!(action)){WARN(#action'failed:%s',LastErrorMessage());返回; }
EAllAccess_t EBlankAll;
 
EAreaAccess_t EBlankArea;
 
EAllAccess_t EEraseAll;
 
EAreaAccess_t EEraseArea;
 
EAllAccess_t EProgAll;
 
EAreaAccess_t EProgArea;
 
// EAllAccess_t EReadAll;
 
EAreaAccess_t EReadArea;
 
EAllAccess_t EVerifyAll;
 
EAreaAccess_t EVerifyArea;
 
void LoadLibraries()
 
{
 
 HINSTANCE eprcore,dbca,lef,file;
 
 TRY(eprcore = LoadLibrary(L'eprcore60.dll'));
 
 TRY(dbca = LoadLibrary(L'dbca60.dll'));
 
 TRY(lef = LoadLibrary(L'lef60.dll'));
 
 TRY(file = LoadLibrary(L'file60.dll'));
 TRY(CGetLastError =(char *(*)())GetProcAddress(dbca,'CGetLastError'));
 TRY(ESelectPort =(int(*)(const char *))GetProcAddress(eprcore,'ESelectPort'));
 // TRY(EReadAll =(EAllAccess_t)GetProcAddress(eprcore,'EReadAll'));
 
 TRY(ESelectHard =(int(*)(const char *,const char *,BOOL))GetProcAddress(eprcore,'ESelectHard'));
 TRY(EReadArea =(EAreaAccess_t)GetProcAddress(eprcore,'EReadArea'));
 TRY(EVerifyAll =(EAllAccess_t)GetProcAddress(eprcore,'EVerifyAll'));
 
 TRY(EVerifyArea =(EAreaAccess_t)GetProcAddress(eprcore,'EVerifyArea'));
 TRY(EProgAll =(EAllAccess_t)GetProcAddress(eprcore,'EProgAll'));
 
 TRY(EProgArea =(EAreaAccess_t)GetProcAddress(eprcore,'EProgArea'));
 TRY(EEraseAll =(EAllAccess_t)GetProcAddress(eprcore,'EEraseAll'));
 
 TRY(EEraseArea =(EAreaAccess_t)GetProcAddress(eprcore,'EEraseArea'));
 TRY(EBlankAll =(EAllAccess_t)GetProcAddress(eprcore,'EBlankAll'));
 
 TRY(EBlankArea =(EAreaAccess_t)GetProcAddress(eprcore,'EBlankArea'));
}
void ReadMemory()
 
{
 
 DWORD PROGRAM_MEMORY,DATA_MEMORY;
 尝试(ESelectHard('ST-LINK','游泳',假));
 
 TRY(ESelectDevice( 'STM8L15xC6'));
 
 TRY(ESelectPort( 'USB'));
 
 TRY(EGetId('PROGRAM MEMORY',& PROGRAM_MEMORY));
 
 TRY(EGetId('DATA MEMORY',& DATA_MEMORY));
 
 WARN('程序存储器=%d,数据存储器=%d',PROGRAM_MEMORY,DATA_MEMORY);
 
}
 
int main()
 
{
 
 TCHAR pwd [MAX_PATH];
 
 _wgetcwd(pwd,MAX_PATH);
 
 WWARN(当前工作目录:%s  n',pwd);
 
 SetDllDirectory会(L'C:\ st_toolset \ STVP');
 
 LoadLibraries();
 ReadMemory();
 的getchar();
 
 返回0;
 
}

以上来自于谷歌翻译


以下为原文




I accidentally sent the incomplete question and can't find a way to edit it.
I wanted to ask, what is the policy of searching for the .cnf files in the file60.dll -- are the paths hard coded, or are they relative to the dll files, or can their path be set somehow?
I enclose the complete source code of my attempts below:

#include 'stdafx.h'

#include

#include


#ifndef MAX_PATH

#define MAX_PATH 260

#endif // MAX_PATH

using namespace std;

#define WARN(msg, ...) fprintf(stderr, msg 'n', ## __VA_ARGS__)

#define WWARN(wmsg, ...) fwprintf(stderr, wmsg L'n', ## __VA_ARGS__)

typedef int(*EAllAccess_t)(DWORD dwAreaId);

typedef int(*EAreaAccess_t)(DWORD dwAreaId, long FirstAddr, long LastAddr);

int(*ESelectDevice)(const char *szDevice);

int (*ESelectHard)(const char *szCard, const char *szProtocol, BOOL bDemo);

int(*ESelectPort)(const char *szPort);

int(*ESetPreferences)(int iPreference, BOOL bState);

int(*ESetProtection)(const char *szProtectMode, BOOL bState);

int(*ECheckSum)(DWORD dwAreaId, long *FileCheckSum, long *MemoryCheckSum);

int (*EGetId)(const char *szName, DWORD *pdwId);

char *(*EGetImagePtr)(DWORD dwAreaId, long *MemSize);

int(*ECloseComm)();

char *(*CGetLastError)() = NULL;

char *LastErrorMessage()

{

    if (CGetLastError)

    {

        return CGetLastError();

    }

    return 'unknown error';

}

#define TRY(action) if(!(action)) { WARN(# action ' failed: %s', LastErrorMessage()); return; }

EAllAccess_t EBlankAll;

EAreaAccess_t EBlankArea;

EAllAccess_t EEraseAll;

EAreaAccess_t EEraseArea;

EAllAccess_t EProgAll;

EAreaAccess_t EProgArea;

//EAllAccess_t EReadAll;

EAreaAccess_t EReadArea;

EAllAccess_t EVerifyAll;

EAreaAccess_t EVerifyArea;


void LoadLibraries()

{

    HINSTANCE eprcore, dbca, lef, file;

    TRY(eprcore = LoadLibrary(L'eprcore60.dll'));

    TRY(dbca = LoadLibrary(L'dbca60.dll'));

    TRY(lef = LoadLibrary(L'lef60.dll'));

    TRY(file = LoadLibrary(L'file60.dll'));

    TRY(CGetLastError = (char *(*)()) GetProcAddress(dbca, 'CGetLastError'));

    TRY(ESelectPort = (int(*)(const char *))GetProcAddress(eprcore, 'ESelectPort'));

    //TRY(EReadAll = (EAllAccess_t)GetProcAddress(eprcore, 'EReadAll'));

    TRY(ESelectHard = (int(*)(const char *, const char *, BOOL)) GetProcAddress(eprcore, 'ESelectHard'));

    TRY(EReadArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EReadArea'));

    TRY(EVerifyAll = (EAllAccess_t)GetProcAddress(eprcore, 'EVerifyAll'));

    TRY(EVerifyArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EVerifyArea'));

    TRY(EProgAll = (EAllAccess_t)GetProcAddress(eprcore, 'EProgAll'));

    TRY(EProgArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EProgArea'));

    TRY(EEraseAll = (EAllAccess_t)GetProcAddress(eprcore, 'EEraseAll'));

    TRY(EEraseArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EEraseArea'));

    TRY(EBlankAll = (EAllAccess_t)GetProcAddress(eprcore, 'EBlankAll'));

    TRY(EBlankArea = (EAreaAccess_t)GetProcAddress(eprcore, 'EBlankArea'));

}

void ReadMemory()

{

    DWORD PROGRAM_MEMORY, DATA_MEMORY;

    TRY(ESelectHard('ST-LINK', 'SWIM', FALSE));

    TRY(ESelectDevice('STM8L15xC6'));

    TRY(ESelectPort('USB'));

    TRY(EGetId('PROGRAM MEMORY', &PROGRAM_MEMORY));

    TRY(EGetId('DATA MEMORY', &DATA_MEMORY));

    WARN('PROGRAM MEMORY = %d, DATA MEMORY = %d', PROGRAM_MEMORY, DATA_MEMORY);

}


int main()

{

    TCHAR pwd[MAX_PATH];

    _wgetcwd(pwd, MAX_PATH);

    WWARN(L'Current Working Directory: %sn', pwd);

    SetDllDirectory(L'C:\st_toolset\stvp');

    LoadLibraries();

    ReadMemory();

    getchar();

    return 0;

}
举报

张建国

2018-10-31 16:18:18
我设法通过调用'CSetWorkingDir'函数来解决问题。对不起噪音。

以上来自于谷歌翻译


以下为原文




I managed to solve the problem by invoking the 'CSetWorkingDir' function. Sorry for the noise.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分