User Tools

Site Tools


labadmin:fpga_parallel_programmer

Xilinx JTAG Cable Drivers in Linux

Building the driver on a Ubuntu amd64 system

  1. Download the source code to the driver available at this web link http://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver?a=snapshot;h=HEAD;sf=tgz
  2. Make sure the USB development libraries are installed (root# sudo apt-get install libusb-dev)
  3. Make sure you have the essential build tools (root# sudo apt-get install build-essential)
  4. Uncompress the source code (user$ tar xzvf usb-driver-HEAD.tar.gz)
  5. Go to the usb-driver directory (user$ cd usb-driver)
  6. Compile the 64bit driver for your computer (user$ make)
  7. Make sure you have the 32-bit libc6 development libraries (root# sudo apt-get install libc6-dev-i386)
  8. Make sure you have the general 32-bit libraries available for cross-compiling (root# sudo apt-get install ia32-libs)
  9. Make sure you have the motif window system libraries installed (root# sudo apt-get install libmotif3)
  10. Make sure you have the multilib version of gcc (root# sudo apt-get install gcc-multilib)
  11. Make sure you have wget to download files easily (root# sudo apt-get install wget)
  12. Download the 32bit libusb-dev libraries from (user$ wget http://mirrors.kernel.org/ubuntu/pool/main/libu/libusb/libusb-dev_0.1.12-7_i386.deb)
  13. Extract the files from the deb (user$ mkdir tmp) (user$ dpkg-deb -x libusb-dev_0.1.12-7_i386.deb tmp)
  14. Copy the libraries to the lib32 directory (root# sudo cp tmp/usr/lib/libusb.* /usr/lib32/)
  15. Compile the 32bit driver for your computer (user$ make lib32) (–it should work if you have all the right packages)
  16. Copy libusb-driver.so to the /usr/lib32 directory (root# sudo cp libusb-driver.so /usr/lib32)
  17. Make the library available to XilinxISE by preloading it before starting impact. The command to do this is different depending upon your shell
# for sh and bash users
user$ export LD_PRELOAD=/usr/lib32/libusb-driver.so 
# for csh and tcsh users
user$ setenv LD_PRELOAD /usr/lib32/libusb-driver.so 

For 32 bit operating systems the command is :

# for sh and bash users
user$ export LD_PRELOAD=/usr/lib/libusb-driver.so 
# for csh and tcsh users
user$ setenv LD_PRELOAD /usr/lib/libusb-driver.so 

Configuration for using a USB cable

  1. Copy the udev rules file from the server to your local machine (root# sudo cp /server/apps/XilinxISE_92i/bin/lin/xusbdfwu.rules /etc/udev/rules.d/)
  2. Install the fxload package (root# sudo apt-get install fxload)
  3. Copy the firmware file to the /usr/share directory (root# sudo cp /server/apps/XilinxISE_92i/bin/lin/xusbdfwu.hex /usr/share/xusbdfwu.hex)

Configuration for a Parallel Port JTAG cable

  1. Install the proper kernel modules (root# sudo modprobe parport)
  2. Install the proper kernel modules (root# sudo modprobe parport_pc)
  3. Install the proper kernel modules (root# sudo modprobe ppdev)
  4. Add users that will be using this module to the lp group (root# sudo adduser <username> scanner)
  5. Restart udev (root# sudo /etc/init.d/udev restart)

If you get “Programming failed” or “DONE did not go high” when programming through the parallel cable with Impact 9.1, make sure to have the option “Use HIGHZ instead of BYPASS” enabled in Edit → Preferences → iMPACT Configuration Preferences. If you are using batch mode, add the following line to your cmd file: setPreference -pref UseHighz:TRUE

Configuration for a FTDI-based ICEBear JTAG cable

  1. Create a new udev rules file (root# sudo touch /etc/udev/rules.d/99-ftdi_icebear_jtag)
  2. Using your favorite text editor, add the following line this file (root# sudo vi /etc/udev/rules.d/99-ftdi_icebear_jtag)
ACTION=="add", BUS=="usb", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="c140", MODE="666"
  1. Restart udev (root# sudo /etc/init.d/udev restart)

Testing your cable

  1. Run impact (user$ /server/apps/XilinxISE_92i/bin/lin/impact)

Other approaches

  1. Make sure that subversion is installed (root# sudo apt-get install subversion)
  2. Make sure libftdi-dev is installed (root# sudo apt-get install libftdi-dev)
  3. Make sure g++ is installed (root# sudo apt-get install g++)

I had to install libftdi-dev to get the code to compile. I also had to checkout the xc3sprog code from the sourceforge directory using subversion. I then needed to remove the xc3sprog directory in the trunk of the checked out subversion code to get it to compile. The shell commands are as follows :

user$ svn co https://xc3sprog.svn.sourceforge.net/svnroot/xc3sprog xc3sprog

I needed to remove the xc3sprog directory in the trunk of the checked out subversion code :

cd xc3sprog/trunk
rm -rf xc3sprog
make

The following was taken from :

http://www.clifford.at/writings/xilinx_install_drivers_20070924.patch

Below are the writings of the patch author. He suggests you download the file install_drivers.tar.gz from Xilinx at the supplied web address. Then run “md5sum install_drivers.tar.gz” to verify that you have exactly the same version of the drivers as the author as the patch will likely only work on the exact same copy of the driver source. Once you verify this, you extract the files to your local disk with a “tar xzvf install_drivers.tar.gz” command. Then you patch the contents of these files by creating a “diff” file (explained below) and then writing the modifications to the appropriate files in the extracted source code. Then run the “install_drivers” script to compile and install your linux Xilinx programming drivers.

Quick&Dirty Hotfixes for the xilinx install_drivers sources for linux kernel
2.6.22.7 api.

The install_drivers.tar.gz I have found via

	http://www.xilinx.com/xlnx/xil_ans_display.jsp?getPagePath=22648

have the following md5sum:

	# md5sum install_drivers.tar.gz
	d0aea515f1b4523eb2537df86bc6db41  install_drivers.tar.gz

Patch the clean sources (best re-extract it to a fresh directory) using
this patch and remove old pre-compiled modules:

	rm -vf /lib/modules/*/kernel/drivers/misc/{xpc4drvr,windrvr6}.ko

Now simply calling the 'install_drivers' script should work fine..

 - Clifford Wolf <clifford@clifford.at>

Here are the contents of the patch file you need to create.

--- install_drivers/linux_drivers/windriver32/windrvr/linux_wrappers.c.orig	2007-03-27 22:35:36.000000000 +0200
+++ install_drivers/linux_drivers/windriver32/windrvr/linux_wrappers.c	2007-09-24 00:32:44.000000000 +0200
@@ -44,9 +44,6 @@
 #endif
 #include <asm/mman.h>
 #include "linux_wrappers.h"
-#if defined(LINUX_26)
-    #include <linux/ioctl32.h>
-#endif
 #if defined(UDEV_SUPPORT)
     #include <linux/devfs_fs_kernel.h>
 #endif
@@ -91,7 +88,10 @@
 #endif
 
 #if defined(MODULE_LICENSE)
-    MODULE_LICENSE("Proprietary");
+    // MODULE_LICENSE("Proprietary");
+    // Uh! Uh! We need to set this to GPL so we can talk to the USB API.
+    // Is it a copyright infringement if I do that for private use??
+    MODULE_LICENSE("GPL");
 #endif
 #if defined(MODULE_AUTHOR)
     MODULE_AUTHOR("Jungo");
@@ -587,7 +587,7 @@
     if (!bh)
         return NULL;
     memset(bh, 0, sizeof(*bh));
-    bh->data = data;
+    atomic_long_set(&bh->data, data);
 #if defined(LINUX_26)
     bh->func = routine;
     bh->entry.next = &bh->entry;
@@ -650,7 +650,7 @@
 #else
 void
 #endif
-wrapper_handler(int irq, void *ctx, struct pt_regs *pt)
+wrapper_handler(int irq, void *ctx)
 {
     struct int_wrapper *context = (struct int_wrapper *)ctx;
     int rc = 0;
@@ -1023,7 +1023,7 @@
     }
 
     #if defined(WINDRIVER_KERNEL)
-        pci_module_init(&generic_pci_driver);
+        pci_register_driver(&generic_pci_driver);
     #endif
     return 0;
 #endif
--- install_drivers/linux_drivers/xpc4drvr2_6/xpc4drvr/Makefile.orig	2007-09-24 00:36:20.000000000 +0200
+++ install_drivers/linux_drivers/xpc4drvr2_6/xpc4drvr/Makefile	2007-09-24 00:36:27.000000000 +0200
@@ -17,7 +17,7 @@
 # Run ./configure first, to generate regparm_option
 REG_PARM = $(shell grep -c "regparm=3" $(PWD)/regparm_option)
 SYM_FILE_DIR = /lib/modules/$(shell uname -r)/build
-GET_USER_SIZE_SYM = $(shell grep -c "get_user_size" $(SYM_FILE_DIR)/Module.symvers)
+GET_USER_SIZE_SYM = 0
 ARCH_64BIT = $(shell arch | grep -c "64")
 ifeq ($(ARCH_64BIT),1)
 CFLAGS += -mcmodel=kernel

Dump the patch file text into a file : patch-2.6.22.diff. Then from the install_drivers directory run the patch and compile commands :

bash$ patch -p1 < patch-2.6.22.diff
bash$ ./install_drivers

Making a Ubuntu Gutsy CHROOT 32bit system on an Ubuntu amd64 distribution

Step 1:

  1. sudo apt-get install dchroot debootstrap
  2. sudo mkdir /chroot/
  3. sudo gedit /etc/dchroot.conf
  4. Add this line: gutsy /chroot
  5. sudo debootstrap –arch i386 gutsy /chroot/ http://archive.ubuntu.com/ubuntu
  6. sudo chroot /chroot/
  7. sudo apt-get install –reinstall language-pack-en
  8. dpkg-reconfigure locales

Step 2:

In another terminal window (or by existing chroot):

  1. sudo gedit /chroot/etc/apt/sources.list
  2. Add the following lines:
deb http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb-src http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb http://security.ubuntu.com/ubuntu gutsy-security universe
deb-src http://security.ubuntu.com/ubuntu gutsy-security universe
deb http://security.ubuntu.com/ubuntu gutsy-security multiverse
deb-src http://security.ubuntu.com/ubuntu gutsy-security multiverse

Step 3:

In your chrooted environment (chroot /chroot):

  1. apt-get update ; apt-get upgrade

Step 4:

In another terminal window (or by existing chroot):

  1. sudo cp /etc/passwd /chroot/etc/
  2. sudo cp /etc/shadow /chroot/etc/
  3. sudo cp /etc/group /chroot/etc/
  4. sudo cp /etc/sudoers /chroot/etc/
  5. sudo cp /etc/hosts /chroot/etc/
  6. sudo gedit /etc/fstab
  7. Add the following lines:
/home /chroot/home none bind 0 0
/tmp /chroot/tmp none bind 0 0
/dev /chroot/dev none bind 0 0
/proc /chroot/proc proc defaults 0 0
/media/cdrom0 /chroot/media/cdrom0 none bind 0 0
/usr/share/fonts /chroot/usr/share/fonts none bind 0 0
  1. sudo mkdir /chroot/media/cdrom0
  2. sudo mkdir /chroot/usr/share/fonts
  3. sudo mount -a
  4. sudo gedit /usr/local/bin/do_dchroot
  5. Add the following:
#!/bin/sh
/usr/bin/dchroot -d "`echo $0 | sed 's|^.*/||'` $*"
  1. sudo chmod 755 /usr/local/bin/do_dchroot

Step 5: In a new terminal:

  1. dchroot -d
  2. sudo apt-get install synaptic
  3. sudo ln -s /usr/sbin/synaptic /usr/sbin/synaptic32
  4. exit
  5. sudo ln -s /usr/local/bin/do_dchroot /usr/local/bin/synaptic32
  6. sudo synaptic32

Step 6: Customize things for Xilinx

In a new terinal :

  1. dchroot -d
  2. sudo mkdir /server

In a new terminal :

  1. vi /etc/fstab
  2. Add the line :
/server /chroot/server none bind 0 0
  1. sudo apt-get install libstdc++5

Making a Debian sid CHROOT 32bit system on an Ubuntu amd64 distribution

Step 1:

  1. sudo apt-get install dchroot debootstrap
  2. sudo mkdir /chroot_debian
  3. sudo gedit /etc/dchroot.conf
  4. Add this line: sid /chroot_debian
  5. sudo debootstrap –arch i386 sid /chroot_debian/ http://http.us.debian.org/debian
  6. sudo chroot /chroot_debian
  7. apt-get install locales
  8. dpkg-reconfigure locales

Step 2:

In another terminal window (or by existing chroot):

  1. sudo gedit /chroot/etc/apt/sources.list
  2. Add the following lines:
deb http://http.us.debian.org/debian/ unstable main contrib non-free
deb-src http://http.us.debian.org/debian/ unstable main 
deb http://non-us.debian.org/ sarge/non-US main contrib non-free
deb http://debian-multimedia.org/ etch main
deb http://security.debian.org/ sarge/updates main contrib non-free

Step 3:

In your chrooted environment (chroot /chroot):

  1. apt-get update ; apt-get upgrade
  2. apt-get install sudo

Step 4:

In another terminal window (or by existing chroot):

  1. sudo cp /etc/passwd /chroot_debian/etc/
  2. sudo cp /etc/shadow /chroot_debian/etc/
  3. sudo cp /etc/group /chroot_debian/etc/
  4. sudo cp /etc/sudoers /chroot_debian/etc/
  5. sudo cp /etc/hosts /chroot_debian/etc/
  6. sudo gedit /etc/fstab
  7. Add the following lines:
/home /chroot_debian/home none bind 0 0
/tmp /chroot_debian/tmp none bind 0 0
/dev /chroot_debian/dev none bind 0 0vi
/proc /chroot_debian/proc proc defaults 0 0
/media/cdrom0 /chroot_debian/media/cdrom0 none bind 0 0
/usr/share/fonts /chroot_debian/usr/share/fonts none bind 0 0
  1. sudo mkdir /chroot/media/cdrom0
  2. sudo mkdir /chroot/usr/share/fonts
  3. sudo mount -a
  4. sudo gedit /usr/local/bin/do_dchroot_sid
  5. Add the following:
#!/bin/sh
/usr/bin/dchroot -d -c sid "`echo $0 | sed 's|^.*/||'` $*"
  1. sudo chmod 755 /usr/local/bin/do_dchroot_sid

Step 5: In a new terminal:

  1. dchroot -d -c sid
  2. sudo apt-get install synaptic
  3. sudo ln -s /usr/sbin/synaptic /usr/sbin/synaptic32
  4. exit
  5. sudo ln -s /usr/local/bin/do_dchroot_sid /usr/local/bin/synaptic32
  6. sudo synaptic32

Step 6: Customize things for Xilinx

In a new terinal :

  1. dchroot -d -c sid
  2. sudo mkdir /server

In a new terminal :

  1. vi /etc/fstab
  2. Add the line :
/server /chroot_debian/server none bind 0 0
  1. sudo apt-get install libstdc++5
labadmin/fpga_parallel_programmer.txt · Last modified: 2009/10/07 17:57 (external edit)