交叉开发环境

交叉开发环境的网络设置(arm_linux)

主机(windowsXP) :192.168.1.106

主机(虚拟机Linux):192.168.1.112

开发板(arm_linux):192.168.1.6

 

三个操作系统的IP地址要设在一个网段里(192.168.1.*)

当开发板启动时进入bootloader模式,要使用其网络传输文件功能时,bootloaderIP也要设为一个网段192.168.1.55(有的bootloader需要设置MAC地址12:45:77:11:22:ab)

 

交叉开发环境构建:

1. 安装交叉开发工具

a) 拷贝交叉开发工具软件包到指定目录.( cross-3.3.2.tar.bz2版本)

#cp cross-3.3.2.tar.bz2  /usr/local/arm/

在当前目录解压文件

#tar xjvf arm.tar.bz2

b) 设置编译器路径

#vi /etc/profile

下面是profile要添加内容的位置

#path manipulation

if [ id �Cu = 0]; then

pathmunge /sbin

pathmunge /usr/sbin

pathmunge /usr/local/sbin 

pathmunge /usr/local/arm/3.3.2/bin //这行是添加的编译器路径

fi

保存profile文件

#sh /etc/profile

//系统注销,使新的profile文件生效.

如安装好,shell命令行输入arm,可用TAB,命令补齐打出arm-linux-

查看gcc版本号

#arm-linux-gcc �Cv

 

2. 配置NFS

开发板同虚拟机IP地址要在一个网段里.

可手工修改NFS配置文件exports.

#vi /etc/exports

/home    192.168.1.*   (rw,sync)

//上述设置内容是/home目录,可以被192.168.1.*网段挂载.

重启NFS服务

#service nfs restart

本地挂载测试.

#mount  192.168.1.112:/home  /mnt/nfs

//192.168.1.112linux IP,/home为可挂载的目录,/mnt/nfs为挂载到本机的目录(/mnt/nfs/目录要在存在,不存在可#mkdir /mnt/nfs创建).

#ls /mnt/nfs   //查看是否挂载成功.

开发板挂载

#ping 192.168.1.112  //首先虚拟机linux IP

#mount  -t  nfs  -o  nolock  192.168.1.112:/home  /mnt/nfs

#cd /mnt/nfs

 

3. 交叉开发调试程序

在虚拟机Linux建立程序的源文件.

#vi hello.c

#arm-linux-gcc �Co hello hello.c //使用arm-linux-gcc 编译源程序.

#cp hello /home    //编译好的可执行文件copymount的目录.

#chmod 777 hello  //修改执行文件的权限

在开发板的挂载目录运行测试.

[@/mnt/nfs]#./hello

 

 

tftp服务安装的问题

里面选择everything,导致没有安装tftp服务(典型的就是安装完成后没有/tftpboot目录,setup-->system services里面也没有tftp选项),这时若要重新完全安装就太麻烦了,可如下单独安装改服务:

如果用下面一条命令能够看到服务已经启动则不用安装否则需要按12点安装tftp-server服务器.

[arm@localhost arm]#netstat -a | grep tftp

udp 0 0 *:tftp *:*

有些客户在安装REDHAT LINUX 时,有时没有选Custom-->Packages 

1. 安装tftp的方法:

#rpm  �Civh   tftp-server-0.32-4.i386.rpm

iinstall   vverbose(详细的) hhash(输出#)

其中tftp-server-0.32-4.i386.rpmRedhat9的第3张光盘里面。

路径:/mnt/cdrom/RedHat/RPMS/

该软件也可从网上下载得到。

2. 修改配置文件

[root@localhost btools]#vi   /etc/xinetd.d/tftp

service tftp

{

disable = no

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /tftpboot

per_source = 11

cps = 100 2

flags = IPv4

}

 

检查tftp服务是否打开

[root@localhost btools]#chkconfig  --list

如果tftp的服务没有打开,则用下面命令打开tftp服务开关

[root@localhost btools]#chkconfig  tftp  on

重启服务

#/etc/init.d/xinetd  restart

#netstat -a | grep tftp

udp 0 0 *:tftp *:*

进入开发板的命令终端

#tftp  -g �Cr  hello 192.168.1.112

//从远程主机192.168.1.112下载文件hello

#ls//查看下文件是否下载成功

#chmod 777 hello   //修改权限

#./hello//运行程序


你可能感兴趣的:(linux,嵌入式,交叉开发)