The target-interface system uses CrossStudio's JavaScript (ECMAScript) interpreter to support board-specific and target-specific behavior.

The main use for this is to support non-standard target and board reset schemes and to configure the target after reset using the Reset Script and Loader Reset Script facilities, described later.

The target script system can also be used to carry out target-specific operations when the target interface connects or disconnects, or when the debugger uses the Connect, Disconnect, Stop, and Run scripts, described later.

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 whose project property File Type is 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 defined in this script file.

Attach script

The Attach Script property in the Target project-property group specifies the script to be 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 arm_target_script_TargetInterface for a description of the TargetInterface object the attach script uses to access the target hardware.

Connect script

The Connect Script property in the Target project-property group specifies the script to be executed when the user connects to the target interface.

See arm_target_script_TargetInterface for a description of the TargetInterface object the connect script uses to access the target hardware.

Disconnect script

The Disconnect Script property of the Target project-property group specifies the script to be executed when the user disconnects from the target interface.

See arm_target_script_TargetInterface for a description of the TargetInterface object the disconnect script uses to access the target hardware.

Loader reset script

The Loader Reset Script property in the Target project-property group specifies the script to be executed in order to reset and configure the target prior to downloading a loader application. It does essentially the same job as the Reset Script property, but it will be used only prior to downloading a loader application, thereby allowing a loader to have a different reset script than the application. If this property is not defined, the script defined by the Reset Script property will be used.

See arm_target_script_TargetInterface for a description of the TargetInterface object the loader reset script uses to access the target hardware.

Reset script

The Reset Script property in the Target project-property group defines a script to execute in order 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 target memory by accessing the configuration registers directly. See arm_target_script_TargetInterface for a description of the TargetInterface object the reset script uses 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

Run script

The Run Script property in the Target Script Options project-property group is used to define a script to be 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 is carried out after the application has hit a breakpoint or was 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, for example, to re-enable caches previously disabled by the stop script.

See arm_target_script_TargetInterface for a description of the TargetInterface object the run script uses to access the target hardware.

Stop script

The Stop Script property in the Target Script Options 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 is 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, because the script can disable and flush the caches, giving the debugger access to the current memory state.

See arm_target_script_TargetInterface for a description of the TargetInterface object the stop script uses to access the target hardware.

Debug Interface Reset Script

The Debug Interface Reset Script property held in the Target Script Options project property groups is used to define a script that is executed when CrossWorks resets the debug interface. This should not affect the target processor and will be executed for example when the debugger attaches to a running target. Use this script if you don't want CrossWorks to execute a TRST to reset the JTAG TAP, for example if the device has a JTAG router.

See arm_target_script_TargetInterface for a description of the TargetInterface object which is used by the debug interface reset script to access the target hardware.

TAP Reset Script

The TAP Reset Script property held in the Target Script Options project-property groups is used to define a script that is executed when CrossWorks resets the JTAG connection when exploring the JTAG chain. This script can be used to configure a JTAG router that would be reset when the standard TRST sequence is applied.

See arm_target_script_TargetInterface for a description of the TargetInterface object the TAP Reset Script uses to access the target hardware.