Burning the Sanguino Bootloader using Arduino as ISP

From RepRap
Jump to: navigation, search
Crystal Clear action run.png
Sanguinololu Bootloader Burning

Release status: working

Img1.jpg
Description
Works with ATmega 644P
License
unknown
Author
Contributors
Based-on
Categories
CAD Models
External Link


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)


Hardware Needed

Arduino as ISP components.jpg

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 [1]

Software needed

DO NOT USE the ArduinoISP sketch from Arduino 1.0 !!!! It is Broken. See this for details
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

The Schematic

Arduino as ISP atmega644p.gif

Click for high resolution version.

Arduino to ATmega 644p Connections

  1. Arduino Pin D13 to ATmega 644p Pin 8 SCK
  2. Arduino Pin D12 to ATmega 644p Pin 7 MISO
  3. Arduino Pin D11 to ATmega 644p Pin 6 MOSI
  4. Arduino Pin D10 to ATmega 644p Pin 9 Reset
  5. Arduino Pin D9 to ATmega 644p LED1 Anode
  6. Arduino Pin D8 to LED2 Anode
  7. Arduino Pin D7 to LED3 Anode
  8. LED1, LED2, and LED3 Cathodes  to R1
  9. R1 to Arduino GND
  10. Arduino Pin Reset to C1
  11. C1 to Gnd
  12. Arduino Pin 5v to ATmega 644p Pin 30 VCC
  13. Arduino Pin Gnd to Breadboard GND
  14. ATmega 644p Pin 30 VCC to ATmega 644p Pin 32 VCC
  15. ATmega 644p Pin 32 VCC to ATmega 644p Pin 10 VCC
  16. ATmega 644p Pin 31 to Breadboard Gnd
  17. Resonator Middle Pin to ATmega 644p Pin 11
  18. Resonator Middle Pin to Breadboard Gnd
  19. Resonator Left Leg * to ATmega 644p Pin 12
  20. 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:

  1. XTAL Pin 1 to ATMega 644p Pin 12
  2. 22pF Cap#1 Pin 1 to XTAL Pin 1
  3. 22pF Cap#1 Pin 2 to GND
  4. XTAL Pin 2 to ATMega 644p Pin 13
  5. 22pF Cap#2 Pin 1 to XTAL Pin 2
  6. 22pF Cap#2 Pin 2 to GND
  7. ATMega 644p Pin 11 to GND

Img1.jpg

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.

Testing

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.

Attribution

The Sanguino development board is an extension of the popular Arduino board designed and developed by Zach Hoeken et.al..

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