OpenOCD Ubuntu Package

As an alternative to compiling OpenOCD from source, OpenOCD is available via Ubuntu’s Advanced Packaging Tool (APT). Ubuntu 10.04 users can download and install OpenOCD using the apt-get command.

 

Flyswatter2 Support

This package is based on the OpenOCD 0.4.0 release available at http://prdownload.berlios.de/openocd/openocd-0.4.0.tar.gz. It does not include support for the TinCanTools Flyswatter2. To compile OpenOCD with Flyswatter2 support, see Compiling OpenOCD Linux for Flyswatter2.

 

Installing the OpenOCD Package

Open a terminal window (Applications menu > Accessories > Terminal) and type:

sudo apt-get install openocd

The Ubuntu APT will install OpenOCD and its config files to your computer. As with any command using sudo, you will need an administrator password to run this command.

 

Linking to /usr/share/openocd

The package installs config files to /usr/share/openocd/scripts, but OpenOCD looks for config files in /usr/local/share/openocd/scripts. Fix that now by creating a symbolic link in /usr/local/share to /usr/share/openocd. In the terminal window, type:

cd /usr/local/share
sudo ln -s /usr/share/openocd .

OpenOCD will now be able to find its config files. For more information on how OpenOCD searches for config files, see OpenOCD Config File Paths.

 

Running OpenOCD

