Template:HowToWin

From eLinux.org
Revision as of 18:29, 11 April 2012 by Wmat (talk | contribs) (Porting TinCanTools wiki content.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This guide will walk you through connecting the {{{{{1}}}_PRODUCTLINK}} and the {{{{{2}}}_PRODUCTLINK}} to your Windows PC, and installing and running OpenOCD. This guide was tested with Windows XP and Windows 7. Instructions are identical on 32-bit and 64-bit versions of Windows unless otherwise noted.


{{{{{1}}}_{{{2}}}_CONNECT}}


{{{{{1}}}_{{{2}}}_COMPILEOCDWIN|{{{1}}}|{{{2}}}}}


Running OpenOCD

Now you are ready to run OpenOCD. Open a command line window; if you're not sure how to do this, see Running OpenOCD on Windows. Navigate to the folder containing openocd.exe (the openocd-bin folder you created in the compile guide) and type:

cd C:\openocd-bin
openocd {{{{{1}}}_CFGRELPATH}} {{{{{2}}}_CFGRELPATH}}

{{{{{2}}}_RUNOCDBRIEF_WIN|{{{1}}}}}

Telnet Connection

You cannot enter commands directly to OpenOCD. Open a new command window and type:

telnet localhost 4444

You will should see this prompt:

Telnet win.png

You can give commands to OpenOCD through this prompt. If you don't see the prompt on Windows 7, you may need to enable the Telnet client. See Configuring Windows 7 for OpenOCD.


Common OpenOCD Commands

To see a full list of OpenOCD commands, enter help in the telnet window.

reset

Resets the {{{{{2}}}_DEVICENAME}}. The output of the Reset command should look like this:

{{{{{2}}}_IMG_OCDRESET_WIN}}

halt

Sends a halt request to the {{{{{2}}}_DEVICENAME}}. If the {{{{{2}}}_DEVICENAME}} halts, you will see text output in the telnet window. (If the {{{{{2}}}_DEVICENAME}} is already halted, you will see no output.)

{{{{{2}}}_IMG_OCDHALT_WIN}}

halt [timeout]

You can also use halt followed by a time in milliseconds. OpenOCD waits for the target to halt the specified amount of time, then gives up if the target has not halted. You can use this to avoid OpenOCD hanging because the {{{{{2}}}_DEVICENAME}} fails to halt. For example, to send a halt command with a timeout of one second, type:

halt 1000

resume

Enter resume to end a halt. You will not see any text output in the telnet window.

reg

Displays a numbered list of all of the {{{{{2}}}_DEVICENAME}}'s registers.

{{{{{2}}}_IMG_OCDREG_WIN}}

reg [entry]

Run reg with a register number to display the contents of a register, in hexadecimal. The register number corresponds to the output of the reg command with no arguments, above. You must run the halt command before reading registers.

{{{{{2}}}_IMG_OCDREG0_WIN}}

If you run reg while the {{{{{2}}}_DEVICENAME}} is not halted, you will still see the value stored in the register. However, registers change contents very quickly while the device is running; by the time you see the value, the value actually in the register may be different. If you try to run reg while the device is not halted, you will see this:

{{{{{2}}}_IMG_OCDREGNOTHALTED_WIN}}


reg [entry] [value]

Sets the value of a register. The register number corresponds to the output of the reg command with no arguments, above. Make sure the {{{{{2}}}_DEVICENAME}} is halted (with the halt command) before you change the value of a register!

You can enter registry values in either decimal, by typing a number by itself, or in hexadecimal, by prefacing the value with 0x.

{{{{{2}}}_IMG_OCDREGSET_WIN}}


GDB Debugger

GDB, the GNU Project Debugger is a debugging tool provided with the GNU Compiler Collection (GCC). GDB allows you to stop and start a running program, examine its functioning, and make changes. To install and use GDB with OpenOCD, follow the instructions on the Windows GDB Debugger page below.

Windows GDB Debugger

The GDB debugger page will walk you through installing GDB for use with OpenOCD, and loading and testing a simple program.