I've just bought myself a  Spartan-3A DSP 1800A XtremeDSP Starter Platform (actually the Microblaze development kit).

I want to run this on my 64 bit Fedora 9 box, not on one of the Linux distributions that Xilinx supports officially.

Installing the Xilinx Tools

With the Microblaze kit I got a CD with Xilinx EDK and ISE. The license I got is for ISE WebPack? which is not available for 64 bit Linux systems, and I of course I do have a 64 bit Linux machine, so when I installed from the CD I did not even get the choice to install Webpack.

There are a few other problems with running the i386 version of the Xilinx tools on a Fedora 9 x86_64 machine. A bunch of i386 libraries don't get installed by default, so install them with:

yum install e2fsprogs-libs.i386 libXrender.i386 libXrandr.i386 libXcursor.i386 libXft.i386 libSM.i386 libXmu.i386
yum install glibc-devel.i386 libusb.i386

Without some of these packages the setup program will just fail to start without any error messages or anything. And the other packages are needed by some later programs, so you might as well install them at the same time.

The Xilinx tools also require an old version of libdb which is not available on Fedora 9. I found an old CentOS package that contained the libraries I needed:

wget ftp://ftp.funet.fi/.m/mirrors2/centos.org/4.6/os/i386/CentOS/RPMS/compat-db-4.1.25-9.i386.rpm
rpm -ivh --oldpackage compat-db-4.1.25-9.i386.rpm
ldconfig

After all that you can install the free ISE Webpack and EDK from the DVD with:

i386 ./setup

The i386 is needed to make the setup program believe it is running on a 32 bit machine.

You also need to run ise with the same i386 prefix, otherwise impact called from within ise will fail.

Xilinx Platform Cable USB

Impact has two ways of accessing the cable: one way is using the Jungo Windriver, but often breaks with new kernel versions, and since Greg KH changed the USB subsystem to use EXPORT_GPL, Windriver will have big problems working unless it lies about the license. The other way is to tell impact to use libusb to talk to the cable, you do that with an environment variable:

XIL_IMPACT_USE_LIBUSB=1

The right way to install the drivers for the Xilinx Platform Cable USB is to do the following:

cd /opt/Xilinx/10.1/ISE/bin/lin
sh setup_pcusb

Wrapper scripts

I actually have a wrappper to start ISE that looks like this:

#! /bin/sh
XILINX_DIR=/opt/Xilinx/10.1
. $XILINX_DIR/EDK/settings32.sh
. $XILINX_DIR/ISE/settings32.sh
XIL_IMPACT_USE_LIBUSB=1
export XIL_IMPACT_USE_LIBUSB
echo "Starting real ISE" 1>&2
exec i386 ise "$@"

Loading firmware manually

I still had some problems getting the download cable working so here's what I did to load the firmware manually. After this impact started working.

Impact has two ways of accessing the cable: one way is using the Jungo Windriver, but often breaks with new kernel versions, and since Greg KH changed the USB subsystem to use EXPORT_GPL, Windriver will have big problems working unless it lies about the license. The other way is to tell impact to use libusb to talk to the cable, you do that with an environment variable:

XIL_IMPACT_USE_LIBUSB=1

But even with libusb, impact for some reason fails to download the firmware into the cable. But since the Xilix cables are using a good old Cypress FX2 chip I managed to work around that.

When plugging in a cable, the firmware won't be loaded and the cable will have one USB Vendor/Product? ID:

  • 03fd:000f Xilinx DLC9LP, uses the xusbdfwu.hex firmware
  • 03fd:0013 Xilinx DLC10, uses the xusb_xp2.hex firmware

The firmware can be downloaded with fxload, and after that the cable disconnect from the USB bus and reconnect with a new USB Vendor/Product? ID which is the same for all devices:

  • 03fd:0008 Xilinx, Inc

After this impact will happily talk to the cable.

So, here's what I did to automate the firmware loading.

You will also need a program called fxload, so install it with:

yum install fxload

Create a file /etc/udev/rules.d/98-xilinx.rules with the following contents:

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="03fd", GROUP="xilinx", MODE="0664", RUN+="/usr/local/libexec/xilinx_fxload.sh"

Note, this will make the Xilinx USB device usable by members in the group "xilinx", so you'll have to create such a group and add yourself to it. If you are the only user on your machine, you can make the Xilinx device usable by everyone by setting the mode to 0666 instead:

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="03fd", MODE="0666", RUN+="/usr/local/libexec/xilinx_fxload.sh"

Tell udevd to reload its rules with:

udevadm control --reload-rules

Create /usr/local/libexec/xilinx_fxload.sh and make it executable:

#! /bin/sh
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
(
XILINX=/opt/Xilinx/10.1/ISE

#echo -- "$0" "$@"
#env

if [ "$DEVTYPE" = "usb_device" ]; then
    case "$PRODUCT" in
        3fd/8/0)
            echo "Xilinx Platform Cable USB successfully configured"
            ;;

        3fd/f/0)
            echo "Loading firmare for Xilinx DLC9LP"
            fxload -t fx2 -I $XILINX/bin/lin/xusbdfwu.hex -D "$DEVICE"
            ;;

        3fd/13/0)
            echo "Loading firmare for Xilinx DLC10"
            fxload -t fx2 -I $XILINX/bin/lin/xusb_xp2.hex -D "$DEVICE"
            ;;

        *)
            echo "Unknown Xilinx USB device"
            ;;
    esac
fi

) 2>&1 | logger -t "`basename \"$0\"`"

After this all you have to do is to plug in the cable. The firmware should automatically load and the LED on the cable should light up.

So, to run the Hello World example from Xilinx UG486 "Spartan-3A DSP 3SD1800A MicroBlaze? Processor Edition", here's what works for me:

. /opt/Xilinx/10.1/EDK/settings32.sh
. /opt/Xilinx/10.1/ISE/settings32.sh

export XIL_IMPACT_USE_LIBUSB=1

cd s3adsp1800a_mb_bclinux/ready_for_download

# If you have run the impact tools as root before, you'll have a
# _impactbatch.log that stops you from running it as a user so remove it

rm -f _impactbatch.log

impact -batch ug486.cmd
xmd -opt ug486.opt
dow helloworld_executable.elf
run