<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://elinux.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://elinux.org/index.php?title=Running_OpenOCD_on_Linux&amp;feed=atom&amp;action=history</id>
		<title>Running OpenOCD on Linux - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://elinux.org/index.php?title=Running_OpenOCD_on_Linux&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=Running_OpenOCD_on_Linux&amp;action=history"/>
		<updated>2013-06-18T05:59:16Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.22alpha</generator>

	<entry>
		<id>http://elinux.org/index.php?title=Running_OpenOCD_on_Linux&amp;diff=118874&amp;oldid=prev</id>
		<title>Wmat: Adding proper categories</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=Running_OpenOCD_on_Linux&amp;diff=118874&amp;oldid=prev"/>
				<updated>2012-04-18T03:25:36Z</updated>
		
		<summary type="html">&lt;p&gt;Adding proper categories&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 03:25, 18 April 2012&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 143:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 143:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*run the OpenOCD command to set the Flyswatter's clock speed&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*run the OpenOCD command to set the Flyswatter's clock speed&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*run commands in ''hammer.cfg'' (which loads ''samsung_s3c2410.cfg'' and runs commands found there)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*run commands in ''hammer.cfg'' (which loads ''samsung_s3c2410.cfg'' and runs commands found there)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:TinCanTools]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:OpenOCD]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Wmat</name></author>	</entry>

	<entry>
		<id>http://elinux.org/index.php?title=Running_OpenOCD_on_Linux&amp;diff=111794&amp;oldid=prev</id>
		<title>Wmat: Porting the TCT content.</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=Running_OpenOCD_on_Linux&amp;diff=111794&amp;oldid=prev"/>
				<updated>2012-03-30T00:35:30Z</updated>
		
		<summary type="html">&lt;p&gt;Porting the TCT content.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;''This guide contains general information on running OpenOCD, but all examples use the {{HAMMER_PRODUCTLINK}}. For examples using the {{BEAGLEBOARD_PRODUCTLINK}}, see [[Running OpenOCD on Linux with the Beagleboard]].''&lt;br /&gt;
