安装步骤

1、准备工具安装目录

将压缩包gcc-linaro-arm-linux-bnueabihf-4.9-2014.07_linux.tar存放在一个目录下,这个目录就是你等会解压缩的目录,以后这个目录就不能随便删掉了,我的存放路径是/home/zyr/Am335x/Sourcefiletools,如下图,记住这个路径,等会还会用到。

  1. zyr@ubuntu:~/Am335x/Sourcefiletools$ ls
  2. gcc-linaro-arm-linux-gnueabihf-4.9-.07_linux
  3. gcc-linaro-arm-linux-gnueabihf-4.9-.07_linux.tar
  4. zyr@ubuntu:~/Am335x/Sourcefiletools$ pwd
  5. /home/zyr/Am335x/Sourcefiletools
  6. zyr@ubuntu:~/Am335x/Sourcefiletools
 

2、安装软件

使用tar命令:tar xvf gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar将Sourcefiletools文件夹下的gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux.tar解压缩安装到当前目录。通过下图可以看到解压成功了,并且解压后的文件存放在了

  1. /home/zyr/Am335x/Sourcefiletools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux

文件夹下,如下图所示,这个存放路径可得记住,如下图

  1. zyr@ubuntu:~/Am335x/Sourcefiletools/gcc-linaro-arm-linux-gnueabihf-4.9-.07_linux$ ls
  2. arm-linux-gnueabihf bin lib libexec share
  3. zyr@ubuntu:~/Am335x/Sourcefiletools/gcc-linaro-arm-linux-gnueabihf-4.9-.07_linux$

3、配置系统环境变量

配置环境前先坐下普及:

Ubuntu不同目录下profile与bashrc的区别

/etc/profile  此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行,并从/etc/profile.d目录的配置文件中搜集shell的设置。

/etc/bash.bashrc  为每一个运行bash shell的用户执行此文件,当bash shell被打开时,该文件被读取。

~/.bash_profile  每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次,默认情况下,他设置一些环境变量,执行用户的.bashrc文件。

~/.bashrc  该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取。

~/.bash_logout  当每次退出系统(退出bash shell)时,执行该文件。

另外,/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系。

~/.bash_profile  是交互式、login 方式进入 bash 运行的。

~/.bashrc  是交互式 non-login 方式进入 bash 运行的。

通常二者设置大致相同,所以通常前者会调用后者。

接下来配置系统环境变量,把交叉编译工具链的路径添加到环境变量PATH中去,这样就可以在任何目录下使用这些工具。记下上一步中的安装路径,使用命令:vim  /home/aldrich/.bashrc 编辑.bashrc文件,添加环境变量。

