More Related Content Similar to JTAGを使ってみよう (20) More from Study Group by SciencePark Corp. (20) JTAGを使ってみよう2. • 名前:板垣 大地 (イタガキ ダイチ)
• サイエンスパーク株式会社 バグダス検証課に所属
• 約半年くらい前から、IoT機器のはんだ付け~
ファームウェア吸出し~解析をやらされる
自己紹介
4. 1.ターゲット
Raspberry pi zero WH
Processor:BCM2835
Architecture:ARM1176JZF-S Classic Processors Arm11
特徴
• Trust zone対応
• Wireless LAN対応
• Bluetooth対応
• 価格が安い:2000~3000円程度
• 消費電力が少なめ:約150mA
• ×MiniHDMI→ディスプレイを使わない場合OK
今回は、Raspbian-2020-02-14 busterをインストール済み
https://developer.arm.com/ip-products/processors/classic-processors
5. boot sequence中のピン設定
1. Power-on
2. Setting by the bootrom
3. Setting by bootcode.bin
4. Setting by dt-blob.bin
5. Setting by the GPIO command in config.txt
6. Additional firmware pins (e.g. UARTS)
7. Kernel/Device Tree
4と5に注目 Device Tree blob file は、2014/7/14 から対応
Changing the default pin configuration
https://www.raspberrypi.org/documentation/configuration/pin-configuration.md
2.ブートシーケンス
6. Dt-blob.bin
→ 設定ファイルのバイナリ
• 最近のraspberry Piのイメージには、含まれていません。
• /boot に配置
• Dt-blob.bin example code
https://github.com/raspberrypi/firmware/blob/master/extra/dt-blob.dts
• NOOBSは、パーティションの切り方がraspbianと異なるので注意
NOTE: In the case of NOOBS installs, the DTB file should be placed on the recovery partition
instead.
Changing the default pin configuration
https://www.raspberrypi.org/documentation/configuration/pin-configuration.md
3.dt-blob
7. dt-blob.dts → dt-blob.bin
sudo apt install device-tree-compiler
・Raspbian Buster では、インストール済み
ソースからバイナリへ変換
sudo dtc -I dts -O dtb -o /boot/dt-blob.bin dt-blob.dts
バイナリからソースへ変換
dtc -I dtb -O dts -o dt-blob.dts /boot/dt-blob.bin
Changing the default pin configuration
https://www.raspberrypi.org/documentation/configuration/pin-configuration.md
3.dt-blob
9. dt-blob.dts
前のページより続く
pin@p2 { function = "i2c1"; termination = "pull_up"; }; //
I2C 1 SDA
pin@p3 { function = "i2c1"; termination = "pull_up"; }; //
I2C 1 SCL
途中略
}; // pin_config
途中略
};
}; // pin_defines
}; // pins
};
};
2200行ぐらいあります。。。
3.dt-blob
11. 5.JTAG Pin
https://www.raspberrypi.org/documentation/usage/gpio/README.md
Pin #
ALT4
Function Rsp
40pin
ARM
JTAG20
- Vref 1 1
- GND 14 4
GPIO22 ARM_TRST 15 3
GPIO26 ARM_TDI 37 5
GPIO27 ARM_TMS 13 7
GPIO25 ARM_TCK 22 9
GPIO23 ARM_RTCK 16 11
GPIO24 ARM_TDO 18 13
https://www.segger.com/products/debug-probes/j-link/technology/interface-description/
Raspberry pi
GPIO40pin
コネクタ勘合面より
J-Link コネクタピ
ン
https://www.raspberrypi.org/documentation/configuration/config-txt/gpio.md
13. 7.ターゲットの検出
SEGGER J-Link Commander V6.60e (Compiled Jan 17 2020 17:26:41)
DLL version V6.60e, compiled Jan 17 2020 17:25:00
Connecting to J-Link via USB...O.K.
Firmware: J-Link V11 compiled Jan 7 2020 16:52:13
Hardware version: V11.00
S/N: XXXYYYZZZ
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref=3.341V
J-Link Commanderを実行後のJ-Link起動画面
14. 7.ターゲットの検出
Type "connect" to establish a target connection, '?' for help
J-Link>connect
Please specify device / core. <Default>: ARM11
Type '?' for selection dialog
Device>
Please specify target interface:
J) JTAG (Default)
TIF>
Device position in JTAG chain (IRPre,DRPre) <Default>: -1,-1 => Auto-
detect
JTAGConf>
Specify target interface speed [kHz]. <Default>: 4000 kHz
Speed>
Device "ARM11" selected.
J-Link設定
15. 7.ターゲットの検出
Connecting to target via JTAG
TotalIRLen = 5, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x07B7617F, IRLen: 05, ARM1176 Core
ARM11 identified.
J-Link>
J-Link CPUの認識
ARM1176 Coreが認識された。
Editor's Notes 1. ターゲットは、JTAG接続を試みるボード、CPUについて説明します。
2.ブートシーケンスでは、ピン設定の流れを説明します。
3.Dt-blob : Device Tree,
4.Config.txt で、JTAGピンの設定について説明をします。
5.JTAG PINで、ハードウェア上のピン設定について説明します。
6.J-Linkの接続で、JTAGプローブ J-Linkの接続の様子を写真を紹介いたします。
7.ターゲットの検出で、実際に接続した状態を示します。 今回は、Raspberry Pi Zero をターゲットにしました。
W:無線あり H:ヘッダーあり
・ヘッダーがあると、ヘッダーがケースに干渉して、カメラ用のケースに入りません。
・miniHDMIのケースの厚みで、コネクタによっては注意が必要です。
・消費電流が少なく、組み込み向け
・ARMv6 アーキテクチャだけど、Trust Zone(セキュリティ機能)対応しています。
・Wifi、Bluetoothが使える。
・VNC も動きます。。
・デスクトップも使える。
・ブラウザは、重たいです。
2.botrom.bin ブートローダ読み込み
3.bootcode.bin FATパーティションよりファームウェア読出し
4.dt-blob デバイスツリー読出し
5.config.tx GPIOなどの設定読出し
JTAGでは、4と5に注目 Dt-blob.bin デバイスツリー(設定ファイル)のバイナリ
サンプルは、Git hubよりダウンロード可。今回は未使用。
NOOBSは、複数OSを選んでインストールできるようになっているため、
パーテイションの切り方がraspbianと異なる。 ソース dts とバイナリ bin変換ができます。 参考までに、dt-blobの中を見てみると。。。
ピン設定情報の記述がほとんどです。
polarity = active_high, 極性 = active_high
termination = "pull_down", 終端=プルダウン
Startup_state = 起動時設定 = 無効
行数も多く、ピン設定がほとんどなので、実際にこのファイルを設定することは、あまりないと思われます。 Config.txtで、
・GPIOの設定
・グラフィックスの設定
・カメラの設定
・ブートの設定 等、多岐設定ができます。
また、デバイスツリーにパラメータを渡すことができます。
JTAGを使う場合、
enable_jtag_gpio=1の記述が必要です。
JTAGピンについて、モードが、ALT4の設定を参照します。
GPIOの番号と実際のピンの番号は一致していないです。 J-Link edu は、教育向けの使用のみで、商用開発には使用しないこと。
右下隅が、ケース入りのRaspberry PI Zero WHです。
・ARM1176JZF-S なので、ARM11 coreを選択
IRPre, DRPre
IRPre : TDI側から数えた、Instruction Resistorの全長。 ARM11では、5bit
DRPre: TDI側から数えた、デバイスの数
Pre TDI側から、Post TDO側より。。。
JTAGポートに複数のデバイス(コア)が繋がっていると、細かく設定する必要あり。
今回は、1デバイスのみ。 カーネルやデバイスツリーをリコンパイルする必要もなく、config.txtに、
オプション設定を1つ追加するだけで、JTAG接続できることがわかりました。
Raspberry Pi Zero と普通のRaspbianの組み合わせでのJTAG接続について、
Webに、あまり資料がなかったので、今回、ご紹介いたしました。