Skip to content

Instantly share code, notes, and snippets.

@tnishinaga
Created July 12, 2017 19:21
Show Gist options
  • Save tnishinaga/25c8cd2e48f5ad86ebac9bf7083cd9ba to your computer and use it in GitHub Desktop.
Save tnishinaga/25c8cd2e48f5ad86ebac9bf7083cd9ba to your computer and use it in GitHub Desktop.
Olimex-ARM-JTAG-TINY-Hを使ったデバッグが動かない問題

問題

Olimex-ARM-JTAG-TINY-H + OpenOCD(0.10.0-dev-00251-g888d5a50.10.0-dev-00251-g888d5a5)の組み合わせでgdbからloadが行えない。

問題のログ

gdb load error

(gdb) load
Loading section .text, size 0x14b8 lma 0x8000
Loading section .text.startup, size 0x48 lma 0x94b8
Load failed

OpenOCD error output

$ sudo openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f raspi.cfg                                                          
Open On-Chip Debugger 0.10.0-dev-00251-g888d5a5 (2016-05-04-20:32)            
Licensed under GNU GPL v2              
For bug reports, read                  
        http://openocd.org/doc/doxygen/bugs.html                              
adapter speed: 1000 kHz                
none separate                          
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.                                              
raspi.arm                              
Info : clock speed 1000 kHz            
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf (Broadcom), part: 0x7b76, ver: 0x0)                                                      
Info : found ARM1176                   
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints                   
Info : accepting 'gdb' connection on tcp/3333                                 
Error: 931 words out of 1326 not transferred                                  
Error: 11 words out of 18 not transferred  

うまくいくパターン

使うconfigを変えて、

sudo openocd -f interface/olimex-arm-usb-tiny-h.cfg -f raspi.cfg

にするとうまく行く

成功ログ

gdb load

(gdb) load
Loading section .text, size 0x14b8 lma 0x8000
Loading section .text.startup, size 0x48 lma 0x94b8
Loading section .rodata, size 0x73 lma 0x9500
Loading section .data, size 0x2c lma 0x9574
Start address 0x8000, load size 5535
Transfer rate: 28 KB/sec, 1383 bytes/write.

OpenOCD

$ sudo openocd -f interface/olimex-arm-usb-tiny-h.cfg -f raspi.cfg                                                               
Open On-Chip Debugger 0.10.0-dev-00251-g888d5a5 (2016-05-04-20:32)            
Licensed under GNU GPL v2              
For bug reports, read                  
        http://openocd.org/doc/doxygen/bugs.html                              
Info : only one transport option; autoselect 'jtag'                           
adapter speed: 1000 kHz                
none separate                          
raspi.arm                              
Warn : Using DEPRECATED interface driver 'ft2232'                             
Info : Consider using the 'ftdi' interface driver, with configuration files in interface/ftdi/...                                                            
Info : max TCK change to: 30000 kHz    
Info : clock speed 1000 kHz            
Info : JTAG tap: raspi.arm tap/device found: 0x07b7617f (mfg: 0x0bf (Broadcom), part: 0x7b76, ver: 0x0)                                                      
Info : found ARM1176                   
Info : raspi.arm: hardware has 6 breakpoints, 2 watchpoints                   
Info : accepting 'gdb' connection on tcp/3333

成功/失敗時の差異

成功時はOpenOCDのログに以下が出ている。

Warn : Using DEPRECATED interface driver 'ft2232'
Info : Consider using the 'ftdi' interface driver, with configuration files in interface/ftdi/...

使っているスクリプトは同じものと思っていたが、差異があるのではと考えdiffをとった

olimex-arm-usb-tiny-h.cfg と ftdi/olimex-arm-usb-tiny-h.cfg のdiff

[tnishinaga@tx201 interface]$ pwd
/usr/share/openocd/scripts/interface

[tnishinaga@tx201 interface]$ diff -u olimex-arm-usb-tiny-h.cfg ftdi/olimex-arm-usb-tiny-h.cfg 
--- olimex-arm-usb-tiny-h.cfg   2016-05-04 20:32:43.000000000 +0900
+++ ftdi/olimex-arm-usb-tiny-h.cfg      2016-05-04 20:32:43.000000000 +0900
@@ -4,8 +4,11 @@
 # http://www.olimex.com/dev/arm-usb-tiny-h.html
 #
 
-interface ft2232
-ft2232_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
-ft2232_layout olimex-jtag
-ft2232_vid_pid 0x15ba 0x002a
+interface ftdi
+ftdi_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
+ftdi_vid_pid 0x15ba 0x002a
 
+ftdi_layout_init 0x0808 0x0a1b
+ftdi_layout_signal nSRST -oe 0x0200
+ftdi_layout_signal nTRST -data 0x0100 -oe 0x0100
+ftdi_layout_signal LED -data 0x0800

使っているdriverが違うっぽい。 ftdi/olimex-arm-usb-tiny-h.cfg のほうが推奨のようだが、うまく動かないのは厳しい。

解決策

調査中。

--- olimex-arm-usb-tiny-h.cfg 2016-05-04 20:32:43.000000000 +0900
+++ ftdi/olimex-arm-usb-tiny-h.cfg 2016-05-04 20:32:43.000000000 +0900
@@ -4,8 +4,11 @@
# http://www.olimex.com/dev/arm-usb-tiny-h.html
#
-interface ft2232
-ft2232_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
-ft2232_layout olimex-jtag
-ft2232_vid_pid 0x15ba 0x002a
+interface ftdi
+ftdi_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
+ftdi_vid_pid 0x15ba 0x002a
+ftdi_layout_init 0x0808 0x0a1b
+ftdi_layout_signal nSRST -oe 0x0200
+ftdi_layout_signal nTRST -data 0x0100 -oe 0x0100
+ftdi_layout_signal LED -data 0x0800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment