Arduino Mega2560 can't be programmed via USB

Driver is correct. I've tried both in Windows 7 and Ubuntu 12.04.
Port is correct: it can upload small sketch "TimeSetRTC" which is DS1307 example. But my sketch doesn't.
In log file you can see PC recognized port as /dev/ttyACM12.