Difference between revisions of "Debugging"

From coreboot
Jump to navigation Jump to search
(6 intermediate revisions by 2 users not shown)
Line 4: Line 4:
  [*] GDB debugging support
  [*] GDB debugging support
  [*]  Wait for a GDB connection
  [*]  Wait for a GDB connection
Then Coreboot will stop and wait for a GDB connection.
Then Coreboot will stop and wait for a GDB connection in the beginning of the ramstage.

To connect to the remote coreboot instance  over serial do:
To connect to the remote coreboot instance  over serial do:
Line 25: Line 25:
  85 call hardwaremain
  85 call hardwaremain
=== usefull tricks ===
Note that [https://git.kernel.org/cgit/utils/kernel/kgdb/agent-proxy.git/ agent-proxy] is capable of multiplexing GBD and the serial console.
==== Howto ====
./agent-proxy 5550^5551 0 /dev/ttyUSB0,115200
telnet localhost 5550
$ gdb
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
(gdb) file ./build/cbfs/normal/coreboot_ram.debug
Reading symbols from /home/gnutoo/x86/coreboot-X60/build/cbfs/normal/coreboot_ram.debug...done.
(gdb) target remote localhost:5551
Remote debugging using localhost:5551
_text () at src/arch/x86/lib/c_start.S:89
89 call main
(gdb) b set_boot_successful
Breakpoint 1 at 0x10a7b3: file src/arch/x86/include/arch/io.h, line 63.
(gdb) c

== Exceptions with GDB ==
== Exceptions with GDB ==
Line 59: Line 87:
  #9  0x0010f8b5 in hardwaremain ()
  #9  0x0010f8b5 in hardwaremain ()
  #10 0x00100099 in _text ()
  #10 0x00100099 in _text ()
= Windows 7 USB =
This is documentation on how to setup Windows 7 on USB, so it can be used with a USB debug device and WinDbg to track down Windows errors that are otherwise hard to debug (eg. black screen, Stop codes, ACPI issues).
== Prepare Windows Media ==
=== Step 1: Get media ===
I used Windows 7 Ultimate 64bit English, ISO image has SHA1: 36AE90DEFBAD9D9539E649B193AE573B77A71C83
I also tried Windows 8 Consumer Preview 64bit English, ISO image has SHA1: 1288519C5035BCAC83CBFA23A33038CCF5522749
=== Step 2: Prepare disk ===
Use some sufficiently large USB media (4GB+), and format it as NTFS.
Windows 7 might work on FAT, but Windows 8 definitely wont, as the main file archive is >4GB, which even FAT32 doesn't like.
For reference, I called the volume WININST, but I doubt that matters.
=== Step 3: Copy the entire disk content to disk ===
I started out from an ISO image (as obtained from digitalriver), and extracted it using 7-zip to the media.
After that I had a directory that looks like this:
Datentrger in Laufwerk E: ist WININST
Volumeseriennummer: 86DF-6846
Verzeichnis von E:\
12.04.2011  11:38              122 autorun.inf
03.05.2012  18:54    <DIR>          boot
12.04.2011  11:38          383.786 bootmgr
12.04.2011  11:38          669.568 bootmgr.efi
03.05.2012  18:54    <DIR>          efi
12.04.2011  11:38          106.768 setup.exe
03.05.2012  18:56    <DIR>          sources
03.05.2012  18:56    <DIR>          support
03.05.2012  18:56    <DIR>          upgrade
              4 Datei(en),      1.160.244 Bytes
              5 Verzeichnis(se),  4.976.803.840 Bytes frei
=== Step 4: Install boot sector ===
For this, you need to run a Windows Console prompt as Administrator. Its not enough to run as the admin user, but you need to go through the run as administrator + UAC motions.
On Windows 7, the fastest way is to open the start menu, type cmd in the search field, wait for cmd to appear (with that black window + C:\ icon), right click it, and select run as administrator. On Windows 8, there's an Admin Command Line in the Win+X menu.
Move to the drive with the install data (E:\ in my case), enter boot\, and run bootsect like this:
E:\>cd boot
E:\boot>bootsect /nt60 e: /force /mbr
Target volumes will be updated with BOOTMGR compatible bootcode.
E: (\\?\Volume{39f55ea8-3ea1-11e1-afe7-005056c00008})
    Forced dismount complete, open handles to this volume are now invalid.
    Successfully updated NTFS filesystem bootcode.
    Successfully updated disk bootcode.
Bootcode was successfully updated on all targeted volumes.
=== Step 5: Prepare installer for USB debug device ===
In the same Console prompt (and same directory), run:
bcdedit /store bcd /dbgsettings usb targetname:TargetSystem
bcdedit /store bcd /set {default} debug yes
If you have access to the legacy serial port, you can use that to run a kernel debugger session without usb debug device (and its setup, which can be complicated in the presence of Rate Matching Hubs).
In such a setup, instead of the first command use
bcdedit /store bcd /dbgsettings serial debugport:1 baudrate:115200
=== Step 6: Install ===
Start your coreboot + seabios system, and make it boot from your USB device.
If everything is well, dance and jump with joy! If not, you have a chance to improve coreboot!
=== Step 7: Boot Windows ===
Once installation is done, boot the new system. Thats another source of trouble, since this is a slightly different Windows than the one driving the installer.
And there was no chance to setup debug mode for it yet! (TBD)
== Setup Debugging Environment ==
=== Configuring WinDbg ===
First, install WinDbg. You can find in the Debugging Utilities for Windows. Set up the symbol file path, so it can resolve the addresses it gets from the target:
* Create a directory somewhere (C:\Symbols is the default).
* Create an empty "index2.txt" in there.
* Start Windbg
* File, Symbol File Path
* Enter <code>"SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols"</code> (fill in your path instead of <code>C:\Symbols</code>)
With this configuration, WinDbg will fetch symbol files from the Microsoft server.
=== Start debug operation ===
Select the communication channel in File, Kernel Debug (USB 2.0 or serial).
For USB, fill in the name (TargetSystem in the example above), for serial, configure the port. Press OK.
WinDbg will wait for the target to break into the kernel debugger now. It might take a while on the first runs as it has to download the symbol files. Eventually it will print the error and location.

Latest revision as of 13:47, 2 November 2013