Chinaunix首页 | 论坛 | 博客
  • 博客访问: 676225
  • 博文数量: 194
  • 博客积分: 3831
  • 博客等级: 中校
  • 技术积分: 1843
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-28 13:24
文章分类

全部博文(194)

文章存档

2012年(41)

2011年(42)

2010年(45)

2009年(66)

分类: LINUX

2009-04-12 21:47:38

 

 

说明:我只是一个嵌入式的初学者,怀着对嵌入式的好奇,而且目前做关于嵌入式的毕业设计,很想把它做圆满。但是目前心有余而力不足,研究生复试马上就要开始了。我想赶在复试之前把它作出来。然后我就可以把学校的事都放下,回家过一段时间在回校了。根据现在对目前对嵌入式的了解,对ARM的了解,对我来说好像很难。只能将我所能想到的,能做到的尽力做好了。

1、到这里你的交叉编译工具就算做完了,简单验证一下你的交叉编译工具

用它来编译一个很简单的程序 helloworld.c

#include
int main(void)
{
    printf("hello world\n");
    return 0;
}
$arm-linux-gcc helloworld.c -o helloworld
$file helloworld
helloworld: ELF 32-bit LSB executable, ARM, version 1,
dynamically linked (uses shared libs), not stripped

这样就代表你成功了

Ubuntu,有人是这么说的。

2arm-linux-gcc hello.c –o hello

arm -linux-gcc是第一次出现,有人可能会问这个哪里来的,不妨打开刚才安装的交叉编译工具目录 /usr/local/arm/2.95.3/bin/可以发现里面有一个arm-linux-gcc文件,这个就是针对armCPU gcc编译器了。以后用其它编译工具链式也可以通过这种方法看看其编译器是什么了。编译好了以后就可以下载到目标机进行测试了。当然也可以先在PC机上测试正误。用gcc hello.c o hello就可以生成PC机上程序了,在运行./hello 就可以发现终端显示hello!字样。用arm-linux-gcc编译的程序在PC机上是不能运行的,运行后给出错误报告:无法执行二进制文件。说明经过交叉编译环境编译出的文件是硬件可执行的二进制代码文件。(等我运行出来了,这样的话就没有意义了。哈哈哈)

3.测试这个程序:需要用到工具skyeye-testsuits

下载skyeye-binary-testutils-1.2.0.tar.bz2 解压缩:

$tar jxvf skyeye-binary-testutils-1.2.0.tar.bz2

进入目录:

$cd skyeye-binary-testutils-1.2.0/at91x40/uclinux2

$ls

boot.romlinuxreadmeskyeye.conf

这个目录里有四个文件,其中linux就是内核镜像,boot.rom是要写到Flash里面去的,里面包含文件系统。skyeye.conf是配置文件。

终端下键入:

$skyeye -e linux

呵呵,看到了吧,感觉不错吧

____ __

/__| ||_|

__| || | _ ________

| | | | || || |_ \| | | |\ \/ /

| |_| | |__| || | | | | |_| |/\

|___\____|_||_|_| |_|\____|\_/\_/

| |

|_|

建立目录 romfs/用来倒boot.rom里的文件和helloworld程序

$mkdir romfs

建立挂载目录tmp,并挂载boot.rom,然后拷贝文件到romfs

$mkdir tmp

$sudo mount -o loop boot.rom ./tmp/

$sudo cp -r tmp/* romfs/

$umount tmp

进入romfs/可以看到:

$cd romfs

$ls

bindevetchomelibmntprocsbintmpusrvar

$cd ..

helloworld放到bin/目录下:

$sudo cp ~/Promgram/Arm/helloworld romfs/bin/

genromfs这个工具重新制作文件系统,再运行

$sudo genromfs -f boot.rom -d romfs/

$skyeye -e linux

....

/>helloworld

Hello World! embedded linux!

/>

 

从网上搜索的相关文件仅此而已,无奈了

不过我刚找到一篇可借鉴的好东西,有望了
阅读(871) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~