&lt;br /&gt;
[[OpenOCD]] provides a command line interface for interacting with embedded devices. To use [[OpenOCD]] you will need to run it from the command line. This guide includes basic information about using the Ubuntu command line interface, the terminal window. If you are already proficient with the command line, you can find information specific to [[OpenOCD]] under the '''OpenOCD Config Files''' and '''Telnet Connection''' headings.&lt;br /&gt;
&lt;br /&gt;
This guide was written for the Ubuntu 10.04 LTS release. You may encounter differences on other Linux distributions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Opening the Command Prompt==&lt;br /&gt;
&lt;br /&gt;
Open the '''Applications''' menu from the menu bar on your desktop, and choose '''Accessories &amp;gt; Terminal.''' Ubuntu should open black window with white text and a prompt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Command Prompt Basics - Paths and Navigation==&lt;br /&gt;
&lt;br /&gt;
The command prompt displays your current directory location. You will need to navigate to the [[OpenOCD]] directory to run it. To change directories, type '''cd'' followed by a file path. File paths can be absolute...&lt;br /&gt;
&lt;br /&gt;
 cd /home&lt;br /&gt;
 cd /usr/local/lib&lt;br /&gt;
&lt;br /&gt;
...or relative...&lt;br /&gt;
&lt;br /&gt;
 cd lib/mingw&lt;br /&gt;
 cd TinCanTools/openocd&lt;br /&gt;
&lt;br /&gt;
Absolute paths are from your root directory, and begin with a slash. Relative paths are from the current directory and do not begin with a slash. File paths are case sensitive.&lt;br /&gt;
&lt;br /&gt;
If you need to navigate to your home directory, type '''cd''' by itself like this...&lt;br /&gt;
&lt;br /&gt;
 cd&lt;br /&gt;
&lt;br /&gt;
If you need to go back to the parent of the current directory, you can type...&lt;br /&gt;
&lt;br /&gt;
 cd ..&lt;br /&gt;
&lt;br /&gt;
You can even use this as part of a longer relative path. For example...&lt;br /&gt;
&lt;br /&gt;
 cd ../../TinCanTools&lt;br /&gt;
&lt;br /&gt;
...would take you up two levels, and then into a folder called TinCanTools.&lt;br /&gt;
&lt;br /&gt;
To reach your root directory, you can type:&lt;br /&gt;
&lt;br /&gt;
 cd /&lt;br /&gt;
&lt;br /&gt;
If you need to include your home directory in a path ('''home/USERNAME''', replacing USERNAME with the name of your account), you can type it out as normal, or you can use the tilde key ('''~''') as shorthand. For example:&lt;br /&gt;
&lt;br /&gt;
 cd /home/USERNAME/TinCanTools&lt;br /&gt;
 cd ~/TinCanTools&lt;br /&gt;
&lt;br /&gt;
...both take you to the same place.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running OpenOCD==&lt;br /&gt;
&lt;br /&gt;
Navigate to the directory containing your openocd executable. In the folder with the executable, make sure you also see three directories called '''interface/''', '''board/''', and '''target/'''. If you don't see these directories, create a new folder somewhere on your computer containing '''openocd''', '''interface/''', '''board/''', and '''target/'''. (If you have just compiled OpenOCD yourself, you can find the executable in '''openocd/src''' or '''openocd-{{OPENOCD_VERNUM}}/src''', and the three directories you need in '''openocd/tcl''' or '''openocd-{{OPENOCD_VERNUM}}/tcl'''.&lt;br /&gt;
&lt;br /&gt;
In the directory containing the openocd executable, type...&lt;br /&gt;
&lt;br /&gt;
 sudo openocd -f path_to/cfg_file [-f path_to/other_cfg_file]&lt;br /&gt;
&lt;br /&gt;
Replace ''path_to/cfg_file'' and so on with the .cfg files for your hardware devices. For example, to run OpenOCD for the Flyswatter2 and the hammer, you would use:&lt;br /&gt;
&lt;br /&gt;
 sudo openocd -f interface/flyswatter2.cfg -f board/hammer.cfg&lt;br /&gt;
&lt;br /&gt;
For the original Flyswatter and the Beagleboard, you would use:&lt;br /&gt;
&lt;br /&gt;
 sudo openocd -f interface/flyswatter.cfg -f board/ti_beagleboard.cfg&lt;br /&gt;
&lt;br /&gt;
See below for more information on config files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Telnet Connection==&lt;br /&gt;
&lt;br /&gt;
[[OpenOCD]] runs as a daemon. It accepts connections from other programs, but does not provide any means for you to give it commands directly. Once [[OpenOCD]] is running on your computer you will need to connect to it through another program, such as telnet.&lt;br /&gt;
&lt;br /&gt;
To run telnet and connect to [[OpenOCD]], open a new command prompt. From any directory, type:&lt;br /&gt;
&lt;br /&gt;
 telnet localhost 4444&lt;br /&gt;
&lt;br /&gt;
You may need to run telnet as root:&lt;br /&gt;
&lt;br /&gt;
 sudo telnet localhost 4444&lt;br /&gt;
&lt;br /&gt;
You should see a simple prompt ('''&amp;gt;'''). From this prompt you will be able to send commands to [[OpenOCD]]. To exit the telnet prompt, press '''CTRL + C'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==OpenOCD and Permissions==&lt;br /&gt;
&lt;br /&gt;
[[OpenOCD]] needs administrator privileges to interact with your USB drivers. Even Linux users with administrator privileges do not typically log on with those privileges active. However, Linux provides commands to run another command as the root user. On Ubuntu, this command is ''sudo''. To run a program as root, type ''sudo'', then a space, then the name of the program. For example...&lt;br /&gt;
&lt;br /&gt;
 openocd -f interface/flyswatter.cfg -f board/hammer.cfg&lt;br /&gt;
&lt;br /&gt;
...runs [[OpenOCD]] with your user permissions, and likely prevents [[OpenOCD]] from interacting with libUSB. However...&lt;br /&gt;
&lt;br /&gt;
 sudo openocd openocd -f interface/flyswatter.cfg -f board/hammer.cfg&lt;br /&gt;
&lt;br /&gt;
...runs [[OpenOCD]] as root, with full permission to access your USB drivers.&lt;br /&gt;
&lt;br /&gt;
When you use the '''sudo''' command, Linux will prompt you for the root user's password. If you do not have access to this password, contact your system administrator. You can also configure Linux to allow [[OpenOCD]] to access specific hardware devices without ''sudo''. See [[Accessing Devices without Sudo]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Search Path==&lt;br /&gt;
&lt;br /&gt;
[[OpenOCD]] searches in its own directory first for config files. This guide assumes that the '''openocd''' binary is in a directory containing three folders, called '''interface/''', '''board/''', and '''target/'''. If you have just compiled OpenOCD yourself, you will need to move the '''openocd''' executable somewhere where it can find '''interface/''', '''board/''', and '''target''', as described in the compilation guides on this page.&lt;br /&gt;
&lt;br /&gt;
You can also tell OpenOCD where to look for '''interface/''', '''board/''', and '''target/''' with the ''-s'' flag, like this:&lt;br /&gt;
&lt;br /&gt;
 sudo openocd -s ../tcl -f interface/flyswatter.cfg -f board/hammer.cfg&lt;br /&gt;
