Cannot upload sketch to arduino: "avrdude: stk500_getsync(): not in sync: res...

When trying to upload a test sketch to my new Seeeduino, I get the following errors from avrdude:

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x00

I am using the command-line Makefile (Arduino.mk – http://mjo.tc/atelier/2009/02/arduino-cli.html), NOT the arduino IDE (as it can’t detect my serial port).

OS: Crunchbang Linux statler (bear in mind this was cleanly installed today and may be missing some packages/drivers)
Serial port: /dev/ttyUSB0 (USB-to-serial connector)

The code is the equivalent of the Blink sketch. No external wires or shields are attached (just the USB cable)

The board is a new Seeeduino (using ATmega368P, verified with specs), running off USB power supply. The sketch uploads and runs perfectly on my older ATMega168 Seeeduino (2 years old).

On reset, the L light flashes once, then pauses for around a second. The TX and L lights then begin to flash rapidly (~5Hz). After ~30 secs, the TX light stops but L continues to flash rapidly. I have checked the data transmitted to the PC and found it to consist entirely of NULs (0x00s).

The board is set to automatic reset mode. Actually pressing the reset button (at various time intervals), with or without manual reset enabled, has no effect.

Complete output from upload:

$ sudo make upload
[sudo] password for kier: 
for STTYF in 'stty --file' 'stty -f' 'stty <' ; \
		  do $STTYF /dev/tty >/dev/null 2>/dev/null && break ; \
		done ;\
		$STTYF /dev/ttyUSB0  hupcl ;\
		(sleep 0.1 || sleep 1)     ;\
		$STTYF /dev/ttyUSB0 -hupcl 
/home/kier/libraries/arduino-0018/hardware/tools/avrdude -q -V -p atmega328p -C /home/kier/libraries/arduino-0018/hardware/tools/avrdude.conf -c stk500v1 -b 19200 -P /dev/ttyUSB0 \
			-U flash:w:build-cli/test.hex:i
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x00

avrdude done.  Thank you.

make: *** [raw_upload] Error 1

The source code tarball is at http://dl.dropbox.com/u/26542062/test.tgz

I have searched the web for a solution to this problem and it seems that different solutions work for different people. As of yet, none have worked for me. And yes, I’ve read the troubleshooting.

Does the port speed match?

If the seeeduino comes with later bootloaders (optiboot), you need to set it to 115200. I think 57600 was used at one point as well, but I may be wrong.

madworm:
Does the port speed match?

If the seeeduino comes with later bootloaders (optiboot), you need to set it to 115200. I think 57600 was used at one point as well, but I may be wrong.

Optiboot uses 115200? Not so sure thats such a good idea. Sometimes the Arduino<->PC communication is a bit buggy at 115200 and probably shouldn’t be used for code upload.

Thanks! Problem solved!

Setting the baud rate to 57600 (and pressing reset at the right time) got it working.