Compile urJTAG for Windows

From DP

Jump to: navigation , search

Contents

Introduction

Urjtag is a modern tool for communicating over JTAG with flash chips, CPU's etc. This version aimed at supporting Bus Blaster high speed JTAG/flash programmer development.

We are going to cross-compile urJTAG from another platform, preferably Linux, but also under Cygwin. The compiled version will run in native MS Windows.

If you wanted to use CodeBlocks as your IDE go here: Compiling Urjtag Using CodeBlocks for Windows

Requirements

Before you can compile Urjtag for Windows, you need to have a cross-compiler environment for your OS.

In linux,

refer to http://www.mingw.org/wiki/LinuxCrossMinGW

If you are using debian, you may also run the Synaptic Package Manager and search for 'cross' under Debian also, you can use the command to download and install the needed packages:

aptitude install -R autoconf automake bash bison bzip2 cmake flex g++ intltool make sed libtool openssl libssl-dev libxml-parser-perl patch perl pkg-config scons unzip wget yasm

or

Download and install the files from http://mingw-w64.sourceforge.net/:

Aside from these latest builds, you also need the following:

  • the latest Urjtag from the svn, which we will download later and
  • the required Windows libraries from ftdichip.com

Building the cross compile environment

Fortunately the people behind MingGW-w64 have done it for you. All you have to do is uncompress the downloaded toolchain into a directory of your choice and add the "bin" path to your PATH environment variable (assuming you uncompress toolchain tarball in /mingw-w32):

export PATH=/mingw-w32/bin:`printenv PATH`

Check your path by running:

printenv PATH

Testing the build environment

To test your cross-compile environment, create a simple hello.c:

 /* hello.c -- hello world example. */

 #include <stdio.h>
 int main () {
     printf ("Hello world!\n");
     return 0;
 }

and compile with the command:

i686-w64-mingw32-gcc -o hello hello.c

then find the generated hello.exe file in your home directory, test it in both Windows and Linux.

Patching Urjtag

You can run the following syntax to patch the source from the svn repository.

patch -p0 -i ./patch-file

Cross compiling Urjtag for Windows

When everything is working well, here is the sequence for cross-compilation:

  • Download the latest Urjtag from the repositories:

svn co http://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk urjtag
cd to your urjtag installation root
cd urjtag/urjtag

  • Run your patch (optional)

patch -p0 -i ./patch-file

  • Run ./autogen to create makefiles for your system

./autogen.sh

  • Run the ./configure along with its flags and parameters: (Debian/Linux)

CFLAGS="-DJTAG_BIN_DIR=\\\"/\\\" -DJTAG_DATA_DIR=\\\"/data\\\"" LDFLAGS="-L/home/username/CDM20808/i386" LIBS="-lftd2xx" ./configure --enable-maintainer-mode --host=i586-mingw32msvc --with-ftd2xx="/home/username/CDM20808" --disable-werror --disable-nls --without-libusb --disable-silent-rules --enable-relocatable

  • Run make

make

And find your exe file in your src/apps/jtag directory.

Please note that the --host flag need to be modified accordingly. The command above has worked for a linux environment. In Cygwin it could be: --host=i686-w64-mingw32 and the cross-compiler bin directory must be the first in the PATH variable.

Testing and running on Windows

Transfer the exe file created from the cross-compiler to a subdirectory and run the jtag.exe. You should see the following, along with the build no.:

Urjtagscreen.png

Some tricks and Notes

You may download the Windows binary from the repository, install it and just replace the exe file with your build. Don't forget to move the FTDI libraries into their own directories or include them in Windows's PATH.

The filename's prefix in the 'bin' directory is used as parameter in the --host during ./configure.

Patches, BSDL, SVF

http://dangerousprototypes.com/forum/viewtopic.php?f=37&t=1655&start=45#p15771

References and Resources

http://urjtag.sourceforge.net/

http://mingw-w64.sourceforge.net/

http://wiki.osdev.org/GCC_Cross-Compiler

http://wiki.njh.eu/Cross_Compiling_for_Win32#Debian_cross_compiling_for_w32-i386

http://mingw-cross-env.nongnu.org/

http://packages.debian.org/stable/devel/mingw32

Credits

Tjtag & Robots