&lt;br /&gt;
This would tell OpenOCD to look for '''interface/''' and '''board/''' one level up in a directory called '''tcl/'''. For more information, see [[OpenOCD Config File Paths]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==OpenOCD Config Files==&lt;br /&gt;
&lt;br /&gt;
Each time you use [[OpenOCD]] you will need to configure it by passing it paths to configuration files. In the [[OpenOCD]] {{OPENOCD_VERNUM}} release, these files are found in '''openocd-{{OPENOCD_VERNUM}}/tcl''' and its subdirectories. From the '''tcl''' directory, the configuration file for the Flyswatter is at '''interface/flyswatter.cfg'''. The file for the TinCanTools Hammer is at '''board/hammer.cfg'''. If your copy of [[OpenOCD]] includes support for the Flyswatter2, its config file is at '''interface/flyswatter2.cfg'''.&lt;br /&gt;
&lt;br /&gt;
When you start [[OpenOCD]], you tell it to use the config files for your hardware with the '''-f''' switch, like this:&lt;br /&gt;
&lt;br /&gt;
 sudo openocd -f path_to/cfg_file [-f path_to/other_cfg_file]&lt;br /&gt;
&lt;br /&gt;
For example, suppose you want to run [[OpenOCD]] for the Flyswatter2 and the Hammer. The current directory contains the [[OpenOCD]] executable and the '''board''', '''interface''', and '''target''' directories provided with the OpenOCD source. You would type:&lt;br /&gt;
&lt;br /&gt;
 sudo openocd -f interface/flyswatter2.cfg -f board/hammer.cfg&lt;br /&gt;
&lt;br /&gt;
Be aware that config files may contain paths to other config files. For example '''hammer.cfg''', the config file for the TinCanTools Hammer, contains this line:&lt;br /&gt;
&lt;br /&gt;
 source [find target/samsung_s3c2410.cfg]&lt;br /&gt;
&lt;br /&gt;
When you run [[OpenOCD]] with the '''hammer.cfg''' file, [[OpenOCD]] searches from the current directory for '''target/samsung_s3c2410.cfg'''. If the current directory does not contain [[OpenOCD]]'s '''target''' directory, it may not find the '''samsung_s3c2410.cfg''' file, or it may find a different '''samsung_s3c2410.cfg''' file elsewhere on your system. You can avoid this by giving OpenOCD the path to your config files. For more information, see [[OpenOCD Config File Paths]].&lt;br /&gt;
&lt;br /&gt;
If you have compiled OpenOCD yourself, the easiest way to avoid these issues is to copy the '''openocd''' binary from your '''openocd-{{OPENOCD_VERNUM}}/src''' directory to your '''openocd-{{OPENOCD_VERNUM}}/tcl''' directory. To run [[OpenOCD]], navigate to '''openocd-{{OPENOCD_VERNUM}}/tcl''' in the command terminal and run [[OpenOCD]] as above. You can also create a new directory anywhere on your system, and copy the '''openocd''' binary and the contents of '''openocd-{{OPENOCD_VERNUM}}/tcl''' to the new directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running Commands on Startup: the ''-c'' Flag==&lt;br /&gt;
&lt;br /&gt;
You can instruct OpenOCD to run a command on startup with the ''-c'' flag. For example:&lt;br /&gt;
&lt;br /&gt;
 sudo openocd -f interface/flyswatter.cfg -c &amp;quot;jtag_khz 6000&amp;quot; -f board/hammer.cfg&lt;br /&gt;
&lt;br /&gt;
The ''jtag_khz'' command sets the Flyswatter's clock speed. Starting OpenOCD like this does the following, in order:&lt;br /&gt;
&lt;br /&gt;
*run commands in ''flyswatter.cfg''&lt;br /&gt;
*run the OpenOCD command to set the Flyswatter's clock speed&lt;br /&gt;
*run commands in ''hammer.cfg'' (which loads ''samsung_s3c2410.cfg'' and runs commands found there)&lt;/div&gt;</summary>
		<author><name>Wmat</name></author>	</entry>

	</feed>