Difference between revisions of "Template:CompileOpenOCDWin"

From eLinux.org
Jump to: navigation, search
(Adding proper categories)
(Adding a noinclude and includeonly to categorize the template properly.)
 
Line 99: Line 99:
 
You can now run [[OpenOCD]] from '''C:\openocd-bin'''. To get started running OpenOCD, see [[Running OpenOCD on Windows]].
 
You can now run [[OpenOCD]] from '''C:\openocd-bin'''. To get started running OpenOCD, see [[Running OpenOCD on Windows]].
  
[[Category:TinCanTools]]
+
<includeonly>[[Category:TinCanTools]]</includeonly>
[[Category:OpenOCD]]
+
<includeonly>[[Category:OpenOCD]]</includeonly>
 +
<noinclude>[[Category:OpenOCD Templates]]</noinclude>

Latest revision as of 01:44, 22 May 2013

This guide will compile OpenOCD {{{3}}} on {{{{{1}}}_OSNAME}} with the {{{{{2}}}_NAME_CAPS}} 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 {{{{{1}}}_OSNAME}} ({{{{{2}}}_NAME_CAPS}}) - Pre June 2011]].


{{{{{1}}}_SEC_CONFIGSHORT}}


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. {{{{{1}}}_IMG_CYGINSTALL}}

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. {{{{{2}}}_WIN_LIBUSBINSTALL|{{{1}}}}}


{{{{{2}}}_INSTALL|{{{1}}}}}


{{MAKEERRORNOTE_{{{3}}}}}


Downloading OpenOCD

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


{{FS3PATCH_{{{3}}}|{{{1}}}|/home/openocd-{{{3}}}}}


Compiling OpenOCD

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

cd /home/openocd-{{{3}}}

{{{{{2}}}_OPENOCD_CONFIG}}

make


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\openocd\tcl. 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:

board
chip
cpld
cpu
openocd.exe
interface
target
test
bitsbytes.tcl
memory.tcl
mmr_helpers.tcl
readable.tcl

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