Announcing BootDrive for Arduino

(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: BootDrive for Arduino | Bald Wisdom

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:

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.

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

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 ...

Indeed this is a cool idea!
I was thinking of the possiblity to let Arduino update itself alone from a SD card.

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

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 :frowning:

Hi guys!So I have an uno bootloaded standalone atmega328p on a breadboard with a seperate micro usb power supply.I also have an arduino uno rev.3(atmega328 based).I am trying to get the uno to program the standalone atmega328 using a program from an sd card.I am using bald wisdoms bootDrive to do this.

Ok so i have the setup, and put the .hex file into the sd card.When i try it,the standalone atmega is receiving something(pin 13 flashes rapidly),but it isn't running anything. :o Bald Wisdom's pinout for bootdrive is super COMPLICATED.It only requires 3 pins,but n the code he has one set of pins,on the website he has one set of pins,and on the diagram on his site he has a different set of pins.In the video(on his site)he says that pins 4 and 5 on the I2SD are pins 1 and 2 on the uno.When i tried this it still didn't work.Here is his code that I'm using(the forum isn't ;etting me post the code because it has to many characters)What should I change the variable #define BOOT_BAUD to?I put 9600 but it was 115200 before.Which pins should I use?By the way what does it mean by indicator leds on pins 2 and 3 in the code?Also I only found a .cpp.hex file in the /tmp directory but in the code i only used .hex would this affect it?

Hi,

Great project, wondering if you have anything planed for arduino mega (STK500 V2)?