在该文件中最后一行添加:

  1. sudo gedit /etc/profile
  1. # /etc/profile: system-wide .profile file for the Bourne shell (sh())
  2. # and Bourne compatible shells (bash(), ksh(), ash(), ...).
  3.  
  4. if [ "$PS1" ]; then
  5. if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
  6. # The file bash.bashrc already sets the default PS1.
  7. # PS1='\h:\w\$ '
  8. if [ -f /etc/bash.bashrc ]; then
  9. . /etc/bash.bashrc
  10. fi
  11. else
  12. if [ "`id -u`" -eq ]; then
  13. PS1='# '
  14. else
  15. PS1='$ '
  16. fi
  17. fi
  18. fi
  19.  
  20. if [ -d /etc/profile.d ]; then
  21. for i in /etc/profile.d/*.sh; do
  22. if [ -r $i ]; then
  23. . $i
  24. fi
  25. done
  26. unset i
  27. fi
  28. export PATH=$PATH:/home/zyr/Am335x/Sourcefiletools/gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux/bin/

这个路径就是那个bin目录所在的路径,可能你的不一样,按照你实际的目录填就可以了,

编写完保存就好了

4、使环境变量生效

使用命令:source /etc/profile 使环境变量生效

5、检查环境变量是否设置成功

在终端上输入命令 arm-linux-gnueabifh- 再按Tab键,可以看到下图,说明环境变量设置成功了

  1. zyr@ubuntu:~$ arm-linux-gnueabihf-
  2. arm-linux-gnueabihf-addr2line arm-linux-gnueabihf-gfortran
  3. arm-linux-gnueabihf-ar arm-linux-gnueabihf-gprof
  4. arm-linux-gnueabihf-as arm-linux-gnueabihf-ld
  5. arm-linux-gnueabihf-c++ arm-linux-gnueabihf-ld.bfd
  6. arm-linux-gnueabihf-c++filt arm-linux-gnueabihf-ldd
  7. arm-linux-gnueabihf-cpp arm-linux-gnueabihf-ld.gold
  8. arm-linux-gnueabihf-dwp arm-linux-gnueabihf-nm
  9. arm-linux-gnueabihf-elfedit arm-linux-gnueabihf-objcopy
  10. arm-linux-gnueabihf-g++ arm-linux-gnueabihf-objdump
  11. arm-linux-gnueabihf-gcc arm-linux-gnueabihf-pkg-config
  12. arm-linux-gnueabihf-gcc-4.9. arm-linux-gnueabihf-pkg-config-real
  13. arm-linux-gnueabihf-gcc-ar arm-linux-gnueabihf-ranlib
  14. arm-linux-gnueabihf-gcc-nm arm-linux-gnueabihf-readelf
  15. arm-linux-gnueabihf-gcc-ranlib arm-linux-gnueabihf-size
  16. arm-linux-gnueabihf-gcov arm-linux-gnueabihf-strings
  17. arm-linux-gnueabihf-gdb arm-linux-gnueabihf-strip
  18. zyr@ubuntu:~$ arm-linux-gnueabihf-

6、安装32位库兼容包(因为系统是64位的,安装的交叉编译器是32位的)

sudo apt-get install ia32-libs 装一些32位的库

出现上述界面是因为Ubuntu16.04版本已不支持ia32-libs的软件包,而是使用了lib32ncurses5、lib32z1软件包做为替代,所以在Ubuntu16.04版本当中应该安装执行:

  1. sudo apt-get install lib32ncurses5 lib32z1

待安装完32位的库之后,再使用命令:arm-linux-gnueabihf-gcc -v,出现这种错误:

ubuntu arm-linux-gnueabihf-gcc: error while loading shared libraries: libstdc++.so.6

安装:

  1. sudo apt-get install lib32stdc++6

然后再查看arm-linux-gnueabihf-gcc -v就可以看到版本了:

  1. zyr@ubuntu:~/Am335x/Kernel/linux-4.1.$ arm-linux-gnueabihf-gcc -v
  2. Using built-in specs.
  3. COLLECT_GCC=arm-linux-gnueabihf-gcc
  4. COLLECT_LTO_WRAPPER=/home/zyr/Am335x/Sourcefiletools/gcc-linaro-arm-linux-gnueabihf-4.9-.07_linux/bin/../libexec/gcc/arm-linux-gnueabihf/4.9./lto-wrapper
  5. Target: arm-linux-gnueabihf
  6. Configured with: /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/gcc-linaro-4.9-2014.07/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install --with-sysroot=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran --disable-multilib --enable-multiarch --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=hard --with-pkgversion='crosstool-NG linaro-1.13.1-4.9-2014.07 - Linaro GCC 4.9-2014.07' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-mpfr=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-mpc=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-isl=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-cloog=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --with-libelf=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/arm-linux-gnueabihf/build/static --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-plugin --enable-gold --with-local-prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/arm-linux-gnueabihf/libc --enable-c99 --enable-long-long --with-mode=thumb --disable-multilib --with-float=hard
  7. Thread model: posix
  8. gcc version 4.9. (prerelease) (crosstool-NG linaro-1.13.-4.9-2014.07 - Linaro GCC 4.9-2014.07)

7、交叉编译工具验证--编译内核:

在内核目录下建立如下脚本文件(bulid-kernel.sh):

  1. #! /bin/bash
  2. echo "Configure the kernel"
  3. until
  4. echo "1.make the omap2plus.defconfig"
  5. echo "2.make the menuconfig( Boot options -> Kernel command line type (root=/dev/mmcblk0p2 rootwait console=ttyo0,115200) )"
  6. echo "3.make the dtb"
  7. echo "4.make the zImage"
  8. echo "5.make the uImage"
  9. echo "6.make the distclean"
  10. echo "7.make the modules"
  11. echo "8.quit"
  12.  
  13. read input
  14. test $input =
  15. do
  16. case $input in
  17. )make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap2plus_defconfig;;
  18. )make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig;;
  19. )make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x-boneblack.dtb;;
  20. )make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage;;
  21. )make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x80008000 uImage;;
  22. )make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean;;
  23. )make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8 modules;;
  24. )echo"quit";;
  25. esac
  26. done

运行脚本文件bulid-kernel.sh

sh build-kernel.sh

  1. zyr@ubuntu:~/Am335x/Kernel/linux-4.1.$ sh build-kernel.sh
  2. Configure the kernel
  3. .make the omap2plus.defconfig
  4. .make the menuconfig( Boot options -> Kernel command line type (root=/dev/mmcblk0p2 rootwait console=ttyo0,) )
  5. .make the dtb
  6. .make the zImage
  7. .make the uImage
  8. .make the distclean
  9. .make the modules
  10. .quit
  11.  
  12. #
  13. # configuration written to .config
  14. #
  15. .make the omap2plus.defconfig
  16. .make the menuconfig( Boot options -> Kernel command line type (root=/dev/mmcblk0p2 rootwait console=ttyo0,) )
  17. .make the dtb
  18. .make the zImage
  19. .make the uImage
  20. .make the distclean
  21. .make the modules
  22. .quit

输入控制命令2时产生错误:

  1. 执行make menuconfig时出现如下错误
  2. @ubuntu:/home/dev/busybox-1.19.# make menuconfig
  3. HOSTCC scripts/kconfig/lxdialog/checklist.o
  4. In file included from scripts/kconfig/lxdialog/checklist.c:::
  5. scripts/kconfig/lxdialog/dialog.h::: fatal error: curses.h: 没有那个文件或目录
  6. compilation terminated.
  7. make[]: *** [scripts/kconfig/lxdialog/checklist.o] 错误
  8. make[]: *** [menuconfig] 错误
  9. make: *** [menuconfig] 错误
  10.  
  11. 这时因为ubuntu系统中缺少一个套件 ncurses devel ,把此套件安装下即可
  12. apt-get install libncurses5-dev

按以上方法解决,最终可以配置内核了。

ubuntu16.04(64位)建立交叉编译环境,并配置编译内核的更多相关文章

  1. VisualBox ubuntu14.04 64位 android4.4.4源码编译总结

    转载请保留出处:http://www.cnblogs.com/wi100sh/p/4337907.html 折腾了好几天,今天终于编译通过,用了4个多小时,太不容易了.如下图所示: 软件环境 虚拟机: ...

  2. 【转】Ubuntu 64位系统安装交叉编译环境一直提醒 没有那个文件或目录

    安装交叉编译环境搞了一个晚上 一直提示 root@zqs-pc:~# arm-linux-gcc/usr/local/arm/4.3.2/bin/arm-linux-gcc: 行 3: /usr/lo ...

  3. 阿里云服务器(Ubuntu16.04 64位)远程连接

    购买阿里云服务器 1.打开阿里云官方网站,账号登录,选择产品中的云服务器 ECS 2.根据自身需求,选择合适的阿里云服务器系统,(1)点击一键购买,(2)选择地域,(3)根据自身需求,选择系统,这里选 ...

  4. 阿里云服务器(Ubuntu16.04 64位)的使用

    购买阿里云服务器 1.打开阿里云官方网站,账号登录,选择产品中的云服务器 ECS 2.根据自身需求,选择合适的阿里云服务器系统,(1)点击一键购买,(2)选择地域,(3)根据自身需求,选择系统,这里选 ...

  5. Ubuntu16.04 64位编译安装Hi3520D_SDK_V1.0.4.0

    1.复制uboot/tools/mkimage到环境变量路径 2.修改kernel/timeconst.pl,删除define 3.busybox makefile修改: /itc_work/hi35 ...

  6. 关于全志A20的Ubuntu12.04 64位系统下环境配置及编译过程笔记【转】

    本文转载自:https://blog.csdn.net/buqingbuyuan/article/details/43370199 在安装Ubuntu系统之后,安装编译所需的GCC等工具,一般选用GC ...

  7. Ubuntu 14.04(64位)+GTX970+CUDA8.0+Tensorflow配置 (双显卡NVIDIA+Intel集成显卡) ------本内容是长时间的积累,有时间再详细整理

    (后面内容是本人初次玩GPU时,遇到很多坑的问题总结及尝试解决办法.由于买独立的GPU安装会涉及到设备的兼容问题,这里建议还是购买GPU一体机(比如https://item.jd.com/396477 ...

  8. idea2016 64位 安装,jdk环境变量配置

      idea 激活服务器地址: 地址1: http://www.iteblog.com/idea/key.php     地址2:  http://idea.qinxi1992.cn/ intelli ...

  9. ubuntu16.04 64位安装tftp服务器

    1.安装tftpd-hpa和xinetd sudo apt-get install tftpd-hpa xined2.针对64位操作系统安装openbsd-inetd apt-get install ...

随机推荐

  1. Java开发者应该列入年度计划的5件事

    本文写了我今年计划要做的5件事.为了能跟踪计划执行的进度,就把这些事都列了出来.我觉得这些事对其它Java开发者而言也是不错的参考方向. 1.开发一个应用,通过Java来操作一种NoSQL数据库实现存 ...

  2. 在window 8 或windows2012 上用命令行安装framework3.5 方法

    找到对应操作系统安装目录的sources文件夹下的sxs文件夹,拷贝到本地电脑,如F:盘 根目录下 CMD(管理员身份)命令: dism.exe /online /enable-feature /fe ...

  3. [Ubuntu 14.04] 安装Flash && 安装QQ

    一.安装Flash 打开Firefox浏览器弹出的Flash安装提醒早都烦死了,那么Ubuntu14.04怎么安装Flash呢? 1.32位系统命令行安装: 第一步 更新库: sudo apt-get ...

  4. 用C代码简要模拟实现一下RPC(远程过程调用)并谈谈它在代码调测中的重要应用【转】

    转自:http://blog.csdn.net/stpeace/article/details/44947925 版权声明:本文为博主原创文章,转载时请务必注明本文地址, 禁止用于任何商业用途, 否则 ...

  5. Python2和Python3同时安装到Windows

    上月已经把Python2安装好了,安装目录和及其下的Scripts也在安装时添加到了环境变量PATH中,可以使用python命令执行程序. 安装包:python-2.7.14.amd64.msi(没有 ...

  6. python并行计算(持续更新)

    工作中需要对tensorflow 的一个predict结果加速,利用python中的线程池 def getPPLs(tester,datas): for line in datas: tester(l ...

  7. robotframework-ride多次运行,有时候不显示日志信息

    解决方法: 修改"C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunner.py"文件pop方法中  ...

  8. No.4 selenium学习之路之iframe

    查看iframe: 1.top window ——可以直接进行定位

  9. AdvStringGrid 固定行、列

  10. HDU 1507 Uncle Tom's Inherited Land(最大匹配+分奇偶部分)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1507 题目大意:给你一张n*m大小的图,可以将白色正方形凑成1*2的长方形,问你最多可以凑出几块,并输 ...