嵌入式linux应用开发完全手册学习笔记二(嵌入式linux开发环境搭建)

嵌入式linux开发环境搭建


硬件环境构建


主机与目标板结合的交叉开发模式
在主机编辑、编译软件,然后在目标板上运行和验证程序


目标板s3c6410(下周入手)


进行嵌入式linux开发时一般步骤
1 在主机上编译bootloader通过jtag烧入开发板
  通常选用具有串口传输、网络传输、烧写flash功能的bootloader
2 在主机上编译嵌入式linux内核,通过bootlader烧入开发板或直接启动
  内核应支持网络文件系统(nfs),即将应用程序放在主机上,单板启动嵌入
  式linux内核后,通过网络来获取程序,然后运行
3 在主机上编译各类应用程序,开发板启动内核后通过nfs运行它们,验证
  后再烧入开发板




软件环境构建


1虚拟机安装
2虚拟机安装linux
 vmware有四种连接方式
    网桥网络birdged 
    网络地址翻译网络(nat)
    仅为主机网络(host-only)
    客户网络
 如果接上网线,可使用网桥网络
 如果没有接网线,可以使用nat网络,在windows和linux 间进行通信


安装、配置、启动ftp、ssh和nfs服务
ssh
http://blog.csdn.net/retacn_yue/article/details/8454927
nfs
http://blog.csdn.net/retacn_yue/article/details/8454842
tftp
http://blog.csdn.net/retacn_yue/article/details/8454909


基本的开发环境


安装交叉编译工具链
常用的三种方法:
1 分步编译和安装交叉编译人具链所需要的库和源代码
2 通过crosstool脚本工具来实现一次编译生成交叉编译工具链
3 下载已编译好的工具链
  
使用crosstool-0.43制作交叉编译工具链
下载crosstool-0.43
官网地址:http://kegel.com/crosstool/
地址http://kegel.com/crosstool/crosstool-0.43.tar.gz 


解压文件
[root@localhost crosstool-0.43]# tar -xzvf crosstool-0.43.tar.gz 


其他资源
binutils-2.16.1.tar.gz  glibc-2.3.2.tar.gz
gcc-3.3.6.tar.bz2       glibc-linuxthreads-2.3.2.tar.bz2
gcc-4.1.0.tar.bz2       linux-2.6.18.tar.gz
gdb-6.5.tar.bz2         linux-libc-headers-2.6.12.0.tar.bz2


在/home/retacn/downloads目录下解压




建立角本文件
[root@localhost crosstool-0.43]# cd /home/retacn/crosstool-0.43
[root@localhost crosstool-0.43]# cp demo-arm.sh arm.sh
[root@localhost crosstool-0.43]# vi arm.sh 
内容如下:
#!/bin/sh
# This script has one line for each known working toolchain
# for this architecture.  Uncomment the one you want.
# Generated by generate-demo.pl from buildlogs/all.dats.txt


set -ex
#修改此处
TARBALLS_DIR=/home/retacn/downloads
RESULT_TOP=/home/retacn/crosstool


export TARBALLS_DIR RESULT_TOP
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES


# Really, you should do the mkdir before running this,
# and chown /opt/crosstool to yourself so you don't need to run as root.
mkdir -p $RESULT_TOP


#eval `cat arm.dat gcc-2.95.3-glibc-2.1.3.dat` sh all.sh --notest
#eval `cat arm.dat gcc-2.95.3-glibc-2.2.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-2.95.3-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.2.3-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.2.3-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.2.3-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.3.6-glibc-2.2.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.3.6-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.3.6-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.3.6-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.4.5-glibc-2.2.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.4.5-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.4.5-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.4.5-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.4.5-glibc-2.3.5.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.4.5-glibc-2.3.5-tls.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.4.5-glibc-2.3.6.dat` sh all.sh --notest
#eval `cat arm.dat gcc-3.4.5-glibc-2.3.6-tls.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.0.2-glibc-2.2.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.0.2-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.0.2-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.0.2-glibc-2.3.5.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.0.2-glibc-2.3.5-tls.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.0.2-glibc-2.3.6.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.0.2-glibc-2.3.6-tls.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.1.0-glibc-2.2.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.1.0-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm.dat gcc-4.1.0-glibc-2.3.2-tls.dat` sh all.sh --notest
eval `cat arm.dat gcc-4.1.1-glibc-2.3.2.dat` sh all.sh --notest --gdb


echo Done.






建立配置文件
1
[root@localhost crosstool-0.43]# vi arm.dat


