Skip to content

Instantly share code, notes, and snippets.

@cjmeyer
Created December 10, 2012 15:26
Show Gist options
  • Save cjmeyer/4251241 to your computer and use it in GitHub Desktop.
Save cjmeyer/4251241 to your computer and use it in GitHub Desktop.
Bash: OpenOCD build script (Cygwin/MinGW).
#! /usr/bin/sh
OPENOCD_VERSION=0.5.0
D2XXLIB_SRC="CDM%202.08.24%20WHQL%20Certified"
D2XXLIB=CDM_20824
OPENOCD=openocd-${OPENOCD_VERSION}
PREFIX=/opt/${OPENOCD}
PATH_DIR=/opt/openocd
if [ ! -e ${D2XXLIB}.zip ]; then
echo "Downloading D2XX..."
curl -L "http://www.ftdichip.com/Drivers/CDM/${D2XXLIB_SRC}.zip" -o ${D2XXLIB}.zip
fi
if [ ! -e ${OPENOCD}.tar.gz ]; then
echo "Downloading OpenOCD..."
curl -L "http://downloads.sourceforge.net/project/openocd/openocd/${OPENOCD_VERSION}/${OPENOCD}.tar.gz" -o ${OPENOCD}.tar.gz
fi
echo "Unpacking D2XX..."
unzip -uo -qq ${D2XXLIB}.zip -d ${D2XXLIB}
echo "Unpacking OpenOCD..."
tar -zxf ${OPENOCD}.tar.gz
cp ${D2XXLIB}/i386/ftd2xx.dll ${OPENOCD}
chmod +x ${OPENOCD}/ftd2xx.dll
cd ${OPENOCD}
./configure --enable-maintainer-mode --disable-werror --disable-shared \
--enable-ft2232_ftd2xx --with-ftd2xx-win32-zipdir=../${D2XXLIB} \
--prefix=${PREFIX}
make
make install
cd ..
ln -s ${PREFIX} ${PATH_DIR}
echo "Add ${PATH_DIR} to your PATH environment variable."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment