MAXQプロセッサ用シリアル/JTAGボード
要約
このアプリケーションノートでは、シリアル-JTAGボードが受け取るコマンドについて説明します。このボードは、MAXQマイクロコントローラとインタフェースするために使用されます。ここで説明するコマンドを使用することで、開発者は、MAXQのメモリ(コードとデータ)およびレジスタへの読み書き、およびインサーキットデバッガの利用が可能となります。
はじめに
MAXQマイクロコントローラには、4線式同期シリアルインタフェースを経由してホストデバイスと通信するためのテストアクセスポート(TAP)が組み込まれています。このTAPを使用して、インシステムプログラミング(ISP)とインサーキットデバッグをサポートしています。TAPは、JTAG IEEE規格1149に準拠しています。TAPに接続するため、ダラスセミコンダクタは、シリアル/JTAGボードとファームウェアを開発しました。これは、標準のRS-232シリアルポート上でコマンドを受け取って、このコマンドを該当するJTAG信号に変換するものです。このアプリケーションノートでは、ファームウェアによって実装されているコマンドプロトコルについて説明します。シリアル/JTAGボードそのものについての詳細が必要な場合は、テクニカルサポートチームまでご質問をお寄せください。
ダウンロード:このアプリケーションノートに関するソースコードおよび回路図 (English only)
注:このアプリケーションノートでは、MAXQマイクロコントローラのTAPと基本的なJTAG通信に精通していることを想定しています。これに関する詳細については、「MAXQファミリのユーザガイド」を参照してください。
ファームウェアとのインタフェース接続
シリアル/JTAGボードとの通信を確立するには、ボードのシリアルポートに115200ボーで接続します(8データビット、パリティなし、および1ストップビットを使用)。接続が確立されると、ASCIIまたはバイナリのいずれかのモードでファームウェアとインタフェース接続することができます。ファームウェアは、デフォルトではASCIIモードに設定されています。ASCIIモードでは、人間が読むことのできるテキストコマンドがボードに送信され、その結果がテキスト文字列で返されます。バイナリモードでは、後述するように、送信はすべて、一連の8ビットバイトです。2つのモードをいつでも切り替えることのできるコマンドが用意されています。ASCIIモードのとき、表1に挙げたコマンドが常に使用可能です。コマンドはすべて大文字と小文字を区別します。コマンドグループを1行に入力することもできれば、各コマンドを一度に1つずつ入力することもできます。
表1. いずれのモードでも受信されるコマンド
Command | Description |
h | Halts the MAXQ by holding it in reset. |
H | Releases RESET allowing the MAXQ to run. |
I | Puts the system into bypass mode and resets the TAP, returning it to the Run-Test-Idle state. |
JB | Instructs the firmware to begin accepting background mode commands. This command does not switch modes on the target MAXQ nor does it send any JTAG commands to the target device. It is intended only to instruct the firmware that the MAXQ has changed modes by some other means. |
JD | Instructs the firmware to begin accepting debug mode commands. This command does not switch modes on the target MAXQ nor does it send any JTAG commands to the target device. It is intended only to instruct the firmware that the MAXQ has changed modes by some other means. |
JL | Instructs the firmware to begin accepting bootstrap loader commands. This command does not switch modes on the target MAXQ nor does it send any JTAG commands to the target device. It is intended only to instruct the firmware that the MAXQ has changed modes by some other means. |
JX | Instructs the firmware to begin accepting bypass mode commands. This command does not switch modes on the target MAXQ nor does it send any JTAG commands to the target device. It is intended only to instruct the firmware that the MAXQ has changed modes by some other means. |
Q | Queries the interface version number of the JTAG board. The version number will be output as two hexadecimal characters. This version will change anytime the format of any command or its output changes. The interface version at the time this document was written, was 01. |
q | Queries the firmware version number of the JTAG board. The version number will be output as two hexadecimal characters. This version will change anytime the firmware changes. The firmware version at the time this document was written, was 02. |
Vtxxyy | Sets up Timer0 of the JTAG board. As the JTAG clock must be less than 1/8 of the target's clock, the firmware uses Timer0 to control the speed of the JTAG clock. The firmware waits for the timer to overflow before generating each edge of the JTAG clock. Replace 't' with the value to use for the timer's T0M bit, 'xx' with the value to use for TH0, and 'yy' with the value to use for TL0. All values should be entered in hexadecimal format. For more information about the purpose of these values, see the Ultra-High-Speed Flash Microcontroller User's Guide. |
Yrbbdd | Sends a value directly to the TAP. Replace 'r' with the TAP register to which you want to write to: 0 for DR and 1 for IR. 'bb' is the number of bits to write (not including the status bits) and 'dd' is the data to send. All values should be entered in hexadecimal format. |
Z | Switches the firmware to binary transfers. |
z | Executes a single pulse of the JTAG clock. |
+ | Performs a simple hardware test of the JTAG board. The CLK, TMS, and TDI pins are all asserted, and the state of TDO is read and output as a '0' or '1'. The voltage at the pins can then be measured to ensure that they are functioning properly. |
- | Performs a simple hardware test of the JTAG board. The CLK, TMS, and TDI pins are all set to a logic low, and the state of TDO is read and output as a '0' or '1'. The voltage at the pins can then be measured to ensure that they are functioning properly. |
上記のコマンドが示すように、MAXQ JTAGエンジンには、数種類のモードがあります。バイパスモード、ブートストラップローダモード、バックグラウンドモード、およびデバッグモードです。JTAGエンジンの機能は各モードで異なります。このため、JTAGエンジンがこれらの異なるモードに移行すると、上記のコマンドに加えて、他のコマンドも利用可能になります。
バイパスモード
TAPは「パワーオンリセット」時にバイパスモードに初期化されます。このモードでは、TAPは禁止されて、その他のMAXQマイクロコントローラと交信することはありません。TAPを起動するには、このモードで使用可能な2つの追加コマンド「D」および「L」の1つを入力します。「D」コマンドはインサーキットデバッガを起動し、「L」コマンドはブートストラップローダを起動します。
ブートストラップローダモード
「L」コマンドを使用してブートストラップローダを起動すると、MAXQのユーティリティROMにバイトを直接送信することができます。値は、それぞれ2つの16進文字として入力します(ユーティリティROMによって受け取られるバイトの詳細については、テクニカルサポートにお問い合わせください)。入力したバイトごとに、ファームウェアはローダが返すバイトと、TAPから受け取るステータスビットを出力します。出力の書式は「00xx:ss」になります(ここで「xx」は出力バイト、および「ss」はステータスビットです)。「ローダの終了」コマンド(0x01)を入力した場合には、表1に挙げた「J」コマンドの1つを使用して、MAXQがブートストラップローダモードでなくなったことをJTAGボードに通知する必要があります。
バックグラウンドモード
JTAGエンジンのバックグラウンドモードのときには、JTAGブレークポイントレジスタ(BP0~BP5)の読み書き、インサーキットデバッグレジスタ(ICDC、ICDF、ICDA、およびICDD)の読み書き、いつブレークポイントの一致が発生するかの判断、および手動によるデバッグモードの起動が可能となります。これらの動作をサポートするコマンドを表2に示します。このモードで出力されるすべてのコマンドについて、その書式は「xxyy:ss」になります(ここで「xx」は出力データのMSB、「yy」はLSB、および「ss」はTAPが返すステータスビットです)。
表2. バックグラウンドモードで使用可能なコマンド
Command | Description |
A | Read the ICDA register. |
axxyy | Write the ICDA register, where 'xx' is the MSB of the new value and 'yy' is the new LSB. Values should be entered as two hexadecimal characters. |
Bi | Read any of the 6 breakpoint registers, where 'i' is the index of the breakpoint register to read (0 through 5). |
bixxyy | Write any of the 6 breakpoint registers, where 'i' is the index of the breakpoint register to write (0 through 5), 'xx' is the MSB of the new value, and 'yy' is the LSB. The MSB and LSB values should be entered as two hexadecimal characters. |
C | Read the ICDC register. |
cxx | Write the ICDC register, where 'xx' is the new value. Values should be entered as two hexadecimal characters. |
D | Read the ICDD register. |
dxxyy | Write the ICDD register, where 'xx' is the MSB of the new value and 'yy' is the new LSB. Values should be entered as two hexadecimal characters. |
E | Enter debug mode. |
F | Read the ICDF register. |
N | No operation. |
デバッグモード
JTAGエンジンをデバッグモードに移行する方法には2つあります。1番目の方法は、バックグラウンドモードのときに「デバッグモードに移行」コマンド(「E」)を入力することです。デバッグを起動する2番目の方法は、ブレークポイントの一致が発生したときに行われます。この場合、「JD」コマンドを入力して、モードが変更したことをファームウェアに通知する必要があります。デバッグモードに移行すると、MAXQレジスタの読み書き、プログラムスタックの読み取り、データメモリの読み書き、MAXQ CPUのシングルステップ実行、バックグラウンドモードへの復帰、および特定コマンドのロックを解除するためのパスワード照合の実施が可能となります。表3に、この機能をサポートするコマンドを示します。
表3. デバッグモードで使用可能なコマンド
Command | Description |
E | Exit debug mode, return to background mode. |
G | Gets all registers. The order of the registers returned depends on the type of MAXQ device. |
Mxxyyiijj | Read data memory, where 'xx' is the MSB of the word address to read, 'yy' is the LSB of the address, 'ii' is the MSB of the number of words to read, and 'jj' is the LSB of the length. All values should be entered as two hexadecimal characters. |
mxxyyiijj | Write a word to data memory, where 'xx' is the MSB of the word address, 'yy' is the LSB of the address, 'ii' is the MSB of the word to be written, and 'jj' is the LSB of the word to be written. All values should be entered as two hexadecimal characters. |
n | No operation. |
Pxx1...xx32 | Attempt a password match with the given data. All 32 values should be entered as two hexadecimal characters. |
R0iim | Read a register, where 'ii' is the register's index and 'm' is the register's module. The index should be entered as two hexadecimal characters, and the module should be entered as a single hexadecimal character. |
r0iimxxyy | Write a register, where 'ii' is the register's index, 'm' is the register's module, 'xx' is the MSB of the new value, and 'yy' is the LSB. The index and each byte of the new value should be entered as two hexadecimal characters. The module should be entered as a single hexadecimal character. |
Sxxyyiijj | Read the program stack, where 'xx' is the MSB of the word address to read, 'yy' is the LSB of the address, 'ii' is the MSB of the number of words to read, and 'jj' is the LSB of the length. All values should be entered as two hexadecimal characters. |
T | Execute the instruction at the current instruction pointer. |
注:表2に示したバックグラウンドモードのコマンドはすべてデバッグモードでも使用することができます(「E」は除きます)。
バイナリ転送
表1、2、および3に示したコマンドはいずれも手動で簡単に入力することが可能で、出力内容も容易に理解することができます。ただし、多くの場合、ソフトウェアによってJTAGボードが制御されることになります。ASCIIコマンドをソフトウェアで使用することは容易ではなく、また結果をバイナリデータに変換する際に余分な処理が必要となるため、JTAGファームウェアはバイナリ転送もサポートしています。バイナリ転送モードのときにデータをTAPに送信するには、送信するバイト数を示したバイトを最初に送信します。その後にデータを続ける必要があります。送信する各データについて、ファームウェアは2バイトを出力します。返送される1番目のバイトは、転送中に読み込まれたステータスビットです。2番目のバイトは、転送中にTAPから読み込まれた値を保持しています。バイナリモードの間に送信することのできる特殊なコマンドもあります。これらのコマンドは表4で説明しています。これらの特殊コマンドの1つを送信するには、長さを示すバイトとして0を送信します。これによって、受け取る次のバイトを特殊コマンドとして取り扱うようファームウェアに指示します。これらの特殊コマンドについては、1バイトが返送されます。通常、これは単なるコマンドのエコーです。
表4. バイナリ転送で使用される特殊コマンド
Command | Description |
0x00 | Exit binary mode transfers and return to accepting ASCII commands. |
0x01 | Set the TAP's IR register as the destination for data transfers. |
0x02 | Set the TAP's DR register as the destination for data transfers. |
0x03 | Send only the lowest 3 bits of each byte when transferring data. |
0x04 | Set the RESET pin to a logic high. |
0x05 | Clear the RESET pin to a logic low. |
0x06 | Execute a single pulse of the JTAG clock. |
0x07 | Read the state of the TDO pin. |
0x08 | Send all 8 bits of each byte when transferring data. |
0x09 | Set the TMS pin to a logic high. |
0x0A | Clear the TMS pin to a logic low. |
0x0B | Set the TDI pin to a logic high. |
0x0C | Clear the TDI pin to a logic low. |
0x0D | Set the T0M bit. For more information on this bit, refer to the 'V' command described in Table 1. |
0x0E | Clear the T0M bit. For more information on this bit, refer to the 'V' command described in Table 1. |
0x11 | Use the next byte received as the value for TL0. This "next" byte does not require a length byte or the '0' used as the special-command escape character. For more information of the TL0 register, refer to the 'V" command described in Table 1. |
0x12 | Use the next byte received as the value for TH0. This "next" byte does not require a length byte or the '0' used as the special command escape character. For more information of the TH0 register, refer to the 'V" command described in Table 1. |
エラーの検出
ASCII転送モードおよびバイナリ転送モードのどちらでも、発生するエラーはコマンドの出力によって示されます。ASCIIモードでは、エラーは「*ERR=xx*」として出力されます(ここでxxは発生したエラーのタイプを示します)。バイナリモードでは、コマンドエコーの代わりにエラーコードが出力されます。予想されるエラーコードの説明については、表5を参照してください。
表5. エラーコード
Error Code | Description |
0x80 | Command not recognized or invalid command. |
0x90 | Received an invalid hexadecimal character. |
0xA0 | Not enough input received. |
0xB0 | Bad breakpoint register index. |
0xC? | Received unexpected status, where ? represents the status bits received. |
結論
このアプリケーションノートで説明したコマンドを使用すれば、シリアル/JTAGボードを利用することによって、MAXQプロセッサへのコードのロード、システムレジスタの読み書き、メモリの読み書き、およびインサーキットデバッガの利用が可能となります。このプロセスは、ホストソフトウェアでバイナリプロトコルを使用して自動的に行うこともできれば、端末プログラムを用いて対話式に入力することもできます。ここでは、MAXQシステムを完全に制御するために必要なすべてのコマンドの構成要素を説明しました。