UPDI (AVR 0,1-series)

class page

  • http://academy.cba.mit.edu/classes/embedded_programming/index.html

UPDI boards connection

make FTDI board

hello.USB-serial.FT230X

This board is the same as these
- FTDI cable(5V)
- FTDI modules

To use any FTDI, drivers are required

install lsusb

$ lsusb
-bash: lsusb: command not found
$ brew install lsusb
Updating Homebrew...
...
/usr/local/Cellar/lsusb/1.0: 4 files, 12.4KB
$ lsusb
Bus 020 Device 023: ID 0403:6015 Future Technology Devices International Limited FT230X Basic UART  Serial: D307RGA2
$ ls /dev | grep usb
cu.usbserial-D307RGA2
tty.usbserial-D307RGA2

no need programme the bord, just driver is required.

make programmer board for echo-board

hello.serial-UPDI.FT230X

This will be used with hello.USB-serial.FT230X (FTDI)

hello.USB-UPDI.FT230X

$ lsusb
Bus 020 Device 022: ID 0403:6015 Future Technology Devices International Limited FT230X Basic UART  Serial: D307RGA1
$ ls /dev | grep usb
cu.usbserial-D307RGA1
tty.usbserial-D307RGA1

no need programme the bord, just driver is required.

hello.t412.blink

How to get .hex from .ino

Open hello.t412.blink.ino in Arduino IDE

On Arduino IDE
Arduino > preferences…

Additional Boards Manager URLs > add http://drazzy.com/package_drazzy.com_index.json > OK
Click and open the folder Quit Arduino IDE first, then open preferences.txt in a text editor
Add build.path in preferences.txt and save

build.path=/Users/yuichitamiya/Arduino/build/

This is where your .ino.hex will save

Prepare Arduino/build folder

$ cd
$ mkdir Arduino
$ cd Arduino
$ mkdir build
$ cd  build
$ pwd
/Users/yuichitamiya/Arduino/build

Boot Arduino IDE and preferences again
check Use external editor and OK

Open hello.t412.blink.ino in a text editor

Tools > Board > Board Manager…

Type attiny412 and Install megaTinyCore

Tools > Choose board and setting
- Board:ATtiny412/402/212/202 - chip: ATtiny412 - Clock Speed “20 Mhz”


Then compile as usual

hello.t412.blink.ino.hex is made in build.path folder

How to programme a board

install software

$ pip3 install intelhex pylint pyserial

download and unzip pyupdi
or

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

// pipからインストールすると後述のパスの設定やsymbolic linkの設定が不要で、pyupdi.pyが実行できる

$ pyupdi.py -d your_processor -c your_port -b your_baud_rate -f your_hex -v

program

$ python3 pyupdi.py -d your_processor -c your_port -b your_baud_rate -f your_hex -v

for attiny412
ref. https://matwick.ca/pyupdi-2/

$ ls /dev | grep usb
tty.usbserial-D307RGA2

$ python3 pyupdi.py -d tiny412 -c /dev/tty.usbserial-D307RGA2 -b 57600 -f hello.t412.blink.ino.hex -v

Path through

$ cd
$ mkdir bash
$ ls
bin
$ mv ~/Downloads/pyupdi-master ~
$ cd 
$ ls 
pyupdi-master
$ cd pyupdi-master
$ ls
pyupdi.py
$ open .bash_profile
add
export PATH="$HOME/bin:$PATH:."

$ source ~/.bash_profile
$ printenv PATH
/Users/yuichitamiya/bin
$ cd ~/bin
$ ln -s ~/pyupdi-master/pyupdi.py . //symbolic link
$ ls -l
lrwxr-xr-x  1 yuichitamiya  staff  43  2  8 14:44 pyupdi.py -> /Users/yuichitamiya/pyupdi-master/pyupdi.py
$ chmod +x pyupdi.py
$ cd ~/Arduino/build
$ ls
hello.t412.blink.ino.hex
$ python3 /Users/yuichitamiya/bin/pyupdi.py -d tiny412 -c /dev/tty.usbserial-D307RGA2 -b 57600 -f hello.t412.blink.ino.hex -v

or

$ pyupdi.py -d tiny412 -c /dev/tty.usbserial-D307RGA2 -b 57600 -f hello.t412.blink.ino.hex -v

Check symbolic link works

$ cd ~/bin
$ echo date > aaa.sh
$ chmod +x aaa.sh
$ pwd
/Users/yuichitamiya/bin
$ cd
$ pwd
/Users/yuichitamiya
$ aaa.sh
2020年 2月 8日 土曜日 14時39分20秒 JST
$ which aaa.sh
/Users/yuichitamiya/bin/aaa.sh
$ cd Desktop
$ aaa.sh
2020年 2月 8日 土曜日 14時39分21秒 JST

UPDATE 2021/01 Path through in zsh

% which pyupdi
/usr/local/bin/pyupdi
% cd
% touch .zprofile
add 
export PATH="$HOME/usr/local/bin:$PATH:."

% source ~/.zprofile
% printenv PATH
/usr/local/bin

% ls /dev | grep usb
tty.usbserial-D307RGA1

% ln -s ~/usr/local/bin/pyupdi.py .  //symbolic link
% ls -la
lrwxr-xr-x   1 yuichi  staff     37  1  6 15:58 pyupdi.py -> /Users/yuichi/usr/local/bin/pyupdi.py

% cd Arduino/build
% ls
hello.t3216.echo.ino.hex

% pyupdi -d tiny3216 -c /dev/tty.usbserial-D307RGA1 -b 57600 -f hello.t3216.echo.ino.hex -v