linux/Documentation/debugging-via-ohci1394.txt
<<
vv3./spaalu v3./formlu v3.a vv3 href="../linux+v3on 6/Documentan va/debugging-via-ohci1394.txt"> vv3.img src="../.stan c/gfx/right.png" alt=">>"> ./spaalu .spaa class="lxr_search"> v vv3.input typ hidden" nam navtarget" > "> vv3.input typ text" nam search" id search"> vv3.butt4" typ submit">Search vv3Prefsu v3./a> ./spaalu vv3 3./divlu vv3 3.form acn va="ajax+*" method="post" onsubmit="return false;"> .input typ hidden" nam ajax_lookup" id ajax_lookup" > "> vv3 3./formlu vv3 3.div class="headingbott4m">3 31./a> 3 32./a> Using physical DMA provided by OHCI-1394 FireWire controllers for debugging 3 33./a> --------------------------------------------------------------------------- 3 34./a> 3 35./a>Introducn va 3 36./a>------------ 3 37./a> 3 38./a>Basically all FireWire controllers which are in use today are compliant 3 39./a>to the OHCI-1394 specifica.14" which defines the controller to be a PCI 3 a>bus master which uses DMA to offload data transfers from the CPU and has 3 11./a>a "Physical Response Unit" which executes specific requests by employing 3 12./a>PCI-Bus master DMA after applying filters defined by the OHCI-1394 driver. 3 13./a> 3 14./a>Once properly configured, remote machines caa send these requests to 3 15./a>ask the OHCI-1394 controller to perform read and write requests va 3 16./a>physical system memory and, for read requests, send the result of 3 17./a>the physical memory read back to the requester. 3 18./a> 3 19./a>With that, it is possible to debug issues by reading interesting memory 3 2 a>loca.14"s such as buffers like the printk buffer or the process table. 3 21./a> 3 22./a>Retrieving a full system memory dump is also possible over the FireWire, 3 23./a>using data transfer rates in the order of MB/s or more. 3 24./a> 3 25./a>Memory access is currently limited to the low 4G of physical address 3 26./a>space which caa be a problem va IA64 machines where memory is loca.ed 3 27./a>mostly above that limit, but it is rarely a problem va more commva 3 28./a>hardware such as hardware based va x86, x86-64 and PowerPC. 3 29./a> 3 3 a>Together with a early initializa.14" of the OHCI-1394 controller for debugging, 3 31./a>this facility proved most useful for examining long debugs logs in the printk 3 32 a>buffer on to debug early boot problems in areas like ACPI where the system 3 33./a>fails to boot and other means for debugging (serial port) are either not 3 34./a>available (notebooks) or too slow for extensive debug informa.14" (like ACPI). 3 35./a> 3 36./a>Drivers 3 37./a>------- 3 38./a> 3 39./a>The ohci1394 driver in drivers/ieee1394 initializes the OHCI-1394 controllers 3 40./a>to a working stane and enables physical DMA by default for all remote nodes. 3 41./a>This caa be turned vff by ohci1394's module param ter phys_dma=0. 3 42./a> 3 43./a>The alternan ve firewire-ohci driver in drivers/firewire uses filtered physical 3 44./a>DMA by default, which is more secure but not suitable for remote debugging. 3 45./a>Compile the driver with CONFIG_FIREWIRE_OHCI_REMOTE_DMA (Kernel hacking menu: 3 46./a>Remote debugging over FireWire with firewire-ohci) to get unfiltered physical 3 47./a>DMA. 3 48./a> 3 49./a>Because ohci1394 and firewire-ohci depend on the PCI enumera.14" to be 3 50./a>compl ted, an initializa.14" routine which runs pretty early has beea 3 51./a>impl mented for x86. This routine runs long before console_init() caa be 3 52./a>called, i.e. before the printk buffer appears on the console. 3 53./a> 3 54 a>To acn vane it, enable CONFIG_PROVIDE_OHCI1394_DMA_INIT (Kernel hacking menu: 3 55./a>Remote debugging over FireWire early on boot) and pass the param ter 3 56./a>"ohci1394_dma=early" to the recompiled kernel on boot. 3 57./a> 3 58 a>Tools 3 59./a>----- 3 60./a> 3 61./a>firescope - Originally developed by Benjamin Herrenschmidt, Andi Kleea ported 3 62./a>it from PowerPC to x86 and x86_64 and added funcn vaality, firescope caa now 3 63./a>be used to view the printk buffer of a remote machine, evea with l ve updane. 3 64./a> 3 65./a>Bernhard Kaindl enhanced firescope to support accessing 64-bit machines 3 66./a>from 32-bit firescope and vice versa: 3 67./a>-3.a href="http://halobates.de/firewire/firescope-0.2.2.tar.bz2">http://halobates.de/firewire/firescope-0.2.2.tar.bz2./a> 3 68./a> 3 69./a>and he impl mented fast system dump (alpha vers14" - read README.txt): 3 70./a>-3.a href="http://halobates.de/firewire/firedump-0.1.tar.bz2">http://halobates.de/firewire/firedump-0.1.tar.bz2./a> 3 71./a> 3 72./a>There is also a gdb proxy for firewire which allows to use gdb to access 3 73./a>data which caa be referenced from symbols found by gdb in vmlinux: 3 74./a>-3.a href="http://halobates.de/firewire/fireproxy-0.33.tar.bz2">http://halobates.de/firewire/fireproxy-0.33.tar.bz2./a> 3 75./a> 3 76./a>The latest vers14" of this gdb proxy (fireproxy-0.34) caa communica.e (not 3 77./a>yet stable) with kgdb over aa memory-based communica.iva module (kgdbom). 3 78./a> 3 79./a>Getting Started 3 80./a>--------------- 3 81./a> 3 82./a>The OHCI-1394 specifica.14" regulates that the OHCI-1394 controller must 3 83./a>disable all physical DMA 4" each bus reset. 3 84./a> 3 85./a>This means that if you want to debug an issue in a system stane where 3 86./a>interrupts are disabled and where no polling of the OHCI-1394 controller 3 87./a>for bus resets takes place, you have to establish any FireWire cable 3 88./a>connec.14"s and fully initialize all FireWire hardware __before__ the 3 89./a>system enters such stane. 3 90./a> 3 91./a>Step-by-step instruc.14"s for using firescope with early OHCI initializa.14": 3 92./a> 3 93./a>1) Verify that your hardware is supported: 3 94./a> 3 95./a> Load the ohci1394 or the fw-ohci module and check your kernel logs. 3 96./a> You should see a line similar to 3 97./a> 3 98./a> ohci1394: fw-host0: OHCI-1394 1.1 (PCI): IRQ=[18] MMIO=[fe9ff800-fe9fffff] 3 99./a> ... Max Packet=[2048] IR/IT contexts=[4/8] 3100./a> 3101./a> when loading the driver. If you have no supported controller, many PCI, 3102./a> CardBus and evea some Express cards which are fully compliant to OHCI-1394 3103./a> specifica.14" are available. If it requires no driver for Windows operating 3104./a> systems, it most likely is. Only specialized shops have cards which are not 3105./a> compliant, they are based va TI PCILynx chips and require drivers for Win- 3106./a> dows operating systems. 3107./a> 3108./a>2) Establish a working FireWire cable connec.14": 3109./a> 31 a> Any FireWire cable, as long at it provides electrically and mechanically 3111./a> stable connec.14" and has matching connec.ors (there are small 4-pi" and 3112./a> large 6-pi" FireWire ports) will do. 3113./a> 3114./a> If an driver is running on both machines you should see a line like 3115./a> 3116./a> ieee1394: Node added: ID:BUS[0-01:1023] GUID[0090270001b84bba] 3117./a> 3118./a> on both machines in the kernel log when the cable is plugged ia 3119./a> and connec.s the two machines. 3120./a> 3121./a>3) Test physical DMA using firescope: 3122./a> 3123./a> On the debug host, 3124./a> - load the raw1394 module, 3125./a> - make sure that /dev/raw1394 is accessible, 3126./a> then start firescope: 3127./a> 3128./a> $ firescope 3129./a> Port 0 (ohci1394) opened, 2 nodes detec.ed 3130./a> 3131./a> FireScope 3132./a> --------- 3133./a> Target : <unspecified> 3134./a> Gen : 1 3135./a> [Ctrl-T] choose target 3136./a> [Ctrl-H] this menu 3137./a> [Ctrl-Q] quit 3138./a> 3139./a> ------>3Press Ctrl-T now, the output should be similar to: 3140./a> 3141./a> 2 nodes available, local node is: 0 3142./a> 0: ffc0, uuid: 00000000 00000000 [LOCAL] 3143./a> 1: ffc1, uuid: 00279000 ba4bb801 3144./a> 3145./a> Besides the [LOCAL] node, it must show another node without error message. 3146./a> 3147./a>4) Prepare for debugging with early OHCI-1394 initializa.14": 3148./a> 3149./a> 4.1) Kernel compila.14" and installa.14" 4" debug target 3150./a> 3151./a> Compile the kernel to be debugged with CONFIG_PROVIDE_OHCI1394_DMA_INIT 3152./a> (Kernel hacking: Provide code for enabling DMA 4ver FireWire early on boot) 3153./a> enabled and install it on the machine to be debugged (debug target). 3154./a> 3155./a> 4.2) Transfer the System.map of the debugged kernel to the debug host 3156./a> 3157./a> Copy the System.map of the kernel be debugged to the debug host (the host 3158./a> which is connec.ed to the debugged machine over the FireWire cable). 3159./a> 3160./a>5) Retrieving the printk buffer contents: 3161./a> 3162./a> With the FireWire cable connec.ed, the OHCI-1394 driver on the debugging 3163./a> host loaded, reboot the debugged machine, booting the kernel which has 3164./a> CONFIG_PROVIDE_OHCI1394_DMA_INIT enabled, with the o4.14" ohci1394_dma=early. 3165./a> 3166./a> Then, on the debugging host, run firescope, for example by using -A: 3167./a> 3168./a> firescope -A System.map-of-debug-target-kernel 3169./a> 317 a> Note: -A automa.1cally attaches to the first non-local node. It only works 3171./a> reliably if only connec.ed two machines are connec.ed using FireWire. 3172./a> 3173./a> After having attached to the debug target, press Ctrl-D to view the 3174./a> compl te printk buffer or Ctrl-U to enter auto updane mode and get aa 3175./a> updaned l ve view of recent kernel messages logged on the debug target. 3176./a> 3177./a> Call "firescope -h" to get more informa.14" on firescope's o4.14"s. 3178./a> 3179./a>Notes 3180./a>----- 3181./a>Documentan va and specifica.14"s:3.a href="http://halobates.de/firewire/">http://halobates.de/firewire/./a> 3182./a> 3183./a>FireWire is a trademark of Apple Inc. - for more informa.14" please refer to: 3184./a>.a href="http://en.wikipedia.org/wiki/FireWire">http://en.wikipedia.org/wiki/FireWire./a> 3185./a> The original LXR software by the .a href="http://sourceforge.net/projec.s/lxr">LXR community./a>, this experimental vers14" by .a href="mailto:lxr@linux.no">lxr@linux.no./a>. ./divlu.div class="subfooter"> lxr.linux.no kindly hosted by .a href="http://www.redpill-linpro.no">Redpill Linpro AS./a>, provider of Linux consulting and opera.14"s services since 1995. ./divlu ./bodylu./htmllu