Arduino Mega 2560 will not upload program with external circuits connected

Currently, I am developing a tester using an Arduino 2560 R3. The computer I am using is an HP Elitebook 8570 with Window7.

I wrote a program for my tester and was able to debug much of it with no external circuitry attached to the board. The board would upload my program flawlessly and it would run as expected.

I finally got some hardware that I needed for my tester including an external 9vdc power source for the Arduino board. The hard was is a printed circuit board I designed with a power module that powers the Arduino at 9.1vdc and other power sources that power the unit under test.

Initially, I programmed my Arduino 2560 with my program. It worked very well in the application. I found though that I had a small software bug in my code and wanted to update the software in the board with a my fix.

I powered up the tester which in turn powered up the Arduino board. I plugged my USB cable into the Arduino boards USB connector. Using the Arduino software, I uploaded my firmware. When the firmware got to the "Uploading" portion of the process, it just got stuck. It stayed there for several minutes (without a timeout error). I looked at the TX and RX LED's and they were blinking. The power LED was on.

I pressed the reset button on the tester which puts a logic low on the reset line. The board reset and after a few seconds I got this:

Binary sketch size: 16,876 bytes (of a 258,048 byte maximum)
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

This is fine since I did reset the board and I would expect the communication to break.

So I looked in the forum to see if there was some issue similar to mine. The only thing I found was that sometimes it seems, you need to reset the Arduino then try and upload.

Well, I press the down load button and the reset button at about the same time and I got the above message again.

So, I let the board completely reset and come back up and it got stuck communicating again.

So, I disconnected the Arduino board from the tester and hooked it up to the USB cable directly. The board powered up using the USB port power. This time when I uploaded, it did so successfully.

I know that the board works with my external supply, it just won't upload for some reason.

Also, I completely powered down my tester and kept the Arduino board installed into the tester. When I tried uploading my new program into it, I got this result:

Binary sketch size: 16,876 bytes (of a 258,048 byte maximum)
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 have also turned off the tester supply but left the Arduino PCA in the tester and tried to upload the program. It would still not upload. The voltage on the USB connector was at 4.98 VDC when the tester power supply was turned off and it was 5.1vdc when the tester was turned on.

Many times the pins used by your circuitry overlaps to pins used to program the chip, so this (these many times) is normal.

Look for them and if you cannot use other pins for your circuitry (usually you can redefine them in your sketch so is relatively easy to change them) then you have to remember to disconnect those pins.

My last issue was with the reset pin, which I had to disconnect for every upload.
You will see this mentioned now and then (usually in the tutorials that a very detailed).

You are using the SPI headers. As far as I know that may well be OK.

Do you use pins 0 or 1?

Details of the board are here.