You can run OpenOCD from a terminal window from any directory. Installing OpenOCD from the APT allows users to run OpenOCD without sudo. (If you compiled OpenOCD yourself you would need to take special steps to allow users to use OpenOCD without sudo.

In a terminal window, type:

openocd -f path_to/file.cfg [-f another_path_to/file2.cfg]

For example, to run OpenOCD for the TinCanTools Flyswatter and Hammer, type:

openocd -f interface/flyswatter.cfg -f board/hammer.cfg

To get started, see Running OpenOCD on Linux. If you encounter errors, see OpenOCD Troubleshooting.

Compiling OpenOCD v04 WinXP D2XX

This guide will compile OpenOCD 0.4.0 on Windows XP with the FTD2XX driver library, for use with the TinCanTools Flyswatter. The executable created with this guide is compatible with Windows XP and Windows 7. The process is identical on 32 and 64 bit versions of Windows.

This guide makes use of the GCC cross-compiler added to Cygwin on June 2, 2011. The cross-compiler makes compiling OpenOCD for Windows much easier. Older instructions can be found at Compiling OpenOCD for Windows XP (FTD2XX) – Pre June 2011.

 

 

Installing Cygwin

Download and install Cygwin 1.7.9 from http://www.cygwin.com. Cygwin provides a GNU development environment for Windows, which will allow you to compile OpenOCD using the GNU Compiler Collection (GCC). You will not need Cygwin to run OpenOCD. The Cygwin installer is available at http://cygwin.com/install.html.

Installing Cygwin Packages

If you already have Cygwin installed, this guide recommends that you delete it and reinstall completely. Close all Cygwin windows and services and delete your Cygwin directory (by default, C:\cygwin). Then find any packages downloaded but not installed and delete them as well. You set the location of these files when you installed Cygwin. By default they appear in My Documents/Downloads. If you don’t wish to reinstall Cygwin you can find more information at http://cygwin.com/ml/cygwin/2011-06/msg00021.html.

In the Cygwin installer you will be prompted to select additional packages to install. Install the following optional packages, found under the Devel heading:

 

  • autoconf (all packages)
  • automake (all packages)
  • binutils
  • gcc
  • gcc-core
  • gcc-g++
  • git
  • libtool
  • libusb-1.0
  • libusb-win32
  • libusb-devel
  • make
  • mingw-binutils
  • mingw-gcc
  • mingw-gcc-core
  • mingw-gcc-g++
  • mingw-pthreads
  • mingw-runtime
  • patch (found under the Utils heading)

Check all of these packages and click Next. Cygwin will inform you that it must install additional packages to satisfy the above packages’ dependencies. Allow it to do so. Make sure that the Select Required Packages checkbox is checked before you proceed.

 

Installing libusb for the Flyswatter

Libusb is a usb driver library you will need to communicate with the Flyswatter. You will need a newer version of libusb than the one distributed through the Cygwin installer, and you will need libusb for Windows as well. Download libusb-win32-1.2.4.0 from http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/libusb-win32-bin-1.2.4.0.zip/download. Open the zip archive and extract the contents to C:\cygwin\home.

Navigate to the folder \libusb-win32-bin-1.2.4.0\lib\gcc. Copy the file libusb.a to C:\cygwin\lib and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

Navigate to \libusb-win32-bin-1.2.4.0\include. Copy the file usb.h to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.

 

Installing FTD2XX

Download version 2.08.14 of the D2XX Windows drivers from http://www.ftdichip.com/Drivers/D2XX.htm. Direct link is here: http://www.ftdichip.com/Drivers/CDM/CDM20814_WHQL_Certified.zip. Extract the contents to C:\cygwin\home\ftd2xx.

In Windows Explorer, open the ftd2xx folder and find the file ftd2xx.h. Copy this file to C:\cygwin\usr\include and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\include.

Installing FTD2XX

Navigate to C:\cygwin\home\ftd2xx\i386 and find the file ftd2xx.lib. Copy it, rename the copy ftd2xx.a and copy the new file to C:\cygwin\usr\local\lib and C:\cygwin\usr\i686-pc-mingw32\sys-root\mingw\lib.

Plug the Flyswatter into your computer’s USB port. The Windows Found New Hardware Wizard should appear. Choose “No, not this time” to decline to connect to Windows Update. On the next screen, choose “Install from a list of specific location.” On the third screen, choose “Search for the best drivers in these locations,” check “Include this location in the search,” and enter C:\cygwin\home\ftd2xx.

Click Next. Windows should find and install the FTDI drivers. If you see a warning that the drivers have not passed Windows Logo testing, choose “Install Anyway.”

The Found New Hardware Wizard should appear twice. The second time the wizard appears, repeat the process exactly as above.

 

A Note about Make Errors

With the latest version of Cygwin and its associated packages you may encounter errors with make commands. You may be able to fix these errors simply by powering through; if make gives an error, run make again. If it doesn’t halt again in the same place, you can likely proceed without worry.

You may also encounter errors with the bootstrap command used to compile OpenOCD below. Try running bootstrap again. If it passes the point where it previously halted everything is most likely fine.

 

Downloading OpenOCD

Download the OpenOCD 0.4.0 source from http://prdownload.berlios.de/openocd/openocd-0.4.0.zip and extract it to /home/openocd-0.4.0.

 

Installing the Flyswatter 2 / Flyswatter 3 Patch (Optional)

The OpenOCD Flyswatter 3 beta patch provides support for the Flyswatter3 and Flyswatter2, a config file for the Olimex PIC-P32MX development board, and an updated config file for the TinCanTools Hammer. Download the file Media:Openocd-fs3-b0.1.patch. (Right click the link and select Save As.) Save the file to your new openocd-0.4.0 directory.

In the Cygwin console window, navigate to the patch file and patch the source as follows:

cd ~/openocd-0.4.0patch -p1 -i Openocd-fs3-b0.1.patch

For more information on the config files added by this patch, see OpenOCD Config Files.

 

Compiling OpenOCD

In the Cygwin command window, navigate to the new folder containing the OpenOCD source and compile as follows.

cd /home/openocd-0.4.0./configure --disable-werror --enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=../ftd2xx --build=i686-pc-cygwin --host=i686-pc-mingw32make

 

Preparing to Run OpenOCD

Navigate to C:\cygwin\home\openocd\src to find openocd.exe. The executable can be run from the Windows command line and does not require Cygwin.

You can run openocd from C:\cygwin\home\openocd\src, but you may encounter problems with configuration files. For a more in-depth discussion of these issues, see OpenOCD Config File Paths. This guide recommends that you create a new folder containing OpenOCD and its config files. Go to Start Menu > My Computer and open your C: drive. Right-click anywhere in the C: drive window and select New > Folder. Rename the new folder openocd-bin.

In another Windows Explorer window, open C:\cygwin\home\openocdcl. Click and drag to select all the contents of the folder. Right-click on any file and select Copy. Open C:\openocd-bin, right-click anywhere, and select Paste.

Now go to C:\cygwin\home\openocd\src and copy openocd.exe to C:\openocd-bin. The folder should now contain the following files and folders:

boardchipcpldcpuopenocd.exeinterfacetargettestbitsbytes.tclmemory.tclmmr_helpers.tclreadable.tcl

You can now run OpenOCD from C:\openocd-bin. To get started running OpenOCD, see Running OpenOCD on Windows.

Running OpenOCD on Linux

This guide contains general information on running OpenOCD, but all examples use the Hammer. For examples using the Beagleboard, see Running OpenOCD on Linux with the Beagleboard.

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.

This guide was written for the Ubuntu 10.04 LTS release. You may encounter differences on other Linux distributions.

 

Opening the Command Prompt

Open the Applications menu from the menu bar on your desktop, and choose Accessories > Terminal. Ubuntu should open black window with white text and a prompt.

 

Command Prompt Basics – Paths and Navigation

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…

cd /home
cd /usr/local/lib

…or relative…

cd lib/mingw
cd TinCanTools/openocd

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.

If you need to navigate to your home directory, type cd by itself like this…

cd

If you need to go back to the parent of the current directory, you can type…

cd ..

You can even use this as part of a longer relative path. For example…

cd ../../TinCanTools

…would take you up two levels, and then into a folder called TinCanTools.

To reach your root directory, you can type:

cd /

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:

cd /home/USERNAME/TinCanTools
cd ~/TinCanTools

…both take you to the same place.

 

Running OpenOCD

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-0.5.0/src, and the three directories you need in openocd/tcl or openocd-0.5.0/tcl.

In the directory containing the openocd executable, type…

sudo openocd -f path_to/cfg_file [-f path_to/other_cfg_file]

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:

sudo openocd -f interface/flyswatter2.cfg -f board/hammer.cfg

For the original Flyswatter and the Beagleboard, you would use:

sudo openocd -f interface/flyswatter.cfg -f board/ti_beagleboard.cfg

See below for more information on config files.

 

Telnet Connection

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.

To run telnet and connect to OpenOCD, open a new command prompt. From any directory, type:

telnet localhost 4444

You may need to run telnet as root:

sudo telnet localhost 4444

You should see a simple prompt (>). From this prompt you will be able to send commands to OpenOCD. To exit the telnet prompt, press CTRL + C.

 

OpenOCD and Permissions

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…

openocd -f interface/flyswatter.cfg -f board/hammer.cfg

…runs OpenOCD with your user permissions, and likely prevents OpenOCD from interacting with libUSB. However…

sudo openocd openocd -f interface/flyswatter.cfg -f board/hammer.cfg

…runs OpenOCD as root, with full permission to access your USB drivers.

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.

 

Search Path

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.

You can also tell OpenOCD where to look for interface/, board/, and target/ with the -s flag, like this:

sudo openocd -s ../tcl -f interface/flyswatter.cfg -f board/hammer.cfg

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.

 

OpenOCD Config Files

Each time you use OpenOCD you will need to configure it by passing it paths to configuration files. In the OpenOCD 0.5.0 release, these files are found in openocd-0.5.0/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.

When you start OpenOCD, you tell it to use the config files for your hardware with the -f switch, like this:

sudo openocd -f path_to/cfg_file [-f path_to/other_cfg_file]

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:

sudo openocd -f interface/flyswatter2.cfg -f board/hammer.cfg

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:

source [find target/samsung_s3c2410.cfg]

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.

If you have compiled OpenOCD yourself, the easiest way to avoid these issues is to copy the openocd binary from your openocd-0.5.0/src directory to your openocd-0.5.0/tcl directory. To run OpenOCD, navigate to openocd-0.5.0/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-0.5.0/tcl to the new directory.

 

Running Commands on Startup: the -c Flag

You can instruct OpenOCD to run a command on startup with the -c flag. For example:

sudo openocd -f interface/flyswatter.cfg -c "jtag_khz 6000" -f board/hammer.cfg

The jtag_khz command sets the Flyswatter’s clock speed. Starting OpenOCD like this does the following, in order:

  • run commands in flyswatter.cfg
  • run the OpenOCD command to set the Flyswatter’s clock speed
  • run commands in hammer.cfg (which loads samsung_s3c2410.cfg and runs commands found there)

Compiling OpenOCD v06 Linux

This guide will compile OpenOCD 0.6.0 for Ubuntu 10.04 with the LibFTDI driver library, for use with the TinCanTools Flyswatter, Flyswatter2, and Flyswatter3. Version 0.6.0 is the version of OpenOCD currently in development. For instructions on compiling with the most recent release code, see Compiling OpenOCD Linux.

 

OpenOCD 0.6.0 vs the 0.5.0 Release

This guide uses the most recent version of the OpenOCD source currently in development. Unlike the 0.5.0 release the development version includes support for the Flyswatter2 and Flyswatter3, so you won’t need to download or apply a patch before compiling. However, the development code is subject to change at any time. If you encounter problems with this option, try the OpenOCD 0.5.0 instructions in Compiling OpenOCD Linux instead.

 

Installing Packages

You will need to install several packages to compile and run OpenOCD. Open a terminal window (Applications menu > Accessories > Terminal) and type:

sudo apt-get install libtool autoconf texinfo libusb-dev

If you prefer to compile libusb yourself, you can find the source at http://sourceforge.net/projects/libusb/files/libusb-1.0/.

 

Downloading and Compiling libFTDI

libFTDI is an open source library that enables you to talk to FTDI chips like: FT232BM, FT245BM, FT245R, FT2232C, FT2232D and FT2232H. You will need libFTDI to compile OpenOCD. Download libftdi-0.19.tar.gz from:http://www.intra2net.com/en/developer/libftdi/download.php and extract it to your home directory (/home/USERNAME, replacing USERNAME with your username).

Navigate to home/USERNAME/libftdi-0.19/src, and copy ftdi.h to your /usr/include directory. Then create a symbolic link to ftdi.h in /usr/local/include. In the terminal window:

cd ~/libftdi-0.19/srcsudo cp ftdi.h /usr/includecd /usr/local/includesudo ln -s /usr/include/ftdi.h ftdi.h

Return to your libftdi-0.19 directory and compile.

cd ~/libftdi-0.19./configuremakesudo make install

This will install the necessary library files to /usr/local/lib. Navigate to /usr/lib and create symbolic links to the new files.

cd /usr/libsudo ln -s /usr/local/lib/libftdi.a libftdi.asudo ln -s /usr/local/lib/libftdi.la libftdi.lasudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so.1.19.0sudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.sosudo ln -s /usr/local/lib/libftdi.so.1.19.0 libftdi.so.1

 

Downloading OpenOCD

Git is version control software distributed with Ubuntu. You can use git to download the current development code from the OpenOCD git repository at sourceforge.net. In the terminal window, navigate to your home directory and make sure you don’t already have a directory there named openocd/. (Downloading with git will create a directory called openocd/ containing the OpenOCD source. If you already have a directory called openocd/ either rename it or navigate to a different directory before you proceed.) Then download OpenOCD with the following command:

cd ~git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd

There should now be a folder in your home directory called openocd/.

 

Compiling OpenOCD

In the terminal window, navigate to the new folder containing the OpenOCD source and compile as follows.

cd ~/openocdsudo ./bootstrapsudo ./configure --enable-maintainer-mode --disable-werror --enable-ft2232_libftdisudo makesudo make install

Navigate to /home/USERNAME/openocd/src to find the openocd binary. You will need superuser privileges (the sudo command) to run OpenOCD.

 

Preparing to Run OpenOCD

You can run openocd from /home/USERNAME/openocd/src, but you may encounter problems with configuration files. For a more in-depth discussion of these issues, see OpenOCD Config File Paths. This guide recommends that you create a new directory containing OpenOCD and its config files.

Create a new directory in /home/USERNAME called openocd-bin, and copy the openocd binary and the contents of /home/USERNAME/openocd/tcl to the new directory. You can do this from the terminal window with the collowing commands:

cd ~mkdir openocd-bincd ~/openocd/tclcp -r * ~/openocd-bincd ~/openocd/srccp openocd ~/openocd-bin

openocd-bin should now contain the following files and subdirectories:

boardchipcpldcpuopenocdinterfacetargettestbitsbytes.tclmem_helper.tclmemory.tclmmr_helpers.tcl

You can now run OpenOCD from /home/USERNAME/openocd-bin. To get started running OpenOCD, see Running OpenOCD on Linux.

Running OpenOCD on Windows

 

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 Windows command line. 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.

 

Opening the Command Prompt

Open the Start Menu and click on Run… A small dialog box will appear. Type:

cmd

…and click OK. In Windows 7/Vista, the Run command does not appear in the Start Menu by default. To enable it, see Configuring Windows 7 for OpenOCD.

 

Command Prompt Basics – Paths and Navigation

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…

cd \Program Files\TinCanTools
cd C:\windows\system32

…or relative…

cd Program Files
cd TinCanTools/openocd

Absolute paths are from your root directory, and begin with a slash or the current drive letter. Relative paths are from the current directory and do not begin with a slash. Absolute paths use forward slashes (\) and relative paths use backslashes (/). File paths are not case sensitive.

If you need to move to a new drive, type the drive letter followed by a colon…

E:

If you need to go back to the parent of the current directory, you can type…

cd ..

You can even use this as part of a longer relative path. For example…

cd ../../TinCanTools

…would take you up two levels, and then into a folder called TinCanTools.

 

Running OpenOCD

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-0.5.0/src, and the three directories you need in openocd/tcl or openocd-0.5.0/tcl.

In the directory containing the openocd executable, type…

openocd -f path_to/cfg_file [-f path_to/other_cfg_file]

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:

openocd -f interface/flyswatter2.cfg -f board/hammer.cfg

For the original Flyswatter and the Beagleboard, you would use:

openocd -f interface/flyswatter.cfg -f board/ti_beagleboard.cfg

See below for more information on config files.

 

Telnet Connection

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.

Windows XP and Windows Server 2003 provide the telnet client by default. To use telnet in Windows 7/Vista you will need to enable it manually. The Configuring Windows 7 for OpenOCD page will show you how to enable the telnet client.

To run telnet and connect to OpenOCD, open a new command prompt. From any directory, type:

telnet localhost 4444

You should see a simple prompt (>). From this prompt you will be able to send commands to OpenOCD. To exit the telnet prompt, press CTRL + C.

 

OpenOCD and Permissions

OpenOCD needs administrator privileges to interact with your USB drivers. You will need to be logged onto an account with administrator privileges. If you do not have access to such an account, contact your system administrator.

 

Search Path

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.

You can also tell OpenOCD where to look for interface/, board/, and target/ with the -s flag, like this:

openocd -s ../tcl -f interface/flyswatter.cfg -f board/hammer.cfg

This would tell OpenOCD to look for interface/ and board/ one level up in a folder called tcl/. For more information, see OpenOCD Config File Paths.

 

OpenOCD Config Files

Each time you use OpenOCD you will need to configure it by passing it paths to configuration files. In the OpenOCD 0.5.0 release, these files are found in openocd-0.5.0/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.

When you start OpenOCD, you tell it to use the config files for your hardware with the -f switch, like this:

openocd -f path_to/cfg_file [-f path_to/other_cfg_file]

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:

openocd -f interface/flyswatter2.cfg -f board/hammer.cfg

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:

source [find target/samsung_s3c2410.cfg]

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 folder, it may not find the samsung_s3c2410.cfg file, or it may find a different samsung_s3c2410.cfg file elsewhere on your system. For more information, see OpenOCD Config File Paths.

If you have compiled OpenOCD yourself, the easiest way to avoid these issues is to copy openocd.exe from your openocd-0.5.0/src folder to your openocd-0.5.0/tcl folder. To run OpenOCD, navigate to openocd-0.5.0/tcl in the command console and run OpenOCD as above. You can also create a new folder anywhere on your system, and copy openocd.exe and the contents of openocd-0.5.0/tcl to the new folder. You can find more information on creating a new folder for OpenOCD in the Windows guides on the Compiling OpenOCD page.

 

LibUSB Device Filters

When you run OpenOCD for the first time with new hardware, you may encounter this error:

Unable to open FTDI device: unable to claim USB device. Please make sure the default FTDI driver is not in use.

If you see this error, you will need to install a Libusb Device Filter.

 

Running Commands on Startup: the -c Flag

You can instruct OpenOCD to run a command on startup with the -c flag. For example:

sudo openocd -f interface/flyswatter.cfg -c "jtag_khz 6000" -f board/hammer.cfg

The jtag_khz command sets the Flyswatter’s clock speed. Starting OpenOCD like this does the following, in order:

  • run commands in flyswatter.cfg
  • run the OpenOCD command to set the Flyswatter’s clock speed
  • run commands in hammer.cfg (which loads samsung_s3c2410.cfg and runs commands found there)

OpenOCD

OpenOCD (Open On-Chip Debugger) is open-source software that interfaces with the Flyswatter’s JTAG port. OpenOCD provides debugging and in-system programming for embedded target devices. OpenOCD provides the ability to flash NAND and NOR FLASH memory devices that are attached to the processor on the target system. Flash programming is supported for external CFI compatible flashes (Intel and AMD/Spansion command set) and several internal flashes (LPC2000, AT91SAM7, STR7x, STR9x, LM3 and STM32x).

OpenOCD supports the following cores:

CORE TYPE EXAMPLE PROCESSORS
ARM7TDMI LPC2148, AT91SAM7
ARM720T LH79520, EP7312
ARM9TDMI
ARM920T S3C2410, S3C2440
ARM922T
ARM926EJS S3C2412, STN8811, STN8815
ARM966E STR91XF
ARM11 S3C6400, OMAP2420, MSM7200
ARM1136
ARM1156
ARM1176
CORTEX-M3 LM3S series, STM32 series
CORTEX-A8 OMAP3530 BeagleBoard
CORTEX-A8 DM3730 BeagleBoard-xM
CORTEX-A9 OMAP4430 PandaBoard
XSCALE PXA255, PXA270, IXP42X
MARVEL FEROCEON CPU CORE
MIPS M4K

OpenOCD was originally developed by Dominic Rath at the University of Applied Sciences Augsburg. The OpenOCD source code is now available through the GNU General Public License (GPL).

Installing OpenOCD

Compiling OpenOCD

OpenOCD Ubuntu Package

OpenOCD Patches

OpenOCD Config Files

 

Running OpenOCD

Running OpenOCD on Linux

Running OpenOCD on Windows

OpenOCD Troubleshooting

 

External Links

OpenOCD website: http://openocd.sourceforge.net/

OpenOCD source: http://sourceforge.net/projects/openocd/files/openocd/0.7.0/openocd-0.7.0.tar.gz/download

GNU GPL (OpenOCD license): http://www.gnu.org/licenses/gpl.html