uClinux学习笔记之一 Ubuntu 8.04 下uClinux的编译和skyeye仿真

时间:2022-11-28 04:46:26

Ubuntu 8.04uClinux的编译和skyeye仿真

 

 

 

 

  有一段时间没有用Linux,以前要编译与Linux相关的代码用的都是用

 

Cygwin或是MinGW,不到万不得己是不会用Linux,其中的主要原因是开发Linux软件的经历比较少,Qt,Python这些软件,又都是跨平台的,windows下的也照样能用它来编程,其次就是硬盘的空间有限,最近下决心学一下嵌入式Linux,Cygwin是无能为力了,所以试着在Linux下编译。之所以选择Ubuntu,则是因为自己已经听说过很多次这种Linux了,出于好奇,决定就选它了。试用到现在,感觉确实不错,最喜欢的还是它的完善方便的软件管理方式。磕磕碰碰的算是完成了,没有什么新意,只是作一下总结,也为同样想在Ubuntu 8.04下编译uClinux的人作一下参考吧。

 

 

一、uClinux编译环境的配置和编译

1、下载arm-elf-toolsuClinux

 

http://www.uclinux.org/pub/uClinux/arm-elf-tools/arm-elf-tools-20030314.sh

 

http://www.uclinux.org/pub/uClinux/dist/uClinux-dist-20030305.tar.gz

 

2、安装

1)先切换到root

    sudo -s -H

 

2)安装arm-elf-tools

export _POSIX2_VERSION=199209

 

sh ./arm-elf-tools-20030314.sh

3uClinux配置并编译:

更新软件包信息:

 

apt-get update

 

安装一些必备软件包:

 

apt-get installncurses-dev

 

apt-get install tcl

 

apt-get install tk

 

解压 uClinux

 

tar zxvf uClinux-dist-20030305.tar.gz

 

切换到uClinux的解压目录,运行下以下命令之一进行配置:

 

make menuconfig make xconfig

 

编译:

make dep

make

make image

images目录下生成romfs.img,linux.data,

说明:

apt-get update为可选命令,作用是更新软件包信息,如果执行apt-get install命令出错,那必须先执行这个命令。

ncursesmake menuconfig时所需的安装包

tcltkmake xconfig所需的安装包

make menuconfigmake xconfig为用菜单方式或图形界面方式配置uClinux,如何配置可以参考网上的其它资料,因为是用skyey仿真,所以只要将Vendor/Product选为GDB/ARMulator,其它的可用默认选项,当然在实际的配置和裁减中还是有许多其它选项要改的。

 

二、skyeye的安装

ubuntu下安装skyeye相当简单,只要执行以下命令:

 

apt-get install skyeye

 

如果出错先执行apt-get update

 

三、用skyeye仿真uClinux

1、先写一个测试程序,保存为hello.c

//---------------------------------hello.c----------------------------------------------------

 

#include <stdio.h>

 

int main(void)

{

   printf("hello,world/n");

   return 0;

}

//-----------------------------------------------------------------------------------------------

 

 

编译生成flat文件格式的可执行文件hello

arm-elf-gcc -Wl,-elf2flt -o hello hello.c

 

 

2、制作romfs.img

在编译uClinux时已经生成了romfs.img,但是我们要将我们的hello程序加入romfs中,可以按下面步骤来做(以下假设当前目录为uClinux所在目录)

1)首先,挂载romfs.img

切换到uClinux目录下的images目录并建一个romfs目录:

 

 cd images

 

 mkdir romfs

 

创建挂载点:

 

 mkdir /mnt/romfs

      

挂载:

 

mount -o loop romfs.img /mnt/romfs

 

2)制作romfs.img

 

/mnt/romfs目录下的所有文件拷贝到images/romfs目录下:

 

cp -r /mnt/romfs/* romfs

 

制作新的romfs.img

 

genromfs -fromfs.img -d romfs

 

3skyeye仿真

1)先写一个config文件skyeye.conf,保存到images目录下,以下为全部内容:

cpu: arm7tdmi

 

mach: at91

 

mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000

mem_bank: map=M, type=RW, addr=0x01000000, size=0x00400000

mem_bank: map=M, type=R, addr=0x01400000, size=0x00400000, file=./romfs.img

mem_bank: map=M, type=RW, addr=0x02000000, size=0x00400000

mem_bank: map=M, type=RW, addr=0x02400000, size=0x00008000

mem_bank: map=M, type=RW, addr=0x04000000, size=0x00400000

mem_bank: map=I, type=RW, addr=0xf0000000, size=0x10000000

 

2)仿真

转到images目录,执行以下命令:

 

skyeye -e ../linux-2.4.x/linux

 

熟悉的界面出现了,cdbin目录,执行以下命令

 

./hello

 

出现了经典的hello,world

 

 

到此,基本的仿真工作已经做完了,有时间再写一下miniguiembeded Qt的编译和仿真,

 

 

参考资料:

 

 

http://hi.baidu.com/zkheartboy/blog/item/a73927ad3629c9094a36d6f1.htm

 

 http://forum.ubuntu.org.cn/viewtopic.php?t=88369