Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    基于R329开发板构建多房间音频组播系统2——基于Ubuntu 20搭建开发环境

    A Series
    1
    2
    1483
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      yimu163com LV 4 last edited by yimu163com

      搭建环境是做开发的前提,官网有介绍如何基于Ubuntu 14搭建R329开发环境,我的笔记本上本身装有Ubuntu 20,本文记录搭建Ubuntu 20开发环境的过程。
      1 配置软件源
      官网里的配置对Ubuntu 20来说不好用,改为:

      gmei@dell:~$ cat /etc/apt/sources.list
      # deb cdrom:[Ubuntu 20.04.3 LTS _Focal Fossa_ - Release amd64 (20210819)]/ focal main restricted
      
      # deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
      # deb http://mirrors.aliyun.com/ubuntu/ focal universe
      # deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
      # deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
      # deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
      # deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse
      # deb http://security.ubuntu.com/ubuntu/ focal-security universe restricted multiverse main
      
      
      
      deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
      ##测试版源
      deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
      # 源码
      deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
      deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
      ##测试版源
      deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
      
      
      gmei@dell:~$ 
      

      2 安装依赖软件包
      官网指引安装如下软件包:

      gcc,binutils,bzip2,flex, python,perl,make,ia32-libs,find,grep,diff,unzip,gawk,getopt,subversion,libz-dev
      

      安装报错:

      gmei@dell:~/share/r329/evb5$ sudo apt-get install -y gcc binutils bzip2 flex python perl make ia32-libs find grep diff unzip gawk getopt subversion libz-dev
      Reading package lists... Done
      Building dependency tree       
      Reading state information... Done
      Note, selecting 'python-is-python2' instead of 'python'
      Note, selecting 'zlib1g-dev' instead of 'libz-dev'
      Package diff is not available, but is referred to by another package.
      This may mean that the package is missing, has been obsoleted, or
      is only available from another source
      However the following packages replace it:
        diffutils diffutils:i386
      
      Package ia32-libs is not available, but is referred to by another package.
      This may mean that the package is missing, has been obsoleted, or
      is only available from another source
      However the following packages replace it:
        lib32z1
      
      E: Package 'ia32-libs' has no installation candidate
      E: Unable to locate package find
      E: Package 'diff' has no installation candidate
      E: Unable to locate package getopt
      gmei@dell:~/share/r329/evb5$ 
      

      系统已自带diff、find、getopt命令,忽略之;用lib32z1替换ia32-libs,用python-is-python2替换python,用zlib1g-dev替换libz-dev。用以下命令即可成功安装。

      sudo apt-get install -y gcc binutils bzip2 flex python-is-python2 perl make lib32z1 grep unzip gawk subversion zlib1g-dev
      

      官网提示,对于Ubuntu 16.04以上版本,还要执行以下命令:

      sudo apt-get install libc6:i386 libstdc++6:i386 lib32ncurses5 lib32z1
      

      提示:

      E: Unable to locate package lib32ncurses
      

      解决方案:用lib32ncurses5-dev替换lib32ncurses,用以下命令即可成功安装。

      sudo apt-get install libc6:i386 libstdc++6:i386 lib32ncurses5-dev lib32z1
      

      为了在Ubuntu 20.04上成功编译,还需要执行以下命令安装额外的软件包:

      sudo apt-get install -y build-essential git-core libncurses5-dev quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs lib32z1-dev lib32stdc++6 libstdc++6
      

      3 编译
      make -j1后报错:

      gdbusauth.c: In function '_g_dbus_auth_run_server':
      gdbusauth.c:1298:11: error: '%s' directive argument is null [-Werror=format-overflow=]
       1298 |           debug_print ("SERVER: WaitingForBegin, read '%s'", line);
            |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      cc1: some warnings being treated as errors
      make[8]: *** [Makefile:3530: libgio_2_0_la-gdbusauth.lo] Error 1
      make[8]: Leaving directory '/home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/host/glib-2.50.1/gio'
      make[7]: *** [Makefile:4357: all-recursive] Error 1
      make[7]: Leaving directory '/home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/host/glib-2.50.1/gio'
      make[6]: *** [Makefile:1981: all] Error 2
      make[6]: Leaving directory '/home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/host/glib-2.50.1/gio'
      make[5]: *** [Makefile:1201: all-recursive] Error 1
      make[5]: Leaving directory '/home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/host/glib-2.50.1'
      make[4]: *** [Makefile:843: all] Error 2
      make[4]: Leaving directory '/home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/host/glib-2.50.1'
      make[3]: *** [Makefile:177: /home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/host/glib-2.50.1/.built] Error 2
      make[3]: Leaving directory '/home/gmei/share/r329/evb5/package/libs/glib2'
      make[2]: *** [package/Makefile:192: package/libs/glib2/host/compile] Error 2
      make[2]: Leaving directory '/home/gmei/share/r329/evb5'
      make[1]: *** [package/Makefile:189: /home/gmei/share/r329/evb5/out/r329-evb5/staging_dir/target/stamp/.package_compile] Error 2
      make[1]: Leaving directory '/home/gmei/share/r329/evb5'
      make: *** [/home/gmei/share/r329/evb5/build/toplevel.mk:306: world] Error 2
      

      找到gdbusauth.c文件:

      gmei@dell:~/share/r329/evb5$ find -name gdbusauth.c
      ./out/r329-evb5/compile_dir/target/host/glib-2.50.1/gio/gdbusauth.c
      ./out/r329-evb5/compile_dir/target/glib-2.50.1/gio/gdbusauth.c
      gmei@dell:~/share/r329/evb5$
      

      在报错语句前加入非空判断即可解决问题。继续编译,gdbusmessage.c的2698行还会报错,用同样的方式处理。继续编译,报错:

      gawk -f ./mkstrtable.awk -v textidx=2 -v nogettext=1 \
      	-v prefix=GPG_ERR_ -v namespace=errnos_ \
      	./errnos.in >errnos-sym.h
      gawk: fatal: cannot use gawk builtin `namespace' as variable name
      make[6]: *** [Makefile:1324: errnos-sym.h] Error 2
      make[6]: Leaving directory '/home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/libgpg-error-1.27/src'
      make[5]: *** [Makefile:474: all-recursive] Error 1
      make[5]: Leaving directory '/home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/libgpg-error-1.27'
      make[4]: *** [Makefile:405: all] Error 2
      make[4]: Leaving directory '/home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/libgpg-error-1.27'
      make[3]: *** [Makefile:81: /home/gmei/share/r329/evb5/out/r329-evb5/compile_dir/target/libgpg-error-1.27/.built] Error 2
      make[3]: Leaving directory '/home/gmei/share/r329/evb5/package/libs/libgpg-error'
      make[2]: *** [package/Makefile:193: package/libs/libgpg-error/compile] Error 2
      make[2]: Leaving directory '/home/gmei/share/r329/evb5'
      make[1]: *** [package/Makefile:189: /home/gmei/share/r329/evb5/out/r329-evb5/staging_dir/target/stamp/.package_compile] Error 2
      make[1]: Leaving directory '/home/gmei/share/r329/evb5'
      make: *** [/home/gmei/share/r329/evb5/build/toplevel.mk:306: world] Error 2
      

      将out/r329-evb5/compile_dir/target/libgpg-error-1.27/src/目录下的编译相关文件Makefile、Makefile.am、Makefile.in、mkstrtable.awk里的namespace都改为pkg_namespace,编译通过。
      做上述改动后能编译通过,但make clean之后再次编译,还是报同样的错。原因在于clean之后,会从dl目录下拷贝压缩包解压到out目录,覆盖了手动改过的内容。彻底的解决办法是,解压dl目录下的glib-2.50.1.tar.xz,修改其中的gdbusauth.c和gdbusmessage.c文件,打包后放回dl目录;解压dl目录下的libgpg-error-1.27.tar.bz2,修改其中的Makefile、Makefile.am、Makefile.in和mkstrtable.awk,打包后放回dl目录。
      4 编译加速
      编译在开发过程中得反复进行,提升编译效率就是提升开发效率。编译是CPU密集型和IO密集型任务,可从CPU效率和IO效率两个方面来提升编译效率。
      4.1 提升CPU效率——多线程编译
      make -j1只启用一个线程来编译,编译整个软件包花50分钟以上:

      #### make completed successfully (51:17 (mm:ss)) ####
      

      make -j尽可能启用多的线程来编译,编译整个R329软件包花18分钟以下:

      #### make completed successfully (17:53 (mm:ss)) ####
      

      结论:启用多线程多编译效率提升很明显,可节省65%时间。
      4.2 提升IO效率——整个软件包放入内存
      用dd命令测试硬盘和内存读写速度:

      gmei@dell:~/share/shm_test$ dd if=/dev/zero of=file.4k.1g bs=4k count=250000 oflag=direct
      250000+0 records in
      250000+0 records out
      1024000000 bytes (1.0 GB, 977 MiB) copied, 7.05123 s, 145 MB/s
      gmei@dell:~/share/shm_test$ sudo dd if=/dev/zero of=/dev/shm/r329/file.4k.1g bs=4k count=250000
      [sudo] password for gmei: 
      250000+0 records in
      250000+0 records out
      1024000000 bytes (1.0 GB, 977 MiB) copied, 0.507771 s, 2.0 GB/s
      gmei@dell:~/share/shm_test$ 
      gmei@dell:~/share/shm_test$ 
      gmei@dell:~/share/shm_test$ dd if=file.4k.1g of=/dev/null iflag=direct
      2000000+0 records in
      2000000+0 records out
      1024000000 bytes (1.0 GB, 977 MiB) copied, 51.0799 s, 20.0 MB/s
      gmei@dell:~/share/shm_test$ sudo dd if=/dev/shm/r329/file.4k.1g of=/dev/null
      2000000+0 records in
      2000000+0 records out
      1024000000 bytes (1.0 GB, 977 MiB) copied, 2.25148 s, 455 MB/s
      gmei@dell:~/share/shm_test$ 
      

      可知,内存的写速度是硬盘的2000/145=13.7倍,内存的读速度是硬盘的455/20=22.7倍。Dell笔记本配置了32G内存,R329软件包编译后大小为19G,将Ubuntu的共享内存扩大到25G,最大节点数扩大为10000000,将Tina SDK拷贝到共享内存中:

      gmei@dell:~/share/r329/evb5$ sudo mount -o size=25G -o nr_inodes=10000000 -o noatime,nodiratime -o remount /dev/shm
      gmei@dell:~/share/r329/evb5$ sudo mkdir -p /dev/shm/r329/evb5
      gmei@dell:~/share/r329/evb5$ sudo cp -rf ./* /dev/shm/r329/evb5/
      gmei@dell:~/share/r329/evb5$ 
      

      cd到/dev/shm/r329/evb5/,再次用make -j编译

      #### make completed successfully (17:53 (mm:ss)) ####
      

      可知,花费的时间与放在硬盘中分秒不差,提升IO性能不能提升编译效率。
      结论:六代4核i7处理器与SATA固态硬盘搭配起来跑Ubuntu 20编译R329软件包,编译效率的瓶颈在于处理器性能。

      Y 1 Reply Last reply Reply Quote Share 0
      • Y
        yimu163com LV 4 @yimu163com last edited by

        @yimu163com 有无大佬使用E5处理器编译的?效果如何?

        1 Reply Last reply Reply Quote Share 0
        • 1 / 1
        • First post
          Last post

        Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

        行为准则 | 用户协议 | 隐私权政策