This guide pertains to the Pololu STK500 AVR programmer that Slugbotics owns.
Connect the cable as shown in this picture, ensuring that the cables are connected in the correct orientation:
Atmel Studio is an assembly IDE based on Visual Studio. It is only available for Windows.
Install the drivers for your operating system from this page.
Plug the programmer into your computer. Do not plug the arduino into a power supply, it will be powered from the programmer. If it is not, open the Pololu AVR Programmer App that came with the drivers, and set Regulator to "5V" and VCC Output to "enabled". This will only work in the macOS version, the Windows version basically doesn't work.
Check if it's detected in device manager. Make a note of the port name. It will be in the format COMx, where x is the port number. Sometimes the STK500 exposes 2 serial ports to the system, the correct one for flashing is probably the lower number, but if you're having issues, try both.
Open Atmel Studio. Once you have a project open, click Tools > Add target in the menu bar.
For "Select tool" choose "STK500".
For "Select serial port" choose the port you noted earlier.
Now open Tools > Device Programming from the menu bar.
in the "Tool" dropdown, pick "STK500".
for "Device", pick "ATmega328P".
for "Interface", pick "ISP".
Now, the STK500 should show up as an available programmer in Atmel studio.
Click "Build > Build (your code name)" in the menu bar.
Click Tools > Device Programming
Select your tool and device, then click "Apply".
Click "Memories" in the menu on the left.
Make sure the correct hex file is selected in the "Flash" section of the window.
Click "Program".
avrdude is a command line program that can be used to flash code to a microcontroller if Atmel Studio is not working, or if you are using an operating system other than Windows.
Install the drivers for your operating system from this page.
Install avrdude for your operating system (from their site or from your relevant software repositories).
Plug the programmer into your computer. Do not plug the arduino into a power supply, it will be powered from the programmer. If it is not, open the Pololu AVR Programmer App that came with the drivers, and set Regulator to "5V" and VCC Output to "enabled". This will only work in the macOS version, the Windows version basically doesn't work.
Check if it's detected on your computer (device manager on Windows, ls /dev/tty* on *nix operating systems. Make a note of the port name ("COMx" on Windows, "/dev/tty.usbmodemxxxxxxxxx" on *nix operating systems). Sometimes the STK500 exposes 2 serial ports to the system, the correct one for flashing is probably the lower number, but if you're having issues, try both.
Open a terminal emulator and enter the command avrdude -c stk500 -p m328p -P XXX where XXX is the port name your found earlier.
The -c argument specifies which programmer you are using, in our case it's based on the stk500.
-p specifies the microcontroller you are flashing to. In our case, it's the atmega328p, which is passed to avrdude as m328p
-P is the port.
If the programmer is attached and detected by your computer, you'll get this output or something similar:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)
avrdude done. Thank you.
6. to flash code, reenter the same command, but add -U flash:w:(name of your hex file) to the end, like so:
avrdude -c stk500 -p m328p -P /dev/tty.usbmodem002858212 -U flash:w:example_code.hex
The bootloader may need to be burned if you flash code that causes a program halt. This will result in the "board not recognized" issue.
Obtain the ISP flasher (Pololu USB AVR Programmer v2.1), a micro-USB cable, and a computer with Arduino IDE installed.
Connect the flasher to the ISP header on your board.
Plug in the USB cable to the ISP flasher (NOT the Arduino) and your computer
Under ports, there should be two USB devices showing up. Select the first one (I'm not sure it matters, but this is what has always worked for me)
In the Arduino IDE, under Tools > Programmer, select "Atmel STK500 development board"
Click "Burn bootloader"
The board should now be recognized by your computer and able to flash. You can verify this by uploading Blink (File -> Examples -> 0.1 Basics -> Blink)
Be sure to not flash your bad code again so you don't have to repeat this!