Raspberry Pi 3でUrJTAGを使う
とりあえずRasPi3でUrJTAGが動くようにする
MAX10を出先や遠隔でコンフィグしたりするときRaspiでUrJTAGが使えたらなあと調べたら使えたのでメモ
RasPiだとGPIOでもバウンダリスキャンできるらしいので便利かもしれない。
apt install urjtagでインストールしたらUSB Blasterがうまく動かなかったので、仕方なくビルド。
参考はこちらUniversal JTAG library, server and tools / Discussion / Using UrJTAG: raspberry pi gpio port
準備
上記を参考に必要なパッケージをインストールする
$ sudo apt install autoconf autopoint libtool libreadline-dev python-dev libusb-dev libusb-1.0-0-dev flex libftdi-dev bison git
flex,bisonはBSDLをUrJTAGに食わせるのに共に必要なので追加しました。
D2XXのインストール。FTDIのサイトのREADMEを参考に行う。RasPi3は今のところOSが32bitなのでARMv7版を使うようだ。
$ wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-arm-v7-hf-1.4.6.tgz $ tar xvf libftd2xx-arm-v7-hf-1.4.6.tgz $ cd release/build $ sudo cp libftd2xx.* /usr/local/lib $ sudo chmod 0755 /usr/local/lib/libftd2xx.so.1.4.6 $ sudo ln -sf /usr/local/lib/libftd2xx.so.1.4.6 /usr/local/lib/libftd2xx.so
補足:Raspberry Pi Zero/Pi 1/Compute Module(CM1)で同様のことをする場合
検索ワードから「Illegal instruction」でここに来られる方が多いです。このエラーメッセージが出てしまった場合はアーキテクチャが違うことを意味します。
Raspi Zero/Pi 1/Compute Module(CM1)はCPUがARM11系なのでアーキテクチャがARMv6になります。以下のようにしてください。
$ wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-arm-v6-hf-1.4.8.tgz $ tar xvf libftd2xx-arm-v6-hf-1.4.8.tgz $ cd release/build $ sudo cp libftd2xx.* /usr/local/lib $ sudo chmod 0755 /usr/local/lib/libftd2xx.so.1.4.8 $ sudo ln -sf /usr/local/lib/libftd2xx.so.1.4.8 /usr/local/lib/libftd2xx.so
----補足ここまで----
ftd2xx.h,WinTypes.hがないとUrJTAGビルドでエラーになるのでコピーしておく
$ cd ../examples $ sudo cp ftd2xx.h /usr/include/ $ sudo cp WinTypes.h /usr/include/
UrJTAGのビルド。下記サイトの内容そのまま
Universal JTAG library, server and tools / Discussion / Using UrJTAG: raspberry pi gpio port
$ cd ~/ $ git clone git://git.code.sf.net/p/urjtag/git urjtag-git $ cd urjtag-git
ビルドの前にcmd_bfin.cの内容を修正
$ cd urjtag/src/cmd $ nano cmd_bfin.c
cmd_bfin.cソースコード先頭に下記を追加する
#ifndef _SYS_UCONTEXT_H #define _SYS_UCONTEXT_H #endif
ctrl-o,ctrl-xで保存後エディタ終了
UrJTAGのビルド
$ cd ../../ $ ./autogen.sh
Warningはちゃんと見ておくべし。
使いたい項目がyesになっているか確認する。
今回はUSB Blasterを使いたいのでD2XX関連とBSDL,SVFはyesになっているか確認。
urjtag is now configured for Libraries: libusb : 1.0 libftdi : yes (no async mode) libftd2xx : yes inpout32 : no Subsystems: SVF : yes BSDL : yes STAPL : no
問題なかったらmakeする
$ make $ sudo make install
動かん……
$ sudo jtag jtag: error while loading shared libraries: liburjtag.so.0: cannot open shared object file: No such file or directory
共有ライブラリとして認識されてないんじゃないかな…
$ sudo ldconfig
$ sudo jtag UrJTAG 0.10 # Copyright (C) 2002, 2003 ETC s.r.o. Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors UrJTAG is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. There is absolutely no warranty for UrJTAG. warning: UrJTAG may damage your hardware! Type "quit" to exit, "help" for help. jtag>
動いた…