lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together
lumit4510 学习开发板
uClinux & SkyEye 实验手册
Version 1.1
[lumit] - let us make it together
htpp://www.lumit.org
2004年11月
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together
目录
lumit4510 uClinux & SkyEye 实验手册................................................................................1
Version 1.1 ......................................................................................................1
目录..............................................................................................................2
预备知识...........................................................................................................3
第一节 ARM7开发板简介................................................................................................3
第二节 硬件部分......................................................................................................5
2.1 整体布局.......................................................................................................5
2.2 电源...........................................................................................................5
2.3 CPU模块........................................................................................................6
2.4 Nor Flash.....................................................................................................6
2.5 外围器件........................................................................................................7
2.6 SDRAM .........................................................................................................7
2.7 串口............................................................................................................7
2.8 网络............................................................................................................8
2.9 USB............................................................................................................8
2.10 Nand Flash ...................................................................................................8
2.11 LCD...........................................................................................................8
第三节 软件部分......................................................................................................9
3.1 uClinux简介....................................................................................................9
3.2 SkyEye 简介....................................................................................................10
软件实验――操作系统移植与应用程序开发.............................................................................12
实验一 在 ARM7 开发板上下载和运行uClinux 内核....................................................12
Step 1: 开发主机与开发板软硬件连接................................................................12
Step 2: 设置开发板ip地址...................................................................................12
Step 2: 准备相关文件............................................................................................13
Step 3: 设置主机 ip ..............................................................................................13
Step 4: 下载内核并执行........................................................................................14
实验二 uClinux 内核的交叉编译和 SkyEye 仿真调试....................................................23
Step 1 : 安装交叉编译器 GNU Toolchain ...........................................................23
Step 2 : 交叉编译 uClinux 内核..........................................................................23
Step 3 : 在 SkyEye 上仿真调试内核..................................................................26
实验三 添加新的 uClinux 应用程序..................................................................................31
Step 1 : 编写应用程序代码...................................................................................31
Step 2 : 修改相关 Makefile 文件........................................................................31
Step 3 : 修改相关 config.in 文件........................................................................32
Step 4 : 重新编译内核和文件系统.......................................................................32
附录 - uCLinux FAQs .............................................................................................36
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 3 -
预备知识
第一节 ARM7开发板简介
lumit4510是基于三星S3C4510的ARM7开发板,主要面向嵌入式初学者.
该开发板的外观如下:
lumit 4510开发板具有以下资源:
处理器:
S3C4510B ARM7TDMI
运行频率50MHz
存储器:
16x1M字节NOR Flash
32x4M字节SDRAM
16M字节NAND Flash
通信接口:
两个串口
一个10M/100M以太网口
一个USB 1.1 device接口
其他资源:
4个LED
一个7段数码管
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 4 -
实时时钟
拨断开关
蜂鸣器
外部中断
16x2字符型液晶接口
lumit4510开发套件包括如下部分:
1) 一块已测试好的lumit4510开发板
2) 一个JTAG调试头(带调试线)
3) 一根串口线 (公母延长线)
4) 一根并口延长线
5) 一条1.5米网线 (交叉线)
6) 一个 +5V 直流电源
7) 一张lumit4510光盘
在 lumit4510 的网站 http://www.lumit.org 上提供的嵌入式开发资料有:
1) 所用主要芯片的数据手册资料
(s3c4510/sst39vf160 /PDIUSBD12/HY57V641620/K9F2808Q0B)
2) 开发板原理图
(OrCad 格式第三版原理图和 wiggler 调试器sch和pcb图)
3) uclinux for S3C4510的源代码
(20030522 版.和20040408 版全部移植代码)
4) 支持 SkyEye 软件仿真协同开发(没有硬件的可以用 SkyEye 来学习)
5) Bootloader 源代码,支持通过网络 tftp 协议下载 uClinux 内核.
6) uC/OS-II 实时多任务操作系统内核移植源码
7) VxWorks on lumit4510 移植
8) 板子的详细使用说明(如何交叉编译,如何烧写 Flash,如何DIY焊接
等)
9) 开发工具下载
(包含 GNU 交叉编译器,ARM 公司的集成开发工具 ADS/SDT等)
lumit 开源项目正在进行的工作有:
1) 实时时钟 RTC 驱动调试
2) 液晶屏 LCD (2×16)字符驱动显示
3) 基于 Nand Flash 的文件系统移植
4) 开发板使用说明,源码分析,开发手册等相关技术文档工作
www.lumit.org 是一个软硬件资料可以完全免费下载的开源项目,目前主要
目标是制作一个基于arm7tdmi s3c4510开发板的可以实用的u盘,未来我们希望
还能做出 mp3,pda 甚至是 dc,dv 等.
关于 lumit4510 开发板更多相关资料,可以到 http://www.lumit.org 下载.
同时欢迎对此感兴趣的朋友加入!
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 5 -
第二节 硬件部分
2.1 整体布局
网络模块
电源
RTC电池
蜂鸣器
复位 JTAG液晶模块NAND Flash模块
USB
模块
串口 LED与7段数码管拨段开关实时时钟
SDRAM
S3C4510模块
外部中断
Nor Flash
2.2 电源
开发板电源分两部分:
系统电源
系统需要DC +5V和+3.3V电源,5V直接采用外接直流稳压电源,3.3V
通过5V进行DC-DC转换而来.
实时时钟电池电源
实时时钟由于要保存时钟信息,所以在掉电时采用电池供电,系统上电
时使用系统的电源供电
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 6 -
2.3 CPU模块
2.3.1 CPU
S3C4510B是三星公司基于ARM7TDMI的处理器,芯片本身具有资源如下:
ARM7TDMI核
2个UART
2个HDLC
2个GDMA
2个32位定时器
18个可编程IO
8K字节cache/SRAM
1个IIC接口
中断控制器
网络控制器
2.3.2 复位
复位电路采用IMP811芯片
2.3.3 晶振
处理器外接10MHz有源晶振,通过处理器内部PLL倍频到50MHz
2.3.4 JTAG
20针标准JTAG接口
JTAG是一种国际标准测试协议,主要用于芯片内部测试及对系统进行仿真,
调试.目前大多数处理器都支持JTAG.
2.4 Nor Flash
SST39VF160 16x1M字节
Flash存储器是一种可以在线进行擦写,掉电数据不丢失的存储器.具有低
功耗,大容量等特点.主要用在存储程序代码和一些需要保存的数据.
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 7 -
2.5 外围器件
2.5.1 LED
4个LED灯PIO控制
2.5.2 七段数码管
数据总线D0-D7和一些逻辑控制的七段数码管
2.5.3 拨段开关
4位拨断开关,接至IO口
2.5.4 外部中断
外部中断按键
2.5.5 实时时钟
实时时钟PCF8563芯片,使用IIC接口
2.5.6 蜂鸣器
PIO控制蜂鸣器
2.6 SDRAM
两片K4S641632组成32位数据总线宽度
SDRAM运行速度大大快于FLASH存储器,并且单位面积存储容量大和价
格相对低廉,但是掉电数据就会丢失,所以,SDRAM主要用作程序运行空
间,数据区和堆栈区.
2.7 串口
提供两个串口
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 8 -
2.8 网络
以太网接口主要由MAC控制器和物理层接口(PHY)两部分组成,S3C4510B
自带网络控制器,外部结PHY芯片RTL8021B接入以太网
S3C4510B自带的以太网控制器可以在半双工或全双工模式下提供
10M/100M以太网的接入
2.9 USB
采用PDIUSBD12,提供USB1.1 device接口
2.10 Nand Flash
采用K9F2808,数据Flash,可以做文件系统
2.11 LCD
提供16x2字符型液晶接口
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 9 -
第三节 软件部分
3.1 uClinux简介
uClinux 是在 Linux kernel 2.0 之后出现的一个 Linux 的变种,它的目标是将 Linux
应用于没有内存管理单元(Memory Management Units)的处理器.uClinux 中u就是 Micro,
表示微,小的意思;C 就是 Control,即控制.因此可以说,uClinux是针对"微控制领域
而设计的Linux系统".
由于uClinux 是在 Linux 的基础之上添加了对没有 MMU 的微处理器的支持,所以它
一方面继承了 Linux 的大部分优点:例如稳定性,各种网络协议栈的支持以及不同类型的
文件系统支持等等,另一方面,它广泛地应用于嵌入式领域,内核精简(一般小于 512k),
并支持很多常用的嵌入式微控制器系列,例如 Motorola Dragon Ball,ColdFire,ARM7TDMI
( Atmel AT91x,Samsung S3C4510x)等.
与标准Linux操作系统相比,uClinux 最大的区别就在于内存管理.标准 Linux 是针对
有内存管理单元的处理器而设计的,使用虚拟存储器技术通过分页的方式来载入进程.这样
每个进程在其虚拟地址空间上相互独立,通过 MMU 实现从虚拟地址到物理地址的映射.
现代操作系统的内存管理大多采用这种方式,这种做法带来的好处有很多,比如:
1) 可以使用比实际物理内存大得多的内存空间,程序在运行时不必全部装入内存,只
加载需要的部分程序,这样既节省了内存空间,又缩短了程序启动的时间.
2) 可以运行重定位的程序,同时也可以使多个程序驻留在内存中.
3) 可以方便地实现程序代码的共享.即多个进程共享程序的同一个副本.
4) 由于每个进程只在自己的虚拟地址空间上运行,通过 MMU 做虚拟地址->物理地
址的转换,进程的虚拟空间被映射到了不同的内存区域中,因而一个进程不能随意访问和修
改其他进程空间的内容,有利于不同进程之间的保护.
但是,在嵌入式领域 NOMMU 的处理器是相当普遍的,这是因为,一方面 MMU 在
处理器中会占用相当大比例的硅片面积,基于成本和尺寸的考虑,没有 MMU 会更适合于
嵌入式设备的应用;另一方面,当发生页面失效时,从磁盘加载进程的页面到内存中,会相
当消耗时间和处理器资源,这对系统工作的影响很大,容易带来不稳定的因素.
基于上述原因,uClinux 对 NOMMU 的处理器采用了实存储器管理策略(real memory
management).这样一个进程在执行前,系统必须为之分配足够的连续地址空间,然后全部
载入主存储器中.因为在嵌入式开发中,通常都是针对特定环境下的应用,所以这样的实现
也是可行的,从执行效率上讲也更会高一些.
uClinux 的官方网站是 http://www.uclinux.org ,基本上 uClinux 的发布是和 Linux 的
版本发布保持同步更新的.
目前最新支持的内核版本是 2004-04-08 发布的uClinux-dist-20040408.tar.gz.
在本实验指导书的附录中,有关于 uClinux 的常见问题及其解答,可供参阅.
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 10 -
3.2 SkyEye 简介
SkyEye是一个开源软件(OpenSource Software)项目,中文名字是"天目".SkyEye的
目标是在通用的Linux和Windows平台实现一个纯软件集成开发环境,模拟常见的嵌入式
计算机系统(这里假定"仿真"和"模拟"的意思基本相同);可在SkyEye上运行 CLinux以及
C/OS-II等多种嵌入式操作系统和各种系统软件(如TCP/IP,图形子系统,文件子系统
等),并可对它们进行源码级的分析和测试.
3.2.1 SkyEye的起源和发展
2002年11月,一个偶然的机会,一群操作系统的爱好者在网上进行聊天,成立了一个
TM-Linux兴趣小组,希望要做一些感兴趣的事情.当时在清华大学计算机系做博士后的
陈渝提出做一个用软件实现的嵌入式开发板硬件模拟器,可以在模拟器上运行各种操作系
统,这样就可以在没有开发板的情况下学习和研究操作系统.一开始就陈渝一人做,首先他
了解了当前国际上的一些类似的项目,发现著名的 CLinux组织实现了一个armulator模拟
器软件(在Linux系统上运行),可以模拟Ateml AT91(基于ARM7TDMI CPU)开发板,
CLinux可以在armulator(其网址为http://www.uclinux.org/pub/uCLinux/utilities/armulator/)
上运行.于是陈渝以此为基点,借鉴armulator的实现,提出了SkyEye项目,其目标是让
SkyEye仿真多种主流的嵌入式开发板和外设,实现一个可扩展的硬件模拟框架,让更多的
嵌入式操作系统可以在SkyEye上运行.SkyEye项目是在2002年12月1日正式建立后,陈
渝完成的第一件工作是把armulator移植到了cygwin/windows环境下,其成果被 CLinux组
织接收.接下来清华大学计算机系硕士生李明加入到SkyEye的开发中,8天后,SkyEye的
第一个版本推出,再过了4天, C/OS-II for SkyEye推出.在这期间,SkyEye的网站也建
立起来了.紧接着,杨晔,王利明,尹首一等在校学生也加入到SkyEye的开发中,给SkyEye
带来了新的活力,SkyEye进入了新的发展阶段.
3.2.2 SkyEye的的目标和意义
纯软件的模拟器有许多种,如模拟一个芯片时序逻辑的模拟器,只模拟CPU指令的模
拟器,模拟整个硬件开发板的模拟器,模拟一个PDA的模拟器等.存在一些纯软件的仿真
器或模拟器,如Stanford大学的SimOS模拟器,它仿真的是MIPS系列CPU和相关外设,
可以在其上运行SGI公司的Irix操作系统和软件,目前基本上停止了进一步的开发;PSIM
是一个仿真PowerPC指令集的模拟器,目前只支持简单的命令行应用程序;xcopilot是一个
PDA模拟器,它是由Greg Hewgill出于个人喜好编写的,它仿真的是M68K CPU,通过它
可以给基于PalmOS的软件开发者提供一个模拟开发环境.Bochs是一个仿真x86 CPU的开
源项目,目前还支持AMD64 CPU,在它上面可以运行Linux操作系统.其它一些商业的仿
真软件如vmware和virtualPC可以仿真一个真实的x86计算机,而Virtutech Simics仿真器
可以仿真多种CPU和硬件,功能强大,可用于硬件和系统软件的评测.
SkyEye是一个指令级模拟器,可以模拟多种嵌入式开发板,可支持多种CPU指令集,
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 11 -
在SkyEye上运行的操作系统意识不到它是在一个虚拟的环境中运行,而且开发人员可以通
过SkyEye调试操作系统和系统软件.由于SkyEye的目标不是验证硬件逻辑,而是协助开
发,调试和学习系统软件,所以在实现上SkyEye与真实的硬件环境相比还是有一定差别
的.SkyEye在时钟节拍的时序上不保证与硬件完全相同,对软件透明的一些硬件仿真进行
了一定的简化,这样带来的好处是SkyEye的执行效率更高.SkyEye的推出具有下面三方面
的意义:
通过SkyEye仿真集成环境可以很方便地进入到嵌入式系统软件学习和开发的广阔天地
中.尤其对于缺少嵌入式硬件开发环境和软件开发环境的用户来说,它将是一个非常有
效的学习工具和开发手段,因为SkyEye的整个软件系统都是Open Source的,且基于
GPL协议( COS-II除外).因此,如果要学习Linux操作系统或者进行嵌入式系统开
发,但苦于没有硬件支持,SkyEye仿真环境软件是一个很好的选择!
如果想研究与具体硬件无关的系统软件(如TCP/IP协议栈等),采用SkyEye可以有效
地提高工作效率,因为你可以直接在 COS-II和 CLinux for SkyEye上进行开发和调试,
而与具体硬件打交道的各种driver已经存在,且有源码级调试环境,只需关心高层的逻
辑设计和实现就可以了.
SkyEye本身作为一个开放式的项目体系,可以划分为多个独立的子项目系统.通过参
与SkyEye的各个子项目,与大家共同交流,协作,可以进一步学习,分析,精通Linux
内核,掌握ARM嵌入式CPU编程.
在32位嵌入式CPU领域中,ARM系列CPU所占比重很大,而ARM7TDMI是其中最
广泛的一种ARM CPU核,因此SkyEye首先选择了ARM7TDMI作为仿真的目标CPU核,
当然将来SkyEye会支持更多种类的CPU.目前在SkyEye上可运行并进行源码级调试ARM
Linux, CLinux, C/OS-II操作系统和LwIP(一个嵌入式TCP/IP实现)等系统软件,将来
还要支持GUI系统软件.SkyEye可用于学习,分析,开发这些系统软件的实现,了解
ARM嵌入式CPU编程.而这一切都可在一个纯软件的环境中完成.通过分析SkyEye本身
实现,则系统软件开发人员对ARM,8019AS以太网络芯片等硬件的了解也会更深入.
SkyEye并不能取代开发板等硬件的功能,但通过它可以比较容易进入到嵌入式软件的
广阔天地中.由于SkyEye建立在GDB基础之上,使用者可以方便地使用GDB提供的各种
调试手段对SkyEye仿真系统上的软件进行源码级的调试,还可以进行各种分析,如执行热
点分析,程序执行覆盖度分析等.由于SkyEye提供了源代码和相关文档,有经验的用户完
全可以修改和扩充SkyEye来满足自己的需求.
SkyEye 项目的主页: http://www.skyeye.org
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 12 -
软件实验――操作系统移植与应用程序开发
实验一 在 ARM7 开发板上下载和运行uClinux 内核
Step 1: 开发主机与开发板软硬件连接
1,连接 pc 串口0 与 开发板串口0 (即 uart0)
2,连接 pc 网口与开发板网口
3,连接 5v 电源与开发板电源接头
4,在主机端使用串口终端软件和开发板建立通讯,串口设置如下:
端口com1,波特率19200,数据位8,奇偶校验none,停止位 1,流量控制none
比较常用的串口终端软件有 Windows 下的超级终端,Terminal 或者 Linux下的 MiniCom 等工具.
在本节后面有使用这几个软件进行连接的截图,可以帮助大家建立自己需要的连接.
5,通过开发板上 Reset 按钮进行复位,开发板的 Bootloader 会输出如下启动信息:
*************************************************************
lumit4510 ARM7 Board Fireware ( Release 1.3 )
Build date : Oct 17 2004 Time : 17:00:32
[lumit] - let us make it together
To find us at http://www.lumit.org
Type 'help' for more commands.
\>
6,到这里,我们成功地将开发板和主机建立了软硬件的连接并启动了开发板.
Step 2: 设置开发板ip地址
1,通过输入 help 命令可以看到
\>help
help ------ show help
------ = help
load ------ Load file to memory
prog ------ Program flash
boot ------ Boot from flash
ap ------ Auto load image flie and program flash
copy ------ Copy flash from src to dst address
ipcfg ------ Show or set IP address ( ipcfg 192.168.168.101 )
go ------ Go at 0x8000
dn ------ Ev-7t bootloader download
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 13 -
play ------ Play sample music
2,通过输入 ipcfg 命令可以获得开发板的 ip 地址 (缺省即 192.168.168.101)
\>ipcfg
IP address : 192.168.168.101
\>
3,这里我们设置开发板的 ip 为 192.168.0.101 ,大家可以根据自己开发板上的 ip 地址进
行设置,注意尽量避免和别人有 ip 地址冲突,以免影响后面的实验.
\>ipcfg 192.168.0.101
Set IP address : 192.168.0.101
\>
4,这里再次输入 ipcfg 命令查看ip,以确保刚才的设置正确无误.
\>ipcfg
IP address : 192.168.0.101
\>
Step 2: 准备相关文件
1,如果主机是 Windows 操作系统,请到如下地址下载 tftp 工具:
http://www.lumit.org/download/tools/tftp.exe
如果主机是 Linux 操作系统,请确认安装了 tftp 应用程序:
[lumit@localhost lumit]$ which tftp
/usr/bin/tftp
[lumit@localhost lumit]$
2,下载 http://www.lumit.org/download/software/image.ram.rar
3,解压缩image.ram.rar获得image.ram,该文件就是uClinux kernel image
4,检查下载的 image.ram 文件大小是否正确
[lumit@localhost Exp1]$ ls -l
总用量 2020
-rw-r----- 1 lumit lumit 1563584 10月 17 20:45 image.ram
-rw-r----- 1 lumit lumit 493133 10月 17 20:45 image.ram.rar
[lumit@localhost Exp1]$
Step 3: 设置主机 ip
1,检查pc 主机的ip地址设置( 下面以 192.168.0.100 为例进行说明).
2,使用开发套件中的"网络对连线"连接 pc 主机的网口和 lumit 4510 开发板的网口.
3,此时应该看到 D1, D2 led 亮了,说明网络连接正常.
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 14 -
Step 4: 下载内核并执行
1,在开发板上执行 load 命令,表示从网络下载内核
\>load
No begin address for download, use default address 0x8000
Mini TFTP Server 1.0 (IP : 192.168.0.101 PORT: 69)
Load image file from host
Type tftp -i 192.168.0.101 put filename at the host PC
Press ESC key to exit
2,此时开发板开始等待主机发送 image.ram
3,在 Windows 主机上的下载目录中输入 tftp -i 192.168.0.101 put image.ram
tftp -i 192.168.0.101 put image.ram
Transfer successful: 1563584 bytes in 3 seconds, 521194 bytes/s
如果是 Linux 主机,则同样在下载目录下输入 tftp 命令:
[lumit@localhost Exp1]$ tftp
tftp> connect 192.168.0.101
tftp> binary
tftp> put image.ram
Sent 1563584 bytes in 12.3 seconds
tftp>
4,最后一行表示通过 tftp 传输成功,下载 uClinux kernel 完毕.
5,此时在开发板上显示如下信息,表示下载完毕等待启动
Starting the TFTP download...
.........................................
Received 17dbc0 Bytes, END...
Boot Image (y/n) y
6,输入 y 表示确认希望运行 uClinux Kernel image
7,uClinux Kernel 开始输出,显示如下信息:
Linux version 2.4.22-uc0 (root@dailzh) (gcc version 2.95.3 20
010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(u
Clinux XIP and shared lib patches from http://www.snapgear.com/)) #24 9 17
18:54:45 CST 2003
Processor: Samsung S3C4510B revision 6
Architecture: SNDS100
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 15 -
On node 0 totalpages: 4096
zone(0): 0 pages.
zone(1): 4096 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/rom0
Calibrating delay loop... 49.76 BogoMIPS
Memory: 16MB = 16MB total
Memory: 14512KB available (1454K code, 156K data, 40K init)
Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Samsung S3C4510 Serial driver version 0.9 (2001-12-27) with no serial options en
abled
ttyS00 at 0x3ffd000 (irq = 5) is a S3C4510B
ttyS01 at 0x3ffe000 (irq = 7) is a S3C4510B
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: C4358-17DB57 [VIRTUAL C4358-17DB57] (RO)
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize
Samsung S3C4510 Ethernet driver version 0.1 (2002-02-20)
eth0: 00:40:95:36:35:34
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 1024 bind 1024)
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 40K
Shell invoked to run file: /etc/rc
Command: hostname Samsung
Command: /bin/expand /etc/ramfs.img /dev/ram0
Command: /bin/expand /etc/ramfs2048.img /dev/ram1
Command: mount -t proc proc /proc
Command: mount -t ext2 /dev/ram0 /var
Command: mount -t ext2 /dev/ram1 /ramdisk
Command: chmod 777 /ramdisk
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 16 -
Command: mkdir /var/config
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: ifconfig lo 127.0.0.1
Command: route add -net 127.0.0.0 netmask 255.255.255.0 lo
Command: ifconfig eth0 192.168.168.101 netmask 255.255.255.0 up
Command: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || |
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|
For further information check:
http://www.uclinux.org/
Execution Finished, Exiting
Sash command shell (version 1.1.1)
/>
8,使用 ifconfig 命令查看 uClinux 的 ip 地址:
/> ifconfig
eth0 Link encap:Ethernet HWaddr 00:40:95:36:35:34
inet addr:192.168.168.101 Bcast:192.168.168.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:64 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
Interrupt:17
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 17 -
collisions:0 txqueuelen:0
/>
9,修改 ip 地址为 192.168.0.101
/> ifconfig eth0 192.168.0.101
/> ifconfig
eth0 Link encap:Ethernet HWaddr 00:40:95:36:35:34
inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:67 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
Interrupt:17
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
/>
10,进入 /bin 目录,执行下面的应用程序,例如 ping/telnet/ftp/mount 等
例如:
/> cd bin
/bin> ping 192.168.0.100
PING 192.168.0.100 (192.168.0.100): 56 data bytes
64 bytes from 192.168.0.100: icmp_seq=0 ttl=128 time=0.0 ms
64 bytes from 192.168.0.100: icmp_seq=1 ttl=128 time=0.0 ms
64 bytes from 192.168.0.100: icmp_seq=2 ttl=128 time=0.0 ms
--- 192.168.0.100 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.0/0.0/0.0 ms
/>
可以看出 pc 主机与开发板的连接正常
另外如果在 pc 主机端启动 telnet/ftp server,还可以测试 telnet/ftp 等应用.
可以自己测试一下,telnet 到自己的 pc 上看看目录文件,举例如下:
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 18 -
/bin> telnet 192.168.0.18
Trying 192.168.0.18(5888)...
Connected to 192.168.0.18.
Escape character is '^]'.
Red Hat Linux release 9 (Shrike)
Kernel 2.4.20-8 on an i686
login: lumit
Password: lumit
Last login: Sun Oct 17 21:36:42 from 192.168.0.101
[lumit@localhost resources]$ ls -l
总用量 16
drwxr-x--- 2 lumit lumit 4096 10月 17 20:45 Exp1
drwxr-x--- 3 lumit lumit 4096 10月 17 21:14 Exp2
drwxr-x--- 2 lumit lumit 4096 10月 17 21:40 Exp3
drwxrwxr-x 4 lumit lumit 4096 10月 17 21:33 uClinux
[lumit@localhost resources]$
实验一附录:
下面的图是在 Windows 下使用 Terminal 工具进行设置的界面:
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 19 -
下面的图是使用 Windows 下的超级终端进行设置的界面.
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 20 -
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 21 -
下面是在 Linux 下使用 minicom 进行设置的界面:
[root@localhost root]# minicom –s
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 22 -
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 23 -
实验二 uClinux 内核的交叉编译和 SkyEye 仿真调试
Step 1 : 安装交叉编译器 GNU Toolchain
1. 下载 arm-elf-tools-20030314.sh
http://159.226.40.150/lumit/resources/uClinux/Toolchain/arm-elf-tools-20
030314.sh
2. arm-elf-tools-20030314.sh 是一个可以自动安装的脚本文件,改变属性为可执行文件:
chmod 755 arm-elf-tools-20030314.sh
3. 执行脚本即可完成交叉编译器的安装
./arm-elf-tools-20030314.sh
4. 测试一下,输入 arm-elf-gcc 看看是否能够自动补齐
[admin@localhost admin]$ arm-elf-gcc -v
Reading specs from /usr/local/lib/gcc-lib/arm-elf/2.95.3/specs
gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from
http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from
http://www.snapgear.com/)
[admin@localhost admin]$ which arm-elf-gcc
/usr/local/bin/arm-elf-gcc
表明 arm-elf-gcc 已经安装在 /usr/local/bin/ 目录下了.
Step 2 : 交叉编译 uClinux 内核
1. 下载 uClinux-dist-20040408.tar.gz 到当前工作目录下
http://159.226.40.150/lumit/resources/uClinux/uClinux-dist-20040408.tar.gz
2. 解压 uClinux-dist-20040408.tar.gz 文件到 uClinux-dist 目录
tar xvzf uClinux-dist-20040408.tar.gz
此时当前工作目录下增加了一个名为 uClinux-dist 的目录.
3. 进入 uClinux-dist 目录
cd uClinux-dist
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 24 -
4. 修改 vmlinux-armv.lds.in 文件,
vi linux-2.4.x/arch/armnommu/vmlinux-armv.lds.in
在 65 行处添加三条语句,如下 所示:
65 *(.got) /* Global offset table
*/
66
67 /* add by lumit - http://www.lumit.org */
68 romfs_data = .;
69 romfs.o
70 romfs_data_end = .;
5. 修改 vendors/Samsung/4510B/Makefile 文件,
vi vendors/Samsung/4510B/Makefile
在 image 目标的第三行,增加一条语句,如下所示:
63 image:
64 [ -d $(IMAGEDIR) ] || mkdir -p $(IMAGEDIR)
65 genromfs -v -V "ROMdisk" -f $(ROMFSIMG) -d $(ROMFSDIR)
66 arm-elf-ld -r -o $(ROOTDIR)/$(LINUXDIR)/romfs.o -b binary $(ROMFSIMG)
67 $(CROSS_COMPILE)objcopy -O binary --remove-section=.romvec \
68 --remove-section=.text --remove-section=.ramvec \
69 --remove-section=.init \
70 --remove-section=.bss --remove-section=.eram \
71 $(ROOTDIR)/$(LINUXDIR)/linux $(IMAGEDIR)/linux.data
6. make menuconfig
在 Vendor/Product Selection ---> 中选择
--- Select the Vendor you wish to target
(Samsung) Vendor
--- Select the Product you wish to target
(4510B) Samsung Products
在 Kernel/Library/Defaults Selection ---> 中选择
(linux-2.4.x) Kernel Version
(uClibc) Libc Version
其他选项都不变,按照缺省设置,选择退出,保存配置.
7. make dep
8. make lib_only
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 25 -
9. make user_only
[说明] 编译login,boa程序时可能出现 undefined reference to 'crypt_old'的错误,
boa.elf2flt: In function `auth_check_userpass':
./uClinux-dist/user/boa/src/auth.c:281: undefined reference to `crypt_old'
可以修改
vi config/.config
注释掉第25行的 CONFIG_USER_OLD_PASSWORDS
如下:
24 CONFIG_USER_LOGIN_LOGIN=y
25 # CONFIG_USER_OLD_PASSWORDS=y
26 # CONFIG_USER_ONLY_ROOT is not set
然后再
cd user/boa/src/
rm -rf *.o
cd ../../../
重新编译 make user_only 一下这个目录里面的 obj 文件就可以了.
10. make romfs
11. make
注意这里可能会报错 romfs.o 文件没有找到,没有关系,忽略这个错误往下做12步.
12. make image
13. 此时仍会报错,没有关系,再依次重复步骤10,11,12 就可以通过
[说明] 编译程序时可能出现如下错误提示:
arch/armnommu/mm/mm.o: In function `free_initmem':
./uClinux-dist/linux-2.4.x/arch/armnommu/mm/init.c:240: undefined reference to
`machine_is_ta7v'
这个错误只要注释该文件的相关代码即可.
655 void free_initmem(void)
656 {
657 if (!machine_is_integrator() &&
658 !machine_is_p52() &&
659 !machine_is_cx821xx() &&
660 !machine_is_atmel() &&
661 !machine_is_netarm() &&
662 // !machine_is_ta7v() &&
663 !machine_is_ta7s()) {
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 26 -
664 free_area((unsigned long)(&__init_begin),
665 (unsigned long)(&__init_end),
666 "init");
14.此时得到 ./uClinux-dist/linux-2.4.x/linux 文件
和 ./uClinux-dist/images/image.bin
Step 3 : 在 SkyEye 上仿真调试内核
在开始第三步之前,先简要介绍 Exp3/release 目录下几个文件之间的关系:
[admin@localhost release]$ ll
total 13832
-rw-rw-rw- 1 admin admin 1809372 9月 14 17:52 image.ram
-rw-rw-rw- 1 admin admin 1842436 9月 14 17:36 linux
-rw-rw-rw- 1 admin admin 77 9月 14 17:51 Makefile
-rwxr-xr-x 1 admin admin 10476890 9月 14 17:27 skyeye
-rw-rw-rw- 1 admin admin 177 9月 14 17:29 skyeye.conf
其中 skyeye 是可在 RedHat9.0 下执行的 SkyEye 模拟器;
skyeye.conf 是 skyeye 执行需要的配置文件,主要是指定 cpu 类型;
linux 是 uClinux Kernel Source 编译之后得到的 linux-2.4.x/linux 文件
image.ram 是 uClinux Kernel Source 编译之后得到的 image/image.ram 文件
Makefile 是一个简单说明 linux 和 image.ram 之间关系的文件,
即 linux 通过 arm-elf-objcopy 得到 image.ram
【注意】
下载 skyeye 或者 解压 rar 压缩文件包之后,需要通过 chmod 命令改变 skyeye 的
属性.
chmod 755 skyeye (这样 skyeye 就可以在 redhat9.0 以上版本中执行了)
否则,直接执行 ./skyeye 会报错:
-bash: ./skyeye: Permission denied
Exp 3:
在 SkyEye 模拟环境中运行 linux 的输出显示
[admin@localhost release]$ ./skyeye linux
***************************************************************
**** ****
**** SkyEye Simulator Ver 0.8.0 with GDB 5.3 Interface ****
**** ****
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 27 -
***************************************************************
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This SkyEye was configured as "--host=i686-pc-linux-gnu --target=arm-elf"...(no
debugging symbols found)...
(SkyEye) target sim
cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
mach info: name s3c4510b, mach_init addr 0x813e884
SKYEYE: use arm7100 mmu ops
Connected to the simulator.
(SkyEye) load
Loading section .init, size 0xa000 vma 0x8000
Loading section .text, size 0x1a60b8 vma 0x12000
Loading section .data, size 0x7bdc vma 0x1ba000
Start address 0x8000
Transfer rate: 14410912 bits in ls
bin
dev
etc
home
lib
mnt
proc
sbin
tmp
usr
var
/> cd bin
/bin> ls
arp
basename
boa
busybox
date
dhcpcd
dmesg
du
expand
ftp
hostname
ifconfig
inetd
init
kill
killall
login
mount
ping
route
sh
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 30 -
telnet
telnetd
umount
uptime
/bin> hostname
Samsung
/bin> 【此处输入 Ctrl + c 退出 uClinux 运行状态,进入 SkyEye 调试界面】
Program received signal SIGINT, Interrupt.
0x00015dec in ()
(SkyEye) quit
The program is running. Exit anyway (y or n) y
[admin@localhost release]$
特别提示:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
从 linux (elf 格式文件) 得到 image.ram (bin 格式文件)
请执行命令 :
arm-elf-objcopy -O binary -R .note -R .comment -S linux image.ram
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 31 -
实验三 添加新的 uClinux 应用程序
Step 1 : 编写应用程序代码
1. cd uClinux-dist
2. cd user
3. mkdir myapp
4. cd myapp
5. vi demo.c
#include
#include
int main(void)
{
printf("Hello world! \n");
printf("[lumit] - let us make it together \n");
printf("--------------------\n");
printf("http://www.lumit.org\n");
return 0;
}
Step 2 : 修改相关 Makefile 文件
6. vi Makefile
EXEC = demo
OBJS = demo.o
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
romfs:
$(ROMFSINST) /bin/$(EXEC)
clean:
rm -f $(EXEC) *.elf *.gdb *.o
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 32 -
7. vi uClinux-dist/user/Makefile
在 324 行再添加一行 dir_$(CONFIG_USER_MYAPP_DEMO) += myapp
324 # add by lumit
325 dir_$(CONFIG_USER_MYAPP_DEMO) += myapp
326
Step 3 : 修改相关 config.in 文件
8. vi uClinux-dist/config/config.in
增添以下内容到文件最后
#####################################################################
mainmenu_option next_comment
comment 'My New Application'
bool 'demo' CONFIG_USER_MYAPP_DEMO
bool 'app1' CONFIG_USER_MYAPP_APP1
bool 'app2' CONFIG_USER_MYAPP_APP2
bool 'app3' CONFIG_USER_MYAPP_APP3
comment "My New Application"
endmenu
#####################################################################
Step 4 : 重新编译内核和文件系统
9. 进行重新编译内核和文件系统的步骤
make menuconfig
在 Kernel/Library/Defaults Selection ---> 中选择
(linux-2.4.x) Kernel Version
(uClibc) Libc Version
[ ] Default all settings (lose changes)
[ ] Customize Kernel Settings
[*] Customize Vendor/User Settings
[ ] Update Default Vendor Settings
然后退出并保存,此时会在 Main Menu 界面中出现新的一项:
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 33 -
Debug Builds --->
My New Application --->
---
进入后,选择 demo 应用,此时也可以看到刚才添加的 app1,app2,app3 也
出现在 demo 下面,大家可以类似地添加新的应用.
[*] demo
[ ] app1
[ ] app2
[ ] app3
退出保存之后,重复刚才的步骤如下:注意如果前面已经编译成功过一次,那么
后面只需进行 make user_only; make romfs; make
make dep
make clean
make lib_only (这三步可以只做1次,不必要每次都来)
(每次修改过你的应用程序之后,这一步后面的都必须重来)
make user_only
make romfs
make
make image
10. 下载内核,运行看看:
\>load
No begin address for download, use default address 0x8000
Mini TFTP Server 1.0 (IP : 192.168.168.101 PORT: 69)
Load image file from host
Type tftp -i 192.168.168.101 put filename at the host PC
Press ESC key to exit
Starting the TFTP download...
................................................
Received 18baec Bytes, END...
Boot Image (y/n) y
Linux version 2.4.20-uc0 (liming@hpclab.cs.tsinghua.edu.cn) (gcc
version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from
http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from
http://www.snapgear.com/)) #7 Wed Aug 25 22:07:14 HKT 2004
Processor: Samsung S3C4510B revision 6
Architecture: SNDS100
On node 0 totalpages: 4096
zone(0): 0 pages.
zone(1): 4096 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/rom0
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 34 -
Calibrating delay loop... 49.86 BogoMIPS
Memory: 16MB = 16MB total
Memory: 14452KB available (1510K code, 157K data, 40K init)
Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
Inode cache hash table entries: 1024 (order: 1, 8192 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Samsung S3C4510 Serial driver version 0.9 (2001-12-27) with no serial
options enabled
ttyS00 at 0x3ffd000 (irq = 5) is a S3C4510B
ttyS01 at 0x3ffe000 (irq = 7) is a S3C4510B
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: BE7E8-18BBE7 [VIRTUAL BE7E8-18BBE7] (RO)
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize
Samsung S3C4510 Ethernet driver version 0.1 (2002-02-20)
eth0: 00:40:95:36:35:34
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 1024 bind 1024)
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 40K
Shell invoked to run file: /etc/rc
Command: hostname Samsung
Command: /bin/expand /etc/ramfs.img /dev/ram0
Command: /bin/expand /etc/ramfs2048.img /dev/ram1
Command: mount -t proc proc /proc
Command: mount -t ext2 /dev/ram0 /var
Command: mount -t ext2 /dev/ram1 /ramdisk
Command: chmod 777 /ramdisk
Command: mkdir /var/config
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 35 -
Command: mkdir /var/lock
Command: ifconfig lo 127.0.0.1
Command: route add -net 127.0.0.0 netmask 255.255.255.0 lo
Command: ifconfig eth0 192.168.168.101 netmask 255.255.255.0 up
Command: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|
For further information check:
http://www.uclinux.org/
Execution Finished, Exiting
Sash command shell (version 1.1.1)
/> ls
bin
dev
etc
home
lib
mnt
proc
ramdisk
sbin
tmp
usr
var
/>
/> cd bin
/bin> ./demo
Hello world!
[lumit] - let us make it together
--------------------
http://www.lumit.org
/bin>
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 36 -
附录 - uCLinux FAQs
Q: 请问uclinux启动时最先执行哪一个程序文件中的代码
A: 如果是不压缩的内核,则执行 linux-2.4.x/arch/armnommu/kernel/head-armv.S
如果是压缩的内核,则先执行解压的程序
linux-2.4.x/arch/armnommu/boot/compressed/head.S
当然,如果是其他的 arch ,应该可以依此类推.
Q: 程序在 ram 中运行和在 rom 中运行有什么不同
A: 至少有以下这些情况是需要 ram 的 :
程序中定义了全局变量,并进行了赋值. 例如 int a; a = 1;
程序中进行了函数调用,使用了堆栈. 例如 function();
在函数内部使用了局部变量,同样也会使用堆栈. 例如 void f() { int a = 5; }
程序中对某内存地址进行了写操作.例如 str r1, [r2]; *paddr = 1;
如果一个程序没有上面的这些,那么 rom 中也是可以跑的,比如点led的小汇编.
Q: uclinux中,与具体的cpu相关的代码都分布在哪几个目录中
A: 以 Samsung 4510B 为例,以下目录的相关文件比较重要.
uClinux-Samsung\linux-2.4.x\arch\armnommu\mach-samsung\* 芯片级
uClinux-Samsung\vendors\Samsung\4510B\makefile 如何生成 image, romfs
uClinux-Samsung\linux-2.4.x\drivers\char\serial_samsung.c 串口驱动
uClinux-Samsung\linux-2.4.x\include\asm-armnommu\arch-samsung 头文件定义
Q: 编译之后在 images 目录下生成的那些文件都是什么意思
A: 对于一些可能出现的文件,这里做一个解释:
romfs.img: 这个文件是通过 tools/romfs-inst.sh 脚本,生成 romfs 目录及其
下面的文件,然后通过 genromfs 程序打包成一个文件 romfs.img
romfs.img 既可以放在 flash 中,也可以放在 ram 中,但需要在
编译内核时在 driver/block/blkmem.c 里指定地址,以便内核找到.
linux.text: 编译后的内核中 text 段,一般放在 flash 中,只读.
linux.data: 编译后的内核中 data,init 段,一般放在 sdram 中,读写.
image.bin: 上面三个文件顺序连接而生成的 = linux.text + linux.data + romfs.img
有的时候还会得到:
image.rom: 通常 image.rom 的文件大小要比 image.ram 小很多,这是因为 image.rom 是
一个压缩过的内核,前面加上一个小的解压程序负责把内核解压后搬到指定位置.
这个文件可以直接烧进 flash 中,当然也可以在 ram 中运行.这个文件实际上
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 37 -
就是通常 linux 生成的 zImage 文件.
image.ram: 这个内核没有压缩过,而且必须在 ram 里运行.所以需要通过板子上的 bootloader
将它下载到指定位置后开始执行.相对 image.rom 而言,从 ram 里启动内核,则
代码段和数据段都在 ram 里面.这个文件是编译生成的 elf 格式的linux内核,通过
arm-elf-objcopy 工具生成的二进制映像文件.
可以这样形象的说: image.rom = gunzip program + gzipped(image.ram)
boot.rom: 其实就是 uClinux 编译完成后的文件 images/romfs.img,可以看一下它就是一个
连接.
Q: 在 make menuconfig 时读取的配置文件是什么
A: make menuconfig 是用的的配置文件主要有以下几个:
vi config.in
主要是处理 top level config ,包括 vendor/product, linux-2.4.x 版本选择,
Libc version,还有是否选择配置 Kernel Settings,Vendor/User Settings 等.
这个 config.in 文件是通过执行 config/mkconfig > config.in 脚本自动生成的.
( 因此修改 config.in 不起作用哟! )
vi arch/armnommu/config.in
主要是处理和 kernel settings 相关的配置,比如 选择 cpu 类型,选择设备驱动,
文件系统支持,网络支持 等等.这些也是裁减内核最重要的配置文件.
可以修改 arch/armnommu/config.in 来调整 make menuconfig 时的选项设置.
vi config/config.in
主要是处理 Vendor/User Settings 相关的部分,也就是 romfs 中添加的应用程序,
可以修改 config/config.in 来改变相关的选项设置.
vi vendors/Samsung/4510B/config.linux-2.4.x
Q: kernel 链接时用的 vmlinux.lds 是怎么得到的
A: vi linux-2.4.x/arch/armnommu/vmlinux-armv.lds.in 这个是原始文件,
vi arch/armnommu/Makefile 在这里定义了如何通过 sed 命令生成 lds.
其实就是把 Makefile 里面定义的 TEXTADDR 替换到 lds.in 文件里.
Q: kernel 链接时的起始地址 TEXTADDR 在哪里指定
A: vi arch/armnommu/Makefile 在相应的 ARCH 下找,
一般缺省的是 0xC0008000 .但不同的芯片会有不同的定义,例如
148 ifeq ($(CONFIG_ARCH_ATMEL),y)
149 TEXTADDR = 0x1000000
150 MACHINE = atmel
151 endif
166 ifeq ($(CONFIG_ARCH_SAMSUNG),y)
lumit4510 学习开发板 -- uClinux & SkyEye 实验手册
http://www.lumit.org
[lumit] - let us make it together - 38 -
167 TEXTADDR = 0x00008000
168 MACHINE = samsung
169 endif
你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=1089808
|
- 评论人:CHENKUI
2007-05-22 09:30:48
|
|||
想详细了解一下,现在手上有个关于这方面的项目,还不是很清楚从何如手? |
||||