Using Adaboot bootloader with modern Arduino

To make my thermostat more stable, I wanted to add a watchdog. Here is a nice tutorial about that. AVR’s (the basis of Arduino platform) support this, but the standard bootloader hangs when trying to use the function.

A solution for this is using Adafruit’s updated bootloader. Unfortunately, I don’t have a proper programming device, and I also don’t like to use avrdude to upload sketches (as proposed by ladyada).

So I wanted to use ArduinoISP to flash the bootloader and the Arduino IDE for later programming. Here’s what I did:

– Get Ladyada’s bootloader package for 328’s (most modern Arduino’s have these) and extract it.
– For Mac: Open up your Arduino app package (go to applications, right click on Arduino and select “Show package contents”.
– Copy the file named “ATmegaBOOT_xx8_adaboot328.hex” to “/Contents/Resources/Java/hardware/arduino/bootloaders/atmega” inside the application.
– Adjust the boards.txt file (at “Contents/Resources/Java/hardware/arduino”) to include a reference to the Adaboot-“board”:

##############################################################

atmega328ADA.name=Arduino Duemilanove or Nano w/ ATmega328 ADABOOT

atmega328ADA.upload.protocol=stk500
atmega328ADA.upload.maximum_size=30720
atmega328ADA.upload.speed=19200

atmega328ADA.bootloader.low_fuses=0xFF
atmega328ADA.bootloader.high_fuses=0xDA
atmega328ADA.bootloader.extended_fuses=0x05
atmega328ADA.bootloader.path=atmega
atmega328ADA.bootloader.file=adaboot328.hex
atmega328ADA.bootloader.unlock_bits=0x3F
atmega328ADA.bootloader.lock_bits=0x0F

atmega328ADA.build.mcu=atmega328p
atmega328ADA.build.f_cpu=16000000L
atmega328ADA.build.core=arduino

##############################################################

– Not sure if this was really necessary, but replace the stock avrdude.conf with the one from the package (at “Contents/Resources/Java/hardware/tools/avr/etc”) and delete all lines from 522 – 715 (dealing with parallel programmers, throwing errors on OS X for obvious reasons).

– Restart the Arduino IDE. A new board should now show up under Tools > Board called “Arduino Duemilanove or Nano w/ ATmega328 ADABOOT”

– Get an Arduino with auto-reset disabled, select “Arduino Duemilanove or Nano w/ ATmega328” (NOT ADABOOT!) and upload the “ArduinoISP” example.
Wire that up to the second Arduino that you want to upload Adaboot bootloader to.
– Follow the rest of the tutorial

Remember that you’ll have to select “Arduino Duemilanove or Nano w/ ATmega328 ADABOOT” as the board if you want to flash something to that Arduino. I suggest marking the Arduino as such.

Thanks for Dorkbot for much of the details. His tutorial is nice, but a bit outdated…
This post also explained a lot.

A test sketch:

//Watchdogtest.pde
//requires adaboot!

#include <avr/io.h>
#include <avr/wdt.h>

int ledPin = 13;

void setup()
{
wdt_reset();
wdt_enable(WDTO_8S);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
Serial.println(“RESET”);
}

void loop()
{

for(int i = 0; i < 3; i++){

digitalWrite(ledPin, HIGH);   // sets the LED on
delay(1000);                  // waits for a 10 seconds
digitalWrite(ledPin, LOW);    // sets the LED off
delay(250);                  // waits
wdt_reset();
Serial.println(“wdtr”);

}

digitalWrite(ledPin, HIGH);   // sets the LED on
delay(10000);                  // waits for a 10 seconds
digitalWrite(ledPin, LOW);    // sets the LED off

}

I will update my thermostat tonight and post the results.




Like this? You might be interested in my latest project. It's a desk light made completely from a single sheet of printed circuit board. Check it out:


vlak-1

Leave a Reply

Your email address will not be published. Required fields are marked *