Difference between revisions of "EHCI Gadget Debug"

From coreboot
Jump to: navigation, search
(Tested hardware)
m (I had issues getting serial to work, but printk works fine.)
 
(5 intermediate revisions by 3 users not shown)
Line 3: Line 3:
  
 
== Howto ==
 
== Howto ==
 +
=== Patching ===
 +
Download the [[:File:Ehci-debug-gadget-patches.tar.gz|patches]] that maintain TTY connected while debug target power-cycles or when host controller is reset.
 +
 +
Apply the patches from one of the v3.8- or v3.10-debug-gadget directories on your kernel build tree.
 +
 
=== Compiling ===
 
=== Compiling ===
 
* You need to be familiar with (cross) compiling your kernel.
 
* You need to be familiar with (cross) compiling your kernel.
 +
Be sure to set CONFIG_LOCALVERSION.
 +
For example, on Fedora the output of 'uname -r' is 3.16.6-200.fc20.armv7hl, so to be able to load g_dbgp later on CONFIG_LOCALVERSION must be set to -200.fc20.armv7hl. You can extract this from a running system by using this shell command:
 +
uname -r | cut -d- -f 2-
 +
 
* (Cross) compile it as usual but during the configuration do the following:
 
* (Cross) compile it as usual but during the configuration do the following:
 +
 
Go into Device Drivers:
 
Go into Device Drivers:
 
  Device Drivers  --->
 
  Device Drivers  --->
Line 12: Line 22:
 
Then go into USB  Gadget Support:
 
Then go into USB  Gadget Support:
 
  <M>  USB Gadget Support  --->
 
  <M>  USB Gadget Support  --->
Then enable the following option:
+
Then enable the following option (CONFIG_USB_G_DBGP=m):
 
  <M>    EHCI Debug Device Gadget
 
  <M>    EHCI Debug Device Gadget
Then select the printk option for now(a bug has to be fixed to make serial option work properly):
+
 
         EHCI Debug Device mode (printk)  --->
+
Then select the serial option:
 +
         EHCI Debug Device mode (serial)  --->
 +
 
 +
(The 'printk' option will also work and may be easier to debug, but 'serial' is more convenient for grabbing logs)
 +
 
 +
Then run
 +
make M=drivers/usb/gadget
 +
which will take about 2,5 minutes when running a native compile on the beagleboneblack. As long as you use the distribution's kernel source code package there is no need to compile all the other modules and initramfs/uImage/uInitrd/vmlinuz.
 +
 
 
=== Loading ===
 
=== Loading ===
Remove all usb gadget drivers such as g_ehter or g_mass_storage with rmmod then do:
+
Remove all usb gadget drivers such as g_ether or g_mass_storage with rmmod or modprobe -r.
 +
Then move the distribution's dir
 +
/lib/modules/$(uname -r)/kernel/drivers/usb/gadget/
 +
to
 +
/lib/modules/$(uname -r)/kernel/drivers/usb/gadget.distribution
 +
and recreate
 +
/lib/modules/$(uname -r)/kernel/drivers/usb/gadget/
 +
 
 +
Copy over the modules:
 +
for f in $(find drivers/usb/gadget/ -name *.ko); do sudo cp $f /lib/modules/$(uname -r)/kernel/drivers/usb/gadget/ ; done
 +
 
 +
Finally, load g_dbgp:
 
  modprobe g_dbgp
 
  modprobe g_dbgp
 +
 +
=== Running ===
 +
I recommend to open the TTY before starting debug target. Doing it the other way
 +
around slows down the debug target boot and seems to confuse serial gadget framework.
 +
 +
You may want to disable some CR/LF translations on the device:
 +
stty -icrnl -inlcr -F /dev/ttyGS0
 +
 +
You can directly open the device node, possibly redirecting to file:
 +
cat /dev/ttyGS0
 +
.. or use a terminal client:
 +
picocom -ir /dev/ttyGS0
  
 
=== Finding the USB debug port ===
 
