Compiled XServer on Ubuntu System

本文档详细介绍了如何在RK3288 EVB开发板上使用Ubuntu 14.04操作系统构建图形系统。主要内容包括:自建X Server以设置基本显示系统;替换Mali库来利用GPU模块;以及具体的编译步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

This paper would try to teach you how to build the graphic system on rk3288 EVB board with Ubuntu 14.04 operate system.

Two things we need to do in this paper:

  • Build our own XServer, this would help to set up the base display system.
  • Replace the Mali libraries, this would help to take use of the GPU module.

Compile XServer on Ubuntu

Xorg include lots of package, such as armsoc and xserver. And most of those package would need lots of others library support, like xserver would need libxcb. So first step we need to download all the packages we need.

# /bin/bash
# You could download this script by below link:
# https://github.com/yakir-Yang/scripts/blob/master/xorg-build.sh

XORG_REPOS="\
git://git.freedesktop.org/git/xorg/util/macros \
git://anongit.freedesktop.org/xorg/proto/xineramaproto \
git://anongit.freedesktop.org/xorg/proto/xproto \
git://anongit.freedesktop.org/xorg/proto/presentproto \
git://anongit.freedesktop.org/xorg/lib/libXdmcp \
git://anongit.freedesktop.org/xorg/app/xkbcomp \
git://git.freedesktop.org/git/xorg/proto/x11proto \
git://git.freedesktop.org/git/xorg/proto/damageproto \
git://git.freedesktop.org/git/xorg/proto/xextproto \
git://git.freedesktop.org/git/xorg/proto/fontsproto \
git://git.freedesktop.org/git/xorg/proto/videoproto \
git://git.freedesktop.org/git/xorg/proto/renderproto \
git://git.freedesktop.org/git/xorg/proto/inputproto \
git://git.freedesktop.org/git/xorg/proto/xf86vidmodeproto \
git://git.freedesktop.org/git/xorg/proto/xf86dgaproto \
git://git.freedesktop.org/git/xorg/proto/xf86driproto \
git://git.freedesktop.org/git/xorg/proto/xcmiscproto \
git://git.freedesktop.org/git/xorg/proto/scrnsaverproto \
git://git.freedesktop.org/git/xorg/proto/bigreqsproto \
git://git.freedesktop.org/git/xorg/proto/resourceproto \
git://git.freedesktop.org/git/xorg/proto/compositeproto \
git://git.freedesktop.org/git/xorg/proto/fixesproto \
git://git.freedesktop.org/git/xorg/proto/evieproto \
git://git.freedesktop.org/git/xorg/proto/kbproto \
git://git.code.sf.net/p/libpng/code \
git://git.sv.nongnu.org/freetype/freetype2.git \
git://anongit.freedesktop.org/xorg/lib/libXau \
git://git.freedesktop.org/git/xorg/lib/libxtrans \
git://git.freedesktop.org/git/xorg/lib/libX11 \
git://git.freedesktop.org/git/xorg/lib/libXext \
git://git.freedesktop.org/git/xorg/lib/libxkbfile \
git://git.freedesktop.org/git/xorg/lib/libfontenc \
git://git.freedesktop.org/git/xorg/lib/libXfont \
git://git.freedesktop.org/git/xorg/lib/libXfixes \
git://git.freedesktop.org/git/xorg/lib/libXdamage \
git://git.freedesktop.org/git/xorg/lib/libXv \
git://git.freedesktop.org/git/xorg/lib/libXvMC \
git://git.freedesktop.org/git/xorg/lib/libXxf86vm \
git://git.freedesktop.org/git/xorg/lib/libXinerama \
git://git.freedesktop.org/git/xorg/proto/dri2proto \
git://git.freedesktop.org/git/xorg/proto/glproto \
git://git.freedesktop.org/git/xorg/lib/libpciaccess \
git://git.freedesktop.org/git/pixman \
git://git.freedesktop.org/git/xcb/proto \
git://git.freedesktop.org/git/xcb/pthread-stubs \
git://git.freedesktop.org/git/xcb/libxcb \
git://git.freedesktop.org/git/xorg/proto/randrproto \
git://git.freedesktop.org/git/mesa/drm \
git://git.freedesktop.org/git/mesa/mesa \
git://git.freedesktop.org/git/xorg/xserver \
git://anongit.freedesktop.org/xorg/driver/xf86-input-evdev \
git://git.freedesktop.org/git/xorg/driver/xf86-input-mouse \
git://git.freedesktop.org/git/xorg/driver/xf86-input-keyboard \
git://git.freedesktop.org/git/xorg/driver/xf86-input-synaptics \
git://git.freedesktop.org/git/xorg/driver/xf86-video-intel \
https://github.com/dottedmag/libsha1.git \
https://github.com/madler/zlib.git \
https://github.com/mmind/xf86-video-armsoc.git"

