-
Notifications
You must be signed in to change notification settings - Fork 9
Debug
A list of various things to try or look at if you have problems or if you're just curious.
$ lsusb -d 1d50:614d
Get the strings as well (this can cause the device to lock up...):
$ sudo lsusb -v -d 1d50:614d
Get the strings from the kernel (cached):
$ sudo cat /sys/kernel/debug/usb/devices
T: Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#= 5 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d50 ProdID=614d Rev= 1.00
S: Manufacturer=Raspberry Pi
S: Product=Raspberry Pi Zero Display Gadget
S: SerialNumber=00000000f239041b
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=120mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=00 Driver=gud
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
Statistics
$ sudo cat /sys/kernel/debug/dri/<n>/stats
Max buffer size: 16.0 MiB
Number of errors: 0
Compression: lz4
Compression ratio: 103.7
DRM state
$ sudo cat /sys/kernel/debug/dri/<n>/state
plane[31]: plane-0
crtc=crtc-0
fb=42
allocated by = [fbcon]
refcount=2
format=RG16 little-endian (0x36314752)
modifier=0x0
size=1920x1080
layers:
size[0]=1920x1080
pitch[0]=3840
offset[0]=0
obj[0]:
name=0
refcount=3
start=00010000
size=4149248
imported=no
pages_use_count=0
vmap_use_count=0
vaddr=00000000
crtc-pos=1920x1080+0+0
src-pos=1920.000000x1080.000000+0.000000+0.000000
rotation=1
normalized-zpos=0
color-encoding=ITU-R BT.601 YCbCr
color-range=YCbCr limited range
crtc[33]: crtc-0
enable=1
active=1
self_refresh_active=0
planes_changed=1
mode_changed=0
active_changed=0
connectors_changed=0
color_mgmt_changed=0
plane_mask=1
connector_mask=1
encoder_mask=1
mode: "1920x1080": 60 148500 1920 2008 2052 2200 1080 1084 1089 1125 0x48 0x5
connector[36]: HDMI-A-1
crtc=crtc-0
self_refresh_aware=0
# DRM device and their connectors
$ ls /sys/class/drm/
card0 card0-HDMI-A-1 version
$ cat /sys/class/drm/card0-HDMI-A-1/status
connected
$ cat /sys/class/drm/card0-HDMI-A-1/edid | edid-decode | head -2
EDID version: 1.3
Manufacturer: BNQ Model 780a Serial Number
# Disable fbdev emulation
echo 0 | sudo tee /sys/module/drm_kms_helper/parameters/fbdev_emulation
# Backlight (if supported)
echo 50 | sudo tee /sys/class/backlight/card0-USB-1-backlight/brightness
The drm.debug module parameter sets the logging filter:
DRM_UT_CORE = 0x01 DRM core (ioctl's etc.)
DRM_UT_DRIVER = 0x02 Driver
DRM_UT_KMS = 0x04 Kernel Mode Setting
DRM_UT_PRIME = 0x08 PRIME buffer sharing
DRM_UT_ATOMIC = 0x10 Atomic
DRM_UT_STATE = 0x40 Atomic state
DRM_UT_DRMRES = 0x200 Managed resources
Driver logging only:
$ sudo dmesg -C
$ echo 2 | sudo tee /sys/module/drm/parameters/debug
$ dmesg -w
# plug in display
[ 450.167535] usb 1-1.4: new full-speed USB device number 5 using xhci_hcd
[ 455.777586] usb 1-1.4: new high-speed USB device number 6 using xhci_hcd
[ 456.022737] gud 1-1.4:1.0: [drm:gud_probe [gud]] version=1 flags=0x1 compression=0x1 max_buffer_size=16777216
[ 456.023793] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] get: request=0x40 index=0 len=32
[ 456.039518] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] get: request=0x41 index=0 len=320
[ 456.039760] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] get: request=0x50 index=0 len=160
[ 456.039939] gud 1-1.4:1.0: [drm:gud_get_connectors [gud]] Connector: index=0 type=7 flags=0x3
[ 456.040104] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] get: request=0x51 index=0 len=320
[ 456.040282] gud 1-1.4:1.0: [drm:gud_get_connectors [gud]] property: 1 = 0(0x0)
[ 456.040332] gud 1-1.4:1.0: [drm:gud_get_connectors [gud]] property: 2 = 0(0x0)
[ 456.040353] gud 1-1.4:1.0: [drm:gud_get_connectors [gud]] property: 3 = 0(0x0)
[ 456.040372] gud 1-1.4:1.0: [drm:gud_get_connectors [gud]] property: 4 = 0(0x0)
[ 456.042392] [drm] Initialized gud 1.0.0 20200422 for 1-1.4:1.0 on minor 0
[ 456.042794] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] set: request=0x53 index=0 len=0
[ 456.087187] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] get: request=0x54 index=0 len=1
[ 456.087431] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] get: request=0x56 index=0 len=2048
[ 456.087815] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] get: request=0x55 index=0 len=3072
[ 456.096980] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] set: request=0x61 index=0 len=76
[ 456.135276] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] set: request=0x63 index=0 len=1
[ 456.135664] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] set: request=0x62 index=0 len=0
[ 456.151116] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] set: request=0x64 index=0 len=1
[ 456.168710] Console: switching to colour frame buffer device 240x75
[ 456.174002] gud 1-1.4:1.0: [drm] fb0: guddrmfb frame buffer device
[ 456.174554] gud 1-1.4:1.0: [drm:gud_flush_rect [gud]] Flushing [FB:42] 1920x1200+0+0
[ 456.198229] gud 1-1.4:1.0: [drm:gud_usb_transfer [gud]] set: request=0x60 index=0 len=25
Is the DRM device released when the display is unplugged or is userspace keeping a file descriptor open:
$ sudo dmesg -C
$ echo 0x200 | sudo tee /sys/module/drm/parameters/debug
$ dmesg -w
# unplug
[ 500.519691] usb 1-1.4: USB disconnect, device number 6
[ 500.587697] gud 1-1.4:1.0: [drm:drm_managed_release] drmres release begin
...
[ 500.617137] [drm:drm_dev_release] drmres release end
Enable everything:
$ echo 0xff | sudo tee /sys/module/drm/parameters/debug
modetest is a simple tool to test drm drivers.
Build:
$ sudo apt install meson libtool xutils-dev
$ git clone https://gitlab.freedesktop.org/mesa/drm.git libdrm
$ cd libdrm
$ meson builddir/
$ ninja -C builddir/ install
Find connector id:
$ sudo modetest -M gud -c | head
Connectors:
id encoder status name size (mm) modes encoders
36 34 connected HDMI-A-1 520x320 28 34
modes:
index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot
#0 1920x1200 59.95 1920 1968 2000 2080 1200 1203 1209 1235 154000 flags: phsync, nvsync; type: preferred, driver
#1 1920x1080 60.00 1920 2008 2052 2200 1080 1084 1089 1125 148500 flags: phsync, pvsync; type: driver
#2 1920x1080 59.94 1920 2008 2052 2200 1080 1084 1089 1125 148352 flags: phsync, pvsync; type: driver
#3 1920x1080i 30.00 1920 2008 2052 2200 1080 1084 1094 1125 74250 flags: phsync, pvsync, interlace; type: driver
#4 1920x1080i 29.97 1920 2008 2052 2200 1080 1084 1094 1125 74176 flags: phsync, pvsync, interlace; type: driver
Display a test image:
$ sudo modetest -M gud -s 36:1920x1080@RG16
setting mode 1920x1080-60.00Hz on connectors 36, crtc 33
failed to set gamma: Function not implemented
<press enter to stop>
(RG16 is RGB565, XR24 is XRGB8888)
Test properties (obj id for the property is the plane/connector/crtc id being operated on):
# Rotate plane 180
sudo modetest -M gud -s 36:1024x768@RG16 -w 31:rotation:4
# 50 pixels top margin
sudo modetest -M gud -s 36:1024x768@RG16 -w 36:"top margin":50
# TODO: why doesn't this rotate?
# use atomic (all in one commit):
sudo modetest -M gud -a -P 31@33:1024x768 -s 36:1024x768@RG16 -w 31:rotation:4
failed to set PLANE 31 property rotation to 4: Success
setting mode 1024x768-75.03Hz on connectors 36, crtc 33
failed to set gamma: Function not implemented
testing 1024x768@XR24 on plane 31, crtc 33
Verbose modetest:
$ LIBGL_DEBUG=verbose modetest
usbmon can be used to trace USB I/O. The tools/monitor.py tool contains a GUD protocol parser that coupled with usbmon traces gives a view into what happens on the bus.
# Plug in find bus number
$ lsusb -d 1d50:614d
Bus 001 Device 009: ID 1d50:614d OpenMoko, Inc.
# Unplug and pass bus number as parameter
$ sudo modprobe usbmon && sudo python3 gud/tools/monitor.py 1
Monitoring: 001:DISCOVER
# Plug in display
Monitoring: 001:011
GUD_REQ_GET_DESCRIPTOR:
version=1
flags=0x00000001
compression=0x01
max_buffer_size=16777216
min_width=0
max_width=2048
min_height=0
max_height=2048
(0.2 ms)
GUD_REQ_GET_FORMATS: XRGB8888 ARGB8888 RGB565 (0.4 ms)
GUD_REQ_GET_PROPERTIES:
GUD_PROPERTY_ROTATION = 53 (0x35)
(0.3 ms)
GUD_REQ_GET_CONNECTORS:
index=0 type=HDMI flags=0x00000003
(0.2 ms)
GUD_REQ_GET_CONNECTOR_PROPERTIES:
GUD_PROPERTY_TV_LEFT_MARGIN = 0
GUD_PROPERTY_TV_RIGHT_MARGIN = 0
GUD_PROPERTY_TV_TOP_MARGIN = 0
GUD_PROPERTY_TV_BOTTOM_MARGIN = 0
(0.2 ms)
GUD_REQ_SET_CONNECTOR_FORCE_DETECT: (44.5 ms)
GUD_REQ_GET_CONNECTOR_STATUS: index=0 status=connected (CHANGED) (0.2 ms)
GUD_REQ_GET_CONNECTOR_EDID: len=256 (0.2 ms)
GUD_REQ_GET_CONNECTOR_MODES:
mode=1920x1200
mode=1920x1080
mode=1920x1080
mode=1920x1080
mode=1920x1080
mode=1920x1080
mode=1920x1080
mode=1600x1200
mode=1680x1050
mode=1280x1024
mode=1280x1024
mode=1440x900
mode=1280x800
mode=1152x864
mode=1280x720
mode=1280x720
mode=1280x720
mode=1024x768
mode=1024x768
mode=832x624
mode=800x600
mode=800x600
mode=720x480
mode=720x480
mode=720x480
mode=720x480
mode=720x480
mode=720x480
mode=640x480
mode=640x480
mode=640x480
mode=640x480
mode=640x480
mode=720x400
(0.3 ms)
GUD_REQ_SET_STATE_CHECK: mode=1920x1200 format=RGB565 connector=0 properties:
GUD_PROPERTY_TV_LEFT_MARGIN = 0
GUD_PROPERTY_TV_RIGHT_MARGIN = 0
GUD_PROPERTY_TV_TOP_MARGIN = 0
GUD_PROPERTY_TV_BOTTOM_MARGIN = 0
GUD_PROPERTY_ROTATION = 1
(39.0 ms)
GUD_REQ_SET_CONTROLLER_ENABLE: 1 (1.0 ms)
GUD_REQ_SET_STATE_COMMIT: (8.4 ms)
GUD_REQ_SET_DISPLAY_ENABLE: 1 (16.6 ms)
Flush: 1920x1200+0+0 length=4608000/18081 (254.9) ( 8.3 + 1.5 = 9.9 ms)
Flush: 1920x1200+0+0 length=4608000/69061 (66.7) ( 50.4 + 3.2 = 53.9 ms)
Flush: 8x16+88+464 length=256/11 (23.3) ( 11.8 + 0.9 = 12.9 ms)
Flush: 8x16+88+464 length=256/17 (15.1) ( 0.5 + 0.8 = 1.4 ms)
Flush: 8x16+88+464 length=256/11 (23.3) ( 0.4 + 0.9 = 1.5 ms)
Flush: 8x16+88+464 length=256/17 (15.1) ( 0.7 + 1.8 = 2.6 ms)
Flush: 8x16+88+464 length=256/11 (23.3) ( 0.7 + 1.8 = 2.6 ms)
Flush: 8x16+88+464 length=256/17 (15.1) ( 0.8 + 1.6 = 2.5 ms)
Flush: 8x16+88+464 length=256/11 (23.3) ( 0.7 + 2.1 = 3.1 ms)
Flush: 8x16+88+464 length=256/17 (15.1) ( 0.4 + 1.7 = 2.3 ms)
Flush: 8x16+88+464 length=256/11 (23.3) ( 0.4 + 1.7 = 2.3 ms)
Flush: 8x16+88+464 length=256/17 (15.1) ( 0.4 + 1.7 = 2.3 ms)
Flush: 8x16+88+464 length=256/11 (23.3) ( 0.4 + 1.5 = 2.0 ms)
^C
Statistics:
Rects:
1920x1200: 60.7 < 60.9 ms < 61.0 (2)
8x16: 1.1 < 2.2 ms < 3.1 (11)
Full:
1920x1200: 60.7 < 60.9 ms < 61.0 (2)
Totals (13):
time: 2 seconds
compression: 105.6
throughput: 3.9 MB/s
fps=0.9
# Skip the bus number if the device is already plugged in
$ sudo python3 gud/tools/monitor.py
Looking for device...
Found: Raspberry Pi Zero Display Gadget
Monitoring: 001:011
Detected: GUD_DISPLAY_FLAG_STATUS_ON_SET
Flush: 8x16+88+464 length=256/11 (23.3) ( 0.2 + 1.0 = 1.4 ms)
Flush: 8x16+88+464 length=256/17 (15.1) ( 0.5 + 0.8 = 1.4 ms)
Flush: 8x16+88+464 length=256/11 (23.3) ( 0.7 + 1.5 = 2.4 ms)
Flush: 8x16+88+464 length=256/17 (15.1) ( 0.7 + 1.5 = 2.4 ms)
^C
Statistics:
Rects:
8x16: 1.4 < 1.9 ms < 2.4 (4)
Totals (4):
time: 0 seconds
compression: 18.3
throughput: 1.6 kB/s
fps=0.0