修改内容如下:
KERNELCONFIG=`pwd`/arm.config
#表示编译出来的工具样式
TARGET=arm-linux
TARGET_CFLAGS="-O"

[root@localhost crosstool-0.43]# vi gcc-4.1.1-glibc-2.3.2.dat


修改内容如下:
BINUTILS_DIR=binutils-2.16.1
GCC_CORE_DIR=gcc-3.3.6
GCC_DIR=gcc-4.1.1
GLIBC_DIR=glibc-2.3.2
#定义版本
LINUX_DIR=linux-2.6.18
LINUX_SANITIZED_HEADER_DIR=linux-libc-headers-2.6.12.0
GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.2
GDB_DIR=gdb-6.5


执行角本
[root@localhost retacn]# mkdir crosstool
[root@localhost retacn]# chmod 777 crosstool
[root@localhost retacn]# chmod 777 crosstool-0.43
[root@localhost retacn]# su - retacn
[retacn@localhost retacn]# ./arm.sh




在环境变量path中添加路径
export PATH=/home/retacn/crosstool/gcc-4.1.1-glibc-2.3.2/arm-linux/bin:$PATH
使环境变量生效
source /etc/profile


最后在/home/retacn/crosstool下生成新的交叉编译工具
可以使用以下命令进行测试
arm-linux-gcc -v








编译出现错误
chmod: changing permissions of `/home/retacn/crosstool-0.43/config.guess': 


Operation not permitted
GLIBC_ADDON_OPTIONS not set, so guessing addons from GLIBCTHREADS_FILENAME and 


GLIBCCRYPT_FILENAME
/home/retacn/crosstool-0.43/crosstool.sh: line 110: bison: command not found
crosstool: You don't have bison installed.


[root@localhost ~]# yum install bison       <----------------语法分析器


chmod: changing permissions of `/home/retacn/crosstool-0.43/config.guess': 


Operation not permitted
GLIBC_ADDON_OPTIONS not set, so guessing addons from GLIBCTHREADS_FILENAME and 


GLIBCCRYPT_FILENAME
/home/retacn/crosstool-0.43/crosstool.sh: line 111: flex: command not found
crosstool: You don't have flex installed


[root@localhost ~]# yum install flex       <----------------词法分析器



S3C2440芯片没有硬件浮点数(hardfloat),很多软件只能采用软件浮点数(softfloat)


的编译器编译,恰巧现在高版本的u-boot只能采用支持softfloat的交叉编译器编译,否则


会在编译结束前的链接那一步出现不支持softfloat的错误。
        解决办法:
        要解决这个错误的唯一办法就是采用支持softfloat的交叉编译器编译uboot。下面


来说一下制作softfloat的具体过程。
        和上述制作交叉编译器过程一样,不同之处:1.修改arm.dat内容如下,参考arm-


softfloat.dat内容修改。
KERNELCONFIG=`pwd`/arm.config
TARGET=arm-softfloat-linux
TARGET_CFLAGS="-O"
GCC_EXTRA_CONFIG="--with-float=soft"
GLIBC_EXTRA_CONFIG="--without-fp"
        编译完之后,会在/opt/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-


linux/bin生成支持softfloat的交叉编译器,如下所示。
arm-softfloat-linux-addr2line arm-softfloat-linux-g++ arm-softfloat-linux-ld     


  arm-softfloat-linux-size              arm-softfloat-linux-ar         arm-


softfloat-linux-gcc        arm-softfloat-linux-nm  arm-softfloat-linux-strings 


arm-softfloat-linux-as         arm-softfloat-linux-gcc-3.4.5        arm-


softfloat-linux-objcopy     arm-softfloat-linux-strip


arm-softfloat-linux-c++      arm-softfloat-linux-gccbug     arm-softfloat-linux


-objdump  fix-embedded-paths  arm-softfloat-linux-c++filt    arm-softfloat-


linux-gcov       arm-softfloat-linux-ranlib arm-softfloat-linux-cpp        arm-


softfloat-linux-gprof      arm-softfloat-linux-readelf






make[1]: *** [configure-gdb] 错误1
RED HAT系列如果出现No curses/termcap library found提示,
你需要安装:
termcap-11.0.1-16.noarch.rpm
libtermcap-devel-2.0.8-35.i386.rpm
ncurses-5.3-4.i386.rpm
[root@localhost Server]# rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm 
[root@localhost Server]# rpm -ivh termcap-5.5-1.20060701.1.noarch.rpm 
[root@localhost Server]# rpm -ivh ncurses-5.5-24.20060715.i386.rpm 

posted @ 2013-01-16 20:55  retacn_yue  阅读(273)  评论(0编辑  收藏  举报