VM Application Debugging via JTAG: Android TRACE32 JTAG Debug Bridge ADB Architecture Stop-Mode implications for ADB JTAG Transport Outlook TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 1
VM Application Debugging with ADB Host Android Target Eclipse application debugging DVM DVM TCP/IP TCP/IP server daemon USB physical connection USB TCP/IP TCP/IP TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 2
Application Debugging (Run-Mode) Host Eclipse IDE ADT server TCP/IP or USB stack Android Target daemon TCP/IP or USB stack Virtual Machine Process Dalvik VM VM Debug Support Memory Model VM Control VM Interpreter VM Application Code + Objects VM Core Libraries Code + Objects TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 3
Architecture system/core//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 (d) [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 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. Currently, a single '' binary is used for both the server and client. [This] makes distribution and starting the server easier. [...] TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 4
Architecture system/core//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. [...] TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 5
Communication Architecture server _main daemon _main transport transport usb socket usb socket Different transport methods active at the same time: usb_init() local_init() Select transport at startup: IF property(service..tcp.port) listen at tcp:port IF access(/dev/android_) listen at USB gadget device DEFAULT listen at tcp:5037 TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 6
Case A: Using Sockets server _main daemon _main transport transport usb socket usb socket ETH TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 7
Case B: Using USB server _main daemon _main transport transport usb socket usb socket USB2.0 TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 8
VM Application Debugging via JTAG: Android TRACE32 JTAG Debug Bridge ADB Architecture Stop-Mode implications for ADB JTAG Transport Outlook TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 9
Application Debugging via TCP/IP Host Eclipse IDE ADT server TCP/IP Android Target daemon TCP/IP Virtual Machine Process Dalvik VM VM Debug Support Memory Model VM Control VM Interpreter VM Application Code + Objects VM Core Libraries Code + Objects TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 10
App Debug via TCP/IP (Run-Mode) + JTAG Debug (Stop-Mode) Host Android Target TRACE32 USB/ETH stop-mode debugging PowerDebug JTAG Eclipse server TCP/IP run-mode debugging TCP/IP d TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 11
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 but often an ADT reconnect is possible TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 12
Application Debugging via USB Host Eclipse IDE ADT server USB Android Target daemon USB Virtual Machine Process Dalvik VM VM Debug Support Memory Model VM Control VM Interpreter VM Application Code + Objects VM Core Libraries Code + Objects TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 13
App Debug via USB (Run-Mode) + JTAG Debug (Stop-Mode) Host Android Target TRACE32 USB/ETH stop-mode debugging PowerDebug JTAG Eclipse server USB run-mode debugging USB d TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 14
JTAG 'Stop' loss of USB communication Host Eclipse IDE ADT server USB Android Target daemon USB Virtual Machine Process Dalvik VM VM Debug Support Memory Model VM Control VM Interpreter VM Application Code + Objects VM Core Libraries Code + Objects USB comm loss on JTAG 'break' TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 15
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 USB Communication Breakdown TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 16
VM Application Debugging via JTAG: Android TRACE32 JTAG Debug Bridge ADB Architecture Stop-Mode implications for ADB JTAG Transport Outlook TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 17
Introduce Case C: Using JTAG server _main daemon _main transport transport usb socket??? usb socket??? JTAG Is this possible? TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 18
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/ Must be possible on Linux + Windows hosts Must work on SMP systems Use as working code reference TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 19
Communication Architecture server _main daemon _main transport transport usb socket pipe usb socket DCC On the host: TRACE32 FDX using JTAG (named pipe) transport On the target: TRACE32 FDX using JTAG (ARM DCC) transport TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 20
Introduce Case C: Using JTAG server _main daemon _main transport transport usb socket pipe usb socket DCC JTAG This is possible! TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 21
Communication Architecture New Version server daemon _main _main transport transport usb socket pipe usb socket DCC Different transport methods active at the same time: jtag_init() usb_init() local_init() IF property(service..jtag) > 0 listen at DCC register IF property(service..tcp.port) listen at tcp:port IF access(/dev/android_) listen at USB gadget device DEFAULT listen at tcp:5037 TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 22
Assisted Run-Mode Debugging via JTAG bridge Host Eclipse IDE ADT server TRACE32 JTAG bridge Android Target daemon TRACE32 JTAG bridge Virtual Machine Process Dalvik VM VM Debug Support Memory Model VM Control VM Interpreter VM Application Code + Objects VM Core Libraries Code + Objects TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 23
Application Debugging via TRACE32 JTAG Bridge Host Eclipse application debugging Android Target DVM DVM server FDX PIPE TCP/IP USB run-mode debugging daemon ARM DCC TRACE32 stop-mode debugging USB/ETH PowerDebug JTAG TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 24
TRACE32 JTAG Bridge Initial Implementation git patch for server (host) and d (target) adds JTAG transport to (Run-Mode), tested on FroYo TRACE32 FDX in ARM9 10 11 DCC4D mode for d data TRACE32 FDX in Named Pipe mode for server data tested on Linux + Windows hosts and on SMP target on/off switch for d JTAG bridge mode (setprop, d restart) not very fast, but only alternative if ETH or USB are not available working reference code + open source: customers and 3 rd parties can adapt the patch, e.g. for non-arm target platforms TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 25
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) Available Today! TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 26
VM Application Debugging via JTAG: Android TRACE32 JTAG Debug Bridge ADB Architecture Stop-Mode implications for ADB JTAG Transport Outlook TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 27
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 d transport channel easily runtime-switchable git-push code changes to Android and Linux Kernel repos to improve JTAG debugging + transport awareness profile TRACE32 FDX pipe connection, maybe add TCP/IP mode TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 28
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 d transport channel easily runtime-switchable git-push code changes to Android and Linux Kernel repos to improve JTAG debugging + transport awareness everyone can do this (Customer, 3 rd Party, You!) profile TRACE32 FDX pipe connection, maybe add TCP/IP mode only possible for Lauterbach TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 29
Thank You! Hagen Patzke hagen.patzke@lauterbach.com http://www.lauterbach.com/vmandroid.html TRACE32 JTAG Debug Bridge Hagen Patzke 2011-06-16 www.lauterbach.com 30