=== Finding the USB debug port ===
Line 38: Line 79:
 
| [https://github.com/buglabs/bug20-2.6.35-linaro/commits/master bug20-2.6.35-linaro's master (2.6.35) ]
 
| [https://github.com/buglabs/bug20-2.6.35-linaro/commits/master bug20-2.6.35-linaro's master (2.6.35) ]
 
| Lenovo X60
 
| Lenovo X60
 +
| {{yes}}
 +
|-
 +
! [http://www.8devices.com/carambola-2 Carambola 2 dev board (or any other AR9331 board where the location of the usb mode strap resistor is known)]
 +
| [https://dev.openwrt.org/wiki/GetSource OpenWRT git master (3.10.58) with chipidea ar9331 patch]
 +
| ASUS F2A85M-LE
 
| {{yes}}
 
| {{yes}}
 
|-
 
|-
 
|}
 
|}

Latest revision as of 20:42, 3 November 2014

Introduction

This page is about using embedded GNU/Linux devices in order to get the USB debug logs.

Howto

Patching

Download the patches that maintain TTY connected while debug target power-cycles or when host controller is reset.

Apply the patches from one of the v3.8- or v3.10-debug-gadget directories on your kernel build tree.

Compiling

  • You need to be familiar with (cross) compiling your kernel.

Be sure to set CONFIG_LOCALVERSION. For example, on Fedora the output of 'uname -r' is 3.16.6-200.fc20.armv7hl, so to be able to load g_dbgp later on CONFIG_LOCALVERSION must be set to -200.fc20.armv7hl. You can extract this from a running system by using this shell command:

uname -r | cut -d- -f 2-
  • (Cross) compile it as usual but during the configuration do the following:

Go into Device Drivers:

Device Drivers  --->

Then go into USB support:

[*] USB support  --->

Then go into USB Gadget Support:

<M>   USB Gadget Support  --->

Then enable the following option (CONFIG_USB_G_DBGP=m):

<M>     EHCI Debug Device Gadget

Then select the serial option:

        EHCI Debug Device mode (serial)  --->

(The 'printk' option will also work and may be easier to debug, but 'serial' is more convenient for grabbing logs)

Then run

make M=drivers/usb/gadget

which will take about 2,5 minutes when running a native compile on the beagleboneblack. As long as you use the distribution's kernel source code package there is no need to compile all the other modules and initramfs/uImage/uInitrd/vmlinuz.

Loading

Remove all usb gadget drivers such as g_ether or g_mass_storage with rmmod or modprobe -r. Then move the distribution's dir

/lib/modules/$(uname -r)/kernel/drivers/usb/gadget/

to

/lib/modules/$(uname -r)/kernel/drivers/usb/gadget.distribution

and recreate

/lib/modules/$(uname -r)/kernel/drivers/usb/gadget/

Copy over the modules:

for f in $(find drivers/usb/gadget/ -name *.ko); do sudo cp $f /lib/modules/$(uname -r)/kernel/drivers/usb/gadget/ ; done

Finally, load g_dbgp:

modprobe g_dbgp

Running

I recommend to open the TTY before starting debug target. Doing it the other way around slows down the debug target boot and seems to confuse serial gadget framework.

You may want to disable some CR/LF translations on the device:

stty -icrnl -inlcr -F /dev/ttyGS0

You can directly open the device node, possibly redirecting to file:

cat /dev/ttyGS0

.. or use a terminal client:

picocom -ir /dev/ttyGS0

Finding the USB debug port

See EHCI Debug Port#Finding the USB debug port

Tested hardware

Brand and Device kernel used Target devices works?
Goldelico GTA04 A3 neil-plus kernel and branch (3.7) Lenovo X60 Yes
Buglabs's bug 2.0 bug20-2.6.35-linaro's master (2.6.35) Lenovo X60 Yes
Carambola 2 dev board (or any other AR9331 board where the location of the usb mode strap resistor is known) OpenWRT git master (3.10.58) with chipidea ar9331 patch ASUS F2A85M-LE Yes