TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 1
VM Application Debugging via JTAG:
Android TRACE32 JTAG Debug Bridge
ADB Architecture
Stop-Mode implications for ADB
JTAG Transport
Android Target
Android Target
Host
Host
adb
adb
daemon
daemon
adb
adb
server
server
application debugging
Eclipse
TCP/IP
TCP/IP
DVM
DVM
USB
USB
USB
USB
TCP/IP
TCP/IP
adb
physical connection
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 3
Android Debug Bridge
Application Debugging (Run-Mode)
Android
Android
Target
Target
Virtual Machine Process
VM Core Libraries
VM Core Libraries
Code + Objects
Code + Objects
Dalvik VM
Dalvik VM
VM Application
VM Application
Code + Objects
Code + Objects
Memory
Model
VM
Interpreter
VM
Control
adb
adb
daemon
daemon
TCP/IP
TCP/IP
or USB
or USB
stack
stack
VM Debug
Support
Host
Host
Eclipse IDE
ADT
adb
adb
server
server
TCP/IP
TCP/IP
or USB
or USB
stack
stack
Architecture
system/core/adb/OVERVIEW.TXT
[...] As a whole, everything works through the following components:
1.
The ADB server [...] runs on the host [and] is really one giant
multiplexing loop whose purpose is to orchestrate the exchange
of data (packets, really) between clients, services and devices.
2.
The ADB daemon (adbd) [runs on a] device or emulated system [and
connects] to the ADB server (through USB for devices, through TCP for
emulators) and provide[s] a few services for clients that run on the host.
3.
The ADB command-line client [...] is used to run adb commands from a
shell or a script. It first tries to locate the ADB server on the host
machine, and will start one automatically if none is found.
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 5
Android Debug Bridge
Architecture
system/core/adb/protocol.txt
--- a replacement for aproto
---When it comes down to it, aproto's primary purpose is to forward various
streams between the host computer and client device (in either direction).
This replacement further simplifies [this concept].
The host side becomes a simple comms bridge with no "UI", which will be
used by either commandline or interactive tools to communicate with a
device or emulator that is connected to the bridge.
The protocol is designed to be straightforward and well-defined [...].
The protocol discards the layering aproto has and should allow the
implementation to be much more robust. [...]
Communication Architecture
adb server
adb server
adb_main
adb_main
transport
transport
usb
usb
socket
socket
adb daemon
adb daemon
adb_main
adb_main
transport
transport
usb
usb
socket
socket
Different transport methods
active at the same time:
► usb_init()
► local_init()
Select transport at startup:
IF
property(service.adb.tcp.port)
► listen at tcp:
port
■
IF
access(/dev/android_adb)
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 7
Android Debug Bridge
Case A: Using Sockets
adb server
adb server
adb_main
adb_main
transport
transport
usb
usb
socket
socket
adb daemon
adb daemon
adb_main
adb_main
transport
transport
usb
usb
socket
socket
Case B: Using USB
adb server
adb server
adb_main
adb_main
transport
transport
usb
usb
socket
socket
adb daemon
adb daemon
adb_main
adb_main
transport
transport
usb
usb
socket
socket
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 9
VM Application Debugging via JTAG:
Android TRACE32 JTAG Debug Bridge
ADB Architecture
Stop-Mode implications for ADB
JTAG Transport
Application Debugging via TCP/IP
Android
Android
Target
Target
Virtual Machine Process
VM Core Libraries
VM Core Libraries
Code + Objects
Code + Objects
Dalvik VM
Dalvik VM
VM Application
VM Application
Code + Objects
Code + Objects
Memory
Model
VM
Interpreter
VM
Control
adb
adb
daemon
daemon
TCP/IP
TCP/IP
VM Debug
Support
Host
Host
Eclipse IDE
ADT
adb
adb
server
server
TCP/IP
TCP/IP
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 11
Android Debug Bridge
App Debug via TCP/IP (Run-Mode) + JTAG Debug (Stop-Mode)
Android Target
Android Target
TCP/IP
TCP/IP
Host
Host
TCP/IP
TCP/IP
adbd
adbd
adb
adb
server
server
JTAG
JTAG
USB/ETH
USB/ETH
PowerDebug
Eclipse
TRACE32
stop-mode debugging
Stop-Mode Implications for TCP/IP
IP was designed for robustness
Host does not detect device presence
Communication can be resumed
Eclipse can time out
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 13
Android Debug Bridge
Application Debugging via USB
Android
Android
Target
Target
Virtual Machine Process
VM Core Libraries
VM Core Libraries
Code + Objects
Code + Objects
Dalvik VM
Dalvik VM
VM Application
VM Application
Code + Objects
Code + Objects
Memory
Model
VM
Interpreter
VM
Control
adb
adb
daemon
daemon
USB
USB
VM Debug
Support
Host
Host
Eclipse IDE
ADT
adb
adb
server
server
USB
USB
App Debug via USB (Run-Mode) + JTAG Debug (Stop-Mode)
Android Target
Android Target
Host
Host
adb
adb
JTAG
JTAG
USB/ETH
USB/ETH
PowerDebug
Eclipse
TRACE32
stop-mode debugging
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 15
Android Debug Bridge
JTAG 'Stop' ►►► loss of USB communication
Android
Android
Target
Target
Virtual Machine Process
VM Core Libraries
VM Core Libraries
Code + Objects
Code + Objects
Dalvik VM
Dalvik VM
VM Application
VM Application
Code + Objects
Code + Objects
Memory
Model
VM
Interpreter
VM
Control
adb
adb
daemon
daemon
USB
USB
VM Debug
Support
Host
Host
Eclipse IDE
ADT
adb
adb
server
server
USB
USB
USB comm loss
on JTAG 'break'
Stop-Mode Implications for USB
Host periodically polls USB devices
Host detects device presence
ADB 'kicks' disconnected devices
Host reconnect possible only with USB plug-in event
No on-the-fly device reconnect mechanism provided
Multiple reconnects per second can be dangerous
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 17
VM Application Debugging via JTAG:
Android TRACE32 JTAG Debug Bridge
ADB Architecture
Stop-Mode implications for ADB
JTAG Transport
Introduce Case C: Using JTAG
adb server
adb server
adb_main
adb_main
transport
transport
usb
usb
socket
socket
???
???
adb daemon
adb daemon
adb_main
adb_main
transport
transport
usb
usb
socket
socket
???
???
JTAG
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 19
Android Debug Bridge
“TRACE32 JTAG Bridge” Ideas:
ARM9|10|11 has “Debug Communication Channel” - a DCC
register (pair) that debugger can r/w via JTAG
TRACE32 “Fast Data eXchange” (FDX) can use DCC
TRACE32 FDX client can send/receive data
via “TRACE32 RemoteAPI” or via “named pipes”
Try to keep changes limited to system/core/adb
Must be possible on Linux + Windows hosts
Must work on SMP systems
Communication Architecture
adb server
adb server
adb_main
adb_main
transport
transport
usb
usb
socket
socket
pipe
pipe
adb daemon
adb daemon
adb_main
adb_main
transport
transport
usb
usb
socket
socket
DCC
DCC
On the host:
TRACE32 FDX using
JTAG (named pipe) transport
On the target:
TRACE32 FDX using
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 21
Android Debug Bridge
Introduce Case C: Using JTAG
adb server
adb server
adb_main
adb_main
transport
transport
usb
usb
socket
socket
pipe
pipe
adb daemon
adb daemon
adb_main
adb_main
transport
transport
usb
usb
socket
socket
DCC
DCC
JTAG
Communication Architecture – New Version
adb server
adb server
adb_main
adb_main
transport
transport
usb
usb
socket
socket
pipe
pipe
adb daemon
adb daemon
adb_main
adb_main
transport
transport
usb
usb
socket
socket
DCC
DCC
Different transport methods
active at the same time:
► jtag_init()
► usb_init()
► local_init()
IF
property(service.adb.jtag) > 0
► listen at DCC register ■
IF
property(service.adb.tcp.port)
► listen at tcp:
port
■
IF
access(/dev/android_adb)
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 23
Android Debug Bridge
Assisted Run-Mode Debugging via JTAG bridge
Android
Android
Target
Target
Virtual Machine Process
VM Core Libraries
VM Core Libraries
Code + Objects
Code + Objects
Dalvik VM
Dalvik VM
VM Application
VM Application
Code + Objects
Code + Objects
Memory
Model
VM
Interpreter
VM
Control
adb
adb
daemon
daemon
TRACE32
TRACE32
JTAG
JTAG
bridge
bridge
VM Debug
Support
Host
Host
Eclipse IDE
ADT
adb
adb
server
server
TRACE32
TRACE32
JTAG
JTAG
bridge
bridge
Application Debugging via TRACE32 JTAG Bridge
Android Target
Android Target
Host
Host
FDX
FDX
TRACE32
T
C
P
/IP
T
C
P
/IP
adb
adb
daemon
daemon
adb
adb
server
server
application debugging
Eclipse
DVM
DVM
ARM
ARM
DCC
DCC
U
S
B
U
S
B
adb
P
IP
E
P
IP
E
application debugging
run-mode debugging
stop-mode debugging
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 25
Android Debug Bridge
TRACE32 JTAG Bridge – Initial Implementation
git patch for adb server (host) and adbd (target)
adds JTAG “transport” to adb (Run-Mode), tested on FroYo
TRACE32 FDX in ARM9|10|11 DCC4D mode for adbd data
TRACE32 FDX in “Named Pipe” mode for adb server data
tested on Linux + Windows hosts and on SMP target
on/off switch for adbd JTAG bridge mode (setprop, adbd restart)
not very fast, but only alternative if ETH or USB are not available
working reference code + open source: customers and 3
rd
parties
TRACE32 JTAG Bridge Patch – Timeline
2011-04-08 – initial Linux version (tested on MEP6410)
2011-05-24 – reworked pipe system to support Windows
2011-06-10 – SMP support (tested on PandaBoard)
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 27
VM Application Debugging via JTAG:
Android TRACE32 JTAG Debug Bridge
ADB Architecture
Stop-Mode implications for ADB
JTAG Transport
TRACE32 JTAG Bridge – What Can Be Done?
introduce Linux Kernel “JTAG Communication Device”
encapsulate target-specific communciation code,
different platforms expose the same JTAG interface
could provide multiple JTAG communication channels
for Terminal, System Trace, ADB and Customer Use
test on more target platforms
make adbd transport channel easily runtime-switchable
git-push code changes to Android and Linux Kernel repos
to improve JTAG debugging + transport awareness
TRACE32 JTAG Debug Bridge ▪ Hagen Patzke ▪ 2011-06-16 www.lauterbach.com ▪ 29
Android Debug Bridge
TRACE32 JTAG Bridge – Who Can Do It?
introduce Linux Kernel “JTAG Communication Device”
encapsulate target-specific communciation code,
different platforms expose the same JTAG interface
could provide multiple JTAG communication channels
for Terminal, System Trace, ADB and Customer Use
test on more target platforms
make adbd transport channel easily runtime-switchable
git-push code changes to Android and Linux Kernel repos
to improve JTAG debugging + transport awareness