Files
base/devices/script/JLINK/e3/sf.JLinkScript
2025-11-07 09:57:14 +08:00

96 lines
3.4 KiB
Plaintext

/*********************************************************************
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* ConfigTargetSettings()
*
* Function description
* Called before InitTarget(). Mainly used to set some global DLL variables to customize the normal connect procedure.
* For ARM CoreSight devices this may be specifying the base address of some CoreSight components (ETM, ...)
* that cannot be automatically detected by J-Link due to erroneous ROM tables etc.
* May also be used to specify the device name in case debugger does not pass it to the DLL.
*
* Return value
* >= 0 O.K.
* < 0 Error
*
* Notes
* (1) May not, under absolutely NO circumstances, call any API functions that perform target communication.
* (2) Should only set some global DLL variables
*/
int ConfigTargetSettings(void) {
//
// Access Port map specfication
// Core type
// Access Port to use
// Specify core base address
// Specify CTI base address
JLINK_SYS_Report("----------------J-Link script: ConfigTargetSettings() For Semdrive E3 SF Cortex-R5---------------");
JLINK_CPU = CORTEX_R5;
//JLINK_CORESIGHT_IndexAPBAPToUse = 0;
JLINK_CORESIGHT_CoreBaseAddr = 0xF2081000;
return 0;
}
void SetupSecureDebug(void) {
int v;
int key0;
int key1;
int cmd;
cmd = 0xf;
key0 = 0x74657374; // key0 --> SEC_DBG_CFG[31, 0]!!
key1 = 0x6b657930; // key1 --> SEC_DBG_CFG[63, 32]!!
JLINK_SYS_Report("--------------SetupSecureDebug-----------------");
JLINK_SelectTIF(JLINK_TIF_JTAG);
CPU = CORTEX_R5;
//prototype:int JLINK_JTAG_Write(U32 tms, U32 tdi, U32 NumBits);
JLINK_JTAG_Write(0x1f, 0, 5); // goto Test-Logic Reset state
JLINK_JTAG_Write(0x6, 0, 5); //goto shift-ir state
JLINK_JTAG_Write(0x8, cmd, 4); // shift in UID instruction, goto exit1-ir
JLINK_JTAG_Write(0x3, 0x0, 4); //goto shift-dr state
JLINK_JTAG_Write(0x00000000, 0x0, 32); //shift in 64bit dummy code. shift out our uid
v = JLINK_JTAG_GetU32(0);
JLINK_SYS_Report1("UID: ", v);
JLINK_JTAG_Write(0x80000000, 0x0, 32); //shift in 64bit dummy code. shift out our uid, goto exit1-dr
v = JLINK_JTAG_GetU32(0);
JLINK_SYS_Report1("UID: ", v);
JLINK_JTAG_Write(0x1f, 0, 5); // goto Test-Logic Reset state
JLINK_JTAG_Write(0x2, 0x0, 4); // goto shift-dr state
JLINK_JTAG_Write(0x00000000, key0, 32); //shift in the corresponding key
JLINK_JTAG_Write(0x80000000, key1, 32); //shift in the corresponding key, goto exit1-ir
JLINK_JTAG_Write(0x1f, 0, 5); // goto Test-Logic Reset state
JLINK_JTAG_Write(0x2, 0x0, 4); // goto shift-dr state
JLINK_JTAG_Write(0x80000000, 0x0, 32); // shift our IDCODE
v = JLINK_JTAG_GetU32(0);
JLINK_SYS_Report1(" ID: ", v);
JLINK_JTAG_Write(0x1, 0, 2); // goto idle state
}
void InitTarget(void) {
// SetupSecureDebug();
}
/*************************** end of file ****************************/