Burning the Sanguino Bootloader using Arduino as ISP
Burning the Sanguino Bootloader to the ATmega 644P using an Arduino as an ISP.
So you just finished soldering up your Sanguinololu, Gen7 or whatever board and are ready to test it to see if everything is working properly, but before you can upload any firm ware to the board you need to burn a Bootloader to the ATmega 644P. In this tutorial I will cover using an Arduino or Arduino clone as your ISP programmer.
NOTE: Instead of breadboarding, you could use the 6-pin ISP connector found on most RepRap electronics. No tutorial or pictures so far. --Traumflug 10:20, 23 April 2013 (UTC)
Note that the 16mz resonator is missing from this photo.
Before we get started with the tutorial make sure you have the following tools and discrete components on hand and ready to use.
- Arduino or Arduino Mega with FTDI USB interface. (pre Arduino UNO boards) Also any Arduino clone with an FTDI chip will work.
- USB Cable
- Solderless Bread Board with at least 50 positions on each side
- 16Mhz resonator
- 0.1uf ceramic capacitor
- 3x 5mm LEDs
- 1x 1k resistor
- 25 Jumper wires
NOTE: For voltage stability you might want to an external power supply instead of USB power. this is not usually required if your USB port can supply the required current, but is recommended for most chip burners and programmers.
NOTE: if you use an Arduino Mega, you need different wiring: see 
- Arduino 0018 to 0023 or 1.0.1 ( http://arduino.cc/en/Main/Software )
- DO NOT USE the ArduinoISP sketch from Arduino 1.0 !!!! It is Broken. See this for details
- Sanguino software ( http://code.google.com/p/sanguino/downloads/list )
- DO NOT USE the atmega644 hex files in the 0023 versions - you will get "out of range" errors on uploading. There's a bug in the Makefile that has a bad "--section-start" value and loads the bootloader too high in RAM. The only one that works on that site is the 0018 hex file.
- A good version of the latest Sanguino bootloader can be found here
What is a Bootloader?
In short a Bootloader is a small piece of code that is stored in the microcontroller's program memory and allows the user to program and reprogram the microcontroller without using an In System Programmer (ISP). I won't get into the full details of what a Bootloader does in this tutorial, but if you would like to know more check out this article on Emcelettronica.com ( http://dev.emcelettronica.com/what-microcontroller-bootloader-and-how-it-works )
What is an ISP?
ISP is short for "In System Programmer", a device that allows you to program a microcontroller without using a Bootloader. It can be used to burn Bootloaders, and program microcontrollers where a USB interface is not present. In our case we will be using an Arduino with an ATmega 328 to burn the Sanguino Bootloader to our ATmega 644p.
Setting up the Arduino
Before we can burn the Sanguino Bootloader we need to program to Arduino to act as an ISP. Follow the steps below and we can move on to breadboarding the ATmega 644P.
- The first thing you need to do is connect your Arduino to the PC with a USB cable.
- Next, In the Arduino IDE go to File/Examples/ArduinoISP. This will load the Arduino as ISP sketch into Arduino. Fig. 1
- Make sure you have the correct board selected in Tools/Board/Your Arduino Board. Fig.2
- Once that sketch is open click the “play” arrow to compile and upload the sketch to the Arduino. Fig. 3
Click for high resolution version.
Arduino to ATmega 644p Connections
- Arduino Pin D13 to ATmega 644p Pin 8 SCK
- Arduino Pin D12 to ATmega 644p Pin 7 MISO
- Arduino Pin D11 to ATmega 644p Pin 6 MOSI
- Arduino Pin D10 to ATmega 644p Pin 9 Reset
- Arduino Pin D9 to ATmega 644p LED1 Anode
- Arduino Pin D8 to LED2 Anode
- Arduino Pin D7 to LED3 Anode
- LED1, LED2, and LED3 Cathodes to R1
- R1 to Arduino GND
- Arduino Pin Reset to C1
- C1 to Gnd
- Arduino Pin 5v to ATmega 644p Pin 30 VCC
- Arduino Pin Gnd to Breadboard GND
- ATmega 644p Pin 30 VCC to ATmega 644p Pin 32 VCC
- ATmega 644p Pin 32 VCC to ATmega 644p Pin 10 VCC
- ATmega 644p Pin 31 to Breadboard Gnd
- Resonator Middle Pin to ATmega 644p Pin 11
- Resonator Middle Pin to Breadboard Gnd
- Resonator Left Leg * to ATmega 644p Pin 12
- Resonator Right Leg* to ATmega 644p Pin 13
NB: If you do not have a resonator, you can use an oscillator crystal and 2x 22pF capacitors (or 18 pF, something close). Hook up everything exactly the same except replace the resonator steps with the following:
- XTAL Pin 1 to ATMega 644p Pin 12
- 22pF Cap#1 Pin 1 to XTAL Pin 1
- 22pF Cap#1 Pin 2 to GND
- XTAL Pin 2 to ATMega 644p Pin 13
- 22pF Cap#2 Pin 1 to XTAL Pin 2
- 22pF Cap#2 Pin 2 to GND
- ATMega 644p Pin 11 to GND
When finished, it should look something like this.
Installing Sanguino to Arduino 22
OR UPGRADE SANGUINO TO USE OPTIBOOT AND USE THE LATEST ARDUINO IDE 1.0.5 , see note below
Now that you have the circuit Breadboarded with your Arduino and ATmega 644p double check every connection. We have done this many times and still manage to misplace a jumper wire every time.
- If you have not yet downloaded the Sanguino software from then do so now.
- Extract the contents of the Sanguino Zip file
- Copy the contents of the extracted folder to arduino-0022/hardware/ You should end up with a folder hierarchy that looks like this arduino-0018/hardware/sanguino/ Fig.4
NOTE: Recently Sanguino has been ported to use the Arduino Core. The Sanguino is now compilable and uploadable easily with Arduino IDE 1.0.4 or above using Optiboot loader. Atmega644p and Atmega1284p are now build and uploadable sketches on latest Arduino IDE. No special steps have to be followed. Only the zip file contents have to be copied to the /arduino/hardware folder. Close the IDE and restart the IDE. The Sanguino is ready to rock and roll with the latest Arduino IDE 1.0.5 Details on how to use Sanguino with optiboot can be found on Bhashatech blog.
Burning the Bootloader
- Now that you have installed Sanguino files to the Arduino IDE and connected the ATmega 644p (double check again) we can finally burn the Sanguino Bootloader to the chip.
- In the Arduino IDE go to Tools/Board/ and select Sanguino. Fig.5
- Then make sure the correct COM port is selected by going to Tools/Serial Port and select the one that your Arduino is connected to Fig. 6
- Before we go any farther check every connection again and make sure everything is connected exactly the way shown in the schematic above. If you are confident in your connections then you are ready to burn the bootloader.
- Go to Tools/Burn Bootloader and click w/ Arduino as ISP Fig.7
- You will see the TX and RX LEDs flash on your Arduino for about 1-2 minutes. DO NOT UNPLUG THE USB CABLE or touch any part of the circuit at this time. Doing so may damage the ATmega 644P or Arduino beyond repair.
- When the flashing is has stopped for more than 30 seconds you may unplug the USB cable from the Arduino and carefully remove the ATmega 644P from the breadboard. (Remember to wear an anti static wrist strap when handling bare ICs.)
Click Images for High Resolution Versions.
To test if you were successful at burning the Sanguino Booloader to the ATmega 644P you need to place the ATmega 644P into the socket on your Sanguino or Sanguinololu and upload one of the compatible RepRap firmware’s. If the firmware compiles and uploads with out error the you were successful. If you get an error, place the ATmega 644P back in the breadboard and check every connection again and try to burn the bootloader again.
Sanguinololu is a low-cost all-in-one electronics solution for Reprap and other CNC devices. It features an on board Sanguino clone using the ATMEGA644P though a ATMEGA1284 is easily dropped in. Its four axes are powered by Pololu pin compatible stepper drivers. Sanguinololu was developed by Joe "Mosfet" Malone for the RepRap project.
The Arduino as ISP for ATmega 644P Schematic was developed by Nils Vogels of XYZ Printers.
This tutorial was written by Charles Gantt of http://thewakersworkbench.com