There may not be a lot of practical value in running ArduinoISP on an Aruino Due. If you have a Due, it is very likely you have at least one classic Arduino at hand for which running ArduinoISP is well known and documented. On the other hand, ArduinoISP is a standard Arduino sample so I find that it should work on any Arduino. Well, it was good fun to make it work…
I found an opportunity to start with this when I wanted to upgrade the firmware of my Leonardo
Since Arduino 1.0.3, there is an improved boot loader for Leonardo that is a real must have: upon power-on reset, it jumps immediately to your sketch instead of awaiting programmer commands for some seconds.
Just for the sake of it I decided use my Due for this task.
Later on, I tried to program an attiny85. This required some extra measures. The Due’s SPI runs too fast for these targets so I had to use software SPI to slow the Due down.
Wiring, 5V, 3V3…
First thing to take care of was to make sure not to fry the Due which is not 5V tolerant. Connecting it to the ISP port of the Leonardo powered with 5V would probably damage the Due: the Leonardo would drive the MISO signal to 5V. I took a very simple approach: I powered the Leonardo with 3.3V. See red jumper wire between the Due’s 3V3 (don’t accidentally use the adjacent 5V pin) pin and the Leo’s 5V pin.
As usual, my photo’s are lousy, but these are the connections:
Due | Target (Leonardo, attiny85...) MISO | MISO SCK | SCK MOSI | MOSI GND | GND 3.3V | Vcc (labeled 5V, on the Leonardo) Dig 10 | RESET
It should be warned not to connect the 5V (!) power pin from the Due’s SPI header to the corresponding pin on the Leonardo (using a flat cable would do this). Like most people on the forum I expected this pin to carry 3V3, and first I was tempted to use it to power the Leonardo. Well it has 5V. OK, trap avoided.
Also when this wiring is in place, don’t connect the Leonardo’s USB cable !
In general, don’t power the target at 5V when doing this.
Get a “Due – ready” version of ArduinoISP
The version of ArduinoISP that comes with the ide is a bit outdated. It does not even compile for the Due because the SPI functionality is implemented using AVR specific SPI registers.
I keep a version here that works on the Due without need for further tweaking, nor patches in the core.
I plan to write more about its details in a later post. It has some options you can configure and it has a few new fixes.
Also for other Arduino’s, this version works out of the box, with a reasonable default configuration. Therefore I think it is a candidate for inclusion in the IDE. We’ll see…
For now I just wish to thank Sylvan Butler, whose SPI bitbang implementation I started from.
Try it out.
Compile and upload the sketch with arduino 1.5.2 to your Due. Once that is done it is ready to do ISP. Use the native USB port (see photo).
From this point on, when it comes to programming a target, it makes more sense to use arduino 1.0.x. This is OK, the IDE does not care your ArduinoISP programmer is actually a Due.
Windows users have one more thing to take care of: the ide must be instructed to use “arduino” as programmer instead of “stk500v1″. It is explained here (go to point 7), but looking back on it, I find it more easy to just go into the arduino-1.0.x\hardware\arduino\programmers.txt and change the entry:
That is it. I tested burning the bootloader into my Leonardo using arduino 1.0.3 on linux (Ubuntu 12.04.2 LTS) and on Windows 7 SP1 64bit. I also burned a bootloader into a 328p clocked with16MHz.
It was also possible to burn some led blinking firmwares into an attiny85 clocked@1MHz, internal oscillator.