Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "Template:CompileOpenOCDFedoraGit"

From eLinux.org
Jump to: navigation, search
(Switching Ubuntu to Fedora)
(Adding a noinclude and includeonly to categorize the template properly.)
 
(8 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
==Installing Packages==
 
==Installing Packages==
  
You will need to install several packages to compile and run [[OpenOCD]]. Open a terminal window ('''Applications menu > Accessories > Terminal''') and type:
+
You will need to install several packages to compile and run [[OpenOCD]]. Open a terminal window ('''Applications menu > Terminal Emulator''') and type:
  
  sudo apt-get install libtool autoconf texinfo libusb-dev
+
  sudo yum install git 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/.
 
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==
 
==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-{{{{{2}}}_VERNUM}}.tar.gz''' from:
+
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]].  
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-{{{{{2}}}_VERNUM}}/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-{{{{{2}}}_VERNUM}}/src
+
sudo cp ftdi.h /usr/include
+
cd /usr/local/include
+
sudo ln -s /usr/include/ftdi.h ftdi.h
+
 
+
Return to your '''libftdi-{{{{{2}}}_VERNUM}}''' directory and compile.
+
 
+
cd ~/libftdi-{{{{{2}}}_VERNUM}}
+
./configure
+
make
+
sudo 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/lib
+
Fedora 17 provides libftdi-0.19To install:
sudo ln -s /usr/local/lib/libftdi.a libftdi.a
+
sudo ln -s /usr/local/lib/libftdi.la libftdi.la
+
  sudo ln -s /usr/local/lib/{{LIBFTDI_SO_VER}} {{LIBFTDI_SO_VER}}
+
sudo ln -s /usr/local/lib/{{LIBFTDI_SO_VER}} libftdi.so
+
sudo ln -s /usr/local/lib/{{LIBFTDI_SO_VER}} libftdi.so.1
+
  
 +
$ sudo yum install libftdi
  
 
==Downloading OpenOCD==
 
==Downloading OpenOCD==
Line 59: Line 36:
  
 
  cd ~
 
  cd ~
  git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
+
  git clone git://git.code.sf.net/p/openocd/code
  
 
There should now be a folder in your home directory called '''openocd/.'''
 
There should now be a folder in your home directory called '''openocd/.'''
 
  
 
==Compiling OpenOCD==
 
==Compiling OpenOCD==
Line 69: Line 45:
  
 
  cd ~/openocd
 
  cd ~/openocd
  sudo ./bootstrap
+
  ./bootstrap
  sudo ./configure --enable-maintainer-mode --disable-werror --enable-ft2232_libftdi
+
  ./configure --enable-maintainer-mode --disable-werror --enable-ftdi
  sudo make
+
  make
 +
 
 +
At this point you can continue and do:
 +
 
 
  sudo make install
 
  sudo make install
 +
 +
I personally prefer not to do this, as I prefer to copy the openocd binary and supporting files to a /bin directory within my home directory.  This is described below.
  
 
Navigate to '''/home/USERNAME/openocd/src''' to find the '''openocd''' binary. You will need superuser privileges (the ''sudo'' command) to run [[OpenOCD]].
 
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==
 
==Preparing to Run OpenOCD==
Line 88: Line 67:
 
  cd ~/openocd/tcl
 
  cd ~/openocd/tcl
 
  cp -r * ~/openocd-bin
 
  cp -r * ~/openocd-bin
  cd ~/openocd/src
+
  cd ../src
 
  cp openocd ~/openocd-bin
 
  cp openocd ~/openocd-bin
  
Line 106: Line 85:
 
  mmr_helpers.tcl
 
  mmr_helpers.tcl
  
 +
===Set udev rules to allow non-root running of OpenOCD===
 +
 +
$cd /etc/udev/rules.d
 +
$sudo vim 45-flyswatter2.rules
 +
Paste the following lines:
 +
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", \
 +
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", GROUP="wheel", MODE="0666"
 +
 +
NOTE that I used the wheel group, as I know my user is a member.  You can also omit the GROUP variable and add OWNER="<username>" where <username> is your username.
 +
 +
Be sure to unplug you Flyswatter2 from your PC at this point, before reloading the udev rules as changes only apply to new events.
 +
 +
$sudo udevadm control --reload
 +
 +
Now plug your Flyswatter2 back in and proceed to running OpenOCD as a non-root user.
 
You can now run [[OpenOCD]] from '''/home/USERNAME/openocd-bin'''. To get started running OpenOCD, see [[Running OpenOCD on Linux]].
 
You can now run [[OpenOCD]] from '''/home/USERNAME/openocd-bin'''. To get started running OpenOCD, see [[Running OpenOCD on Linux]].
  
[[Category:TinCanTools]]
+
<includeonly>[[Category:TinCanTools]]</includeonly>
[[Category:OpenOCD]]
+
<includeonly>[[Category:OpenOCD]]</includeonly>
[[Category:Fedora]]
+
<includeonly>[[Category:Fedora]]</includeonly>
 +
<noinclude>[[Category:OpenOCD Templates]]</noinclude>

Latest revision as of 01:25, 22 May 2013


This guide will compile OpenOCD {{{3}}} for Fedora 17 with the {{{{{2}}}_NAME_CAPS}} driver library, for use with the TinCanTools Flyswatter and Flyswatter2. Version {{{3}}} 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, 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 > Terminal Emulator) and type:

sudo yum install git 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.

Fedora 17 provides libftdi-0.19. To install:

$ sudo yum install libftdi

Downloading OpenOCD

Git is version control software distributed with Fedora. 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://git.code.sf.net/p/openocd/code

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 ~/openocd
./bootstrap
./configure --enable-maintainer-mode --disable-werror --enable-ftdi
make

At this point you can continue and do:

sudo make install

I personally prefer not to do this, as I prefer to copy the openocd binary and supporting files to a /bin directory within my home directory. This is described below.

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-bin
cd ~/openocd/tcl
cp -r * ~/openocd-bin
cd ../src
cp openocd ~/openocd-bin

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

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

Set udev rules to allow non-root running of OpenOCD

$cd /etc/udev/rules.d
$sudo vim 45-flyswatter2.rules

Paste the following lines:

SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", \
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", GROUP="wheel", MODE="0666"

NOTE that I used the wheel group, as I know my user is a member. You can also omit the GROUP variable and add OWNER="<username>" where <username> is your username.

Be sure to unplug you Flyswatter2 from your PC at this point, before reloading the udev rules as changes only apply to new events.

$sudo udevadm control --reload

Now plug your Flyswatter2 back in and proceed to running OpenOCD as a non-root user. You can now run OpenOCD from /home/USERNAME/openocd-bin. To get started running OpenOCD, see Running OpenOCD on Linux.