Can burn bootloader but timeout on code upload

Hi, I've been working on this project for a while now and I'm at the point where I have some PCBs made and trying to assemble a prototype. My project uses the Arduino Mega and I made sure to include a pin header for the ISP. I soldered only the chip, resonator, and 1M resistor in and made sure all the pins are properly soldered. After I soldered those things in, I went to try to flash the chip to make sure everything set up correctly and that the chip was good. Using the ISP header, I was able to burn the bootloader with no issues using an Arduino UNO running the Arduino as ISP sketch (connecting both ISP headers together pin for pin except the reset pin on the UNO side with pin 10 going to the MEGAs reset pin). After I burned the bootloader (without touching anything), I went to upload the sketch for my program. I ended up getting a timeout multiple times while trying to upload the sketch. I then tried the Blink example sketch and the same thing happened. I'm not quite sure what could be causing this issue. Any help on this I would greatly appreciate!

The error message I got is as follows:

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
An error occurred while uploading the sketch

Try this:

Sketch > Upload

Watch the black console window at the bottom of the Arduino IDE window. As soon as you see something like this:

Sketch uses 656 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.

Press and release the reset button on your PCB. If it doesn’t have a reset button, then you’ll need to momentarily connect a wire between the reset and ground pins to cause the reset.

Does that result in a successful upload?

You also need to have the 100nF decoupling capacitors on the board. Not having them can cause all sorts of issues, and there's no point troubleshooting until you've put them on.

You say you tried to upload sketch "without touching anything"

Does that mean you were trying to upload the sketch using the ISP programmer? In that case, you need to do "upload using programmer" not "upload". Note that this will erase the bootloader (though fuse settings will remain).

If you mean that you were trying to upload through the serial port, you need to also put a 0.1uF cap between the DTR pin of the serial adapter, and reset of the atmega2560 (and also remove the ISP programmer connections), and have 10k resistor from reset to Vcc.

Thanks for the replies! I did get it to work via the "upload using programmer" option. It's so weird that it wouldn't just do this by default when having "Arduino as ISP" selected as your programmer

TokyoScarab:
Thanks for the replies! I did get it to work via the "upload using programmer" option. It's so weird that it wouldn't just do this by default when having "Arduino as ISP" selected as your programmer

This is correct behavior.

For boards with a normal upload method (generally serial bootloader) the tools -> programmer field is ignored. It is only used for Burn Bootloader, Upload Using Programmer, and for boards where there is no bootloader (such as typical ATTiny configurations).

This would seem to emphasize the point I was getting at is that could be a much cleaner UI experience to just have it run off the options you mark in the Tools drop down and auto-detect the option based on the settings you choose. In general, I wish the Arduino IDE was a lot better in terms of having any quality of life things you just come to expect in a modern coding environment let alone an IDE. It's not much more than a glorified instance of Microsoft Notepad and it saddens me because it could be so much more.

Think about what you are doing - you have selected a board, Arduino Mega 2560, which has a USB port that you plug a cable into and upload via serial. But that's not what you're doing - you're uploading a sketch via another arduino running an ISP programmer sketch. Surely you would not expect the IDE to divine (since there's no way for it to know what's on the other end of the com port, without it communicating over the port and seeing what's there, which you don't want it to do because in any case other than this, it could disrupt whatever else you're doing with the port - plus the ability to do this would have had to have been planned when writing all the bootloaders for all the Arduino boards, since it would need to be supported on that end... ) that the com port you have selected isn't actually connected directly to the board you have selected, but to a different board running an ISP sketch...

So the IDE assumes the normal case, when you choose the normal upload option - unless you tell it otherwise, by choosing upload using programmer, which informs the IDE that the selected port is not connected directly to the board, but to a programmer....

There are a lot of things that I object to about the IDE, but I can't think of behavior that would make this use case better without making the common use case worse (there are a few technical reasons that make it harder than it would seem, as well) - I can imagine some complete reorganizations of the IDE interface (which of course would obsolete thousands of tutorials online now) that would make the upload experience more coherent replacing tools menu with a board menu or something, then putting an advanced menu that has burn bootloader and programmer menus - but of course that would cause confusion for any board that doesn't have a bootloader). See the problem?

Besides that, it's an open source project, have you ever seen an open source program with a well designed and coherent UI? I haven't. Good UI's are really hard, and require different skills than the rest of the programming work, as well as someone who both understands how the software works, AND how users think AND how to design good UI's - that is a very rare combination, which is why the user experience with most software is as crap as it is.