Before there was such a thing as an Arduino (B.A., before Arduino), AVR enthusiasts wrote programs using avrlibc and uploaded “sketches” using development boards such as the STK200 and STK500. A.A. (after Arduino), my STK500 has been sitting in my “Project Bits” bin, and my STK200 lives in my “Circuit Boards” bin, which is essentially a scrap-heap where I go to scavenge parts. If, like me, you still have a dusty STK500 and would like to put it to good use, here is how you can use it to burn the Arduino Optiboot bootloader onto an Arduino Uno.
Hardware
Connect the STK500 to a power source (12V) and a serial port (RS232 CTRL). Place jumpers on VTARGET, AREF, RESET, XTAL1, and OSCSEL (You may not actually need to do this, but it works without having to dig up the old STK500 manual to find out what those jumpers actually do!).
Next, connect the Arduino’s ISP port to the ISP6PIN header. If your cable has a red stripe, it indicates Pin 1. On the Arduino, Pin 1 is indicated by a silkscreened dot on the PCB. If you are programming a chip that isn’t inserted into an Arduino, I imagine you could insert it into SCKT3200A2 or SCKT3500D, but you’d probably have to check the STK500 manual to confirm which one. Line-up the notch in the end of the chip with the notch in the end of the socket.
The Arduino will be powered by the ISP so you don’t need to provide separate power. Test that everything is working by reading the ATMEGA328 chip on the UNO:
$ sudo avrdude -P /dev/ttyS0 -c stk500v2 -p m328p avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.01s avrdude: Device signature = 0x1e950f avrdude: safemode: Fuses OK avrdude done. Thank you. (change the port number if required)
Software
This assumes you are using Linux and have the Arduino IDE installed and can compile and upload sketches. The Arduino environment includes the libraries and compiler you need to build the source. You’ll also want “make” and “git” and a few others:
sudo apt-get install make git sudo apt-get install gcc-avr avr-libc avrdude sudo apt-get install arduino
Now get the Arduino source.
git clone https://github.com/arduino/Arduino.git
The whole source is 1.4G, of which you’ll only need 16M, so you may just want to use the sources installed by the IDE. On Ubuntu, see /usr/share/arduino. I recommend making a copy as you’ll need to make some changes.
Change to the ./hardware/arduino/bootloaders/optiboot directory and make the following changes:
ISPPORT should match the STK500’s serial port and the MCU_TARGET is set for newer Arduinos. The main function is changed from ‘naked’ to ‘OS_main’ to prevent avr-gcc 4.5.3 from creating binaries that are too large (more details here).
With these changes in place, build and burn the bootloader by running:
make atmega328 #build only, or... make atmega328_isp #build and program
Using ‘make’ to flash the device will not only upload the HEX files, but also set the required fuses.
Test
Confirm the new bootloader is working by loading the Arduino IDE and uploading a sketch.
[…] How To Build and Burn Arduino Bootloader with STK500 Windows Recognizes UNO as Kontrol F1 […]
[…] I have read that it is possible to use the alternative Optiboot loader, with mixed success. If using this loader, you must set the board to “Arduino UNO” in the IDE, instead of “Arduino Pro Mini 3.3V”, or customize boards.txt. To quickly tell which loader is installed on a Pro Mini, count the number of green LED flashes after a reset: the standard bootloader flashes once, and the Optiboot loader flashes 3 times. I prefer to use the standard bootloader on all my Pro Mini devices to avoid confusion, but if you want to use the Optiboot loader, please see the procedure for burning a bootloader to an Arduino UNO. […]