N-Wire(のJTAG相当部分)経由で生存確認

さて,先程の件.N-Wire(のJTAG相当部分)をhackしてみる.

用意するもの

こんなとき便利なのがUrJTAG. openwince の jtag 辺りからスピンオフしたもののはず.個人的にはPoorman's MITOUJTAGと密かに呼んでいる.
こいつとJTAGアダプタを併用すれば,かなり柔軟に,かつユーザフレンドリにJTAGポートを弄れる.
オープンソースなのでビルドが必要だが,刺身包丁の通販ページからWin32バイナリを無償で入手できるので,これを使うと楽.

まずは物理的に繋ぐ

UrJTAGは多種多様なJTAGアダプタをサポートしている.電圧レベルさえ合っていれば,どのアダプタでもよいはずだが,今回は商売上の理由で刺身包丁を使う.

まず,JTAGの信号線5本(TDI,TCK,TMS,TDO,TRST)およびGNDをつなぐ.BKTGIOなる信号は繋がない.

そして論理的に繋ぐ

そしておもむろにホスト上で UrJTAGを実行する.

$ /opt/urjtag-0.10/bin/jtag

UrJTAG 0.10 #1502
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>

刺身包丁は(非公式ではあるが)OSXでも動く.Linuxでも動く.

立ち上がったら,USBの先にあるJTAGアダプタを認識させる.「oocdlink-s」の部分は,手持ちのJTAGアダプタ次第.

jtag> cable oocdlink-s
Connected to libftd2xx driver.

繋がる.ここから先は,アダプタの種類は考えなくて良い.(抽象化される)

読む

UrJTAGについて記述している日本語のwebコンテンツはいくつかあるが,いずれもすでにUrJTAGがサポートしている石へのアクセスを想定しており,いきなり

jtag> detect

などしている.今回のように海のものとも山のものともわからん石に対して行ってもオイシイことはない.

jtag> detect
IR length: 5
Chain length: 1
Device Id: 0 (0x0000000000000000)
chain.c(149) Part 0 without active instruction
chain.c(200) Part 0 without active instruction
chain.c(149) Part 0 without active instruction

など言われてオシマイ.まあ,IRの長さが解る*1から無駄ってこともないけれど.

おすすめは,discovery コマンド.IRの長さを検出した上で,各IRに対するDRの長さを検出してくれる.
出力はこんな感じ.

jtag> discovery
Detecting IR length ... 5
Detecting DR length for IR 11111 ... 1
Detecting DR length for IR 00000 ... 191
Detecting DR length for IR 00001 ... 191
Detecting DR length for IR 00010 ... 7
Detecting DR length for IR 00011 ... 22
Detecting DR length for IR 00100 ... 24
Detecting DR length for IR 00101 ... 11
Detecting DR length for IR 00110 ... 5
Detecting DR length for IR 00111 ... 4
Detecting DR length for IR 01000 ... 128
Detecting DR length for IR 01001 ... 64
Detecting DR length for IR 01010 ... 1
Detecting DR length for IR 01011 ... 1
Detecting DR length for IR 01100 ... 1
Detecting DR length for IR 01101 ... 1
Detecting DR length for IR 01110 ... 1
Detecting DR length for IR 01111 ... 1
Detecting DR length for IR 10000 ... 1
Detecting DR length for IR 10001 ... 1
Detecting DR length for IR 10010 ... 1
Detecting DR length for IR 10011 ... 1
Detecting DR length for IR 10100 ... 1
Detecting DR length for IR 10101 ... 1
Detecting DR length for IR 10110 ... 1
Detecting DR length for IR 10111 ... 1
Detecting DR length for IR 11000 ... 1
Detecting DR length for IR 11001 ... 1
Detecting DR length for IR 11010 ... 1
Detecting DR length for IR 11011 ... 1
Detecting DR length for IR 11100 ... 1
Detecting DR length for IR 11101 ... 1
Detecting DR length for IR 11110 ... 1

それらしい情報が返ってきているので,コアのJTAG部分が生きていることはほぼ確定*2.たぶんターゲットボードは生きていると推測可能.

余談.本当にBSR無いのか?

さきほどのdiscoveryの結果をもういちど眺めてみる.

Detecting DR length for IR 00000 ... 191
Detecting DR length for IR 00001 ... 191

EXTEST (00000)および SAMPLE (00001) のレジスタ長が同じ191という辺り,もしかしてバウンダリスキャンレジスタ(BSR)があるのではないかという気がする.ただ,TECH IのMIPSプロセッサ入門によると,VR5701は352ピンABGAとのことで,外に出ている全ピンをスキャンできるものではないのかもしれないけれども.
MIPSプロセッサ入門―アーキテクチャの解説から評価ボードを使った組み込みプログラミング事例まで (TECH I Processor)
とはいっても,VR4系ではBSRが無いのかもしれないし,実際にBSRである確証がえられているわけでもないので,「なひたふJTAG日記」の記述とは個別に検証が必要なものと考えるべきかもしれない.

さてお遊びはここまで.情報を公開してくれないメーカの石で延々と遊ぶほど,私は暇人でもお人好しでもない.

*1:ちなみに,IRの長さが「なひたふJTAG日記」の記述と違う.VR4系とVR5系の違いだろうか.

*2:中身が判らないので断定はできない