download()
{
        sudo apt-get update
        sudo apt-get install git --reinstall
        sudo apt-get install libcurl3-gnutls --reinstall
        sudo apt-get install libtool --reinstall
        sudo pat-get install libxfont-dev
        sudo apt-get install libevdev-dev
        sudo apt-get install libmtdev-dev

        #
        # Clone the source code of xorg by defined repos,
        # and if repo already have been download, then
        # just update it.
        #
        for repo in $XORG_REPOS; do
                echo "======> Git cloning $repo"
                git clone $repo
        done

        # Correct the directory name of libpng
        mv code libpng;
}


case "$1" in
    download)
        download
        ;;
esac

2. Compile the xorg packages

  • Compiled the marcos, create the aclocal enviroment.
# /bin/bash
export DEST="/"
export PREFIX="$DEST/usr"
export PKG_CONFIG=pkg-config
export CC=arm-linux-gnueabihf-gcc
export MAKE="make -j4"
export CFLAGS="-I"$PREFIX"/include -I"$PREFIX"/include/freetype2/"
export LDFLAGS="-L"$PREFIX"/lib -Wl,-rpath-link,$PREFIX/lib"
export PKG_CONFIG_PATH=""$PREFIX"/lib/pkgconfig:$PREFIX/share/pkgconfig"
export ACLOCAL="aclocal -I"$PREFIX"/share/aclocal"
export DESTDIR=

compiled_macros()
{
        cd macros
        ./autogen.sh --host=arm-linux --prefix="$PREFIX"
        make -j4 || exit 1
        make install || exit 1
        cd ..

        echo xorg_cv_malloc0_returns_null=yes > arm-linux.cache
}

case "$1" in
        download)
                download
                ;;
        compiled)
                sudo stop lightdm
                compiled_macros
                sudo start lightdm
                ;;
esac


  • Compiled the freetype2 libraries separately, cause we need to enable the png and zlib future support for it.
compiled_freetype2()
{
        # Compiled zlib source code
        cd zlib
        ./configure --prefix="$PREFIX"
        make || exit 1
        make install || exit 1
        cd ..

       # Compiled libpng source code
        cd libpng;
        ./autogen.sh
        ./configure  --host=arm-linux --prefix="$PREFIX"
        make || exit 1
        make install || exit 1
        cd ..

        # Compile freetype2 with zlib and png support
        cd freetype2
        ./autogen.sh
        ./configure  --host=arm-linux --with-png=yes --with-zlib=yes --prefix=$PREFIX
        make || exit 1
        make install || exit 1
        cd ..
}

case "$1" in
    download)
        download
        ;;
    compiled)
        sudo stop lightdm
        compiled_macros
        compiled_freetype2
        sudo start lightdm
        ;;
esac


  • Compiled the left related libraries.
modules="\
libsha1 \
xproto \
fontsproto \
x11proto \
xextproto \
videoproto \
renderproto \
inputproto \
damageproto \
xf86vidmodeproto \
xf86dgaproto \
xf86driproto \
xcmiscproto \
scrnsaverproto \
bigreqsproto \
resourceproto \
compositeproto \
resourceproto \
evieproto \
kbproto \
fixesproto \
libxtrans \
proto \
pthread-stubs \
libXau \
libxcb \
libX11 \
libXext \
libxkbfile \
libfontenc \
libXfont \
libXv \
libXvMC \
libXxf86vm \
xineramaproto \
libXinerama \
libXfixes \
libXdamage \
dri2proto \
glproto \
libpciaccess \
pixman \
presentproto \
libXdmcp \
randrproto"

compiled_xorg_modules()
{
        for module in $modules; do
                cd $module
                echo ======================
                echo configuring $module
                echo ======================
                ./autogen.sh  --prefix="$PREFIX" --host=arm-linux --cache-file=../arm-linux.cache || exit 1
                if [ $? -ne 0 ]; then
                        echo "Failed to configure $i."
                        exit
                fi
                make -j4 || exit 1
                make install || exit 1
                cd ..
        done
}

case "$1" in
    download)
        download
        ;;
    compiled)
        sudo stop lightdm
        compiled_macros
        compiled_freetype2
        compiled_xorg_modules
        sudo start lightdm
        ;;
esac


  • Compiled the important XServer package, before we start to compiled the XServer, we need to checkout the some package branch to the special version we want. 

For example, if we want to build the XServer 1.12.4 

Checkout the xfont to version 
cd libXfont; 
git branch -a; 
git checkout libXfont-1.5.1 -b libXfont-1.5.1; 
cd -
 

Checkout the xserver to version 
cd xserver; 
git tag | grep 1.12.4 
git checkout xorg-server-1.12.4 -b xorg-server-1.12.4 
cd -
 

Checkout the armosc to rokchip branch 
cd xf86-video-armsoc; 
git branch -a; 
git checkout remotes/origin/devel/rockchip -b rockchip; 
cd -;

After declare the build version, then we could start to compiled the main XServer module.

spec_modules="\
evdev \
mouse \
keyboard"

