Go Down

Topic: Announcing BootDrive for Arduino (Read 2444 times) previous topic - next topic

osbock

(I don't know if this is the right board..)
If you've ever wanted to load up the code on an Arduino without a computer, or without pulling the chip, check out my new project:
BootDrive for Arduino. It uses one Arduino with an SD card to bootload another Arduino by pretending to be the avrdude program that is used under the covers in the Arduino IDE. You hook up the hardware UART (serial port) on the two Arduinos with transmit and receive crossed, and load away!

Justin graciously sent me one of his latest I2SD boards, and I implemented BootDrive on that. I've written up how to do it with a regular Arduino and an Adafruit micro-sd breakout on my blog: http://baldwisdom.com/bootdrive/

Right now it supports bootloading Arduino Uno's (or probably any optiboot Arduino). It would probably easy to support others if you have the need. I posted the serial captures for duemilanove and a clone (wiblocks PICO1TR) that uses adaboot in my github.
The code is also on github:
https://github.com/osbock/Baldwisdom/tree/master/BootDrive
Or you can download a zip: https://github.com/osbock/Baldwisdom/raw/master/releases/BootDrive1.0.zip

I'm working on a demo now that will load a different program based on an IR code (from the Adafruit tutorial, thanks!) from a Sony remote.

dreschel

Hi,
Thanks for posting BootDrive. Nice work... I migrated it to an AVR109 based booter. I did find one issue and a solution. If the HEX file contains a line shorter than 16 bytes, BootDrive does not load the correct code after that. Here is the code to correct that:

int leftover = 0;
unsigned char leftoverbuf[16];
int readPage(File input, AVRMEM *buf)
{
  int len;
  int address;
  int total_len = leftover;
  if (leftover > 0){
    memcpy(buf->buf,leftoverbuf,leftover);
  }
  // grab 128 bytes or less (one page)
  int i = 0;
  while (total_len < 128){
    len = readIntelHexLine(input, &address, &linemembuffer[0]);
    if (len < 0){
      if (i==0) total_len = len;
      break;
    }
//    else
//      total_len=total_len+len;
    if (i==0)// first record determines the page address
    {
      buf->pageaddress = address - leftover;
      leftover = 0;
    }
    i++;
//    memcpy((buf->buf)+(i*16), linemembuffer, len);
    if ((total_len+len) > 128)
    {
      leftover = (total_len+len)-128;
      memcpy(buf->buf+total_len, linemembuffer,128-total_len);
      int kk = 0;
      for (int k =(128-total_len);k<len;k++)
        leftoverbuf[kk++] = linemembuffer[k];
      leftover = kk; 
      total_len = 128;
    }
    else
    {
      memcpy((buf->buf)+total_len, linemembuffer, len);
      total_len=total_len+len;
    }
  }
 
  buf->size = total_len;
  return total_len;
 
}

Now, this page and all the subsequent ones will contain 128 bytes, until the last page (when it doesn't matter). I have tested it against another boot loader and was finally able to verify the code in memory was correct in two distinct ways.
Bill

CrossRoads

This is awesome - lots of people have asked about this.

You indicate you are going thru the Serial Port - which is the process for uploading a sketch, while a Bootloader generally goes in thru the SPI pins.
So is this really a sketchloader, not a bootloader? Sketch uploads in the field are what folks are after.

I'm off to read the links you posted ...

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

stanleyhuang

Indeed this is a cool idea!
I was thinking of the possiblity to let Arduino update itself alone from a SD card.
My Arduino blog: http://arduinodev.com/blog

CrossRoads

That's another thing folks have asked for. We were discussing that last night even.

http://arduino.cc/forum/index.php?topic=93973.new;topicseen#new
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

skyjumper

There is a boot loader called two boots. It can boot load either from the SD card or from the UART. If you Google "Two Boots" you van find it. But, the SD suport is an older FAT file system and the author has no contact information at all. The code is there for anyone who would care to undertake the mission of updating it. I'm just way way too busy :-(

Go Up