0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ComcertoをOpenOCDで探ってみる

Last updated at Posted at 2019-11-16

JTAGのピンが探し当てられたので、オリジナルのLinuxの挙動をOpenOCDで調べてみることにしました。

OpenOCDは以前雪豹でビルドした0.10.0を使います。

JTAGはTRST以外の4本だけつなげば大丈夫です。

OpenOCDのソースを見たところ、なんとtcl/targetにc100.cfgというComcerto 100の設定がありました。レジスタのアドレスのマクロなど幾つかcfgファイルが用意されていました。

Comcerto 100と1000はCPUはarm1136J-S r1p5で同じで、TIMERなど微妙に作り込みが変わっています。

100ファイルをちょっといじって1000で使えるようにしてみました。

c1000.cfg
# Comcerto 1000 config.
# This is ARM1136 dual core
# this script only configures one core (that is used to run Linux)

# assume no PLL lock, start slowly
adapter_khz 100

if { [info exists CHIPNAME] } {
   set _CHIPNAME $CHIPNAME
} else {
   set _CHIPNAME c1000
}

if { [info exists ENDIAN] } {
   set _ENDIAN $ENDIAN
} else {
   set _ENDIAN little
}

if { [info exists CPUTAPID] } {
   set _CPUTAPID $CPUTAPID
} else {
   set _CPUTAPID 0x7b3645b
}

if { [info exists DSPTAPID] } {
   set _DSPTAPID $DSPTAPID
} else {
   set _DSPTAPID 0x7b3645b
}

jtag newtap $_CHIPNAME dsp -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_DSPTAPID


# Per ARM: DDI0211J_arm1136_r1p5_trm.pdf - the ARM 1136 as a 5 bit IR register
jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_CPUTAPID

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm11 -endian $_ENDIAN -chain-position $_TARGETNAME

# C1000's ARAM 64k SRAM
$_TARGETNAME configure -work-area-phys 0x0a000000 -work-area-size 0x10000 -work-area-backup 0

これでOpenOCDを起動してみます。

$ ./openocd -f ft232h.cfg -f c1000.cfg 
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 100 kHz
adapter speed: 100 kHz
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
wdogc
Info : clock speed 100 kHz
Info : JTAG tap: c1000.dsp tap/device found: 0x07b3645b (mfg: 0x22d (Mindspeed), part: 0x7b36, ver: 0x0)
Info : JTAG tap: c1000.cpu tap/device found: 0x07b3645b (mfg: 0x22d (Mindspeed), part: 0x7b36, ver: 0x0)
Info : found ARM1136
Info : c1000.cpu: hardware has 6 breakpoints, 2 watchpoints

シリアルコンソールでオリジナルのLinuxを起動してtelnetでOpenOCDに入って適当なところでhaltしてみます。

ところがhaltしてしばらくするとリセットしてしまいます。

watchdogが効いてしまってるようです。

それではwatchdogを止めてみましょう。

> mww phys 0x100500D4 0

これで心置きなく確認ができます。:)

例えばGPIOのレジスタは以下のようにして確認できます。

> mdw phys 0x10070000 32
0x10070000: 18f680ac 10ff008d 00000004 00000001 3df66fae 00000040 00000000 8010120c 
0x10070020: 00000c00 00000000 00000000 00000000 00000000 00000004 00000000 00000000 
0x10070040: 8000120c 0000c000 00000002 00000000 01040170 2db6db6d 10fd80bf 00000000 
0x10070060: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

Comcerto 100はJTAGが2本(Core毎)出ていたようですが、1000では1本にまとめられたようです。

OpenOCDでアタッチした状態で、FreeBSDをあげるといきなりUndefined instructionで落ちます。どうもデバッグコードにVFP命令か何かが入ってしまってるようです。:(

Starting kernel ...

initarm: console initialized
 arg1 kmdp = 0xc03b2378
 boothowto = 0x00000000
 dtbp = 0xc0353ad0
 lastaddr1: 0x803e0000
loader passed (static) kenv:
 no env, null ptr
---<<BOOT>>---
ARM Debug Architecture v6
2 watchpoints and 6 breakpoints supported
panic: Undefined instruction in kernel.

time = 1
Uptime: 1s
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?