Thursday, May 26, 2011

Getting Papilio running on Ubuntu (Natty)

1. Get subversion

$ sudo apt-get install subversion

2. Get these packages

$ sudo apt-get install automake
$ sudo apt-get install libftdi-dev

3. a) Get the butterfly loader package
$ svn checkout http://gadgetforge.gadgetfactory.net/svn/butterflyloader

b) Get & install ZPUino according to the instructions on Alvaro's website:
http://www.alvie.com/zpuino/download.html

4. Go to ./butterflyloader/branches/papilioloader and compile the source
$ sudo ./configure && make

Now you should have 'papilioloader' installed and available to run.

6. If you are running with a linux kernel >= 2.6.32 (like I did), you have to create a udev rule to access the JTAG port via USB as a regular user. Here is how:

a) Find out the VID & PID of the FT2232 device
$ lsusb
Bus 005 Device 004: ID 046d:c526 Logitech, Inc.
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 003: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC

b) The FT2232 device provides the JTAG interface (VID=0403, PID=6010). Create /etc/udev/rules.d/45-ft2232.rules as root with the found VID/PID:

$ sudo gedit /etc/udev/rules.d/45-ft2232.rules

Cut & paste the following lines into the 45-ft2232.rules file:

"""
BUS!="usb", ACTION!="add", SUBSYSTEM!=="usb_device", GOTO="kcontrol_rules_end"
SYSFS{idVendor}=="0403", SYSFS{idProduct}=="6010", MODE="664", GROUP="plugdev"
LABEL="kcontrol_rules_end"
"""

c) Unplug and re-attach the board.

[This was based on instructions here: http://infopoort.nl/index.php/Software:OpenOCD]

7. Upload the SPI & main bitfiles.
$ papilioloader -v -b "./butterflyloader/trunk/Fpga/bscan_spi_xc3s250e.bit" -f "zpuino-ZA4-PapilioOne-S3E250.bit" -sa -r

You'll probably get this output:
"""
Using built-in device list
JTAG chainpos: 0 Device IDCODE = 0x11c1a093 Desc: XC3S250E

Uploading "./butterflyloader/trunk/Fpga/bscan_spi_xc3s250e.bit". Done.
Programming time 142.0 ms

Programming External Flash Memory with "zpuino-ZA4-PapilioOne-S3E250.bit".
Uknown Flash Manufacturer
Error: SPI Status Register [0x00] mismatch (Wrong device or device not ready)..
Error occured.
USB transactions: Write 39 read 4 retries 8
"""

8. At this point, if you try to upload a sketch using the Arduino IDE (installed in step 3b), at least you will be able to communicate with the board (and see the TX LED flashing).

I still need to check if this error about the "Uknown Flash Manufacturer" is going to be a problem.

1 comment:

  1. Yes, it worked, thanks 1024 times ;-)

    Only slight deviation from your how-to: I had to run sudo ./autogen.sh before ./configure && make. I had to do configure and make as a two-steps process:
    sudo ./configure
    sudo ./make

    But, tadam! I got papilioloader built in the end

    I do get a "unknown SPI device" too... My next step is to verify that my bitstream actually does what I want :-)

    Cheers!

    ReplyDelete