title: EHCI debugging on the BeagleBone Black ...
Patch BBB's g_dbgp
module (optional, but highly
recommended)
Eneble EHCI Debug on the target's kernel (optional, recommended)
NOTE: this documentation may be outdated, and discusses configuring EHCI debug on the default Debian system that the BBB sometimes comes with. If you want an easier time, just use BBB ScrewDriver which comes pre-configured.
If your computer does not boot after installing libreboot, it is very useful to get debug logs from it, from the payload (grub) and/or the kernel (if gets to there). All of them stream debug logs on the available serial (RS-232) by default. However, most of todays laptops lack RS-232 port. The other option is to stream the logs to USB EHCI debug port.
This section explains step-by-step how to setup BBB as a “USB EHCI debug dongle” and configure libreboot and the linux kernel to stream logs to it (TODO: grub).
I will refer to three computers:
Not all USB controllers support EHCI debug (see: EHCI Debug Port ). Even more, if a USB controller supports EHCI debug, it is available only on a single port that might or might not be exposed externally.
Remember (write down) for each port (external plug) you found that supports debug: PCI device id, the bus id, the port number, and the physical location of the usb plug.
If you do not find a match, you can not get debug over EHCI. Sorry.
^1^ The guys from coreboot were talking about including the script in coreboot distribution (check the status).
BBB must be powered with a barrel power connector since the mini-B USB plug will be used for the EHCI debug stream. So you will need:
(On BBB) The linux kernel includes module (g_dbgp that enables one of the usb ports on a computer to behave as EHCI debug dongle. Make sure you have this module available on your BBB (Debian 7.8 that comes with BBB should have it), if not, you should compile it yourself (see next section):
ls /lib/modules/3.8.13-bone70/kernel/drivers/usb/gadget/g_dbgp.ko
Unload all other g_* modules:
# lsmod
# rmmod g_multi
...
Then load g_dbgp :
# modprobe g_dbgp
# lsmod # should show that g_dbgp is loaded, and no other g_*
Plug the mini-B side of the USB cable in your BBB and the A side in your target. Then one of the usb devices on your target (with lsusb ) should be:
Bus 001 Device 024: ID 0525:c0de Netchip Technology, Inc.
If you see the device on the target, you are good to continue to the next step.
For the reasons why you need this, see: EHCI Gadget Debug.\ Make sure that you have cross compiling environment for arm-linux-gnueabihf setup on your host.
$ cd $work_dir
$ git clone https://github.com/beagleboard/kernel.git
$ cd kernel
$ git checkout $mav (see above)
$ ./patch.sh
$ wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O kernel/firmware/am335x-pm-firmware.bin
$ cp configs/beaglebone kernel/arch/arm/configs/beaglebone_defconfig
git apply ../usbdebug-gadget/v3.8-debug-gadget/0001-usb-dbgp-gadget-Fix-re-connecting-after-USB-disconne.patch
git apply ../usbdebug-gadget/v3.8-debug-gadget/0002-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch
;
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- beaglebone_defconfig -j4@
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4 (is it possoble to build only the gadget modules)
$ mkdir ../tmp && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../tmp modules_install
Libreboot(coreboot) should be configured with debug turned on and to push debug messages to the EHCI debug port.\ If you've downloaded the binary distribution, you can check if it is properly configured in the following way:
./cbfstool/i686/cbfstool $img_path extract -n config -f ./my_config
CONFIG_USBDEBUG=y (Generic Drivers -> USB 2.0 EHCI debug dongle support)
CONFIG_USBDEBUG_IN_ROMSTAGE=y (Generic Drivers -> Enable early (pre-RAM) usbdebug)
CONFIG_USBDEBUG_HCD_INDEX=<HCD Index of usb controller - see below> (Generic Drivers -> Index for EHCI controller to use with usbdebug)
CONFIG_USBDEBUG_DEFAULT_PORT=<USB Debug port - see below> (Generic Drivers -> Default USB port to use as Debug Port)
The following three are behind radio button in the menu. Only the first one^2^ should be = y
USBDEBUG_DONGLE_STD=y (Generic Drivers -> Type of dongle (Net20DC or compatible) -> Net20DC or compatible)
CONFIG_USBDEBUG_DONGLE_BEAGLEBONE=n (Generic Drivers -> Type of dongle (Net20DC or compatible) -> BeagleBone)
CONFIG_USBDEBUG_DONGLE_BEAGLEBONE_BLACK=n (Generic Drivers -> Type of dongle (Net20DC or compatible) -> BeagleBone Black)
^2^ The g_dbgp module on BeagleBone Black (Rev. C) reports it self as Net20DC, the other options are for older BB(B) - ver1. This is documented here (also tested/verified).
Then:
CONFIG_CONSOLE_USB=y (Console -> USB dongle console output)
Also Debugging ---> Output verbose XYZ ) (FIXME somebody verify these):
CONFIG_DEBUG_CBFS=y (Output verbose CBFS debug messages )
CONFIG_HAVE_DEBUG_RAM_SETUP=y (??? What/where is this)
CONFIG_DEBUG_RAM_SETUP=y (Output verbose RAM init debug messages)
CONFIG_DEBUG_SMI=y (Output verbose SMI debug messages)
CONFIG_DEBUG_ACPI=y (Output verbose ACPI debug messages )
CONFIG_DEBUG_USBDEBUG=y (Output verbose USB 2.0 EHCI debug dongle messages)
If some of the above mentioned configuration options are not as specified, you have to configure and compile libreboot yourself. Please refer to the doc(FIXME: link about compiling libreboot.
This applies (and works) only if the USB controller that supports debug (found in the first section) is from Intel.\ If the PCI ID of the port you found in the first section is 0000:00:1a.0 or 0000:00:1d.0 , you are ok. Otherwise you have to try without guarantee that will work.
If the externally exposed port is on a bus with PCI ID == 0000:00:1a.0 then for CONFIG_USBDEBUG_HCD_INDEX choose 2, otherwise choose 0 .
For CONFIG_USBDEBUG_DEFAULT_PORT choose the port from the first section that correspond to the PCI ID
Notes:\ The above is based on the implementation of coreboot/src/southbridge/intel/common/usb_debug.c : pci_ehci_dbg_dev() .\ This is enough as it applies for the supported GM45/G45 Thinkpads. coreboot support some other contollers too, but they are irellevent for libreboot (for now).
stty -icrnl -inlcr -F /dev/ttyGS0
cat /dev/ttyGS0
Note that this is not permanent on BBB, if you reboot it, you have to rmmod g_* and modprobe g_dbgp
You have to know how to compile kernel for your target.
^10^ EHCI Debug Port
^11^ coreboot EHCI debug gadget demonstration
^12^ EHCI Gadget Debug
^13^ Ehci-debug-gadget-patches.tar.gz
^14^ Compiling the BeagleBone Black Kernel
^15^ http://dumb-looks-free.blogspot.ca/2014/06/beaglebone-black-bbb-compile-kernel.html
^16^ http://dumb-looks-free.blogspot.fr/2014/06/beaglebone-black-bbb-kernal-headers.html
^17^ Building BBB Kernel
^18^ http://komposter.com.ua/documents/USB-2.0-Debug-Port%28John-Keys%29.pdf
^19^ Exploring USB at the Hardware/Software Interface
^20^ https://www.kernel.org/doc/Documentation/x86/earlyprintk.txt
^21^ https://wiki.ubuntu.com/Kernel/Debugging/USBearlyprintk
TODO:
Copyright © 2015 Alex David opdecirkel@gmail.com
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License Version 1.3 or any later version published by the Free Software Foundation with no Invariant Sections, no Front Cover Texts, and no Back Cover Texts. A copy of this license is found in ../fdl-1.3.md