2008-10-30 08:23:38 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Set up pathes to binaries, scripts, configuration files
|
|
|
|
|
2011-02-11 09:30:40 +08:00
|
|
|
hostos=`uname -o 2>/dev/null || echo "Other"`
|
2010-05-03 11:32:48 +08:00
|
|
|
if [ "X${hostos}" = "XCygwin" ]; then
|
|
|
|
installdir=/cygdrive/c/gccfd/openocd/bin
|
|
|
|
ft2exe=$installdir/openocd-ftd2xx.exe
|
|
|
|
ppexe=$installdir/openocd-ppdev.exe
|
|
|
|
else
|
|
|
|
installdir=/usr/local/bin
|
|
|
|
ft2exe=$installdir/openocd
|
|
|
|
ppexe=$installdir/openocd
|
|
|
|
SUDO=sudo
|
|
|
|
fi
|
2008-10-30 08:23:38 +08:00
|
|
|
|
|
|
|
# The root to the top-level NuttX directory should be in an environment variable
|
|
|
|
|
2008-11-05 22:40:39 +08:00
|
|
|
if [ -z $STR41XSCRIPTS ]; then
|
|
|
|
echo "Environment variable $STR41XSCRIPTS is not defined"
|
2008-10-30 08:23:38 +08:00
|
|
|
echo "Has NuttX been configured?"
|
|
|
|
echo "If so, try sourcing the setenv.sh script in the top-level directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that at least one configuration file exists at that point
|
2010-05-03 11:32:48 +08:00
|
|
|
if [ ! -f $STR41XSCRIPTS/oocd_ft2xx.cfg ]; then
|
2008-11-05 22:40:39 +08:00
|
|
|
echo "No configuration files found at $STR41XSCRIPTS"
|
2008-10-30 08:23:38 +08:00
|
|
|
echo "Path to configuration files unknown"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Parse command line inputs
|
|
|
|
|
2010-05-03 11:32:48 +08:00
|
|
|
usage="USAGE: $0 [-h] [-d] [-pp] [-ft2xx]"
|
2008-10-30 08:23:38 +08:00
|
|
|
|
|
|
|
debug=no
|
2010-05-03 11:32:48 +08:00
|
|
|
oocdcfg=$STR41XSCRIPTS/oocd_ft2xx.cfg
|
|
|
|
openocd=$ft2exe
|
2008-10-30 08:23:38 +08:00
|
|
|
while [ ! -z "$1" ]; do
|
|
|
|
case $1 in
|
|
|
|
-d )
|
|
|
|
debug=yes
|
|
|
|
set -x
|
|
|
|
;;
|
|
|
|
-pp )
|
2008-11-05 22:40:39 +08:00
|
|
|
oocdcfg=$STR41XSCRIPTS/oocd_wiggler.cfg
|
2010-05-03 11:32:48 +08:00
|
|
|
openocd=$ppexe
|
2008-10-30 08:23:38 +08:00
|
|
|
;;
|
2010-05-03 11:32:48 +08:00
|
|
|
-ft2xx )
|
|
|
|
oocdcfg=$STR41XSCRIPTS/oocd_ft2xx.cfg
|
|
|
|
openocd=$ft2exe
|
2008-10-30 08:23:38 +08:00
|
|
|
;;
|
|
|
|
-h )
|
|
|
|
echo $usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "Unrecognized option: $1"
|
|
|
|
echo $usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# Setup debug options
|
|
|
|
|
|
|
|
export options="-d 1"
|
|
|
|
|
2014-04-14 06:22:22 +08:00
|
|
|
# Run OpenOCD -- here it is assumed (1) that you must have root priveleges to
|
2008-10-30 08:23:38 +08:00
|
|
|
# execute OpenOCD and (2) that your user is listed in the /etc/sudoers file.
|
|
|
|
|
2010-05-03 11:32:48 +08:00
|
|
|
$SUDO $openocd $options -f $oocdcfg
|
|
|
|
if [ "X${hostos}" = "XCygwin" ]; then
|
|
|
|
$openocd $options -f `cygpath -w $oocdcfg`
|
|
|
|
else
|
|
|
|
sudo $openocd $options -f $oocdcfg
|
|
|
|
fi
|