Adafruit AVRProg Grows UPDI Interface Support

Making a small number of things with an embedded application is pretty straightforward, you usually simply plug in a programmer or debugger dongle (such as an AVRISP2) into your board with an appropriate adaptor cable, load your code into whatever IDE tool is appropriate for the device and hit the program button. But when you scale up a bit to hundreds or thousands of units, this way of working just won’t cut it. Add in any functional or defect-oriented testing you need, and you’re going to need a custom programming rig.

Adafruit have a fair bit of experience with building embedded boards and dealing with the appropriate testing and programming, and now they’ve updated their AVR Programming library to support the latest devices which have moved to the UPDI (Unified Programming and Debug Interface) programming interface. UPDI is a single-wire bidirectional asynchronous serial interface which enables programming and debugging of embedded applications on slew of the new AVR branded devices from Microchip. An example would be the AVR128DAxx which this scribe has been tinkering with lately because it is cheap, has excellent capacitive touch support, and is available in a prototype-friendly 28-pin SOIC package, making it easy peasy to solder.

The library is intended for use with the Arduino platform, so it should run on a vast array of hardware, without any special requirements, so making a custom programming jig out of hardware lots of us have lying around is not a huge hassle.

Adafruit provide a few application examples in the project GitHub to get you going, such as this ATTiny817 example that wipes the flash memory, sets appropriate fuses and drops in a bootloader.

The UPDI code was taken from the [brandanlane’s] portaprog which is hosted on the TTGO T-Display ESP32 board from Chinese outfit LilyGo, which is also worth checking out.

A little while ago we saw how the AVR Multitool, the AVRGPP learned to speak UPDI, and since we’re on programming interfaces, its possible to get the cheap-as-chips USBasp to speak TPI as well.

 

11 thoughts on “Adafruit AVRProg Grows UPDI Interface Support

    1. The “fuses” in the new AVRs are actually much nicer than they used to be. Instead of individual bits and bit fields crammed into a couple of bytes, it’s more like up to up to 11 bytes, with “independent” features (like oscillator config or bootloader size) assigned a whole byte. (unfortunately, the tools are a bit behind.)

    1. Well, it replaces SPI, High Voltage Serial Programming, PDI, DebugWire, and JTAG, on the newer AVRs.
      And it’s much better documented than some of them (eg Atmel never documented debugWire commands.)

  1. You can still actually buy those new 8-bit AVR128DAxx parts. Example:

    AVR128DA48T-E/6LX 8-bit Microcontroller MCU 128 KB 48-pin 85CTQFP, 3,021 In Stock, Qty.-1 $2.23, Qty.-100 $2.00

    https://www.mouser.com/ProductDetail/Microchip-Technology/AVR128DA48T-I-PT?qs=%2Fha2pyFadujt9Iv3uc%2F9P25c8myi5llQSqTRUTHnW92RW1LSkZpyLdCaiuOqkiVH

    Unfortunately… Factory Lead-Time: 52 Weeks. Yeah, we’re heading off a cliff. Buy ’em now, before the CCP-funded scalpers swoop in.

    The good old 8-bit standby ATMEGA328P-PU is still available – if you dig around. I think it’s been cloned in China by now, so that should help. It doesn’t have one of those new UPDI ports though. But that doesn’t matter if you’re going to burn a bootloader and you don’t need fancy 1-pin debug.

    ATMEGA328P-PU AVR series Microcontroller IC 8-Bit 20MHz 32KB (16K x 16) FLASH 28-PDIP, 8,136 In Stock, Qty.-1 $2.82, Qty.-100 $2.34

    https://www.digikey.com/en/products/detail/microchip-technology/ATMEGA328P-PU/1914589

    But the bleak handwriting from our future is on the wall over at Mouser:

    ATMEGA328P-PU, 0 in stock, 92,880 on order, 33,156 Expected 7/26/2022, 59,724 Expected 12/12/2022, Qty.-1 $2.60, Qty.-112 $2.33

    https://www.mouser.com/ProductDetail/Microchip-Technology-Atmel/ATMEGA328P-PU?qs=sGAEpiMZZMsxiS4eJwGuBtT8OTELel%252BT7Vvh8juxLfE%3D

    Ooof, that hurts.

  2. 1. Check out ElTangas/jtag2updi firmware. For example it can turn an ATmega328 Arduino into a UPDI bridge. Here’s the toolchain example from the jtag2updi GitHub page:

    avrdude -> HW Serial interface -> Programmer MCU (e.g. Mega328P) -> SW Serial on PD6 -> Target MCU (e.g. tiny817)

    https://github.com/ElTangas/jtag2updi

    2. Here’s a 2-part tutorial that uses an Arduino Nano with jtag2updi as a UPDI bridge. I have not tried this myself:

    – Using the new ATtiny Processors with Arduino IDE

    https://www.hackster.io/john-bradnam/using-the-new-attiny-processors-with-arduino-ide-612185

    – Create Your Own UPDI Programmer

    https://www.hackster.io/john-bradnam/create-your-own-updi-programmer-1e55f1

    3. Programming via UDPI is not the same as debugging via UDPI. As is, jtag2updi is bridge firmware, I have not seen it used with a JTAG debugger application yet – if that’s even possible.

  3. On a slightly related note, if you wish to debug your AVR programs directly on the target, using UPDI with a Linux host machine, you can do so now with Bloom (https://bloom.oscillate.io). Bloom exposes an interface to the connected target, by means of a GDB server. Any IDE with GDP RSP client capabilities can be used with Bloom.

    Disclaimer: I am the author of Bloom.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.