# loadrun.TWL

## Description

This command is for TWL ROMs. See `loadrun` for details on NITRO ROMs.

`loadrun.TWL` is a tool for downloading and executing specified binary data on devices like the IS-TWL-DEBUGGER. This tool can be run quickly from command line because there is no need to run the debugger software.

## Using the Tool

### Start Command

`% loadrun.TWL [OPTION]... [TWLSRLFILE]`

`TWLSRLFILE` is the ROM file to execute. .srl files can be specified.

Specifying the option `-L or --list` will display a list of identifiable devices that are currently connected. The following is an example of a list that may display.

> `---- Connected devices:
> 0: [IS-TWL-DEBUGGER] serial:10000995
> 1: [IS-TWL-DEBUGGER] serial:10000996
> 2 device(s) found.`

`serial` is the serial number specified with the `-s` option. [IS-TWL-DEBUGGER] is the type of device. If the device is being used by some other application like the IS-TWL-DEBUGGER software, `loadrun.TWL` will not be able to find the device.

If `-l` or `--lap` is specified, the time from the start of execution is added to the beginning of each debug output line in {minutes:seconds} format when the ROM file output is displayed using a function such as `OS_Printf`. An example of this display is given below.

> `{0:01}Program started
> {0:01}--- heap init
> {0:02}x=14 y=50
> {0:04}`

If the option `-N` or `--nitro` is specified, applications can be run on the IS-TWL-DEBUGGER in NITRO mode. If nothing is specified, the application will run in TWL mode. In order to use this feature, version 0.64 or later of the IS-TWL-DEBUGGER software is required.

If the `-A` or `--architecture` option is specified, either <A9> or <A7> will be prepended to the beginning of each line of debug output (output from functions like `OS_Printf()`). This indicates the architecture of the processor that generated the output (ARM7 or ARM9).

If the `-n` or `--console` option is specified, <0>-<3> will be prepended to the beginning of each line of output to indicate which window functions like `OS_Printf()` are printing to. Four output windows are available with IS-TWL-DEBUGGER. The destination can be set directly using functions like `OS_FPrintf()`. If not set directly, the output destination will be determined by `OS_SetPrintOutput()`.

If options are specified to distinguish both the processor and the output window, this information will be grouped together (for example <A9:0> or <A7:2>).

The `-s` and `--serial` options take numeric values as arguments. This option specifies the serial number of the device that will download the `.srl` file. Data is downloaded to the device with that specified serial number. Although an unlikely case, if more than one device has the same serial number, data will be downloaded to the first device found. Note that if a serial number such as 04070680 is displayed in the device list when using the `-L` option, you can omit the initial zero and specify the device using 4070680. You can omit all but the lower-order digits of the serial number, as long as the digits you specify are unique among the devices you are using. For example, let's assume you have two devices connected whose serial numbers are 10000123 and 10000453. If you want to indicate the former, you don't have to specify the entire number (`-s10000123`) -- specifying either `-s123` or `-s23` will work just fine.

The `-t` and `--timeout` options take numeric values as arguments. This option is used to specify the display timeout in units of seconds. After executing the .srl file and receiving the latest `OS_Printf()` data, execution is forced to terminate if more data does not arrive transmitted within the specified amount of time. If zero is specified, no timeout occurs. The same holds if this option is not specified.

The `-T` and `--exec-timeout` options take numeric values as arguments. This option is used to specify the execution timeout in units of seconds. Execution is forced to terminate if the number of specified seconds has elapsed since execution of the `.srl` file began. If zero is specified, there is no execution timeout. The same holds if this option is not specified.

The `-a` and `--abort-string` options specify the string that ends execution. If the specified text appears at the beginning of the line, execution is forced to terminate. No determination is made until a carriage return is encountered.Gaps of time between displays is fine.

For example, if the termination string is "ABORT," any of the following

> `OS_Printf("ABORT\n")
> OS_Printf("ABORTING\n")
> OS_Printf("ABORT\nQUIT\n")
> OS_Printf("ABOR");OS_Sleep(1000);OS_Printf("T\n");`

will result in termination, but the following

> `OS_Printf(" 　ABORT\n") // Spaces in front
> OS_Printf("ABO\nRT\n") // Line break in the middle
> OS_Printf("A B O R T\n") // With spaces included so that it the string is not "ABORT"`

will not cause termination. In addition,

> `OS_Printf("ABORT")`

will not immediately terminate because a line break has not been added. Termination will occur after `OS_Printf("\n")`, `OS_Printf(" SOON\n")`, or other line feed code is encountered later.

The `-c` and `--card-slot` options take arguments. ON or OFF may be specified as arguments. This option is used to lock the card slot during execution. OFF is used if unspecified. (This option has not yet been implemented, so please do not use it. Its specification may also change in the future.)

The `-c` and `--cartridge-slot` options take arguments. ON or OFF may be specified as arguments. This option locks the cartridge slot during execution. OFF is used if unspecified. (This option has not yet been implemented, so please do not use it. Its specification may also change in the future.)

If the `-q` or `--quiet` option is specified, quiet mode is used, and only error messages will be output.

If the `-v` or `--verbose` option is specified, detailed operation descriptions are displayed.

The `-h` or `--help` options display simple instructions.

The `--version` option displays the command version.

###
Termination Conditions

- Calling `OS_Exit()` on the TWL will cause the specified text string to be displayed and result in program HALT status. If `loadrun.TWL` accepts this display text string data, the termination status will be set to the value specified by `OS_Exit()` and `loadrun.TWL` will terminate.

- The program will end if the string specified by the user as an option is displayed.

- The program will end if the execution time exceeds the execution timeout specified by the user as an option.

- The program will end if there is no display for a longer period of time than the display timeout specified by the user as an option.

- The program will also end if CTRL-C or a similar command is used to stop the program.

###
Debugger Operation Prohibited Flag

Some `srl` files may prohibit being run on a debugger. This is controlled by a bit in a certain place within the ROM header that is embedded in the `.srl` file. Attempting to load a prohibited file with `loadrun.TWL` will halt with an error.

## Location

`$TWLSDK/tools/bin/loadrun.TWL.exe`

## See Also

`nitrorun.TWL
OS_Exit
loadrun`

## Revision History

2008/06/12 Added a description of running a hybrid ROM in NITRO mode (-n option).
2008/04/28 Added a description of the debugger prohibition flag.
2008/01/12 Initial version.

CONFIDENTIAL