oocd.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. # Set up pathes to binaries, scripts, configuration files
  3. hostos=`uname -o 2>/dev/null || echo "Other"`
  4. if [ "X${hostos}" = "XCygwin" ]; then
  5. installdir=/cygdrive/c/gccfd/openocd/bin
  6. ft2exe=$installdir/openocd-ftd2xx.exe
  7. ppexe=$installdir/openocd-ppdev.exe
  8. else
  9. installdir=/usr/local/bin
  10. ft2exe=$installdir/openocd
  11. ppexe=$installdir/openocd
  12. SUDO=sudo
  13. fi
  14. # The root to the top-level NuttX directory should be in an environment variable
  15. if [ -z $STR41XSCRIPTS ]; then
  16. echo "Environment variable $STR41XSCRIPTS is not defined"
  17. echo "Has NuttX been configured?"
  18. exit 1
  19. fi
  20. # Check that at least one configuration file exists at that point
  21. if [ ! -f $STR41XSCRIPTS/oocd_ft2xx.cfg ]; then
  22. echo "No configuration files found at $STR41XSCRIPTS"
  23. echo "Path to configuration files unknown"
  24. exit 1
  25. fi
  26. # Parse command line inputs
  27. usage="USAGE: $0 [-h] [-d] [-pp] [-ft2xx]"
  28. debug=no
  29. oocdcfg=$STR41XSCRIPTS/oocd_ft2xx.cfg
  30. openocd=$ft2exe
  31. while [ ! -z "$1" ]; do
  32. case $1 in
  33. -d )
  34. debug=yes
  35. set -x
  36. ;;
  37. -pp )
  38. oocdcfg=$STR41XSCRIPTS/oocd_wiggler.cfg
  39. openocd=$ppexe
  40. ;;
  41. -ft2xx )
  42. oocdcfg=$STR41XSCRIPTS/oocd_ft2xx.cfg
  43. openocd=$ft2exe
  44. ;;
  45. -h )
  46. echo $usage
  47. exit 0
  48. ;;
  49. * )
  50. echo "Unrecognized option: $1"
  51. echo $usage
  52. exit 1
  53. ;;
  54. esac
  55. shift
  56. done
  57. # Setup debug options
  58. export options="-d 1"
  59. # Run OpenOCD -- here it is assumed (1) that you must have root priveleges to
  60. # execute OpenOCD and (2) that your user is listed in the /etc/sudoers file.
  61. $SUDO $openocd $options -f $oocdcfg
  62. if [ "X${hostos}" = "XCygwin" ]; then
  63. $openocd $options -f `cygpath -w $oocdcfg`
  64. else
  65. sudo $openocd $options -f $oocdcfg
  66. fi