美文网首页
Linux DRM那些事-libdrm调试准备

Linux DRM那些事-libdrm调试准备

作者: 小田BSP | 来源:发表于2021-04-10 23:48 被阅读0次

    本文主要介绍libdrm的代码下载、编译和调试前的准备工作。

    一、代码下载

    libdrm下载网址:https://dri.freedesktop.org/libdrm/libdrm-2.4.89.tar.bz2

    解压命令:tar -jxvf libdrm-2.4.89.tar.bz2

    在代码解压后,可以使用git命令创建本地git仓,方便代码管理,创建方法后续介绍。

    二、代码编译

    代码完成解压后,按如下命令编译:

    ./configure --prefix=/opt/ --host=aarch64-linux-gnu
    make && make install
    ## 编译删除
    make distclean
    

    1、configure参数

    1)--prefix:配置软件安装目录,可以配置。

    2)--build:指定编译代码的主机,可以不配置。

    3)--host:指定编译后的运行主机,需要配置和单板使用相同的编译工具链前缀

    4)--enable-udev:使用Udev代替mknod一定不要配置

    5)./configure --help查看参数用法。

    2、编译映像

    编译后映像:libdrm-2.4.89/.libs/libdrm.so.2.4.0libdrm-2.4.89/tests/modetest/.libs/modetest

    其它测试命令(如:proptest)路径类似。

    三、调试问题

    1、调试准备

    如使用modetest测试,需要拷贝modetestlibdrm.so.2.4.0,方法:

    ## 文件存在U盘中
    mount /dev/sda4 /tmp/
    cp /tmp/modetest ~/
    chmod 777 modetest
    cd /usr/lib/aarch64-linux-gnu
    rm libdrm.so
    cp /tmp/libdrm.so.2.4.0 .
    ln -s libdrm.so.2.4.0 libdrm.so
    cd ~
    ./modetest
    

    2、--host设置错误

    libdrm编译时,如果--host设置错误,在单板上使用modetest命令时,会提示如下错误:

    cannot execute binary file: Exec format error
    

    3、编译时添加--enable-udev

    libdrm编译时,如果添加--enable-udev,在单板上使用modetest命令时,会提示如下错误:

    root@linaro-alip:~# ./modetest
    trying to open device 'rockchip'...drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: node name is /dev/dri/card1
    drmOpenDevice: node name is /dev/dri/card2
    drmOpenDevice: node name is /dev/dri/card3
    drmOpenDevice: node name is /dev/dri/card4
    drmOpenDevice: node name is /dev/dri/card5
    drmOpenDevice: node name is /dev/dri/card6
    drmOpenDevice: node name is /dev/dri/card7
    drmOpenDevice: node name is /dev/dri/card8
    drmOpenDevice: node name is /dev/dri/card9
    drmOpenDevice: node name is /dev/dri/card10
    drmOpenDevice: node name is /dev/dri/card11
    drmOpenDevice: node name is /dev/dri/card12
    drmOpenDevice: node name is /dev/dri/card13
    drmOpenDevice: node name is /dev/dri/card14
    drmOpenDevice: node name is /dev/dri/card15
    failed
    no device found
    

    4、no device found

    modetest测试失败信息如下:

    root@linaro-alip:~# ./modetest
    trying to open device 'rockchip'...failed
    ...
    no device found
    

    有的平台会显示Permission denied错误。

    原因:/dev/dri/card0被占用。

    需要关闭系统原有的显示进程,方法:

    root@linaro-alip:~# ps -A
      PID TTY          TIME CMD
        1 ?        00:00:03 systemd
      ...
      958 tty7     00:00:00 Xorg      ## 显示进程
      ...
    
    ## 如果一次没有kill Xorg成功,多试几次
    root@linaro-alip:~# killall Xorg && ./modetest
    trying to open device 'rockchip'...failed
    ...
    no device found
    
    ## 此时可成功使用modetest测试。
    root@linaro-alip:~#killall Xorg && ./modetest
    trying to open device 'rockchip'...done
    Encoders:
    id      crtc    type    possible crtcs  possible clones
    87      0       TMDS    0x00000001      0x00000000
    
    Connectors:
    id      encoder status          name            size (mm)       modes   encoders
    88      0       disconnected    HDMI-A-1        0x0             0       87
      props:
            1 EDID:
                    flags: immutable blob
                    blobs:
    
                    value:
            2 DPMS:
                    flags: enum
                    enums: On=0 Standby=1 Suspend=2 Off=3
                    value: 0
            89 hdmi_output_depth:
                    flags: enum
                    enums: Automatic=0 24bit=8 30bit=10
                    value: 8
            90 hdmi_output_format:
    

    5、modetest测试

    在单板上使用modetest命令运行成功时,会出现下列日志:

    root@linaro-alip:~# ./modetest
    trying to open device 'i915'...failed
    trying to open device 'amdgpu'...failed
    trying to open device 'radeon'...failed
    trying to open device 'nouveau'...failed
    trying to open device 'vmwgfx'...failed
    trying to open device 'omapdrm'...failed
    trying to open device 'exynos'...failed
    trying to open device 'tilcdc'...failed
    trying to open device 'msm'...failed
    trying to open device 'sti'...failed
    trying to open device 'tegra'...failed
    trying to open device 'imx-drm'...failed
    trying to open device 'rockchip'...done
    Encoders:
    id      crtc    type    possible crtcs  possible clones
    87      0       TMDS    0x00000001      0x00000000
    
    Connectors:
    id      encoder status          name            size (mm)       modes   encoders
    88      0       disconnected    HDMI-A-1        0x0             0       87
      props:
            1 EDID:
                    flags: immutable blob
                    blobs:
    
                    value:
            2 DPMS:
                    flags: enum
                    enums: On=0 Standby=1 Suspend=2 Off=3
                    value: 0
            89 hdmi_output_depth:
                    flags: enum
                    enums: Automatic=0 24bit=8 30bit=10
                    value: 8
            90 hdmi_output_format:
                    flags: enum
                    enums: output_rgb=0 output_ycbcr444=1 output_ycbcr422=2 output_ycbcr420=3 output_ycbcr_high_subsampling=4 output_ycbcr_low_subsampling=5 invalid_output=6
                    value: 0
    
    ...
    

    在上面的log中,打开其它平台DRM名称(如:i915)时失败,可通过修改代码消除,方法如下:

    ## 把rockchip放到modules的第一位即可或modules中只保留rockchip
    static const char * const modules[] = {
            "rockchip",
            "i915",
            "amdgpu",
            "radeon",
            "nouveau",
            "vmwgfx",
            "omapdrm",
            "exynos",
            "tilcdc",
            "msm",
            "sti",
            "tegra",
            "imx-drm",
            "atmel-hlcdc",
            "fsl-dcu-drm",
            "vc4",
            "virtio_gpu",
            "mediatek",
            "meson",
            "pl111",
    };
    

    注:

    本文基于RockPI 4A单板Debian映像调试。

    注:本文仅在简书、OSCHINA和今日头条发布过,转载请标注原作者和链接。

    相关文章

      网友评论

          本文标题:Linux DRM那些事-libdrm调试准备

          本文链接:https://www.haomeiwen.com/subject/jumokltx.html