compiled_xserver()
{
        # build drm
        echo ======================
        echo building drm
        echo ======================
        cd drm
        ./autogen.sh --prefix="$PREFIX" --disable-cairo-tests --host=arm-linux
        make -j4 || exit 1
        make install || exit 1
        cd ..

        #build xserver
        echo ======================
        echo building xserver
        echo ======================
        cd xserver
        ./autogen.sh --prefix="$PREFIX" --host=arm-linux --enable-dri2 --disable-aiglx --disable-glx --disable-dri --disable-record --with-sha1=libsha1 --disable-xnest
        if [ $? -ne 0 ]; then
                echo "Failed to configure X server."
                exit
        fi
        make -j4 || exit 1
        make install || exit 1
        cd ..

        # build special modules
        for module in spec_modules; do
            cd $module
            echo ======================
            echo configuring $module
            echo ======================
            ./autogen.sh  --prefix="$PREFIX" --host=arm-linux || exit 1
            make -j4 || exit 1
            make install || exit 1
            cd ..
        done

        # build armsoc
        echo ======================
        echo building armsoc
        echo ======================
        cd xf86-video-armsoc
        ./autogen.sh  --host=arm-linux --with-driver=rockchip
        make -j4 || exit 1
        make install || exit 1
        cd ..

case "$1" in
    download)
        download
        ;;
    compiled)
        sudo stop lightdm
        compiled_macros
        compiled_freetype2
        compiled_xorg_modules
        compiled_xserver
        sudo start lightdm
        ;;
    *)
        echo "Usage: $0 donwload | compiled"
        exit 3
esac


3. Configure the XServer

For now you have build the whole XServer packages on Ubuntu system, the last things for lighting your monitor is configuring the XServer. XServer have provided the xorg.config interfaces, we just need to write the write the configure file to ensure that XServer would use Rockchip DRM driver. We have provided therk32.conf file, you just need to place them into /etc/X11/xorg.conf.d/ directly (if it does not exist, then just create it).

# Filename: rk32.conf 
# Path: /etc/X11/xorg.conf.d/rk32.conf

Section "Device"
        Identifier      "Mali FBDEV"
        Driver          "armsoc"
        Option          "fbdev"                 "/dev/fb0"
        Option          "Fimg2DExa"             "false"
        Option          "DRI2"                  "true"
        Option          "DRI2_PAGE_FLIP"        "false"
        Option          "DRI2_WAIT_VSYNC"       "true"
#       Option          "Fimg2DExaSolid"        "false"
#       Option          "Fimg2DExaCopy"         "false"
#       Option          "Fimg2DExaComposite"    "false"
        Option          "SWcursorLCD"   "false"
#       Option          "Debug"                 "true"
EndSection

Section "Screen"
        Identifier      "DefaultScreen"
        Device          "Mali FBDEV"
        DefaultDepth    24
EndSection

Kindliness remind: 
You could download the xorg-build.sh script on githubs

### 解决方案概述 对于Ubuntu 20.04上Torch未与CUDA一起编译导致的`AssertionError`问题,主要挑战在于操作系统默认配置以及依赖库版本兼容性。解决方案涉及调整环境设置、安装适当版本的CUDA及相关工具链,并确保PyTorch能够正确识别并使用这些资源。 ### 安装合适版本的CUDA 由于Ubuntu 20.04自带较新的GCC版本,这可能与旧版CUDA (如CUDA 9.x 或 CUDA 10.x) 不兼容[^1]。建议采用以下方法之一: - **降级GCC版本**:尝试通过PPA或其他方式获取较低版本的GCC用于构建过程。 - **升级CUDA版本**:考虑安装更新版本的CUDA(例如CUDA 11及以上),这类版本通常能更好地适配现代Linux发行版及其预装软件包。 ### 配置开发环境 为了使PyTorch能够顺利调用GPU加速功能,在完成上述操作之后还需要做进一步配置: #### 设置环境变量 将必要的库路径加入到系统的环境变量中以便于程序查找所需的动态链接库文件。可以通过编辑用户的`.bashrc`文件实现这一点[^4]: ```bash export LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu:$LD_LIBRARY_PATH export PATH=$PATH:/usr/src/tensorrt/bin ``` #### 编译自定义扩展模块 当涉及到特定硬件优化或特殊需求时,有时需要重新编译某些组件以适应当前平台特性。针对这种情况,可参照如下指令进行处理[^3]: ```python python setup.py build --cpp_ext --cuda_ext ``` 此命令会触发Python打包工具chain执行一系列任务,包括但不限于准备C++/CUDA源码、编译目标二进制文件等。 另外,如果项目中有额外插件支持,则需按照官方文档指引单独对其进行安装和初始化工作[^2]: ```shell python setup.py install --plugins cmake -B build . cmake --build build --target install && ldconfig ``` 以上步骤有助于确保所有必需项均已就绪且相互之间保持良好协作状态。 ### 相关问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值