Guest shashi

butterflyloader on macosx

13 posts in this topic

Hi folks,

Just got my hands on the Papilio 250K through the Indiashop.  I successfully compiled the butterflyloader on macosx.  I had to edit the configure file and comment out the lines 4076 to 4078 i.e. added the following # to the corresponding lines:

        #PKG_CHECK_MODULES(libftdi, libftdi >= 0.16,

        #      CFLAGS="$CFLAGS $libftdi_CFLAGS";

        #      LIBS="$LIBS $libftdi_LIBS")

Initially followed the description as per http://codedstructure.blogspot.com/2010/08/libftdi-on-mac-os-x.html to install ftdi on my snow leopard macosx system.  In short it needed the download and install of the following (straightforward ./configure && make install from source) libraries:

    * libusb (tested with version 1.0.8)

    * pkg-config (tested with version 0.25)

    * libusb-compat (test with version 0.1.3)

    * libftdi (tested with version 0.18)

Finally, the butteflyloader compiled via make.  The last linking stage failed with errors that it could not understand the ftdi related functions (ld error).  This was solved by running the last g++ command from outside the makefile with the added option of -l ftdi.  The final g++ command run:

      g++  -g -O2  -o butterflyprog butterfly.o bitfile.o devicedb.o iobase.o jtag.o progalgspi.o progalgxc3s.o tools.o ioftdi.o -lftdi

So far I have not tried writing to the board.  Only tested it in the detection commands as below:

$ ./butterflyprog -vj

Using built-in device list

JTAG chainpos: 0 Device IDCODE = 0x11c1a093    Desc: XC3S250E

USB transactions: Write 3 read 2 retries 4

--

and

$ ./butterflyprog -vc

Using built-in device list

JTAG chainpos: 0 Device IDCODE = 0x11c1a093    Desc: XC3S250E

ISC_Done      = 1

ISC_Enabled    = 0

House Cleaning = 1

DONE          = 1

USB transactions: Write 4 read 3 retries 6

Now what is really needed is to check whether the arduino programming environment works on macosx.  Of course there's no Xilinx tool on macosx so eventually I will have to get back to Linux.  But it is nice to see that the loader software is fairly cross-platform....

Thanks to open software and hardware!

Best wishes,

Shashi

--

Shashikiran Ganesh

http://www.prl.res.in/~shashi

http://sarovar.org/users/shashi

