I have run into this error several times. The only fix I have found is to restart the system running the IDE.
I hope there is a better solution. Hopefully, people can help me out.
Binary sketch size: 54,404 bytes (of a 262,144 byte maximum) - 20% used
cygwin warning:
MS-DOS style path detected: C:\Intel\arduino-1.5.3/hardware/arduino/x86/tools/izmir/clupload_win.sh
Preferred POSIX equivalent is: /cygdrive/c/Intel/arduino-1.5.3/hardware/arduino/x86/tools/izmir/clupload_win.sh
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
#!/bin/sh
echo "starting download script"
echo "Args to shell:" $*
# ARG 1: Path to lsz executable.
# ARG 2: Elf File to download
# ARG 3: COM port to use.
starting download script
Args to shell: C:\Intel\arduino-1.5.3/hardware/tools/x86/bin C:\Users\OFFICE~1\AppData\Local\Temp\build2347904014153457648.tmp/SD_readWrite.cpp.elf COM9
COM PORT 9
Converted COM Port COM9 to tty port /dev/ttyS8
Sending Command String to move to download if not already in download mode
Deleting existing sketch on target
#path contains \ need to change all to /
path_to_exe=$1
fixed_path=${path_to_exe//\\/\/}
#COM ports are not always setup to be addressed via COM for redirect.
#/dev/ttySx are present. Howwever, COMy -> /dev/ttySx where x = y - 1
com_port_arg=$3
com_port_id=${com_port_arg/COM/}
echo "COM PORT" $com_port_id
tty_port_id=/dev/ttyS$((com_port_id-1))
echo "Converted COM Port" $com_port_arg "to tty port" $tty_port_id
echo "Sending Command String to move to download if not already in download mode"
echo "~sketch download" > $tty_port_id
#Move the existing sketch on target.
echo "Deleting existing sketch on target"
$fixed_path/lsz.exe --escape -c "mv -f /sketch/sketch.elf /sketch/sketch.elf.old" <> $tty_port_id 1>&0