I've successfully built, tested, and used the breadboard config (with crystal) shown on http://arduino.cc/en/Tutorial/ArduinoISP. I've semi-permanently dedicated a Duemilanove board to my setup and used a zif socket to make it easy to put new chips into the programmer. Everything works well for adding optiboot to new AVR chips.
But I would also like to pre-load sketches into new chips (in addition to the bootloader) and I am struggling to understand how/if I can use my ArduinoISP setup to do this? I'd appreciate any suggestions or help in locating references.
Download latest optiboot_atmega328.hex from arduino github site (this seems to be the June 14, 2011 version by westfw, committed October 10, 2011 by damellis).
Compile the sketch that I want pre-loaded into new chips, then grab the associated *.cpp.hex file from the arduino temporary build area.
Use a text editor to strip off the terminating string (:00000001FF) from my sketch's hex file.
Cut/paste my sketch's hex file contents and insert at the beginning of the optiboot_atmega328.hex file.
Tools : Burn Bootloader : w/Arduino as ISP. I figure this will take care of fuses, right? Is there somewhere I need to tell avrdude the size of the hex file?
I am trying to avoid bricking any chips, so if I've got something screwed up please give me some more hints. Thanks.
The process I'm using is a little clumsy, but it works. Using ArduinoISP I was able to burn bootloader + sketch into a new chip, then put the chip into my Arduino compatible PCB and have the sketch fire up as soon as power was supplied. Cool.
Cutting and pasting the hex files isn't so bad, but there must be a cleaner way to invoke avrdude than by using the IDE to burn optiboot_atmega328.hex. This requires renaming files in the arduino distribution folder.
Something like "make optiboot44_plus_sketch042.hex" would be nice. Time to go hunting in github for the command sequence issued by the IDE when it's asked to burn a bootloader
thats what i use if i only want to burn the bootloader and load the blink sketch (btw the code its written to be run on a unix machine - but im pretty sure you can run something similar for windows )
Do you happen to know the programmer name to put in place of "usbasp" when using ArduinoISP? I've read the avrdude documentation and can't figure out which programmer is being emulated by ArduinoISP, at least as far as avrdude is concerned.
yeah like Coding Badly said its stk500 also if you want to use arduino as isp you need to use the -b to tell the upload speed - usually that upload speed its 19200 also ive had some problems with avrdude something like
Ok, a little slow in getting this solved. But here are a couple of batch files that work for me on Windows XP2. I am using ArduinoISP running on an Uno. Maybe someone else will get some use from these files.
To initialize a new chip and burn the bootloader:
REM Command line example
REM init com14 optiboot_atmega328.hex
avrdude -cavrisp -patmega328p -P%1 -b19200 -U lock:w:0x3F:m
avrdude -cavrisp -patmega328p -P%1 -b19200 -U hfuse:w:0xDE:m -U lfuse:w:0xFF:m -U efuse:w:0x05:m
avrdude -cavrisp -patmega328p -P%1 -b19200 -U lock:w:0x0F:m
avrdude -cavrisp -patmega328p -P%1 -b19200 -U flash:w:%2:a
To flash a hex file to the chip:
REM command line:
REM writehex com14 aBourbon230.hex
avrdude -cavrisp -pATMEGA328P -P%1 -b19200 -U flash:w:%2:a
BTW, the ISP shield from Evil Mad Science really makes this easy:
The process is slow, however, since ArduinoISP only runs at 19200 baud. Has anyone been successful speeding this up?
getting a dedicated programmer would speed things a lot
there is a faster way to burn the bootloader using the optiloader provided by westfw GitHub - WestfW/OptiLoader: Arduino sketch for burning new bootloaders what this is its similar to the arduino isp but it only burns the bootloader (really fast) so you have one problem solved - you now need to figure out how to get the sketch you want after you burned the bootloader
Is there a reason why you want to burn a bootloader into the target as well as a sketch? Using ArduinoISP (or any programmer), you can burn a sketch directly into a target processor without using a bootloader.
dc42:
Is there a reason why you want to burn a bootloader into the target as well as a sketch? Using ArduinoISP (or any programmer), you can burn a sketch directly into a target processor without using a bootloader.
In my case the reason is to preload an application on an Arduino-compatible board prior to shipping to customer. I included the bootloader so other applications could be loaded later by programmer-less individuals.
But you raise a good point that the bootloader isn't needed when you use ISP (except when an as-yet undiscovered bug in your program causes it to only work correctly when the bootloader runs first, but that's a different subject, sigh.....)