This tutorial is pretty simple but it is worth a mention in case others with less experience get into a similar jam. I was having trouble uploading some programs to my Arduino Mega so I decided to burn the bootloader again to see if that fixed the problem. Unfortunately, I had chopped the ICSP headers off about a year ago when I didn’t really understand what they were used for and didn’t want them touching a shield I was putting on top. Fortunately, there is a way around this.
To get around this problem, I first tried unsoldering the cut off pins and soldering in some new ones. Unfortunately, I lifted a trace and couldn’t repair it. Instead, I took advantage of the fact that the ICSP pins are really just the SPI pins plus reset, power, and ground. So I stuck the Mega on a breadboard and ran wires from the SPI pins to the a AVRISPmk2 programmer.
On the mega, you need to know these pins in addition to power, ground, and reset:
And here is the pinout of the AVRISPmk2 programmer from this post.
And here is the very messy setup. Notice the tangle of wires. It’s not great but it is better than not being able to burn a bootloader. Remember that for the programmer to work, you’ll have to power it through the USB and also power the board either from another USB port or the power jack.
You can plug the AVRmk2 jack in using six individual wires, but I’m using a very small little board ICSP breakout board I made and had printed from OSHpark. It cost $1 for 3 and it’s saved me far more than that in reduced frustration.
Now, just select burn bootloader and choose the correct board and you should be good to go. You can also upload sketches this way, just make sure you have the correct programmer selected and chose upload using programmer instead of upload from the file menu. Note that this will take considerably longer than uploading via the normal method.