The target interface system uses CrossStudio's JavaScript (ECMAScript) interpreter to support board and target specific behaviour.
The main use for this is to support non-standard target and board reset schemes and also to configure the target after reset, see Reset Script for more information.
The target script system can also be used to carry out target specific operations when the debugger attaches, stops or starts the target. This can be useful when debugging with caches enabled as it provides a mechanism for the debugger to FLUSH and disable caches when the processor enters debug state and then re-enable the caches when the processor is released into run state. See Attach Script, Stop Script and Run Script for more information.
In order to reduce script duplication, when the target interface runs a reset, attach, run or stop script it first looks in the current active project for a file marked with a project property File Type set to Reset Script. If a file of this type is found it will be loaded prior to executing the scripts, each of the scripts can then call functions within this script file.
The Reset Script property held in the Target project property group is used to define a script to execute to reset and configure the target.
The aim of the reset script is to get the processor into a known state. When the script has executed the processor should be reset, stopped on the first instruction and configured appropriately.
As an example, the following script demonstrates the reset script for an Evaluator 7T target board with a memory configuration that re-maps SRAM to start from 0x00000000. The Evaluator7T_Reset function carries out the standard ARM reset and stops the processor prior to executing the first instruction. The Evaluator7T_ResetWithRamAtZero function calls this reset function and then configures the target memory by accessing the configuration registers directly. See TargetInterface Object for a description of the TargetInterface object which is used by the reset script to access the target hardware.
function Evaluator7T_Reset()
{
TargetInterface.setNSRST(0);
TargetInterface.setICEBreakerBreakpoint(0, 0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x100, 0xF7);
TargetInterface.setNSRST(1);
TargetInterface.waitForDebugState(1000);
TargetInterface.trst();
}
function Evaluator7T_ResetWithRamAtZero()
{
Evaluator7T_Reset();
/***************************************************************************
* Register settings for the following memory configuration: *
* *
* ---------------------- *
* | ROMCON0 - 512K FLASH | 0x01800000 - 0x0187FFFF *
* |----------------------| *
* | ROMCON2 - 256K SRAM | 0x00040000 - 0x0007FFFF *
* |----------------------| *
* | ROMCON1 - 256K SRAM | 0x00000000 - 0x0003FFFF *
* ---------------------- *
* *
***************************************************************************/
TargetInterface.pokeWord(0x03FF0000, 0x07FFFFA0); // SYSCFG
TargetInterface.pokeWord(0x03FF3000, 0x00000000); // CLKCON
TargetInterface.pokeWord(0x03FF3008, 0x00000000); // EXTACON0
TargetInterface.pokeWord(0x03FF300C, 0x00000000); // EXTACON1
TargetInterface.pokeWord(0x03FF3010, 0x0000003E); // EXTDBWIDTH
TargetInterface.pokeWord(0x03FF3014, 0x18860030); // ROMCON0
TargetInterface.pokeWord(0x03FF3018, 0x00400010); // ROMCON1
TargetInterface.pokeWord(0x03FF301C, 0x00801010); // ROMCON2
TargetInterface.pokeWord(0x03FF3020, 0x08018020); // ROMCON3
TargetInterface.pokeWord(0x03FF3024, 0x0A020040); // ROMCON4
TargetInterface.pokeWord(0x03FF3028, 0x0C028040); // ROMCON5
TargetInterface.pokeWord(0x03FF302C, 0x00000000); // DRAMCON0
TargetInterface.pokeWord(0x03FF3030, 0x00000000); // DRAMCON1
TargetInterface.pokeWord(0x03FF3034, 0x00000000); // DRAMCON2
TargetInterface.pokeWord(0x03FF3038, 0x00000000); // DRAMCON3
TargetInterface.pokeWord(0x03FF303C, 0x9C218360); // REFEXTCON
}
The Attach Script property held in the Target project property group is used to define a script that is executed when the debugger first attaches to an application. This can be after a download or reset before the program is run or after an attach to a running application. The aim of the attach script is to carry out any target specific configuration before the debugger first attaches to the application being debugged.
See TargetInterface Object for a description of the TargetInterface object which is used by the attach script to access the target hardware.
The Stop Script property held in the Target project property groups is used to define a script that is executed when the target enters debug/stopped state. This can be after the application hits a breakpoint or when the Debug | Break operation has been carried out. The aim of the stop script is to carry out any target specific operations before the debugger starts accessing target memory. This is particularly useful when debugging applications that have caches enabled as the script can disable and flush the caches enabling the debugger to access the current memory state.
See TargetInterface Object for a description of the TargetInterface object which is used by the stop script to access the target hardware.
This Run Script property held in the Target project property group is used to define a script that is executed when the target enters run state. This can be when the application is run for the first time or when the Debug | Go operation has been carried out after the application has hit a breakpoint or been stopped using the Debug | Break operation. The aim of the run script is to carry out any target specific operations after the debugger has finished accessing target memory. This can be useful to re-enable caches previously disabled by the stop script.
See TargetInterface Object for a description of the TargetInterface object which is used by the run script to access the target hardware.
The TargetInterface object is used to access the currently connected target interface. The following section describes the TargetInterface object's member functions.
TargetInterface.beginDebugAccess() |
Put target into debug state if it is not already in order to carry out a number of debug operations. The idea behind beginDebugAccess and endDebugAccess is to minimize the number of times the target enters and exits debug state when carrying out a number of debug operations. Target interface functions that require the target to be in debug state (such as peek and poke) also use beginDebugAccess and endDebugAccess to get the target into the correct state. A nesting count is maintained, incremented by beginDebugAccess and decremented by endDebugAccess. The initial processor state is recorded on the first nested call to beginDebugAccess and this state is restored when the final endDebugAccess is called causing the count to return to it initial state. |
TargetInterface.delay(milliseconds) |
|
Wait for a specified period of time. | |
Parameters | |
milliseconds | The number of milliseconds to wait.. |
TargetInterface.endDebugAccess(alwaysRun) |
|
Restore the target run state recorded at the first nested call to beginDebugAccess. See beginDebugAccess for more information. | |
Parameters | |
alwaysRun | If non-zero the processor will always exit debug state on the last nested call to endDebugAccess. |
TargetInterface.eraseBytes(address, length) |
|
Erase a block of erasable memory. | |
Parameters | |
address | The start address to erase. |
length | The number of bytes to erase. |
TargetInterface.executeFunction(address, r0, timeout) |
|
Execute a function on the target. | |
Parameters | |
address | The address of the function entry point. |
r0 | The value to set register r0 on entry to the function (in effect the first parameter to the function). |
timeout | The timeout value in milliseconds to wait for the function to complete. |
TargetInterface.getRegister(register) |
|
Get the value of a CPU register. Note that the set of register values are only updated when the CPU stops. | |
Parameters | |
register | A string describing the register to get, which must be one of the
following:
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13" or "sp", "r14" or "lr", "r15" or "pc", "cpsr", "r8_fiq", "r9_fiq", "r10_fiq", "r11_fiq", "r12_fiq", "r13_fiq", "r14_fiq", "spsr_fiq", "r13_svc", "r14_svc", "spsr_svc", "r13_abt", "r14_abt", "spsr_abt", "r13_irq", "r14_irq", "spsr_irq", "r13_und", "r14_und", "spsr_und" |
Returns | |
The register value. |
TargetInterface.peekByte(address) |
|
Reads a byte of target memory. | |
Parameters | |
address | The address from which to read. |
Returns | |
The byte peeked from the specified address. |
TargetInterface.peekBytes(address, length) |
|
Reads a block of bytes from target memory. | |
Parameters | |
address | The start address from which to read. |
length | The number of bytes to read. |
Returns | |
An array containing the bytes read. |
TargetInterface.peekUint16(address) |
|
Reads a 16 bit unsigned integer from target memory. | |
Parameters | |
address | The address from which to read. |
Returns | |
The 16 bit unsigned integer peeked from the specified address. |
TargetInterface.peekUint32(address) |
|
Reads a 32 bit unsigned integer from target memory. | |
Parameters | |
address | The address from which to read. |
Returns | |
The 32 bit unsigned integer peeked from the specified address. |
TargetInterface.peekWord(address) |
|
Reads a word of data from target memory. | |
Parameters | |
address | The address from which to read. |
Returns | |
The word peeked from the specified address. |
TargetInterface.pokeByte(address, data) |
|
Writes a byte of target memory. | |
Parameters | |
address | The target address to write to. |
data | The data byte to write. |
TargetInterface.pokeUint16(address, data) |
|
Writes a 16 bit unsigned integer to target memory. | |
Parameters | |
address | The target address to write to. |
data | The data to write. |
TargetInterface.pokeUint32(address, data) |
|
Writes a 32 bit unsigned integer to target memory. | |
Parameters | |
address | The target address to write to. |
data | The data to write. |
TargetInterface.pokeWord(address, data) |
|
Writes a word of data to target memory. | |
Parameters | |
address | The target address to write to. |
data | The data word to write. |
TargetInterface.pokeBytes(address, length) |
|
Writes a block of bytes to target memory. | |
Parameters | |
address | The start address to write to. |
data | An array containing the bytes to write. |
TargetInterface.peekMultUint16(address, length) |
|
Read a block of 16 bit unsigned integers from target memory. | |
Parameters | |
address | The start address from which to read. |
length | The number of 16 bit unsigned integers to read. |
TargetInterface.peekMultUint32(address, length) |
|
Read a block of 32 bit unsigned integers from target memory. | |
Parameters | |
address | The start address from which to read. |
length | The number of 32 bit unsigned integers to read. |
TargetInterface.pokeMultUint16(address, length) |
|
Write a block of 16 bit unsigned integers to target memory. | |
Parameters | |
address | The start address to write to. |
length | The number of 16 bit unsigned integers to write. |
TargetInterface.pokeMultUint32(address, length) |
|
Write a block of 32 bit unsigned integers to target memory. | |
Parameters | |
address | The start address to write to. |
length | The number of 32 bit unsigned integers to write. |
TargetInterface.setICEBreakerBreakpoint(n, addressValue, addressMask, dataValue, dataMask controlValue, controlMask) |
|
Set an ICEBreaker breakpoint. | |
Parameters | |
n | The number of the watchpoint unit to use. |
addressValue | The address value. |
addressMask | The address mask. |
dataValue | The data value. |
dataMask | The data mask. |
controlValue | The control value. |
controlMask | The control mask. |
TargetInterface.setNSRST(value) |
|
Set the level of the target's nSRST reset signal. | |
Parameters | |
value | Set nSRST high if value does not equal zero. |
TargetInterface.setRegister(register, value) |
|
Set a the value of a CPU register. Note that this function will only change the CPU register state if the CPU is stopped. | |
Parameters | |
register | A string describing the register to set, which must be one of the
following:
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13" or "sp", "r14" or "lr", "r15" or "pc", "cpsr", "r8_fiq", "r9_fiq", "r10_fiq", "r11_fiq", "r12_fiq", "r13_fiq", "r14_fiq", "spsr_fiq", "r13_svc", "r14_svc", "spsr_svc", "r13_abt", "r14_abt", "spsr_abt", "r13_irq", "r14_irq", "spsr_irq", "r13_und", "r14_und", "spsr_und" |
value | The value to set the register to. |
TargetInterface.trst() |
Perform a JTAG TAP reset. |
TargetInterface.waitForDebugState(timeout) |
|
Wait for the target to enter debug state. If the timeout period expires and exception will be thrown which will be caught by the debugger. | |
Parameters | |
timeout | The maximum time in milliseconds to wait for the target to enter debug state. |