Arduino mega2560 times out while uploading sketch in Linux

Hello, I have a new Arduino Mega2560 which I am trying to program it via the usb port. I am using Linux Fedora 14 and arduino version 0021. A couple of times I have managed to successfully program it, but most of the times I get the following error:

avrdude: stk500_2_ReceiveMessage(): timeout

Does anybody know what this means and how it can be avoided? If I press shift while uploading this is the complete message I get:

Binary sketch size: 3794 bytes (of a 258048 byte maximum)
/usr/bin/avrdude -C/etc/avrdude/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/build503225717737270483.tmp/read_apple_serial.cpp.hex:i

avrdude: Version 5.10, compiled on Feb 19 2010 at 10:20:42
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is “/etc/avrdude/avrdude.conf”
User configuration file is “/home/user/.avrduderc”
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/ttyACM0
Using Programmer : stk500v2
Overriding Baud Rate : 115200
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout

I have already gone through the process to update the 8u2 firmware as described in http://arduino.cc/blog/2011/02/15/fix-to-uno-and-mega-2560-linux-serial-problems/ and http://www.wayneandlayne.com/blog/2011/02/16/fixing-linux-firmware-issues-on-arduino-mega-2560/, and I verified that sudo lusb -v -d 2341|grep bcdDevice correctly reports the new version 0.01.

In my system the serial port shows up as /dev/ttyACM0 (sometimes /dev/ttyACM1), and I this is recognized by the Arduino environment, i.e., I can select it correctly in the "Tools|Serial Port" menu.

I have had a look at boards.txt and this is the relevant part for Arduino Mega2560:

##############################################################

mega2560.name=Arduino Mega 2560

mega2560.upload.protocol=stk500v2
mega2560.upload.maximum_size=258048
mega2560.upload.speed=115200

mega2560.bootloader.low_fuses=0xFF
mega2560.bootloader.high_fuses=0xD8
mega2560.bootloader.extended_fuses=0xFD
mega2560.bootloader.path=stk500v2
mega2560.bootloader.file=stk500boot_v2_mega2560.hex
mega2560.bootloader.unlock_bits=0x3F
mega2560.bootloader.lock_bits=0x0F

mega2560.build.mcu=atmega2560
mega2560.build.f_cpu=16000000L
mega2560.build.core=arduino

##############################################################

Maybe the baudrate is wrong? Too high? I have no clue.

P.S.: I also have an avrispmkii hardware programmer and it seems to be working correctly (doing the necessary changes in boards.txt, of course). But I would like to understand what's going on and be able to do without the hardware programmer.

Thanks for your help.

Is there something in your last uploaded sketch that writes to serial port without delay? The serial port may be flooded with output so you can't get access to it. Is something connected to digital pin 0 and/or 1 (rx/tx) while uploading a sketch? Disconnect it and try again.

I was having the same problem with my mega2560 and windows. I found that the mega uses serial port 4 and the mega2560 uses serial port 5. The problem is the arduino software does not switch from port 4 to port 5. I deleted the drivers for both (from when I was using ver 0.18) and let windows reload drivers from Ver 0.22. Now it does nor switch automaticly but I can swap from serial port 4 to serial port 5 manually.