学习心得:嵌入式linux开发环境的建立
2007-05-21 15:18
405 查看
刚开始学习嵌入式的时候,周围没有人请教,幸好的是有一块板子,至少可以摸着石头过河。 在网上找了很多资料,看的很晕,没个人写的都不一样,针对不同的板子,也许方法各异,后来才发现都是殊途同归,即使有些微差异,也是大同。可是在初学者看来却很迷茫 ,至少我曾经经历过那样的迷茫。
绝大多数的linux软件开发都是以native方式进行的,就是本机(host)开发,调试,本机运行的方式。但这种方式不适合于嵌入式系统的软件开发,因为对于嵌入式系统的开发,没有足够的资源在板子上运行开发工具和调试工具。所以嵌入式系统的软件开发一般都是采用一种交叉编译调试的方式。交叉编译调试环境建立在一台主机(pc)上,开发是使用主机上的交叉编译、汇编及连接工具形成在目标板上可以运行的二进制代码。然后下载到板子上运行。
下面我将自己在s3c2410上的过程总结一下。也许跟别的板子有出入,前面说了,殊途同归。希望对需要用的着的朋友有用。
我用的是GX的arm9-s3c2410实验箱,主机环境是RedHat 9.0。过程如下:
一、建立主机开发环境
将光盘放入CDROM中,然后在终端输入
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
mount /dev/cdrom /mnt/cdrom
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
cd /mnt/cdrom
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
./install
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
系统会自动安装,这时只要等就行了,一般需要20分钟左右,这个过程中会有一些提示信息,也有时要等一段时间才会有提示信息输出,耐心等待,别等不及就终止了。
安装完成之后会在根目录下生成两个目录:
工作目录/s3c2410_linux和交叉编译环境目录/opt
s3c2410_linux下有这些目录:
opt下有:
二、配置minicom
minicom类似于windows中的超级终端,这里利用minicom作为开发目标的终端,在使用之前需要配置正确配置。配置的过程如下:
在Linux终端中输入:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
minicom -s
对minicom进行设置。选择serial port setup,然后按A选择Serial Device为/dev/ttyS0,表示串口1,如果有多个串口可以根据自己具体的情况进行选择,一般PC机都只有一个串口,就是COM1,即ttyS0。然后按E选择波特率为115200,8N1。然后按F选择Hardware Flow Control模式为No.
回车退出之后选择Save setup as df1,保存刚才的设置。OK!
三、配置tftp
安装tftp服务器端,google之后下载tftp-server-0.17-9.i386.rpm。进入rpm所在文件夹做以下操作
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost yangdk]# rpm -ivh tftp-server-0.17-9.i386.rpm
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
warning: tftp-server-0.17-9.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Preparing... ########################################### [100%]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
1:tftp-server ########################################### [100%]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost yangdk]#vi /etc/xinetd.d/tftp
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
然后编辑将disable改为no,其他不变如下:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
service tftp
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
socket_type = dgram
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protocol = udp
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
wait = yes
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
user = root
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
server = /usr/sbin/in.tftpd
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
server_args = -s /tftpboot
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
disable = no
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
接下来建立默认的tftp根目录,要跟上面的server_args的路径一样,这里是/tftpboot:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost yangdk]# cd /
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost /]# mkdir tftpboot
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost /]# /etc/rc.d/init.d/xinetd restart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
停止 xinetd: [ 确定 ]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
启动 xinetd: [ 确定 ]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost /]#
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
好了,然后在命令行输入setup,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# setup
选择<system services>选中tftp并去掉iptables选项,再
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost /]# /etc/rc.d/init.d/xinetd restart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
这样就ok了,可以试着自己tftp自己测试tftp服务器是否启动了
四、配置NFS
这个比tftp要简单一些
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# setup
同上选择<system setup>选上nfs并去掉iptables ipchains(没有的话不用管)两项。退出后输入:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# /etc/rc.d/init.d/nfs restart
这样nfs服务就打开了,但是nfs需要配置exports目录,就是共享出来的目录,最终在板子上mount上去,所有的程序最后都放在这个目录下,在板子上mount上去之后就能在这里运行。所以在板子上运行的程序实际上还是在主机上的,只不过是以网络文件系统(nfs)的方式挂载(mount)上去而已。键入vi /etc/exports
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# vi /etc/exports
在exports中加入下面这一行
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
/s3c2410_linux/nfs 192.168.1.101(rw,insecure,no_root_squash,no_all_squash)
其中/s3c2410_linux/nfs为主机上一个已存在的目录。192.168.1.101指开发板的IP,一定要这样具体,有些资料上写成192.168.1.*或者192.168.1/24,我试过了,都不行。必须是具体到制定的ip如192.168.1.101。
退出之后再来一遍这个
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# /etc/rc.d/init.d/nfs restart
这样,NFS就配置完成了。OK了!可以编写嵌入式程序了,明天继续。
绝大多数的linux软件开发都是以native方式进行的,就是本机(host)开发,调试,本机运行的方式。但这种方式不适合于嵌入式系统的软件开发,因为对于嵌入式系统的开发,没有足够的资源在板子上运行开发工具和调试工具。所以嵌入式系统的软件开发一般都是采用一种交叉编译调试的方式。交叉编译调试环境建立在一台主机(pc)上,开发是使用主机上的交叉编译、汇编及连接工具形成在目标板上可以运行的二进制代码。然后下载到板子上运行。
下面我将自己在s3c2410上的过程总结一下。也许跟别的板子有出入,前面说了,殊途同归。希望对需要用的着的朋友有用。
我用的是GX的arm9-s3c2410实验箱,主机环境是RedHat 9.0。过程如下:
一、建立主机开发环境
将光盘放入CDROM中,然后在终端输入
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
mount /dev/cdrom /mnt/cdrom
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
cd /mnt/cdrom
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
./install
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
系统会自动安装,这时只要等就行了,一般需要20分钟左右,这个过程中会有一些提示信息,也有时要等一段时间才会有提示信息输出,耐心等待,别等不及就终止了。
安装完成之后会在根目录下生成两个目录:
工作目录/s3c2410_linux和交叉编译环境目录/opt
s3c2410_linux下有这些目录:
opt下有:
二、配置minicom
minicom类似于windows中的超级终端,这里利用minicom作为开发目标的终端,在使用之前需要配置正确配置。配置的过程如下:
在Linux终端中输入:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
minicom -s
对minicom进行设置。选择serial port setup,然后按A选择Serial Device为/dev/ttyS0,表示串口1,如果有多个串口可以根据自己具体的情况进行选择,一般PC机都只有一个串口,就是COM1,即ttyS0。然后按E选择波特率为115200,8N1。然后按F选择Hardware Flow Control模式为No.
回车退出之后选择Save setup as df1,保存刚才的设置。OK!
三、配置tftp
安装tftp服务器端,google之后下载tftp-server-0.17-9.i386.rpm。进入rpm所在文件夹做以下操作
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost yangdk]# rpm -ivh tftp-server-0.17-9.i386.rpm
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
warning: tftp-server-0.17-9.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Preparing... ########################################### [100%]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
1:tftp-server ########################################### [100%]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost yangdk]#vi /etc/xinetd.d/tftp
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
然后编辑将disable改为no,其他不变如下:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
service tftp
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
socket_type = dgram
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protocol = udp
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
wait = yes
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
user = root
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
server = /usr/sbin/in.tftpd
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
server_args = -s /tftpboot
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
disable = no
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
接下来建立默认的tftp根目录,要跟上面的server_args的路径一样,这里是/tftpboot:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost yangdk]# cd /
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost /]# mkdir tftpboot
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost /]# /etc/rc.d/init.d/xinetd restart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
停止 xinetd: [ 确定 ]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
启动 xinetd: [ 确定 ]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost /]#
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
好了,然后在命令行输入setup,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# setup
选择<system services>选中tftp并去掉iptables选项,再
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost /]# /etc/rc.d/init.d/xinetd restart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
这样就ok了,可以试着自己tftp自己测试tftp服务器是否启动了
四、配置NFS
这个比tftp要简单一些
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# setup
同上选择<system setup>选上nfs并去掉iptables ipchains(没有的话不用管)两项。退出后输入:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# /etc/rc.d/init.d/nfs restart
这样nfs服务就打开了,但是nfs需要配置exports目录,就是共享出来的目录,最终在板子上mount上去,所有的程序最后都放在这个目录下,在板子上mount上去之后就能在这里运行。所以在板子上运行的程序实际上还是在主机上的,只不过是以网络文件系统(nfs)的方式挂载(mount)上去而已。键入vi /etc/exports
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# vi /etc/exports
在exports中加入下面这一行
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
/s3c2410_linux/nfs 192.168.1.101(rw,insecure,no_root_squash,no_all_squash)
其中/s3c2410_linux/nfs为主机上一个已存在的目录。192.168.1.101指开发板的IP,一定要这样具体,有些资料上写成192.168.1.*或者192.168.1/24,我试过了,都不行。必须是具体到制定的ip如192.168.1.101。
退出之后再来一遍这个
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
[root@localhost root]# /etc/rc.d/init.d/nfs restart
这样,NFS就配置完成了。OK了!可以编写嵌入式程序了,明天继续。
相关文章推荐
- 学习心得:嵌入式linux开发环境的建立
- 《华清远见学习手记》之 嵌入式Linux开发环境的建立
- 【嵌入式Linux学习七步曲之第二篇 ARM+Linux开发环境】在AT91RM9200上通过nfs调试linux程序
- 嵌入式学习方法-----关于arm+linux编程开发的学习心得
- arm-linux-gcc安装 和 环境变量设置 分类: 嵌入式开发学习 2011-04-13 11:34 10197人阅读 评论(1) 收藏
- 【嵌入式Linux学习七步曲之第二篇 交叉开发环境】SuSe11.1 上架设NFS服务器
- 一步一步建立linux交叉编译开发环境(学习笔记)
- 嵌入式Linux交叉开发环境建立-NFS
- 【嵌入式Linux学习七步曲之第二篇 ARM+Linux开发环境】详解为什么开发板的TFTP、NFS等网络功能神奇消失
- linux环境搭建和arm开发板环境搭建 续 分类: 嵌入式开发学习 2011-03-22 22:58 2558人阅读 评论(3) 收藏
- 【嵌入式Linux学习七步曲之第二篇 交叉开发环境】FC6 上架设TFTP服务器,Transfer timed out
- <2012 11 13> 一步步建立linux&嵌入式linux应用与开发环境(based on 虚拟机)
- 玩转BeagleBoard xM——建立虚拟机开发环境和嵌入式Linux系统
- LINUX嵌入式开发 PC端 QT开发环境建立过程(STEP 2)
- qt 在linux环境下的搭建 (自己整理) 分类: 嵌入式开发学习 2011-04-29 20:54 6033人阅读 评论(0) 收藏
- Linux环境学习和开发心得(作者:lunker)
- 嵌入式Linux开发环境的建立——Ubuntu上安装nfs服务器
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】虚拟机下Linux和windows的文件共享――共享方式
- 【嵌入式Linux学习七步曲之第一篇 Linux主机开发环境】如何通过vnc图形界面远程控制Linux主机
- 【嵌入式Linux学习七步曲之第二篇 ARM+Linux开发环境】gdb+gdbserver的方式进行ARM程序调试