HIDaspx の件、ハードウェアの方はこれから部品を調達するとして、先にソフトウェアの整備にとりかかった。なお、試した環境は Mac OS 10.6.8(古い)。
- 千秋ゼミのページから
hidspx-2014-0306.tar.gz
をダウンロード・解凍する。 - コンパイルには libusb が必要。上記のアーカイブ中の
Makefile.macos
を見ると MacPorts 経由でインストールしているようだが、今回は MacPorts を使わないことにする。これがなかなか難儀だった。- Google で "libusb" を検索すると、"www.libusb.org" というサイトがトップに出てくるが、これは実は古くて、更新が止まっている。2015年3月現在、libusb.info で更新が継続している。
- libusb-1.0.19 をダウンロード・解凍する。
- libusb をスタティックリンクするため、
--disable-shared
をつけてビルドする。
./configure --disable-shared
make
sudo make install - libusb-compat-0.1.5 をダウンロード・解凍する。
- そのまま
configure
しようとすると、pkg-config
がない、と文句を言われる。pkg-config を MacPorts を使わずにインストールするのは大変なので、環境変数を直接セットして回避する。(2015.3.4. 追記:pkg-config は別に大変じゃなかった。インストールした方がいい。)
export LIBUSB_1_0_CFLAGS=-I/usr/local/include/libusb-1.0
export LIBUSB_1_0_LIBS='-L/usr/local/lib -lusb-1.0'
./configure --disable-shared
make
sudo make install
hidspx-2014-0306/src
に移動する。Makefile.macos
を複製してMakefile.macos.new
とし、#for MacOS X
の次の行(9行目)を以下のように修正する。
コメントアウト:# CFLAGS=-O2 -DUSER_BOOKMARKS -DHIDASP_ONLY -DAVRSPX=1 -DMACOS -DTIME_DISPLAY -I/opt/local/include -L/opt/local/lib
新規挿入:CFLAGS=-O2 -DUSER_BOOKMARKS -DHIDASP_ONLY -DAVRSPX=1 -DMACOS -DTIME_DISPLAY -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0 -lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundationmake -f Makefile.macos.new
ビルドできました。
MacBook:src nagata$ ls -l hidspx -rwxr-xr-x 1 nagata staff 178624 2 28 23:26 hidspx MacBook:src nagata$ ./hidspx AVRSP - AVR Serial Programming tool R0.44 (C)ChaN, 2008 http://elm-chan.org/ Write code and/or data : <hex file> [<hex file>] ... Verify code and/or data : -v <hex file> [<hex file>] ... Read code, data or fuse : -r{p|e|f|F|l} [-o<out hex file>] HEX dump (Flash/Eeprom) : -r{p|e}h [-o<HEX DUMP>] Get AVR Information(Web): -r{I|i|d} Write fuse byte : -f{l|h|x}<bin> Lock device : -l[<bin>] Copy calibration bytes : -c Erase device : -e Control port [-ph] : -p{h|hu} SPI control delay [-d3] : -d<n> Help (Detail) : -? or -h or --help Supported Adapter: HIDasp (USB -ph, -phu) MacBook:src nagata$
動作確認はハードを組み立ててから。ツェナーダイオードと 12 MHz のクリスタルを確保しなくちゃ。