tinyAVR 1-series#

Author : Jun Kawahara (FabLab Kamakura)
Date created : 6/29/2020
update: 2/9/2021 - megaTinyCore updating
update: 2/11/2021 - Kae-san confirmed Neil’s exact sample of hello.USB-UPDI.FT230X works fine.
update: 2/18/2021 - confirmed that hello.serial-FTDI.FT230X meets the requirement, add traces/interiors


Neil introduces new microcontrollers since Fab Academy 2020, one of which is tinyAVR from Microchip Technology.

(image source: Getting Started with tinyAVR® 1-series)

tinyAVR 1-series can be programmed through the UPDI(Unified Program and Debug Interface). The classic ISP programmers cannot be used. Connect RX and TX together with a suitable resistor and connect this node to the UPDI pin of the AVR device.


(image source: mraardvark/pyupdi)

updi programmers#

Neil introduces different types of UPID programmer.

hello.serial-UPDI#

It’s FTDI-UPDI converter, and you still need a USB-FTDI converter to program a target board.

You can use it with an off-the-shelf USB-FTDI converter (image left), or Neil’s board, USB-FT230XS-serial board (right). - hello.USB-serial.FT230X: traces, interior

Info

Neil said that this simple board met the requierment this week, but barely. I think it’s a good start for the first spiral.

hello.USB-UPDI.FT230X#

This programmer concludes USB-UPDI conveter.
- hello.USB-UPDI.FT230X: traces, interior

Info

pyupid procedure described below works fine, but is not readily usable. See megaTinyCore updated section.

software#

  • python3
  • pyupdi
    • Python utility for programming AVR devices with UPDI interface using a standard TTL serial port
  • python dependencies: intelhex, pylint, and pyserial

download pyupdi#

clone or download from the repository
You can install pyupdi.py with pip directly from GitHub

$ pip install https://github.com/mraardvark/pyupdi/archive/master.zip

install python dependencies#

Install all python dependencies for pyupdi via pip.

$ pip3 install intelhex pylint pyserial

install megaTinyCore#

open Arduino > preferences… s Add following URL to Additional Boards Manager URLs section.

http://drazzy.com/package_drazzy.com_index.json

go Tools > Board > Board Mangers…, search megatinycore and install it.

Now you are ready for programming tinyAVRs!

install lsusb#

As an option, install lsusb, which make it easier to find whether your host PC recognize your programmer as an USB device.

brew install lsusb

Why doesn’t my pc recognize a programmer as a USB device?#

Before programming, make sure that your host PC recognize your programmer as a USB device. If your PC does, lsusb command will display like this.

So-called USBPCB is sooooo tricky. I recommend the continuity test. Check connection following paths.

  • D+/D- of USBPCB to USP/USM of FT230X
  • 5V/GND of USBPCB to VCC/GND of FT230

When they are fine, your pc is supposed to recognize your programmer. It is USBPCB which is wrong. My recommendations are,

  • applying solder iron on USBPCB pads
  • using shim (a stack of tapes) on the backside of USBPCB

programming examples#

ATtiny412#

hello.t412.blink

  1. I assume that you already have made a hello.t412.blink, and hello.USB-serial.FT230X board.
    Make sure that your host PC can recognize a USB-serial.FT230X as a USB device.

  2. download hello.t412.blink.ino, open it with Arduino IDE.

  3. File > preferences, open preferences.txt and add a directory path to export compiled binary, like, build.path=/Users/you/Desktop/Arduino_build

Danger

The folder will be clean slate everytime you compiled a sketch. Do not point the path to the your important folder. All files on my desktop were erased!

  1. Inside Tools menu, select a board and a chip.

  2. With Arduino IDE, select Sketch > Export Compiled Binary. It will export a binary file(.hex) to a path you specified above.

  3. connect your computer, hello.USB-serial.FT230X, and hello.t412.blink board

  4. To program your board, type command like below. UART serial and a directory path depend yours.

    $ python3 pyupdi.py -d tiny412 -c /dev/tty.usbserial-DN0561W0 -b 57600 -f ~/Desktop/you/Arduino_build/hello.t412.blink.ino.hex 
    

    If you get Programming successful message on your terminal, your led on a board must be blinking now.

ATtiny1614#

  1. I assume that you already have made a hello.t1614.echo, hello.USB-serial.FT230x, and hello.USB-UPDI.FT230X board.
    Make sure that your host PC can recognize both a hello.USB-serial.FT230X and a hello.USB-UPDI.FT230X as USB devices.

  2. download hello.t1614.echo.ino, open it with Arduino IDE.

  3. Inside Tools menu, select a board and a chip. Then, select Sketch > Export Compiled Binary. It will export a binary file(.hex) to a path you specified above.
  4. Connect your board with a hello.USB-serial.FT230X and a hello.USB-UPDI.FT230X.

  5. To program your board, type command like below. UART serial and a directory path depend yours.

    $ python3 pyupdi.py -d tiny1614 -c /dev/tty.usbserial-DN0561VY -b 57600 -f ~/Desktop/you/Arduino_build/hello.t1614.echo.ino.hex -v
    
    If the command works, you must be looking at a verbose output like this.

  6. After long rambling verbose output, I hope you get Programming successful message on your terminal. Now you are ready to communicate with your board.

  7. Type the command like below. UART serial depends on yours.

    $ python -m serial.tools.miniterm /dev/tty.usbserial-DN0561W0 115200
    
    Type a byte character. It is successful result when the character echoed back on your terminal. Congratulations.

ATtiny3216#

  1. Procedure is the same as ATtiny412.
  2. download hello.t3216.echo.ino, open it with Arduino IDE.
  3. Inside Tools menu, select a board and a chip. Then, Sketch > Export Compiled Binary
  4. Connect your ATtiny3216 board with a hello.USB-serial.FT230X and a hello.USB-UPDI.FT230X. In an image below, I used a USB-UART converter with CH340G, an FTDI-alternative chip.
  5. Type command like below. UART serial and a directory path depends on yours.

    $ python3 pyupdi.py -d tiny3216 -c /dev/tty.usbserial-D307OEP4 -b 57600 -f ~/Desktop/Arduino_build/hello.t3216.echo.ino.hex -v
    

    If Programming successful message is on your terminal, Now you are ready to communicate with your board.

  6. Type the command like below. UART serial depends on yours.

    $ python -m serial.tools.miniterm /dev/tty.wchusbserial145220 115200
    
    Type a byte character. It is successful result when the character echoed back on your terminal. Congratulations.

megaTinyCore updated#

  1. open Arduino > preferences…

    Add following URL to Additional Boards Manager URLs section.

    http://drazzy.com/package_drazzy.com_index.json
    

    go Tools > Board > Board Mangers…, search megatinycore and install it. Make sure that its version is 2.2.0 and higher.

  2. download hello.t3216.echo.ino, open it with Arduino IDE.

  3. Connect your ATtiny3216 board with a hello.USB-serial.FT230X and a hello.USB-UPDI.FT230X. In an image below, I used a USB-UART converter with CH340G, an FTDI-alternative chip.
  4. Inside Tools menu, select your Board, Chip and ,”Serial Port and 4.7k (pyupdi style)” as Programmer

  5. Upload the sketch. After Uploading done, You are now ready to communicate with your board. Type command like below. USB-serial converter depends on yours.

    $ python -m serial.tools.miniterm /dev/tty.wchusbserial141230 115200
    
    Type a byte character. It is successful when the typed character is echoed back on your terminal. Congratulations.

references#