|
| 1 | +Standalone AVR programmer |
| 2 | +========================= |
| 3 | +This sketch can be used to let one Arduino program a sketch or |
| 4 | +bootloader into another one, using the ISP programming pins. |
| 5 | + |
| 6 | +This sketch is based on [OptiLoader][], but modified for use with |
| 7 | +Adafruit's adaloader and to be used without a serial connection. It is |
| 8 | +intended to be used with [Adafruit's standalone programmer kit][kit] (a |
| 9 | +protoshield with ZIF socket, buttons, leds and a buzzer), but it should |
| 10 | +be usable with any Arduino wired up to any AVR chip (respecting the |
| 11 | +pinout, see below). |
| 12 | + |
| 13 | +[OptiLoader]: https://github.com/WestfW/OptiLoader/ |
| 14 | +[kit]: https://www.adafruit.com/product/462 |
| 15 | + |
| 16 | +The sketch to be flashed is stored in the `images.cpp` file inside this |
| 17 | +sketch. By default, it contains the adaLoader bootloader, but you can |
| 18 | +replace it with your own bootloader or sketch as well. To do so, |
| 19 | +compile that sketch into a .hex file (using the Arduino IDE, you can |
| 20 | +use "Sketch" -> "Export compiled Binary" to get the compiled .hex file) |
| 21 | +and paste its contents (it's just a text file) into `images.cpp` (see |
| 22 | +that file for details). There you can also configure the target chip |
| 23 | +signature and fuse settings. |
| 24 | + |
| 25 | +For more info on setting this up, see [Adafruit's tutorial][tutorial]. |
| 26 | + |
| 27 | +[tutorial]: https://learn.adafruit.com/standalone-avr-chip-programmer/overview |
| 28 | + |
| 29 | +Pinout |
| 30 | +------ |
| 31 | +To use this sketch, you can use the following pinout. Here, "programmer" |
| 32 | +means the Arduino running this particular sketch, "target" means the |
| 33 | +chip being programmed. For reference, this also lists pin numbers for an |
| 34 | +Arduino Uno programmer and bare atmega328p target chip, adapt these if |
| 35 | +you use a different setup. |
| 36 | + |
| 37 | +| Programmer pin | Uno pin number | Connects to |
| 38 | +| -------------- | -------------- | -------------- |
| 39 | +| Digital pin 10 | 10 | Target RESET (atmega328p pin 1) |
| 40 | +| MOSI | 11 | Target MOSI (atmega328p pin 17) |
| 41 | +| MISO | 12 | Target MISO (atmega328p pin 18) |
| 42 | +| SCK | 13 | Target SCK (atmega328p pin 19) |
| 43 | +| Digital pin 9 | 9 | Target XTAL1 (optional, atmega328p pin 9) |
| 44 | +| Digital pin 8 | 8 | Error LED (active high) |
| 45 | +| Analog pin 0 | A0 | Activity LED (active high) |
| 46 | +| Analog pin 1 | A1 | Button (active low, internal pullup enabled) |
| 47 | +| Analog pin 3 | A1 | Piezo (outputs 4kHz square wave) |
| 48 | + |
| 49 | +Leds & buzzer |
| 50 | +------------- |
| 51 | +On startup, both leds blink twice and then turn off. |
| 52 | + |
| 53 | +When the target is being programmed the activity led turns on. Once it |
| 54 | +is done, the led turns off and the piezo makes a short beep. |
| 55 | + |
| 56 | +When an error occurs during programming or verification, the error led |
| 57 | +turns on and stays on and the the piezo makes a continuous beep. |
| 58 | + |
| 59 | +Clock output |
| 60 | +------------ |
| 61 | +This sketch generates an 8Mhz clock as an extra utility. This can be |
| 62 | +used if the target chip has fuse settings that expect an external clock |
| 63 | +(or crystal, that also seems to work). If you are only configuring the |
| 64 | +fuses to use the internal oscillator, this is not needed. |
| 65 | + |
| 66 | +Button |
| 67 | +------ |
| 68 | +A single button can be connected, which can be used to start programming |
| 69 | +the next chip (including the first). Alternatively, you can send a |
| 70 | +command (uppercase `'G'`) through serial to start programming. |
| 71 | + |
| 72 | +Autostart |
| 73 | +--------- |
| 74 | +This sketch also supports autostarting the programming when a chip is |
| 75 | +connected. This works by detecting the (internal or external) pullup on |
| 76 | +the reset line. To make sure that the pin reads LOW when nothing is |
| 77 | +connected, this needs a big pulldown on the ISP reset line (so between |
| 78 | +digital pin 10 on the programmer and GND). It should be big enough to |
| 79 | +not interfere with the target's reset pullup, so something like 1M |
| 80 | +should be ok. |
| 81 | + |
| 82 | +To enable autostart, add the pulldown resistor and set `AUTOSTART` to |
| 83 | +`1` in the .ino file. |
| 84 | + |
| 85 | +Now, when you insert a chip and the reset line is stable for a short |
| 86 | +while, the programming will automatically start. If the programmer is |
| 87 | +powered up or reset while a chip is inserted, it must be removed and |
| 88 | +re-inserted to start programming (of course, you can still use the |
| 89 | +button or serial as well). |
0 commit comments