環境は、
- Arduino2009
- macbook OSX 10.4.11 -> 10.9 (2013.12.2更新)
です。
ドライバの準備
ダウンロード
インストール
ReadMe.rtfに従ってインストールする。
(libftd2xx.0.1.6.dylibを/usr/local/libにコピー。
libftd2xx.0.1.6.dylib -> libftd2xx.dylib にシンボリックリンク。
ftd2xx.hとWinTypes.hを/usr/local/includeにコピー。)
% ls -l /usr/local/lib/libftd2xx*
-rwxr-xr-x 1 root wheel 212748 2 24 01:47 /usr/local/lib/libftd2xx.0.1.6.dylib
lrwxr-xr-x 1 root wheel 36 2 24 01:50 /usr/local/lib/libftd2xx.dylib -> /usr/local/lib/libftd2xx.0.1.6.dylib
% ls -l /usr/local/include/(ftd*|Win*)
-rwxr--r-- 1 root wheel 2230 2 24 01:49 /usr/local/include/WinTypes.h
-rwxr-xr-x 1 root wheel 23433 2 24 01:48 /usr/local/include/ftd2xx.h
テスト
(成功例)
% cd D2XX/Samples/BitMode
% make
% ./bitmode
ucMode = 0x0
% cd D2XX/Samples/Simple
追記:このフォルダにあるRules.makeを以下のように修正しないとmakeが失敗する。
修正前:CFLAGS=-Wall -Wextra -L. -lftd2xx -Wl,-rpath /usr/local/lib
修正後:CFLAGS=-Wall -Wextra -L/usr/local/lib -lftd2xx -Wl,-rpath /usr/local/lib
% make
% ./simple
Device 0 Serial Number - A9005bvI
Opened device A9005bvI
^CClosed device
↑こうなれば成功なのだが、Arduinoのシリアルドライバがインストールされている場合うまくいかない。
(失敗例)
% cd D2XX/Samples/BitMode
% ./bitmode
FT_Open(0) failed = 3
% cd D2XX/Samples/Simple
% ./simple
Device 0 Serial Number - A9005bvI
Error FT_OpenEx(3), device
USBシリアルドライバとD2XXドライバは排他的なので同時に使うことができません。
ターミナルから以下のコマンドでUSBシリアルドライバをアンロード/ロードできます。
sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext
sudo kextload /System/Library/Extensions/FTDIUSBSerialDriver.kext
(アンロード&テスト)
sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext
% cd D2XX/Samples/BitMode
% ./bitmode
ucMode = 0x0
bitbangを使い終わったらふたたびArduinoを使えるように、
sudo kextload /System/Library/Extensions/FTDIUSBSerialDriver.kext
としてUSBシリアルドライバをロードしておきます。
avrdude-6.0.1のビルド
ソースからconfigure;make;(sudo?)make installでビルドして使えるようになりました。
"ft232r"あるいは"ft245r"というプログラマ名で使えます。SPI接続は付属のavrdude.confを見てください。
追記:2014年3月28日に再確認したら、3月12日に6.1がリリースされていました。リリースノートは見つかりませんでしたので、何が変わったのかは不明です。ダウンロードは
http://download.savannah.gnu.org/releases/avrdude/から。
serjtag-0.3 + avrdude-5.3.1のビルド
mkdir mac_bitbang
cd mac_bitbang
wget http://www.nmj.sakura.ne.jp/suz-avr/serjtag/serjtag-0.3.tar.gz
# wget http://www.geocities.jp/arduino_diecimila/bootloader/files/serjtag-0.3.tar.gz
wget http://ftp.twaren.net/Unix/NonGNU/avrdude/avrdude-5.3.1.tar.gz
# MD5 (avrdude-5.3.1.tar.gz) = 58c2be9f7a864b930ed9e6f1858f5cc7
# MD5 (serjtag-0.3.tar.gz) = 7228de34ad8221598401cd631dd6f55e
tar xvzf avrdude-5.3.1.tar.gz
tar xvzf serjtag-0.3.tar.gz
cd avrdude-5.3.1
patch -p1 < ../serjtag-0.3/avrdude-serjtag/src/avrdude-5.3.1-usb910.patch
patch -p1 < ../serjtag-0.3/avrdude-serjtag/src/avrdude-5.3.1-avr910d.patch
patch -p1 < ../serjtag-0.3/avrdude-serjtag/src/avrdude-5.3.1-serjtag.patch
patch -p1 < ../serjtag-0.3/avrdude-serjtag/src/avrdude-5.3.1-ft245r.patch
patch -p1 < ../serjtag-0.3/avrdude-serjtag/src/avrdude-5.3.1-baud.patch
mv ser_posix.c ser_posix.c.ORIG
grep -v B3000000 ser_posix.c.ORIG > ser_posix.c
./configure CFLAGS="-g -O2 -DSUPPORT_FT245R" LIBS="-lftd2xx"
make
./avrdude -v
↑ターミナルにコピペしたらOK
配線
色 |
Arduino |
|
tiny2313V |
mega88 |
mega88p |
赤 |
5V |
Vcc |
20 |
7,20 |
|
黒 |
Gnd |
GND |
10 |
8,22 |
|
青 |
(X3:2) |
SCK |
19 |
19 |
|
緑 |
(X3:1) |
MISO |
18 |
18 |
|
黄 |
(X3:3) |
MOSI |
17 |
17 |
|
白 |
(X3:4) |
RESET |
1 |
1 |
|
avrdude.confを編集
#arduino diecimila
programmer
id="diecimila";
desc = "FT232R Synchronous BitBang";
type = ft245r;
miso = 3; # CTS X3(1)
sck = 5; # DSR X3(2)
mosi = 6; # DCD X3(3)
reset = 7; # RI X3(4)
;
追加する。
実行
~/tmp/mac_bitbang/avrdude-5.3.1/avrdude -C ~/tmp/mac_bitbang/avrdude-5.3.1/avrdude.conf -c diecimila -p t2313 -vv -B 4800
~/tmp/mac_bitbang/avrdude-5.3.1/avrdude -C ~/tmp/mac_bitbang/avrdude-5.3.1/avrdude.conf -c diecimila -p t2313 -vv -B 4800 -U flash:w:main.hex:i
リセットが解除されない
なんかリセットが常にLOWのような気がする。
プルアップ10kを付けてもだめ。
配線を外すと書き込んだプログラムが動き始める。
うごかないときは
ReadMe.rtfにヒントがあった。
Q. Cannot open a port even though installation has been successful.
A1. This is possibly due to the FTDI serial driver holding the port with your VID and PID. Solution is to uninstall
the serial driver (see www.ftdichip.com knowledgebase on how to do this). To completely eradicate the possibility of
this occurring in future it is recommended a new VID and PID is used to distinguish between devices.
A2. Another possibility is an incorrect VID/PID. Try changing your application to use the FT_SetVIDPID API call to
quickly determine if this is the case.
参考サイト
最終更新:2014年03月28日 12:46