| # This script is inspired from ./openocd.sh, and from both flash_dfu.sh and |
| # fwversion.sh, included in arduino101-factory_recovery-flashpack.tar.bz2, |
| # which is available from https://downloadcenter.intel.com/download/25470 |
| DFUUTIL_EXE=${DFUUTIL:-dfu-util} |
| DFUUTIL_CMD="$DFUUTIL_EXE -d,$DFUUTIL_PID" |
| if ! which $DFUUTIL_EXE >/dev/null 2>&1; then |
| echo "Error: Unable to locate dfu-util executable: $DFUUTIL_EXE" |
| if [ ! -f "$DFUUTIL_IMG" ]; then |
| echo "Error: Unable to locate binary image: $DFUUTIL_IMG" |
| $DFUUTIL_CMD -l |grep "$DFUUTIL_ALT" >/dev/null 2>&1 |
| # Wait until DFU device is ready |
| echo "Please reset your board to switch to DFU mode..." |
| # Flash DFU device with specified image |
| # Do NOT reset with -R, to avoid random 'error resetting after download' |
| $DFUUTIL_CMD -a $DFUUTIL_ALT -D $DFUUTIL_IMG |
| if [ $ok -eq 0 -a $reset_dfu -eq 1 ]; then |
| echo "Now reset your board again to switch back to runtime mode." |
| echo "Unsupported command '$CMD'" |