Using an Arduino board and optiLoader
if Arduino ISP hacks are not working, there is still hope ! And it is called optiLoader.
This project, initiated by Bill Westfield is ‘based’ on the ArduinoISP sketch.
Optiloader is a sketch designed for bulk upgrading of Arduino board boot-loaders using another Arduino as a device programmer. It stores multiple copies of the optiboot boot-loader in program flash memory. When run (ie by hitting reset), it probes the target device, figures out the type of CPU (ATmega8, ATmega168, ATmega328, ATmega328P) and initiates upload of the bootloader and proper fuse programming.
This sketch is to be used as the ArduinoISP sketch, but is slightly different. The ArduinoISP sketch communicates with the computer to get the proper boot-loader. This sketch, on the contrary, has some boot-loaders already including directly in the code. So it is stored in the memory from the beginning.
These boot-loaders are only working with a 16MHz setup. If you want to run with 8 MHz clock, you will either have to modify this sketch, or use one of the previous methods.
Optiloader Source code
Please, visit Bill Westfield’s git repository: https://github.com/WestfW/OptiLoader
Using this sketch with your IDE
In order to open it with the Arduino IDE and upload it to your Arduino Board, you just need the .pde and .h files (resp. the sketch and the header). Copy these two files into a folder named “optiLoader” into your IDE’s Sketch Folder. Then it should appear in the IDE:
As this sketch uses the old Arduino extension .pde, the newer versions of the IDE (v1.0) will ask to rename the file with the proper .ino extension which is required.
Now that it is open, upload it to your arduino UNO. Then open the embedded terminal, configure it to 19200 baud.
You should then have the following message :
If you receive this message, then, everything is working properly. If not, something went wrong 🙂
The optiLoader sketch is designed to try to upload a boot-loader directly after reset. It is not intended to stay connected to the computer, but if it is, it will spit some messages through the serial port.
If you are interested in reading this message, then, leave the Arduino connected as it is after the previous steps. If this is usually bad to make ‘hot’ connections, this sketch has the particularity to power off the 5V supply and pull the I/Os to GND while waiting for a user to plug a blank chip.
For this reason, and this reason only, I would recommend to leave the Arduino connected (and powered on) while you make the connection to the blank chip. In any case, always connect the ground first.
Connecting the Arduino with the blank chip
The connection between the Arduino and the blank chip is pretty straight forward. But keep in mind that a connection error could damage both the chip or the Arduino. So double check the connection before powering up. Tips: a good way not to smoke the chip by misconnecting something is to make a dedicated cable with clear markings as shown on the picture below.
Hereunder, the schematics related to this connection.
Now you can either push the reset button on the Arduino board, or send the ‘G’ character in order to lunch a new burning process.
If it is successful, you should see the following message:
OptiLoader Bootstrap programmer.
2011by Bill Westfield(WestfW)
Target power on!...
Starting Program Mode[OK]
Start address at7E00
Total bytes read:502
Setting fuses forprogramming
Lock:3FFFE000 Low:FF FFA000 High:DE FFA800 Ext:5FFA400
Programming bootloader:512bytes at0x3F00
Restoring normal fuses
Target power OFF!
Type‘G’orhit RESET fornext chip
This boot-loader is the most complicated part of the process. Once you master this, you won’t have any more ‘real’ trouble. And if you understand all the slight implications that may cause a problem at this step, you will probably be able to debug everything from now on.
This boot-loader is useful as it allows you to upload your codes onto the chip’s memory directly via a serial communication. Otherwise, you would have to program it the same way as we did to burn the boot-loader : via an on-chip programmer.
If you have any question about this process, I will give my best answer, but keep in mind that what ever problem you have, you are probably not the first one, so google it. Keep as well in mind that there is an official website out there that has a lot of information.