Uploading Program on a Arduino Mega 2560 Board

I have just purchased a Arduino Mega 2650 board along with a GSM modem.

I made the setup ready with GND of GSM board connected to GND after PIN 13 in Arduio board. Then Tx,RX of GSM board where connected to RX0,TX0 of Arduino. My aim is to write a GSM/GPRS code.

Once I downloaded the IDE my first task was to download a siple example code. But I started getting below error:

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

I tried with disconnecting all the wires to Arduino and it worked - no issues while downloading the program.

Repeatedly I tried with / without wires - it seems that if I have TX of GSM Modem card connected to RX0 of Arduino I am unable to download a program and the above error comes.

So do I always have to remove the wiring to download program. How can I correct the issue ?

The TX/RX pins on the Arduino are used for communications with the computer, so if you have something else connected to them while uploading (or serial communication), there's going to be interference.

The Mega has more than one hardware serial, you can try to adjust your code to one of the alternatives (see some info here Serial - Arduino Reference).