Registered linux user number: 39542 (http://counter.li.org)

Share this post


Link to post
Share on other sites

Shashi,

Welcome to the Papilio community, we are just getting started here and are glad to have you on board.

This is excellent information, thank you for taking the time to document your efforts. I created a cross-platform section in Playground and posted a link to your forum post. Please feel free to update the Playground with any thing you think might be useful.

Thanks,

Jack.

Share this post


Link to post
Share on other sites

Thanks Jack for the welcome.

I am just posting a query about the arduino IDE on Linux in the other section. 

We will also be testing out the ZPU core on the Papilio One.

Will keep you posted on developments / bug you with queries ...

Thanks,

Shashi

Share this post


Link to post
Share on other sites

Hello  When I tried to get ButterflyLoader1.5 to compile on 10.6.8,I was unable to find the lines mentioned in the OP. I had to copy ftdi.h and usb.h from /opt/local/include/ (Macports installation) to the Program folder.  It was also necessary to unload the ftdi kext -    sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext    - in order to program the Papilio.(I was getting the message "Could not access USB device 0403:6010.") Then, reload the kext -    sudo kextload /System/Library/Extensions/FTDIUSBSerialDriver.kext -    to use it as a serial port.

Share this post


Link to post
Share on other sites

Thank you for the update, in the end did you get the tools working under OSX?

Thanks,

Jack.

Share this post


Link to post
Share on other sites

Jack,

I've been trying to replicate this, but hit a couple of snags.  The autoconf change in the first post *shouldn't* be necessary, as Mac OS X ships with pkg-config which should in turn include that macro.  I am still trying to come up with a better solution there.

The second issue is worse though; libftdi can't steal the device from the system's FTDI driver, so because you don't have a custom VID/PID pair there's no way short of manually unloading the system FTDI driver to talk to it.

This then of course means that you have to re-load it if you want to use the serial port to talk to your design, which is a bit suboptimal.

= Mike

Share this post


Link to post
Share on other sites

Mike,

It is possible to compile the papilio loader app to use the FTDI drivers instead of using the libftdi drivers. Maybe that would solve the issue?

Jack.

Share this post


Link to post
Share on other sites

I've solved the issues mentioned and updated the installation steps for papilio-loader. Here's the steps to duplicate my work. I am assuming you already have Xcode and MacPorts installed, as they make this much easier.

First, we install the dependancies (sorry if I'm missing some):


sudo port install libftdi libusb git

Then get the source code:


git clone git://github.com/GadgetFactory/Papilio-Loader.git
cd Papilio-Loader/Program/

And build:


./autogen.sh
export libftdi_CFLAGS="-I/opt/local/include"
export libftdi_LIBS="-L/opt/local/lib -lftdi"
./configure && make

Now the programmer side is ready, go ahead and plug in your board and verify it works:


./papilio-prog -vj
#Using built-in device list
#JTAG chainpos: 0 Device IDCODE = 0x11c1a093  Desc: XC3S250E
#USB transactions: Write 3 read 2 retries 1

./papilio-prog -C
#Using built-in device list
#JTAG chainpos: 0 Device IDCODE = 0x11c1a093  Desc: XC3S250E
#
#STAT Register
#ID_ERROR  = 0      IDCODE not validated.
#DONE      = 1      Input from the DONE pin.
#INIT      = 1      Input from the INIT pin.
#MODE      = 001b  Input from the MODE pins (M2:M0).
#GHIGH_B  = 1      0 = asserted.
#GWE      = 1      0 = all FFs and Block RAMs are write-disabled.
#GTS_CFG  = 1      0 = all I/Os are 3-stated.
#IN_ERROR  = 0      Legacy input error.
#DCI_MATCH = 1      DCI is matched.
#DCM_LOCK  = 1      DCMs are locked.
#CRC_ERROR = 0      CRC error.

The next step is to get the USB <-> serial driver working. If you don't need it, you can stop here.

Download & install the appropriate driver from http://www.ftdichip.com/Drivers/VCP.htm

After re-inserting the fpga device, you will now have two new serial devices (the exact numbers could be different):

/dev/tty.usbserial-0000111AA

/dev/tty.usbserial-0000111AB

However, we don't want that first serial port since it conflicts with the papilio-prog.

The final step is to make the FTDI driver play nicely with the papilio-prog by deleting the port:


sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext
cd /System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents
sudo cp Info.plist Backup-Info.plist

# edit the plist comment-out or delete the sections (key and dict) where you find <key>FT2232C_A<key> or <key>FT2232H_A</key>
# (see my Info.plist below for an example. note that I had to delete many of the other device ID's to get it to fit in the character limit for this post. they don't make a difference. the only ones you care about and need to remove is the one(s) mentioned previously)
sudo nano Info.plist

sudo kextload /System/Library/Extensions/FTDIUSBSerialDriver.kext


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleDevelopmentRegion</key>
  <string>English</string>
  <key>CFBundleExecutable</key>
  <string>FTDIUSBSerialDriver</string>
  <key>CFBundleIdentifier</key>
  <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
  <key>CFBundleInfoDictionaryVersion</key>
  <string>6.0</string>
  <key>CFBundleName</key>
  <string>I/O Kit Driver for FTDI USB Devices</string>
  <key>CFBundlePackageType</key>
  <string>KEXT</string>
  <key>CFBundleShortVersionString</key>
  <string>2.2.16</string>
  <key>CFBundleSignature</key>
  <string>?</string>
  <key>CFBundleVersion</key>
  <string>2.2.16</string>
  <key>IOKitPersonalities</key>
  <dict>
      <key>485USBTB-4W</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>idProduct</key>
        <integer>44084</integer>
        <key>idVendor</key>
        <integer>2134</integer>
      </dict>
      <!-- <key>FT2232C_A</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>idProduct</key>
        <integer>24592</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict> -->
      <key>FT2232C_B</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>1</integer>
        <key>idProduct</key>
        <integer>24592</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <!--<key>FT2232H_A</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>bcdDevice</key>
        <integer>1792</integer>
        <key>idProduct</key>
        <integer>24592</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>-->
      <key>FT2232H_B</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>1</integer>
        <key>bcdDevice</key>
        <integer>1792</integer>
        <key>idProduct</key>
        <integer>24592</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FT232H</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>bcdDevice</key>
        <integer>2304</integer>
        <key>idProduct</key>
        <integer>24596</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FT4232H_A</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>bcdDevice</key>
        <integer>2048</integer>
        <key>idProduct</key>
        <integer>24593</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FT4232H_B</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>1</integer>
        <key>bcdDevice</key>
        <integer>2048</integer>
        <key>idProduct</key>
        <integer>24593</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FT4232H_C</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>2</integer>
        <key>bcdDevice</key>
        <integer>2048</integer>
        <key>idProduct</key>
        <integer>24593</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FT4232H_D</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>3</integer>
        <key>bcdDevice</key>
        <integer>2048</integer>
        <key>idProduct</key>
        <integer>24593</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FTDI R Chip</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>bcdDevice</key>
        <integer>1536</integer>
        <key>idProduct</key>
        <integer>24577</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FTDI Recovery PID</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>idProduct</key>
        <integer>24582</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FTDI2XXAM</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>bcdDevice</key>
        <integer>512</integer>
        <key>idProduct</key>
        <integer>24577</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
      <key>FTDI2XXBM</key>
      <dict>
        <key>CFBundleIdentifier</key>
        <string>com.FTDI.driver.FTDIUSBSerialDriver</string>
        <key>ConfigData</key>
        <dict>
            <key>LatencyTimer</key>
            <integer>16</integer>
            <key>MIDI</key>
            <false/>
        </dict>
        <key>IOClass</key>
        <string>FTDIUSBSerialDriver</string>
        <key>IOProviderClass</key>
        <string>IOUSBInterface</string>
        <key>bConfigurationValue</key>
        <integer>1</integer>
        <key>bInterfaceNumber</key>
        <integer>0</integer>
        <key>bcdDevice</key>
        <integer>1024</integer>
        <key>idProduct</key>
        <integer>24577</integer>
        <key>idVendor</key>
        <integer>1027</integer>
      </dict>
  </dict>
  <key>OSBundleLibraries</key>
  <dict>
      <key>com.apple.iokit.IOSerialFamily</key>
      <string>1.0.4</string>
      <key>com.apple.iokit.IOUSBFamily</key>
      <string>1.8</string>
      <key>com.apple.kernel.bsd</key>
      <string>6.0</string>
      <key>com.apple.kernel.iokit</key>
      <string>1.0.7</string>
      <key>com.apple.kernel.libkern</key>
      <string>1.0.7</string>
      <key>com.apple.kernel.mach</key>
      <string>1.0.7</string>
  </dict>
  <key>OSBundleLibraries_i386</key>
  <dict>
      <key>com.apple.iokit.IOSerialFamily</key>
      <string>1.0.4</string>
      <key>com.apple.iokit.IOUSBFamily</key>
      <string>1.8</string>
      <key>com.apple.kpi.bsd</key>
      <string>8.0.0</string>
      <key>com.apple.kpi.iokit</key>
      <string>8.0.0</string>
      <key>com.apple.kpi.libkern</key>
      <string>8.0.0</string>
      <key>com.apple.kpi.mach</key>
      <string>8.0.0</string>
  </dict>
  <key>OSBundleLibraries_x86_64</key>
  <dict>
      <key>com.apple.iokit.IOSerialFamily</key>
      <string>1.0.4</string>
      <key>com.apple.iokit.IOUSBFamily</key>
      <string>1.8</string>
      <key>com.apple.kpi.bsd</key>
      <string>8.0.0</string>
      <key>com.apple.kpi.iokit</key>
      <string>8.0.0</string>
      <key>com.apple.kpi.libkern</key>
      <string>8.0.0</string>
      <key>com.apple.kpi.mach</key>
      <string>8.0.0</string>
  </dict>
</dict>
</plist>

And that's it! You should have only one serial port (B) that works along side the papilio-prog.

Programming your Papilio FPGA:


./papilio-prog -v -f ~/Downloads/Quickstart-Papilio_One_250K-v1.5.bit

Write to your Papilio SRAM:


./papilio-prog -v -f ~/Downloads/Quickstart-Papilio_One_250K-v1.5.bit -b ../Fpga/bscan_spi_xc3s250e.bit

Open a serial port:


screen /dev/tty.usbserial-0000111AB 9600

(edited 2/27/12 to fix missing newline -- good catch rafadose)

Share this post


Link to post
Share on other sites

If during configure script you get the error:


./configure: line 4076: syntax error near unexpected token `libftdi,'
./configure: line 4076: ` PKG_CHECK_MODULES(libftdi, libftdi >= 0.16,'

You must modify aclocal line of autogen.sh (it's explained in this blog):

#!/bin/sh



echo "Generating build system..."
aclocal -I /opt/local/share/aclocal \
&& autoheader \
&& automake --add-missing --copy --foreign \
&& autoconf

Share this post


Link to post
Share on other sites

If during configure script you get the error:


./configure: line 4076: syntax error near unexpected token `libftdi,'
./configure: line 4076: `  PKG_CHECK_MODULES(libftdi, libftdi >= 0.16,'

You must modify aclocal line of autogen.sh (it's explained in this blog):

#!/bin/sh



echo "Generating build system..."
aclocal -I /opt/local/share/aclocal \
&& autoheader \
&& automake --add-missing --copy --foreign \
&& autoconf

that makes sense. it seems that since I had previously installed MacPorts autoconf, automake, and pkgconfig, this issue didn't come up for me.

Share this post


Link to post
Share on other sites

After rebooting, it appears it may be necessary to reload the kext once with the board plugged in to (re-)delete port A, until the next reboot. (confirmed by rafadose)

Share this post


Link to post
Share on other sites

(I'm the same as Guest_vtjnash from the old system)

 

Update for 10.10 Yosemite:

 

Apple now includes the FTDI driver with the OS, so downloading the driver separately is not required. However, the file to update is slightly different because of this.

 

In /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBFTDI.kext/Contents/Info.plist

comment out or remove the section "<key>AppleUSBEFTDI-6010-0</key><dict>...</dict>"

 

Then run:

sudo touch /System/Library/Extensions

so the system will rebuild the kernel cache (to pick up the changes on the next reboot), and run

kextunload /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBFTDI.kextkextload /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBFTDI.kext

to pick up the changes immediately.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now