コグノスケ


link 未来から過去へ表示(*)  link 過去から未来へ表示

link もっと前
2022年2月1日 >>> 2022年1月23日
link もっと後

2022年1月29日

HiFive1のJTAG周りについて

目次: OpenOCD

HiFive1のJTAGを使う際はJ-Linkの設定(tcl/interface/jlink.cfg)を使えばOKです。しかしSEGGER J-LinkのJTAG箱が見当たらないのに、なぜこの設定で動くのか若干気になりました。調べたら納得だったのでメモしておきます。

回路図を見るとマイコンでUSB-JTAG変換を実現しています。USB端子はNXP MK22FN128VLH10(MK22FN128VLH10 Product Information - NXP)に接続されており、このICからJTAGの信号(TDIなど)が出ています。JTAGの信号線はSiFive FE310に接続されています。

なぜ突然NXPのマイコンICが出てくるのか?J-Linkはどこから来た??と思いきや、実はこれSEGGER J-LinkのオンチップJTAG、J-Link-OBというシリーズの1つで使われているマイコンです(参考: J-Link OB Debug Probe - SEGGER)。SEGGER J-Linkは専用のICがあるわけではなく、NXPやSTのマイコンで実現しているんですね、なるほど。

カタログ上はCortex-M/Cortex-A用となっていますが、これはSEGGER独自の機能が使えるか使えないかを表しているのでしょう。JTAGは4つの信号線(TMS, TCK, TDI, TDO)でJTAGのプロトコルを理解するデバイスが相手であれば良くて、CPUの種類は特に気にしないはず……。

編集者:すずき(2023/09/24 09:18)

コメント一覧

  • コメントはありません。
open/close この記事にコメントする



2022年1月28日

OpenOCD on Rapberry PiでJTAGデバッグ

目次: OpenOCD

SiFiveのHiFive1というボード(SiFiveのサイトへのリンク)をデバッグするときは、HiFive1のオンボードUSB-JTAGを使うことが多いと思います。

非常に便利ですがUSB接続ゆえに近くにPCが必要です。PCを作業机の横に置けば何の問題もないんですけど、我が家の場合は諸事情でちょっと困った配置になっています。

  • HiFive1は作業机の上(手の届く範囲)に置きたい
  • PCは隣の部屋(ファイルサーバーの近く、有線ネットワークが繋がる範囲)に置きたい

PCを作業机の横に持ってくる手も考えましたが、悪あがきとしてRaspberry Pi 3でOpenOCDを実行してサーバー代わりにしてみました。結果から言うと、思っていたよりうまく動いてくれました。嬉しい、Raspberry Pi偉い。

各機器の接続

各機器の接続関係はこんな感じです。各ソフトに改造は不要です。GDBのTCP経由でデバッグできる機能と、OpenOCDのGDB serverとして振る舞う機能の合わせ技で実現できます。

PC, HiFive1, Raspberry Piの接続
(通常)
PCのGDB <-(TCP local接続)-> PCのOpenOCD <-(USB)-> HiFive1

(今回)
PCのGDB <-(TCP接続)-> Raspberry Pi 3のOpenOCD <-(USB)-> HiFive1

こんな変な使い方まで想定内とは驚きです。GDBもOpenOCDも良くできています。

Raspberry Pi 3側のログ(OpenOCD)

Raspberry Pi 3ではOpenOCDを実行します。

OpenOCDログの一例
$ ./src/openocd -c 'bindto 0.0.0.0' -f tcl/interface/jlink.cfg -f ./tcl/board/sifive-hifive1-revb.cfg

Open On-Chip Debugger 0.11.0+dev-00551-gaad871805 (2022-01-16-22:30)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Interface already configured, ignoring
Info : J-Link OB-K22-SiFive compiled Nov 22 2019 12:57:38
Info : Hardware version: 1.00
Info : VTarget = 3.300 V
Info : clock speed 4000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
Info : datacount=1 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40101105
Info : starting gdb server for riscv.cpu.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : Found flash device 'issi is25lp032' (ID 0x0016609d)
Ready for Remote Connections
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections


Info : JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1606 ms). Workaround: increase "set remotetimeout" in GDB
Info : JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1523 ms). Workaround: increase "set remotetimeout" in GDB
Info : JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1599 ms). Workaround: increase "set remotetimeout" in GDB
Info : JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1610 ms). Workaround: increase "set remotetimeout" in GDB
Warn : Error writing to GDB socket. Dropping the connection.
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
Info : JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1614 ms). Workaround: increase "set remotetimeout" in GDB

PC側からmonitor resetを実行すると「1,000ms以内に返事が来ない!タイムアウトしたぞ!」というWarningログが頻発します。HiFive1の反応が遅いのか、Raspberry Pi 3の判断が遅いのか、どちらかよくわかりません。両方かな……?

PC側のログ(GDB)

PCではGDBを実行します。例ではZephyrのバイナリを送っていますが、Zephyr以外でも手順は同じです。

GDBログの一例
$ riscv64-zephyr-elf-gdb build/zephyr/zephyr.elf

GNU gdb (crosstool-NG 1.24.0.378_e011758) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=riscv64-zephyr-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build/zephyr/zephyr.elf...

