223.50K

ISP DLL User Guide

1.

ISP DLL User Guide
4.9.2

2.

Topic
_ISP_Config
_ISP_TurnOnAC
_ISP_RetrieveDeviceID
_ISP_TurnOfAC
_ISP_UnlockDebugPort
_ISP_SaveLog
_ISP_EMMCDownload
Sample Code
_ISP_EMMCUpload
_ISP_SPIUpload
_ISP_SPINANDUpload

3.

_ISP_Config
int _ISP_Config(char *configName, char *value)
• Return
0
1
success
unknown name
• Input
name
config name, supported config and default value are listed below
“ISP Slave Address”
0x92
“Serial Debug Slave Address”
0xB2
value
value to be set, represented by string
• Description
change DLL settings

4.

_ISP_RetrieveDeviceID
int _ISP_RetrieveDeviceID(char *buffer, int length)
• Return
0
-1
success
buffer length must be >= 16
• Input
buffer
length
buffer to store retrieved id string
buffer length, must >=16
• Description
read device id for secured device
something wrong if id is 0x000000000000 or 0xFFFFFFFFFFFF

5.

_ISP_UnlockDebugPort
int _ISP_UnlockDebugPort(char *pswd, char *chipType)
• Return
0
-1
-2
success
unlock failed
unknown password format
• Input
pswd
chipType
password
chip type string, supported value: "2nd generation"
• Description
unlock debug port communication by a password

6.

_ISP_EMMCDownload
int _ISP_EMMCDownload(char *loader, char *imageFile)
• Return
0
-1
-2
2
4
50
success
unable to enter ISP mode
connect fail, or unable to detect device type
Program file not ready yet
User break
Program Error
• Input
loader
imageFile
loader to write image
image to be written
• Description
write an image file to emmc

7.

_ISP_EMMCUpload
int _ISP_EMMCUpload(char *loader, char *dumpedFile)
• Return
0
-1
-2
1
2
3
success
unable to enter ISP mode
connect fail, or unable to detect device type
no loader file
strange dumped file path
unable to open dumped file
• Input
loader
dumpedFile
loader to load image
file to be dumped to
• Description
read from emmc and write to a file

8.

_ISP_SPIUpload
int _ISP_SPIUpload(char *dumpedFile, const DWORD
startAddr, const DWORD endAddr)
• Return
0
-1
-2
1
2
3
10
success
unable to enter ISP mode
connect fail, or unable to detect device type
start address larger than end address
end address larger then device size
unable to create dumped file
flash is busy (SPI)
• Input
dumpedFile
startAddr
endAddr
file to be dumped to
start address to be dumped
end address to be dumped
• Description
read from spi flash and write to a file

9.

_ISP_SPINANDUpload
int _ISP_SPINANDUpload(char *dumpedFile, const DWORD
startAddr, const DWORD endAddr)
• Return
0
-1
-2
1
2
3
20
21
success
unable to enter ISP mode
connect fail, or unable to detect device type
start address larger than end address
end address larger then device size
unable to create dumped file
base address too large (SPINAND only)
over max block (SPINAND only)
• Input
dumpedFile
startAddr
endAddr
file to be dumped to
start address to be dumped
end address to be dumped
• Description
read from spi flash and write to a file

10.

_ISP_TurnOnAC
int _ISP_TurnOnAC(void)
• Return
0
1
success
fail
• Input
No input
• Description
turn on AC
a mstar debug board must be used to control an ac relay

11.

_ISP_TurnOffAC
int _ISP_TurnOffAC(void)
• Return
0
1
success
fail
• Input
No input
• Description
turn off AC
a mstar debug board must be used to control an ac relay

12.

_ISP_SaveLog
int _ISP_SaveLog(char * logFilePath)
• Return
0
1
success
unable to open log file
• Input
logFilePath
file to save log
• Description
save log of DLL APIs to a file for debug usage
due to memory consideration, only log of last few APIs will be record

13.

Sample Code - DLL Loading
typedef
typedef
typedef
typedef
int
int
int
int
(*RETRIEVE_API)(char
(*UNLOCK_API)(char *
(*DOWNLOAD_API)(char
(*LOG_SAVE_API)(char
* , int);
, char *);
* , char *);
*);
RETRIEVE_API ISP_RetrieveDeviceID;
UNLOCK_API ISP_UnlockDebugPort;
DOWNLOAD_API ISP_EMMCDownload;
LOG_SAVE_API ISP_SaveLog;
HINSTANCE hInst = LoadLibrary(sEccDllFile);
if(!hInst) return;
ISP_RetrieveDeviceID = (RETRIEVE_API)GetProcAddress(hInst, "_ISP_RetrieveDeviceID");
ISP_UnlockDebugPort = (UNLOCK_API)GetProcAddress(hInst, "_ISP_UnlockDebugPort");
ISP_EMMCDownload = (DOWNLOAD_API)GetProcAddress(hInst, "_ ISP_EMMCDownload ");
ISP_SaveLog = (LOG_SAVE_API)GetProcAddress(hInst, "_ ISP_SaveLog ");

14.

Sample Code – Secure EMMC Download
int iReturn;
char idBuffer[16];
char password[128];
char * sLoaderFile = “D:\Product\Loader\loader_user.bin”;
char * sDownloadFile = “D:\Product\Image\image.bin”;
iReturn = ISP_RetrieveDeviceID(idBuffer, 16);
//
// Customer to do: use device id to get unlock password
//
iReturn = ISP_UnlockDebugPort(password, “2nd generation”);
iReturn = ISP_EMMCDownload(sLoaderFile, sDownloadFile);
if(iReturn)
{
printf("download error!! error no = %d\n", iReturn);
}
iReturn = ISP_SaveLog(“isp_dll_log.txt”);
English     Русский Правила