Avrdude intermittent problem (Mega2560)

Hi, my program interacts with the (windows xp - groan) command line using bat files. Avrdude 5.11.

In my bat file
"cd directory_where_hex_is
avrdude -c wiring -P com12 -p m2560 -U flash:w:plus1.hex"

plus1.hex was made using the arduino IDE. Usually this works fine, however the odd time the flashing hangs:

" ... Reading : #### : 16% 0.16savrdude stk500v2_ReceiveMessage(): timeout (repeated)"

Or when Writing.

Clues on the interwebs have pointed towards toggling the DTR signal of the com port (by use of -c arduino). But when I try to use this it hangs (I just replaced "wiring" with "arduino").

Should I include the baud rate in the command, or is this already catered for by specifying m2560? Any help (by way of complete commands) would be appreciated.

Cheers!

(deleted)

Works a treat - a hat tip to you, my man.

Unfortunately I spoke too soon

Both commands work, however the problem persists.

I will remake the hex files with a different com..

(deleted)

I think it's a hardware problem then. The board is flashed twice every 5 minutes, continuously. Perhaps there's a defect in the memory. Or a problem with the USB - I moved to another, lets see.

Thanks for the help!

Hi

Same issue, sometimes works fine (90% of the time, it works every time).

Here´s the error when I try to flashg when it´s in a non-responsive state.

avrdude -c wiring -P com12 -p atmega2560 -b115200 -U flash:w:minus1.hex:i
avrdude: ser_open(): can't set com-state for "\.\com12"
avrdude: ser_drain(): read error: Controlador no vßlido.

The problem can be resolved by replugging the USB. I was looking into a way with "mountvol com12 /d" "mountvol com12" to mimic this reset everytime, but as the arduino board isn´t a volume I didn´t find a way to do this.

Any ideas appreciated.

Cheers!

(deleted)

Ok, perhaps you could suggest a more appropriate forum? Thanks for the arduino command help before.

(EDIT: Going to see what I can destroy with http://support.moates.net/usb-drivers-ftclean/)