(gdb) target remote 192.168.1.106:3333
Remote debugging using 192.168.1.106:3333
0x00001004 in ?? ()

(gdb) monitor reset halt
JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1615 ms). Workaround: increase "set remotetimeout" in GDB

GDBもタイムアウトがどうのこうのと怒っています。特に異常動作はしないので放っておいても良いですけど、邪魔であればメッセージのおススメ通りにset remotetimeoutの値を伸ばすと良いでしょう。

Raspberry Pi 3の変なエラー

基本的には以上です動きました良かったね!で終わりなんですけど、Raspberry Pi 3のdmesgを見ていたら見慣れないエラーが出ていたのでメモしておきます。

Under-voltageエラー
[  253.885123] usb 1-1.5: new full-speed USB device number 6 using dwc_otg
[  254.021413] usb 1-1.5: New USB device found, idVendor=1366, idProduct=1051, bcdDevice= 1.00
[  254.021440] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  254.021475] usb 1-1.5: Product: J-Link
[  254.021490] usb 1-1.5: Manufacturer: SEGGER
[  254.021505] usb 1-1.5: SerialNumber: 000979016829
[  254.023795] cdc_acm 1-1.5:1.0: ttyACM0: USB ACM device
[  254.027758] cdc_acm 1-1.5:1.2: ttyACM1: USB ACM device
[  254.031278] usb-storage 1-1.5:1.5: USB Mass Storage device detected
[  254.032081] scsi host0: usb-storage 1-1.5:1.5
[  254.875197] Under-voltage detected! (0x00050005)    ★★★★これと★★★★
[  255.037642] scsi 0:0:0:0: Direct-Access     SEGGER   MSD Volume       1.00 PQ: 0 ANSI: 4
[  255.038948] sd 0:0:0:0: Attached scsi generic sg0 type 0
[  255.043115] sd 0:0:0:0: [sda] 21829 512-byte logical blocks: (11.2 MB/10.7 MiB)
[  255.052887] sd 0:0:0:0: [sda] Write Protect is off
[  255.052914] sd 0:0:0:0: [sda] Mode Sense: 0b 00 00 08
[  255.055179] sd 0:0:0:0: [sda] No Caching mode page found
[  255.055202] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  255.148361]  sda:
[  255.166356] sd 0:0:0:0: [sda] Attached SCSI removable disk
[  259.035120] Voltage normalised (0x00000000)    ★★★★これ★★★★

このエラーはRaspberry Pi 3とHiFive1のUSB端子を接続したときに出現します(私の環境だと接続のたびに必ず発生)。電力供給ラインであるUSBのVBus端子電圧が下がっているという意味ですかねえ……?可能性としてはHiFive1が起動時だけ一気に大電力を消費することが考えられますが、深追いしておらず真相はわかりません。

編集者:すずき(2023/09/24 09:18)

コメント一覧

  • コメントはありません。
open/close この記事にコメントする



link もっと前
2022年2月1日 >>> 2022年1月23日
link もっと後

管理用メニュー

link 記事を新規作成

<2022>
<<<02>>>
--12345
6789101112
13141516171819
20212223242526
2728-----

最近のコメント5件

  • link 24年4月22日
    hdkさん (04/24 08:36)
    「うちのHHFZ4310は15年突破しまし...」
  • link 24年4月22日
    すずきさん (04/24 00:37)
    「ちゃんと数えてないですけど蛍光管が10年...」
  • link 24年4月22日
    hdkさん (04/23 20:52)
    「おお... うちのHHFZ4310より後...」
  • link 20年6月19日
    すずきさん (04/06 22:54)
    「ディレクトリを予め作成しておけば良いです...」
  • link 20年6月19日
    斎藤さん (04/06 16:25)
    「「Preferencesというメニューか...」

最近の記事3件

  • link 24年2月7日
    すずき (04/24 02:52)
    「[複数の音声ファイルのラウドネスを統一したい] PCやデジタル音楽プレーヤーで音楽を聞いていると、曲によって音量の大小が激しく...」
  • link 24年4月22日
    すずき (04/23 20:13)
    「[仕事部屋の照明が壊れた] いきなり仕事部屋のシーリングライトが消えました。蛍光管の寿命にしては去年(2022年10月19日の...」
  • link 24年4月17日
    すずき (04/18 22:44)
    「[VSCodeとMarkdownとPlantUMLのローカルサーバー] 目次: LinuxVSCodeのPlantUML Ex...」
link もっとみる

こんてんつ

open/close wiki
open/close Linux JM
open/close Java API

過去の日記

open/close 2002年
open/close 2003年
open/close 2004年
open/close 2005年
open/close 2006年
open/close 2007年
open/close 2008年
open/close 2009年
open/close 2010年
open/close 2011年
open/close 2012年
open/close 2013年
open/close 2014年
open/close 2015年
open/close 2016年
open/close 2017年
open/close 2018年
open/close 2019年
open/close 2020年
open/close 2021年
open/close 2022年
open/close 2023年
open/close 2024年
open/close 過去日記について

その他の情報

open/close アクセス統計
open/close サーバ一覧
open/close サイトの情報

合計:  counter total
本日:  counter today

link About www.katsuster.net
RDFファイル RSS 1.0

最終更新: 04/24 08:36