User:Arch dude/Xilinx ISE Webpack 12

The Xilinx ISE is an integrated development environment for Xilinx FPGAs and CPLDs. the Webpack is the no-cost version of ISE, which has some restrictions. While it is provided for Linux, Xilinx specifies that it is intended to run only on RHEL and SUSE. There is a large user community of developers that run the ISE on other Linux environments, however. Installation has become progressively easier from version to version, but each version has different challenges:
 * For ISE 11, please see Xilinx ISE Webpack 11.
 * For versions before ISE 11, please see Xilinx ISE WebPACK (10 and Earlier).

The ISE is a GUI that invokes ISE tools to perform various design steps. Most of the tools are simple POSIX-compliant batch applications that will run in essentially any Linux environment. The GUI has more extensive demands on the system. A few of the tools interact with the target hardware via a "programming cable" (usually just called a "cable.") The interface to the cable is via a "cable driver" that must be integrated with the system.

Historically, There have been three main areas of difficulty when running a "non-standard" setup:
 * 32-bit versus 64-bit problems
 * Library incompatibilities affecting the GUI
 * Cable drivers

For ISE 12, Webpack installation on Gentoo Linux, and specifically on 64-bit Gentoo Linux, has finally become fairly simple. There are no obvious problems with the GUI or with 64-bit compatibility as there were in previous versions, so the only remaining challenge is the cable drivers. Even here, the workarounds are simple.

The approach described here is to simply run the Xilinx installer, and then make some fix-ups for the cable drivers. This works on an up-to-date Gentoo system (as of 2010-12-23.) If this fails for you, please look at the solutions for the older ISE installations and attempt to adapt them. If you are still running a 32-bit system, then the installer will install a 32-bit WebPack. Unless your situation is unusual, there is no reason to install a 32-bit WebPack on a 64-bit Linux system.

Prerequisites
You need to be logged in as root to do many of these steps.

The webpack needs some packages to be installed prior to installation. This will be true for any ISE installation on any Linux platform. Therefore: emerge acroread emerge mozilla-firefox emerge libusb emerge fxload

We also need a simple way to invoke the Xilinx programs. Create a script named /usr/local/bin/xilinx. Place the following in the script: source /opt/Xilinx/12.4/ISE_DS/settings64.sh DISPLAY=:0 exec ise
 * 1) !/bin/sh

and make it executable: chmod +x /usr/local/bin/xilinx

Cable Driver Problems
ISE 11.1 does not properly access a USB cable when installed as described above. To correct this, we use the (mis-named) libusb-driver. First, acquire the source tarball for the driver and compile it. Then, move the library into the Xilinx library directory. Now comes the tricky part: we force the relevant ISE command-line tools to use the driver even though they think they are using a Xilinx-supplied kernel driver. We do this by "preloading" our new library when we load those command-line tools. In older versions of the ISE, we did this in the general invocation script, but this won't work for ISE 11.1, because the tools are now invoked from scripts within the ISE. Therefore, we follow the advice of Ken Ryan and for each tool that uses a cable, we move the tool's binary file and add a tiny script that preloads the driver and then calls the binary. For WebPack, the only tool is impact, but other Xilinx tools in the full ISE can be handled the same way.

for impact, first find the binary whose name is _impact and move it to _impact.bin in the same directory. For ISE 11.1 WebPack, the tool is at /opt/Xilinx/11.1/ISE/bin/lin so cd /opt/Xilinx/11.1/ISE/bin/lin mv _impact _impact.bin

now, create a file named _impact and make it executable touch _impact chmod +x _impact edit _impact to look like this: LD_PRELOAD=libusb-driver.so $0.bin $*
 * 1) !/bin/sh
 * 2) Preload driver binary

Cable Alternatives
In ISE 10.1, Xilinx implemented a way to use libusb directly, without the use of libusb-driver. This is good, because (among other things) the ISE installation now adjusts the udev entries properly to grant user permissions. Unfortunately, This altetnative fails in 11.1, (at least for WebPack on a 64-bit Gentoo) and I cannot find a fix.

I also had problems with a 32-bit Gentoo. There were actually two issues. The iMPACT driver will double check that the installed firmware is the one distributed with the Xilinx installation. So make sure you have  or   available even if you installed the firmware in a different directory or tell udev to use the firmware directly from the installation directory. Secondly, iMPACT tries to load  via dlopen. This fails on newer Gentoo installations because  is only a linker script and not a symlink to the actual libusb.so. I fixed this by putting a symlink to the correct libusb.so in the Xilinx library directory.

The "standard" approach is to install specialized cable drivers in the kernel. This approach is fragile, because the drivers must be recompiled for each new kernel and because these drivers sometimes fall out of sync. This approach is no linger preferred even by Xilinx.

A third alternative is not use the Xilinx cables tools at all, but to use xc3sprog.

Possible Webpack 11.1 + libusb on AMD64 fix
A possible fix that worked for this author is to self-compile a special libusb install. Simply emerging libusb will build libusb against the system libraries, which aren't necessarily the same as the xilinx versions. Steps that worked for me were : source /opt/Xilinx/11.1/settings64.sh; cd libusb-sources; ./configure --prefix=/opt/libusb --exec-prefix=/opt/libusb --without-pkgconfig --disable-build-docs; make; make install; export LD_LIBRARY_PATH=/opt/libusb/lib:$LD_LIBRARY_PATH; impact

Simply mod settings64.sh to change the LD_LIBRARY_PATH to include that, and you're good from then on. For reference, I was using it with a Platform Cable USB II. Ensure that you do the "source" command first. This exposes the right libraries to the linker when building libusb.

Manual Installation
When using the lib-usb solution, one problem is the actual installation of the 'Cable Drivers' onto the system. In the following section, the installation procedure from the Xilinx 11.4 software is described (as reverse engineered from a SuSE system).

First, make sure 'fxload' is installed, this is needed to load the firmware for the JTAG programmer.

emerge -av fxload

Next, create a file in '/etc/udev/rules.d/' called 'xusbdfwu.rules', this is the magic that loads the firmware into the programmer upon connecting: SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0008", MODE="666" BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0007", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusbdfwu.hex -D $TEMPNODE" BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0009", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xup.hex -D $TEMPNODE" BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="000d", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_emb.hex -D $TEMPNODE" BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="000f", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xlp.hex -D $TEMPNODE" BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0013", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xp2.hex -D $TEMPNODE" BUS=="usb", ACTION=="add", SYSFS{idVendor}=="03fd", SYSFS{idProduct}=="0015", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xse.hex -D $TEMPNODE"
 * 1) version 0003

In case the default version does not work (it does not on udev 151), use the updated version below: ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0008", MODE="666" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0007", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusbdfwu.hex -D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0009", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xup.hex -D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000d", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_emb.hex -D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000f", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xlp.hex -D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0013", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xp2.hex -D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0015", RUN+="/sbin/fxload -v -t fx2 -I /usr/share/xusb_xse.hex -D $tempnode"
 * 1) version 0003

The rules above assume the firmware is actually present in '/usr/share'. To prevent the Xilinx software from installing all kinds of files in your Gentoo system, it might be wise to replace the paths above with files from the Xilinx directory. Use something like this to track down the firmware: find /opt/Xilinx -name "*.hex"

For some reason the firmware seems to be present in multiple locations (albeit in 32-bit and 64-bit versions). I used the firmware from the installer directory: '/opt/Xilinx/11/ISE/bin/lin64/install_script/install_drivers/linux_drivers/pcusb' - note that the path might differ on your system! Also, these are the 64-bit versions which seems to differ from the 32-bit version, make sure to select the correct version.