AVR ISP Programmer Shield Clarifications

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
gwideman
 
Posts: 19
Joined: Wed Jun 27, 2012 9:04 am

AVR ISP Programmer Shield Clarifications

Post by gwideman »

I am in need of a concise explanation of exactly how the Standalone AVR ISP Programmer Shield fits into the AVR programming landscape -- and I can't help thinking other customers might also like this.

(FWIW, I have many years of software development experience, and embedded experience from the 8051 and EEPROM-burning era.)

1. Is there a schematic for this product? I'd like more traction on exactly what it implements.

2. This product is called an "ISP" programmer, yet the product description and photos clearly are about _out_ of system programming. Is there some additional feature whereby this product is useful for hooking up to an in-system AVR? Or does the "ISP" refer only to the aspect that it's using the ISP programming pins on the AVR?

3. The product description shows use with atmega328p, but is it usable with other AVRs? Presumably the fewer-pins AVRs would need different wiring to the ZIF socket (which suggests wiring the ZIF using headers and jumpers instead of soldered wires).

4. Stand-alone programming mode -- can this program arbitrary code to the target, or just bootloader code?

5. Part of my puzzlement is probably an incomplete understanding of ISP and bootloader-enabled programming. I *think* the way it works is as follows:

a. A blank (or otherwise bootloader-lacking) AVR can be programmed with arbitrary code via ISP, which uses SPI + Reset twiddling. (And ISP can be used to set the fuses in addition to the flash.)

b. Can ISP replace only _part_ of the code on a previously-programmed AVR?

c. One of the things you can load via ISP is a bootloader program (assuming the chip has enough flash memory).

d. Once a chip has a bootloader, it can be programmed by a host talking to the bootloader. This communication is over serial line, I guess SPI. For an AVR not in an Arduino board, that means you need a gadget that translates USB to SPI. That hardware seems basically the same as an ISP programmer, so can ISP programmers in general (and the AVR ISP programmer specifically) be also used by a host to talk to a raw-AVR-with-bootloader and do bootloader-style programming?

6. So... what is the overlap and non-overlap between this product, and "USBtinyISP AVR Programmer Kit (USB SpokePOV Dongle)".

Thanks!

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: AVR ISP Programmer Shield Clarifications

Post by adafruit_support_mike »

gwideman wrote:1. Is there a schematic for this product? I'd like more traction on exactly what it implements.
A schematic wouldn't tell you much of interest.. there's no additional hardware, so you'd have two boxes with lines going between pins marked VCC, GND, MISO, MOSI, etc.
gwideman wrote:2. This product is called an "ISP" programmer, yet the product description and photos clearly are about _out_ of system programming.
"ISP" refers to the programming interface rather than the physical location of the chip. The alternatives are bootloader programming, high-voltage programming, and JTAG programming.
gwideman wrote:3. The product description shows use with atmega328p, but is it usable with other AVRs?
To the extent that you can adjust the signal positions to match the target chip, yes. The ISP interface is the same for a broad range of Atmel microcontroller.
gwideman wrote:4. Stand-alone programming mode -- can this program arbitrary code to the target, or just bootloader code?
Arbitrary. As far as either microcontroller is concerned, it's just a stream of bytes.
gwideman wrote:a. A blank (or otherwise bootloader-lacking) AVR can be programmed with arbitrary code via ISP, which uses SPI + Reset twiddling. (And ISP can be used to set the fuses in addition to the flash.)
Generally correct. The ISP interface can write arbitrary data to the target chip and set some fuses. There are other fuses which require a high-voltage interface to change (which prevents power glitches from changing those values when the chip is physically in-circuit).
gwideman wrote:b. Can ISP replace only _part_ of the code on a previously-programmed AVR?
Yes, but it's generally more bother than it's worth.

Microcontroller memory is arranged in 'pages' of 64 or 128 bytes. All the values in a page are written at the same time, and each page has a limit on the number of writes you can do before it no longer stores information reliably (10,000 write/erase cycles for Flash, 100,000 write/erase cycles for EEPROM). The ISP interface allows you to write individual pages, but you have to get into the details of the hexfile format to make it work.

In general, it's easier (and better design practice) to write the whole Flash at once, and store information that should be independent of the Flash in EEPROM.
gwideman wrote:c. One of the things you can load via ISP is a bootloader program (assuming the chip has enough flash memory).
Correct.
gwideman wrote:d. Once a chip has a bootloader, it can be programmed by a host talking to the bootloader.
Correct.
gwideman wrote:This communication is over serial line, I guess SPI.
Not necessarily. The bootloader is a software shim between the chip's IO interfaces and its Flash/EEPROM. You can make a bootloader that takes data from the SPI bus, but you could also use I2C, parallel input, or even the ADC if you were masochist enough. The Arduino bootloader uses the UART interface.
gwideman wrote:For an AVR not in an Arduino board, that means you need a gadget that translates USB to SPI.
You have the right idea, but the protocol is UART rather than SPI. Again, SPI would be possible if you chose to do it that way.
gwideman wrote:That hardware seems basically the same as an ISP programmer, so can ISP programmers in general (and the AVR ISP programmer specifically) be also used by a host to talk to a raw-AVR-with-bootloader and do bootloader-style programming?
It's technically possible, but is kind of like using a computer screen as a whiteboard.
gwideman wrote:6. So... what is the overlap and non-overlap between this product, and "USBtinyISP AVR Programmer Kit (USB SpokePOV Dongle)".
It's roughly the difference between a printing press and a desktop printer.

