Skip to content

Instantly share code, notes, and snippets.

@tsnow
Last active September 25, 2016 21:22
Show Gist options
  • Save tsnow/1eeeceaed79a2541f6d2b3eb00bfcb1e to your computer and use it in GitHub Desktop.
Save tsnow/1eeeceaed79a2541f6d2b3eb00bfcb1e to your computer and use it in GitHub Desktop.
Fixing icestudio's binaries to upload to icestick
#!/bin/bash
# Downloaded FTDI Driver from here: http://www.libdivecomputer.org/drivers.html http://www.ftdichip.com/Drivers/VCP/MacOSX/FTDIUSBSerialDriver_v2_3.dmg and installed it first.
# Did forgotten things with the ~/.icestudio venv and reinstalled apio a couple times via the UI.
homebrew_lib=/opt/boxen/homebrew/lib/
for k in ~/.apio/packages/system/find_all ~/.apio/packages/toolchain-icestorm/bin/iceprog do
echo "libftdi1.2.dylib libftdi1.2.dylib
/Users/bqlabs/develop/tools-usb-ftdi/build_darwin/lib/libusb-1.0.0.dylib libusb-1.0.0.dylib
/usr/local/opt/libusb/lib/libusb-1.0.0.dylib libusb-1.0.0.dylib
/usr/local/opt/libftdi/lib/libftdi1.2.dylib libftdi1.2.dylib
" | while read i j; do
install_name_tool -change $i "$homebrew_lib"$j $k
done
done
(venv) %m%# otool -L /Users/tsnow/.apio/packages/system/find_all
/Users/tsnow/.apio/packages/system/find_all:
libftdi1.2.dylib (compatibility version 2.0.0, current version 2.2.0)
/Users/bqlabs/develop/tools-usb-ftdi/build_darwin/lib/libusb-1.0.0.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
(venv) %m%# find /usr/local/ -name 'libftdi*'
(venv) %m%# find /opt/ -name 'libftdi*'
X11/ boxen/ homebrew-cask/ rubies/ vagrant/
(venv) %m%# find /opt/boxen/homebrew/ -name 'libftdi*'
.git/ .travis.yml CONTRIBUTING.md Library/ completions/ include/ opt/ var/
.github/ .yardopts Cellar/ README.md docs/ lib/ sbin/
.gitignore CODEOFCONDUCT.md LICENSE.txt bin/ etc/ manpages/ share/
(venv) %m%# find /opt/boxen/homebrew/ -name 'libftdi*'
/opt/boxen/homebrew//bin/libftdi-config
/opt/boxen/homebrew//bin/libftdi1-config
/opt/boxen/homebrew//Cellar/libftdi
/opt/boxen/homebrew//Cellar/libftdi/1.3/bin/libftdi1-config
/opt/boxen/homebrew//Cellar/libftdi/1.3/include/libftdi1
/opt/boxen/homebrew//Cellar/libftdi/1.3/lib/cmake/libftdi1
/opt/boxen/homebrew//Cellar/libftdi/1.3/lib/libftdi1.2.3.0.dylib
/opt/boxen/homebrew//Cellar/libftdi/1.3/lib/libftdi1.2.dylib
/opt/boxen/homebrew//Cellar/libftdi/1.3/lib/libftdi1.a
/opt/boxen/homebrew//Cellar/libftdi/1.3/lib/libftdi1.dylib
/opt/boxen/homebrew//Cellar/libftdi/1.3/lib/pkgconfig/libftdi1.pc
/opt/boxen/homebrew//Cellar/libftdi/1.3/lib/pkgconfig/libftdipp1.pc
/opt/boxen/homebrew//Cellar/libftdi/1.3/share/libftdi
/opt/boxen/homebrew//Cellar/libftdi0
/opt/boxen/homebrew//Cellar/libftdi0/0.20/bin/libftdi-config
/opt/boxen/homebrew//Cellar/libftdi0/0.20/lib/libftdi.1.dylib
/opt/boxen/homebrew//Cellar/libftdi0/0.20/lib/libftdi.a
/opt/boxen/homebrew//Cellar/libftdi0/0.20/lib/libftdi.dylib
/opt/boxen/homebrew//Cellar/libftdi0/0.20/lib/pkgconfig/libftdi.pc
/opt/boxen/homebrew//include/libftdi1
/opt/boxen/homebrew//lib/cmake/libftdi1
/opt/boxen/homebrew//lib/libftdi.1.dylib
/opt/boxen/homebrew//lib/libftdi.a
/opt/boxen/homebrew//lib/libftdi.dylib
/opt/boxen/homebrew//lib/libftdi1.2.3.0.dylib
/opt/boxen/homebrew//lib/libftdi1.2.dylib
/opt/boxen/homebrew//lib/libftdi1.a
/opt/boxen/homebrew//lib/libftdi1.dylib
/opt/boxen/homebrew//lib/pkgconfig/libftdi.pc
/opt/boxen/homebrew//lib/pkgconfig/libftdi1.pc
/opt/boxen/homebrew//lib/pkgconfig/libftdipp1.pc
/opt/boxen/homebrew//Library/Locks/libftdi.brewing
/opt/boxen/homebrew//Library/Taps/homebrew/homebrew-core/Formula/libftdi.rb
/opt/boxen/homebrew//Library/Taps/homebrew/homebrew-core/Formula/libftdi0.rb
/opt/boxen/homebrew//opt/libftdi
/opt/boxen/homebrew//opt/libftdi0
/opt/boxen/homebrew//share/libftdi
/opt/boxen/homebrew//var/homebrew/linked/libftdi
/opt/boxen/homebrew//var/homebrew/linked/libftdi0
/opt/boxen/homebrew//var/homebrew/locks/libftdi.brewing
/opt/boxen/homebrew//var/homebrew/locks/libftdi0.brewing
(venv) %m%# DYLIB_LIBRARY_PATH=/opt/boxen/homebrew//lib/libftdi1.2.dylib:$DYLIB_LIBRARY_PATH ~/.icestudio/venv/bin/apio upload
Info: use apio.ini board: icestick
dyld: Library not loaded: libftdi1.2.dylib
Referenced from: /Users/tsnow/.apio/packages/system/find_all
Reason: image not found
Error: board not detected
(venv) %m%# otool -L /Users/tsnow/.apio/packages/system/find_all
/Users/tsnow/.apio/packages/system/find_all:
libftdi1.2.dylib (compatibility version 2.0.0, current version 2.2.0)
/Users/bqlabs/develop/tools-usb-ftdi/build_darwin/lib/libusb-1.0.0.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
(venv) %m%# install_name_tool -change libftdi1.2.dylib /opt/boxen/homebrew//lib/libftdi1.2.dylib
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] input
(venv) %m%#
(venv) %m%# install_name_tool -change libftdi1.2.dylib /opt/boxen/homebrew//lib/libftdi1.2.dylib /Users/tsnow/.apio/packages/system/find_all
(venv) %m%# DYLIB_LIBRARY_PATH=/opt/boxen/homebrew//lib/libftdi1.2.dylib:$DYLIB_LIBRARY_PATH ~/.icestudio/venv/bin/apio upload
Info: use apio.ini board: icestick
dyld: Library not loaded: /Users/bqlabs/develop/tools-usb-ftdi/build_darwin/lib/libusb-1.0.0.dylib
Referenced from: /Users/tsnow/.apio/packages/system/find_all
Reason: image not found
Error: board not detected
(venv) %m%# otool -L /Users/tsnow/.apio/packages/system/find_all
/Users/tsnow/.apio/packages/system/find_all:
/opt/boxen/homebrew//lib/libftdi1.2.dylib (compatibility version 2.0.0, current version 2.2.0)
/Users/bqlabs/develop/tools-usb-ftdi/build_darwin/lib/libusb-1.0.0.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
(venv) %m%# find /opt/boxen/homebrew/ -name 'libusb*'
/opt/boxen/homebrew//bin/libusb-config
/opt/boxen/homebrew//Cellar/libusb
/opt/boxen/homebrew//Cellar/libusb/1.0.20/include/libusb-1.0
/opt/boxen/homebrew//Cellar/libusb/1.0.20/include/libusb-1.0/libusb.h
/opt/boxen/homebrew//Cellar/libusb/1.0.20/lib/libusb-1.0.0.dylib
/opt/boxen/homebrew//Cellar/libusb/1.0.20/lib/libusb-1.0.a
/opt/boxen/homebrew//Cellar/libusb/1.0.20/lib/libusb-1.0.dylib
/opt/boxen/homebrew//Cellar/libusb/1.0.20/lib/pkgconfig/libusb-1.0.pc
/opt/boxen/homebrew//Cellar/libusb/1.0.20/share/libusb
/opt/boxen/homebrew//Cellar/libusb-compat
/opt/boxen/homebrew//Cellar/libusb-compat/0.1.5/bin/libusb-config
/opt/boxen/homebrew//Cellar/libusb-compat/0.1.5/lib/libusb-0.1.4.dylib
/opt/boxen/homebrew//Cellar/libusb-compat/0.1.5/lib/libusb.a
/opt/boxen/homebrew//Cellar/libusb-compat/0.1.5/lib/libusb.dylib
/opt/boxen/homebrew//Cellar/libusb-compat/0.1.5/lib/pkgconfig/libusb.pc
/opt/boxen/homebrew//include/libusb-1.0
/opt/boxen/homebrew//lib/libusb-0.1.4.dylib
/opt/boxen/homebrew//lib/libusb-1.0.0.dylib
/opt/boxen/homebrew//lib/libusb-1.0.a
/opt/boxen/homebrew//lib/libusb-1.0.dylib
/opt/boxen/homebrew//lib/libusb.a
/opt/boxen/homebrew//lib/libusb.dylib
/opt/boxen/homebrew//lib/pkgconfig/libusb-1.0.pc
/opt/boxen/homebrew//lib/pkgconfig/libusb.pc
/opt/boxen/homebrew//Library/Locks/libusb.brewing
/opt/boxen/homebrew//Library/Taps/homebrew/homebrew-core/Formula/libusb-compat.rb
/opt/boxen/homebrew//Library/Taps/homebrew/homebrew-core/Formula/libusb.rb
/opt/boxen/homebrew//opt/libusb
/opt/boxen/homebrew//opt/libusb-compat
/opt/boxen/homebrew//share/libusb
/opt/boxen/homebrew//var/homebrew/linked/libusb
/opt/boxen/homebrew//var/homebrew/linked/libusb-compat
/opt/boxen/homebrew//var/homebrew/locks/libusb-compat.brewing
/opt/boxen/homebrew//var/homebrew/locks/libusb.brewing
(venv) %m%# install_name_tool -change /Users/bqlabs/develop/tools-usb-ftdi/build_darwin/lib/libusb-1.0.0.dylib /opt/boxen/homebrew//lib/libusb-1.0.0.dylib /Users/tsnow/.apio/packages/system/find_all
(venv) %m%# otool -L /Users/tsnow/.apio/packages/system/find_all
/Users/tsnow/.apio/packages/system/find_all:
/opt/boxen/homebrew//lib/libftdi1.2.dylib (compatibility version 2.0.0, current version 2.2.0)
/opt/boxen/homebrew//lib/libusb-1.0.0.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
(venv) %m%# DYLIB_LIBRARY_PATH=/opt/boxen/homebrew//lib/libftdi1.2.dylib:$DYLIB_LIBRARY_PATH ~/.icestudio/venv/bin/apio upload
Info: use apio.ini board: icestick
Number of FTDI devices found: 1
Checking device: 0
Manufacturer: Lattice, Description: Lattice FTUSB Interface Cable
Using default SConstruct file
[Sun Sep 25 16:56:28 2016] Processing icestick
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Executing: scons -Q upload fpga_type=hx fpga_pack=tq144 fpga_size=1k device=0 prog=ftdi -f /Users/tsnow/.icestudio/venv/lib/python2.7/site-packages/apio/managers/../resources/SConstruct
FPGA_SIZE: 1k
FPGA_TYPE: hx
FPGA_PACK: tq144
PROG: ftdi
DEVICE: 0
iceprog -d i:0x0403:0x6010:0 hardware.bin
dyld: Library not loaded: /usr/local/opt/libftdi/lib/libftdi1.2.dylib
Referenced from: /Users/tsnow/.apio/packages/toolchain-icestorm/bin/iceprog
Reason: image not found
scons: *** [upload] Error -5
============================================================================= [ ERROR ] Took 0.63 seconds =============================================================================
(venv) %m%# install_name_tool -change /usr/local/opt/libftdi/lib/libftdi1.2.dylib /opt/boxen/homebrew//lib/libftdi1.2.dylib /Users/tsnow/.apio/packages/toolchain-icestorm/bin/iceprog
(venv) %m%# DYLIB_LIBRARY_PATH=/opt/boxen/homebrew//lib/libftdi1.2.dylib:$DYLIB_LIBRARY_PATH ~/.icestudio/venv/bin/apio upload
Info: use apio.ini board: icestick
Number of FTDI devices found: 0
Error: board not detected
(venv) %m%# ~/.icestudio/venv/bin/apio drivers --enable
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.
Warning: libftdi-1.3 already installed
Configure FTDI drivers for FPGA
Password:
(kernel) Kext com.FTDI.driver.FTDIUSBSerialDriver not found for unload request.
Failed to unload com.FTDI.driver.FTDIUSBSerialDriver - (libkern/kext) not found.
(kernel) Kext com.apple.driver.AppleUSBFTDI not found for unload request.
Failed to unload com.apple.driver.AppleUSBFTDI - (libkern/kext) not found.
FPGA drivers enabled
(venv) %m%# ~/.icestudio/venv/bin/apio drivers --disable
Revert FTDI drivers' configuration
FPGA drivers disabled
(venv) %m%# DYLIB_LIBRARY_PATH=/opt/boxen/homebrew//lib/libftdi1.2.dylib:$DYLIB_LIBRARY_PATH ~/.icestudio/venv/bin/apio upload
Info: use apio.ini board: icestick
Number of FTDI devices found: 0
Error: board not detected
(venv) %m%# ~/.icestudio/venv/bin/apio drivers --enable
Warning: libftdi-1.3 already installed
Configure FTDI drivers for FPGA
FPGA drivers enabled
(venv) %m%# DYLIB_LIBRARY_PATH=/opt/boxen/homebrew//lib/libftdi1.2.dylib:$DYLIB_LIBRARY_PATH ~/.icestudio/venv/bin/apio upload
Info: use apio.ini board: icestick
Number of FTDI devices found: 0
Error: board not detected
(venv) %m%# DYLIB_LIBRARY_PATH=/opt/boxen/homebrew//lib/libftdi1.2.dylib:$DYLIB_LIBRARY_PATH ~/.icestudio/venv/bin/apio upload
Info: use apio.ini board: icestick
Number of FTDI devices found: 1
Checking device: 0
Manufacturer: Lattice, Description: Lattice FTUSB Interface Cable
Using default SConstruct file
[Sun Sep 25 17:07:35 2016] Processing icestick
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Executing: scons -Q upload fpga_type=hx fpga_pack=tq144 fpga_size=1k device=0 prog=ftdi -f /Users/tsnow/.icestudio/venv/lib/python2.7/site-packages/apio/managers/../resources/SConstruct
FPGA_SIZE: 1k
FPGA_TYPE: hx
FPGA_PACK: tq144
PROG: ftdi
DEVICE: 0
iceprog -d i:0x0403:0x6010:0 hardware.bin
dyld: Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
Referenced from: /Users/tsnow/.apio/packages/toolchain-icestorm/bin/iceprog
Reason: image not found
scons: *** [upload] Error -5
============================================================================= [ ERROR ] Took 0.63 seconds =============================================================================
(venv) %m%# install_name_tool -change /usr/local/opt/libftdi/lib/libftdi1.2.dylib /opt/boxen/homebrew/lib/libftdi1.2.dylib /Users/tsnow/.apio/packages/toolchain-icestorm/bin/iceprog
(venv) %m%# install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib /opt/boxen/homebrew/lib/libusb-1.0.0.dylib /Users/tsnow/.apio/packages/toolchain-icestorm/bin/iceprog
(venv) %m%# DYLIB_LIBRARY_PATH=/opt/boxen/homebrew//lib/libftdi1.2.dylib:$DYLIB_LIBRARY_PATH ~/.icestudio/venv/bin/apio upload
Info: use apio.ini board: icestick
Number of FTDI devices found: 1
Checking device: 0
Manufacturer: Lattice, Description: Lattice FTUSB Interface Cable
Using default SConstruct file
[Sun Sep 25 17:08:32 2016] Processing icestick
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Executing: scons -Q upload fpga_type=hx fpga_pack=tq144 fpga_size=1k device=0 prog=ftdi -f /Users/tsnow/.icestudio/venv/lib/python2.7/site-packages/apio/managers/../resources/SConstruct
FPGA_SIZE: 1k
FPGA_TYPE: hx
FPGA_PACK: tq144
PROG: ftdi
DEVICE: 0
iceprog -d i:0x0403:0x6010:0 hardware.bin
init..
cdone: high
reset..
cdone: low
flash ID: 0x20 0xBA 0x16 0x10 0x00 0x00 0x23 0x50 0x81 0x14 0x24 0x00 0x68 0x00 0x27 0x10 0x04 0x15 0x6A 0xFB
file size: 32220
erase 64kB sector at 0x000000..
programming..
reading..
VERIFY OK
cdone: high
Bye.
============================================================================= [SUCCESS] Took 9.66 seconds =============================================================================
(venv) %m%#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment