基于Zynq的GNULinux在线编译调试记录

 

--20171228

1、实验环境

         硬件环境:联想ThinkPad E430(内存加到10G)、显示屏×2、VGA线×1、HDMI线×1

、鼠标×2、键盘×1、USB分线器×1、ZedBoard开发板套件×1、AD-FMCOMMS2-EBZ×1、网线×1、SD卡×1。

         windows软件环境(E430运行软件):Window 7、VMware Workstation Pro12、串口调试助手、Win32DiskImager、VMware Workstation Pro12虚拟机上安装ubuntu-14.04.5-desktop-amd64。

         虚拟机运行ubuntu-14.04.5-desktop-amd64系统软件环境:gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux、eleclipce等。

         ZedBoard运行系统:2016_R2-2017_06_29、内核(linux-2017_R1)。

2、软件安装

2.1、安装VMware Workstation Pro12

软件:VMware Workstation 12 Pro

版本:12.0.1 build-3160714

软件来源:http://bbs.feng.com/read-htm-tid-9815751.html

安装教程:VMware Workstation 12 Pro 虚拟机安装步骤详解_百度经验

2.2、安装虚拟系统ubuntu-14.04.5-desktop-amd64

      版本:14.04.5

软件来源:https://www.ubuntu.com/download/desktop

安装教程:VMware12安装虚拟机教程、Ubuntu16.04安装教程_百度经验

         注意:可参照以下链接提升一下VMware的运行速度:

                                             http://www.jb51.net/article/97295.htm

2.3、交叉编译环境的搭建

         软   件:gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz

         软件来源:https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabihf/

 

2.3.1、Ubuntu14.04  64bit系统下安装标准的C开发环境

           sudo apt-get install gcc g++ libgcc1 libg++ make gdb

或者  sudo apt-get install build-essential

 

 

2.3.2下载gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz

⑴ 在/usr/local/文件夹下建立名为ARM-toolchain的文件夹

       $ sudo mkdir /usr/local/ARM-toolchain

      

       ⑵ 下载gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz

       $ cd /usr/local/ARM-toolchain

         $sudo wget https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabihf/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz

 

       ⑶ 安装gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz

       解压gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz

         $ xz –d gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz

$ tar xvf gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar

 

         ⑷ 修改环境变量,把交叉编译器的路径加入到PATH

       修改/etc/bash.bashrc文件(此文件只对当前用户适用)

$sudo gedit  /etc/bash.bashrc

然后在文件的末尾空白处加入一下代码:

export      PATH=$PATH:/usr/local/ARM-toolchain/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin

 

⑸ 使新的环境变量生效(不用重启电脑)

              $ source /etc/bash.bashrc

        

         ⑹ 测试是否安装成功

                  $ arm-linux-gnueabi-gcc -v

执行上面的命令,显示arm-linux-gnueabi-gcc -v信息和版本:

zhangjun@zhangjun-virtual-machine:~/eclipse_workspace/hello/Debug$ arm-linux-gnueabihf-gcc -v

Using built-in specs.

COLLECT_GCC=arm-linux-gnueabihf-gcc

COLLECT_LTO_WRAPPER=/usr/local/ARM-toolchain/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/7.2.1/lto-wrapper

Target: arm-linux-gnueabihf

Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/arm-linux-gnueabihf/snapshots/gcc.git~linaro-7.2-2017.11/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --with-float=hard --with-fpu=vfpv3-d16 --with-mode=thumb --with-tune=cortex-a9 --with-arch=armv7-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/arm-linux-gnueabihf/_build/sysroots/arm-linux-gnueabihf --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabihf/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabihf --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu

Thread model: posix

gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)

 

2.4、安装Eclipse IDE for C/C++

         标准的Eclipse只支持JAVA开发,要进行C/C++程序开发,必须安装CDT插件。

在Ubuntu下,可用apt-get命令先安装eclipse-platform,再安装CDT插件eclipse-cdt,可以获得Eclipse C/C++开发环境。命令如下:

                  $sudo apt-get install eclipse-platform

$sudo apt-get install eclipse-cdt

安装完成,直接输入eclipse命令即可启动Eclipse环境。

 

3、Zynq硬件平台搭建

3.1 下载Linux 镜像

Download Linux Image地址:

http://swdownloads.analog.com/cse/2016_R2-2017_06_29.img.xz

         搭建平台教程:https://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz

         启动后照片如下图3.1所示:

 

图3.1

4、NFS服务器

         PC机虚拟机Ubuntu系统上NFS的安装详见:嵌入式Linux开发教程.PDF(周立功等编著)的6.4章节。

         ZedBoard的Ubuntu系统上NFS的安装,nfs安装完成后,启动服务器发现如下提示:

                   /mount.nfs:No such device

         出现这原因是因为内核没有开启nfs功能,因此我们需要重新编译内核。我们将按照下面教程重新编译内核:https://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz/software/linux/zynq_2015r2

         在该教程中的《Configure the kernel》步骤前用wget打开文件zynq_xcomm_adv7511

_defconfig,先要删除掉# CONFIG_NETWORK_FILESYSTEMS is not set这一行,并在该位置加上如下配置内容:

CONFIG_NETWORK_FILESYSTEMS=y

CONFIG_NFS_FS=y

CONFIG_NFS_V2=y

CONFIG_NFS_V3=y

# CONFIG_NFS_V3_ACL is not set

# CONFIG_NFS_V4 is not set

# CONFIG_NFS_SWAP is not set

CONFIG_ROOT_NFS=y

# CONFIG_NFSD is not set

CONFIG_LOCKD=y

CONFIG_LOCKD_V4=y

CONFIG_NFS_COMMON=y

CONFIG_SUNRPC=y

# CONFIG_SUNRPC_DEBUG is not set

# CONFIG_CEPH_FS is not set

# CONFIG_CIFS is not set

# CONFIG_NCP_FS is not set

# CONFIG_CODA_FS is not set

# CONFIG_AFS_FS is not set

         添加完成后,保存并关闭wget。然后执行《Configure the kernel》和之后的步骤。

5、交叉编译和远程调试

         程序在主机开发完毕,需要放到到ARM上运行的话,需要重设工程的编译器为交叉编译器并进行重新编译。

         具体操作详见:嵌入式Linux开发教程.PDF(周立功等编著)的10.4章节。

 

转载于:https://www.cnblogs.com/k030941503/p/9397255.html

你可能感兴趣的:(运维,开发工具,c/c++)