日期:2014-05-16  浏览次数:20673 次

嵌入式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 a