AtTiny412 General Purpose Blinky Board and UPDI Programming

In the 2020 season of Fab Academy, we are encouraged to use new chips (as opposed to the Attiny 84/85 chips). The new chips the lab got were AtTiny 412. This is a tiny 8-pin chip is pretty neat. Here’s my old design which was an EagleCAD Board file. It is based on Neil’s design for the AtTiny412 (Go here), ctrl+f for Attiny412 and look at his “board” link) board but I moved the LED to Digital Pin 0 (which is PA6 in Atmel speak – pin 2 from the top left) of the chip. My new design used KiCAD and is available here.

Here’s the layout of my board:

BOM:

  • AtTiny412
  • LED
  • 499Ω resistor
  • 4.9kΩ resistor
  • 6-pin SMT header (FTDI)
  • 2x 2×2 SMT header (Optional, general purpose for connecting other stuff to)

Once the board was made I needed a programmer. The new chips use UPDI instead of ISP protocol. There are two easy ways of making a cheap programmer for this. One is simple software but complex hardware (Arduino-based) and the other is simple hardware and complicated software (python upload/downloader). I tried them both to see what I could simplify about them.

First, mill the board. With this, I experimented with a lacquer finish as a soldermask it came out pretty well actually.

Complex hardware, simple software (Arduino):

First I installed the megaTinyCore library into Arduino.

Followed these instructions to make a UDPI programmer out of an arduino. Here’s a board you I designed that you can fab yourself for this project. Simply download the jtag2UDPI sketch to an arduino board to make it a programmer. You’ll need to connect up a 4.7k resistor from Digital Pin 6 to go to the AtTiny412 board to program.  Additionally, if you can’t disconnect the the DTR line from the serial chip to the reset pin of the arduino, just add a large capacitor from the reset pin to ground. The capacitor acts like a tiny battery and when the DTR pin on the FTDI chip drops voltage to 0 to reset the arduino (typically how it works when using the arduino software) the capacitor will keep the voltage high so the jtag2UPDI won’t reset in the middle of trying to program the AtTiny chip.

This is a stupid simple solution that costs very very little. You can get an arduino board for $2 online and add a resistor and capacitor to make it a programmer and you’re done. This is the way to go. The issue is that Fab academy wants you to actually build your own programmer.  I’ll revisit this in another post soon…

Once you’ve built the programmer, change your chip in the Arduino software to the AtTiny412 and change the Programmer to “jtag2UPDI”  then load up Blink example and change the led_pin to pin 0 (if you are using my board design).  When you click program, all should go well.

Simple Hardware Complex Software:

This solution uses just a USB serial chip (FTDI or similar) and only 1 resistor.  No additional arudino required. Neil encouraged in week 2 Instructors meeting to build his FTDI-based UDP programmer and use PyUDPI (See under “hardware” if you search for “UPDI” here). Basically you use a simple USB to serial converter chip (FTDI chip or similar) and all the hard work is done on the software side. The setup for PyUDPI is a lot of overhead when you can just get it working directly in arduino using the jtag2UDPI linked above.

The first board Fab academy recommends is hello.serial-UPDI.FT230X assumes you have an FTDI board. This only provides a resistor and two connectors. One connector accepts the FTDI 6-pin header and the other is the 1 pin and Gnd signal to program the AtTiny. Of course this one is WAY too easy to build…

The second board under “hardware” on that page (hello.USB-UPDI.FT230X)  is an actual FTDI board, exactly like you could buy. The FTDI chip has smaller pin pitch than the ones we typically do in FabLab so he recommended using the heated desoldering iron.

The workflow will be to use Arduino (because why not?) or any other compiler to generate the hex file, then use the PyUDPI python script to send the hex file to the AtTiny chip manually.

Since this used Python 3 and the terminal, I didn’t want to mess around with windows paths and all that disastrous junk. I installed it in an osboxes.org virtualbox linux installation inside my windows machine and tunneled access to the USB device to it.

  1. First install Python 3 (NOT python 2!) if you don’t already have it. Open a terminal and check
    $ python3 --version

    If not installed, then install it:

    $ sudo apt-get update
    $ sudo apt-get install python3.6
  2. Install pip 3  (Tom Dubick says – python since version 3.2 comes with PIP)
  3. Then install the dependencies for PyUPDI with this line
    pip3 install intelhex pylint pyserial
  4. Download and unzip the pyUPDI project from here (Click the “clone or download” green button and download a zip (you need the whole thing so just unzip the whole folder).
  5. Plug in a 3.3v FTDI chip (Convert a 5v version to 3.3 volts shown here)
  6. Open Arduino and load up the blink example. Change the LED pin to 0 since that’s what my board uses. Save the file to the Desktop. Export a compiled Binary from the Sketch menu in Arduino. Sketch—?Export compiled Binary This will save the .hex file in the Arduino project folder. (You saved this to the Desktop like I told you to right?) Otherwise you’ll be digging through temp files to find it.
  7. Open a terminal window inside the pyUDPI folder (or navigate to it). Open a terminal and download to the board using the following command:
    sudo python3 pyupdi.py -d tiny412 -c /dev/ttyUSB0 -b 115200 -f Blink.ino.hex -v

Where /dev/ttyUSB* is the path to the FTDI port and Blink.ino.hex is your file’s name.

Board:

Tweaked the design of Neil’s Blinky board. I changed the pinout of his board to use Pin 0. You can see the pinouts of the new chips:

 

Image source: https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/ATtiny_x12.md

Other new chip pinouts available in uncropped image:

Tom Dubick added the following resource which is great as well: https://npk-stn.ru/2019/07/19/simple_programming_attiny414_via_updi/?lang=en

Leave a Comment

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