The standalone programmer is exactly that: a standalone device. Once you program the Arduino it can operate without any further connection to or data from a computer. It takes a certain amount of time and effort to set it up, but once that's done the cycle times are about as fast as the chips will allow. It justifies its existence when you need lots of chips programmed the same way.

The general programmer is a conduit between a computer and a chip. It doesn't store data, it just converts input to signals that will program the chip. It's good for testing code on the actual hardware, and reprogramming chips that are physically in a circuit. The cycle time is a bit longer and it requires more hardware, but the setup time is negligible for any given chunk of data you send through it.

User avatar
gwideman
 
Posts: 19
Joined: Wed Jun 27, 2012 9:04 am

Re: AVR ISP Programmer Shield Clarifications

Post by gwideman »

Hi Mike,

Thanks for your response, you made a number of helpful comments, notably pointing out that bootloader-facilitated progamming employs the UART (plus Reset) interface, not SPI.

> A schematic wouldn't tell you much of interest [...] you'd have two
> boxes with lines going between pins marked VCC, GND, MISO, MOSI, etc.

Yes, that's exactly what I needed to know in order to narrow down what the shield can and cannot do. I ended up making my own schematic.

Not quite answered:

> > can ISP programmers in general (and the AVR ISP
> > programmer specifically) be also used by a host to talk
> > to a raw-AVR-with-bootloader and do bootloader-style programming?

> It's technically possible, but is kind of like using a computer
> screen as a whiteboard.

I am asking whether one ~$20+$20 device also contains the functions found in another ~$20 device, given the conceptual similarity -- not sure how to interpret the analogy in that regard.

From the schematics I derived, I've concluded that the tutorial's wiring doesn't include the UART wires that would be needed for bootloader-facilitated programming, and presumably that the sketch for this project doesn't include code that would allow the host Arduino to behave as a simulated FTDI.

I've also concluded that it would be trivial to add an ISP connector to the Protoshield to perform actual In-System-Programming, though that wouldn't take care of 5V vs 3.3V level shifting when that's an issue. Also, that the ICSP connector pads on the Protoshield are not wired for that purpose (but could be used if the existing traces are cut).

> The standalone programmer is exactly that: a standalone device.
> Once you program the Arduino it can operate without any further
> connection to or data from a computer.

So this raises the question -- is this gadget's sketch _only_ able to function in standalone mode, or can it function in the mode of a regular ISP interface, without an intermediate "prepare for standalone operation" phase... like the ArduinoISP tutorial http://arduino.cc/en/Tutorial/ArduinoISP?

I guess the bottom line here is: It would be a very helpful addition to the product description to have a concise statement of what alternative programming workflows the hardware and sketches support (and don't support).

Thanks!

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: AVR ISP Programmer Shield Clarifications

Post by adafruit_support_mike »

If you aren't planning to program chips in bulk (100 minimum), don't bother with the standalone programmer.

WRT using a programmer to talk to a bootloader, people have done it, but mostly out of a sense of, "hey, I wonder if it's possible to push the hardware this way." The methods are basically creative abuse of the programmer's pin functions, like sending the TX half of a UART data stream out the MOSI pin with the timing tweaked to match a baudrate the target bootloader can read. People have also used FTDI cables to program chips directly from USB, which works if you don't mind data rates of about 2 bytes per second.

If you want to talk to a bootloader, it's much easier to do it with another microcontroller. An Arduino gives you all the hardware and programming capacity in an easy-to-use package, but you could also program a blank microcontroller to act as your bootloader interface if you needed something special. Both options are more effective and less convoluted than handling bootloader communication through a programmer.

If you just want to use an Arduino as a programmer, you don't need the standalone shield. The Arduino IDE already has built-in support for "ArduinoISP", and the website shows how to make the hardware connections: http://arduino.cc/en/Tutorial/ArduinoISP

User avatar
gwideman
 
Posts: 19
Joined: Wed Jun 27, 2012 9:04 am

Re: AVR ISP Programmer Shield Clarifications

Post by gwideman »

Hi Mike:

Thanks for your patient answers once again. Between your answers, and some intense googling and reading, I understand the landscape much better.

That said, I'm a little surprised at your description of the difficulties of making a gadget that can be both an SPI programmer and an "FTDI cable" substitute.

Agreed that trying to emulate ISP/SPI with a UART is silly, and likewise the other way around. However I don't see what the problem is implementing both functionalities in one device using separate I/Os equipped for the purpose.

Turns out that's exactly what the Pololu USB AVR programmer offers (though with other tradeoffs).

I am now very satisfied that ISP programming of standalone AVR chips in-system is not the intended scope of the "Standalone AVR In System Programming Programmer Shield", and that serving the FTDI-cable needs of a standalone AVR is also not in scope either.

However, it was not unreasonable to think it might be.

Maybe there's an opportunity!

-- Graham

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”