<?xml version="1.0" encoding="gbk"?> <rss version="2.0"><channel> <title>定阅帖子更新</title> <link>http://www.broadkey.com.cn/XML.ASP</link><description>TEAM Board - 科伟奇电子</description> <copyright>TEAM 2.0.5 Release</copyright><generator>TEAM Board by TEAM5.Cn Studio</generator> <ttl>30</ttl><item><link>http://www.broadkey.com.cn/Thread.asp?tid=233 </link><title>基于AT91RM9200的嵌入式ARM开发平台的实现</title><author>nicky2008</author><pubDate>2009/12/3 8:47:08</pubDate><description><![CDATA[<a class="jt" title="" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="35"><font color="#0033cc">嵌入式</font></a>系统是以应用为中心，以计算机技术为基础，软硬件可以裁剪来适应系统对功能、可靠性、成本、体积、功耗要求严格的专用计算机体系。随着各种<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_03.html" target="_blank" jquery1259801054174="37"><font color="#0033cc">微处理器</font></a>功能的完善以及软件上操作系统的支持，使得<a class="jt" title="" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="38"><font color="#0033cc">嵌入式</font></a>系统有了完整的体系架构。
<p jquery1259801054174="40">　　在专用的<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="39"><font color="#0033cc">嵌入式</font></a>板上运行操作系统需要利用Bootloader来引导加载内核和系统程序。Bootloader主要实现初始化硬件设备、建立内存空间的映射图，从而把<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="41"><font color="#0033cc">嵌入式</font></a>硬件和<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="42"><font color="#0033cc">嵌入式</font></a>操作系统很好地衔接起来。</p>
<p sizcache="3" sizset="0" jquery1259801054174="44">　　U-Boot是当前比较流行、功能强大、比较有代表性的Bootloader，支持的处理器包括Power<a class="jt" title="" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="43"><font color="#0033cc">ARM</font></a>(<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="45"><font color="#0033cc">ARM</font></a>7，<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="46"><font color="#0033cc">ARM</font></a>9，Srongarm，Xscale)、MIPS、X86、Motorola等系列。</p>
<p jquery1259801054174="48">　　与目前常见的<a class="jt" title="" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="47"><font color="#0033cc">嵌入式</font></a>操作系统如Vxworks，QNx，Windows CE，Palm Os等相比，<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="49"><font color="#0033cc">嵌入式</font></a>Linux操作系统以价格低廉、功能强大而且易于移植被广泛地使用到各种<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="50"><font color="#0033cc">嵌入式</font></a>设备当中。文中主要介绍了基于at91 rm9200的<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="51"><font color="#0033cc">ARM</font></a>硬件开发平台，以及U-Boot和Linux-2．6．20内核在此平台上的移植。</p>
<p jquery1259801054174="53">　　AT91RM9200处理器，是由Atmel公司开发的基于<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="52"><font color="#0033cc">ARM</font></a>920T内核的<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_03.html" target="_blank" jquery1259801054174="54"><font color="#0033cc">微处理器</font></a>，带有MMU，CPU时钟最高可达240 MHz，有着丰富的标准接口、EBI接口，内部集成了静态存储控制器、SDRAM控制器、Burst Flash控制器等。SDRAM采用两片hy57v651620b芯片，组成32 bit通道，大小一共16 MB，Flash采用Intel Js28f128芯片，容量为16 MB。网络芯片采用dm9161a。系统硬件平台的原理，如图1所示。</p>
<p align="center"><img style="letter-spacing: normal" border="0" hspace="0" alt="系统硬件平台的原理" src="/uploadfile/qrs/uploadfile/200911/20091130084421702.jpg" width="443" height="278" /></p>
<p>　　<strong>1 U-Boot移植</strong></p>
<p>　　对于AT91RM9200，系统上电时，通过检测BMS来选择系统的启动方式，如果BMS为高电平，则系统从片内ROM启动，如果BMS为低电平，则从片外的Flash启动。在没有移植U-Boot到Flash之前，只能选择片内ROM启动。片内启动时，AT91RM9200的ROM上电之后被映射到了0x0和0x100000处，在这两个地址处都可以访问ROM。AT91RM9200的ROM固化了一个Bootloarder程序，这个Bootloader主要完成一些相应的初始化工作，并且运行Xmodem协议等待接收Loader．bin映像。Loader.bin代码可以到Atmel官方网站下载，Loader.bin主要完成的任务是通过Xmodem协议将U-Boot．bin下载到内存中直接运行。U-Boot．bin在内存中跑起来之后就可以利用U-Boot的功能把Boot．bin和U-Boot．bin写到Flash中，从而实现片外Flash启动。其中Boot．bin主要实现的任务是把Flash中的U-Boot拷贝到内存中执行。</p>
<p>　　U-Boot的源代码可以到官方网站下载。文中所用的版本是U-Boot-1．1．1，对AT91RM9200的芯片完全支持，由于具体硬件的不同，需要做一定的修改。支持AT91RM9200代码在BOARD／AT91RM9200 目录下面，主要有AT91RM9200DK．c，Flash．c，U-Boot．lds，Con-fig．mk几个文件。主要做的修改如下：</p>
<p>　　(1)修改Config．mk中的Tex_base为0x20f00000，和前面的boot地址保持一致；</p>
<p jquery1259801054174="56">　　(2)修改Flash．c文件，使其支持Intel JS28F128芯片。由于官方使用支持的是AMD Flash，需要在代码里添加对本系统芯片的支持。在U-Boot的代码中Strong <a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="55"><font color="#0033cc">ARM</font></a>架构里的xm250，它的代码是支持Intel Flash的，可以参考相应代码实现移植；</p>
<p>　　(3)修改头文件 include／Configs／AT91RM9200dk．H，主要修改的是针对SDRAM以及Flash的参数配置：将phys_sdram设置成0x20000000，这个是SDRAM的起始地址，phys_flash_sdram_size设置为0x1000000，SDRAM容量为16 MB。对于Flash，需要修改的是：Flash起始地址设置为0x10000000(Flash挂在bank0上)，phys_flash_size设置为0x1000000。扇区的总数cfg_max_flash_sect相应设置为128。</p>
<p>　　最后在Linux里安装交叉编译器，笔者用的交叉编译器的版本是2．95．3，编译代码，生成U-Boot．bin文件。U-Boot启动后显示，如图2所示。</p>
<p align="center"><img style="letter-spacing: normal" border="0" hspace="0" alt="U-Boot启动后显示" src="/uploadfile/qrs/uploadfile/200911/20091130084421929.jpg" width="452" height="325" /></p>
<p>　　<strong>2 Linux2．6．20内核移植</strong></p>
<p><strong>　　2．1 Linux内核版本选择</strong></p>
<p>　　Linux内核版本更新速度非常块，现在最新的版本已发展到了2．6．26．3。与2．4内核相比，2．6内核稳定性更好、对于总线、文件系统、块设备支持、多媒体、网络安全性等方面都有了更好的支持，因此笔者选择移植功能和可靠性都比较欧成熟的Linux2．6．20版本到本系统中。Linux内核的源代码可在www．kernel．org网站上下载，Atmel官方网站上可以获取针对AT91RM9200的补丁2．6．20-AT91．patch．gz和Linux-2．6．20-exp．diff．Bz2。对Linux2．6．20源代码打上支持AT91RM9200处理器的补丁之后，内核就可以支持AT91RM9200处理器了。</p>
<p>　　<strong>2．2 交叉编译环境的建立</strong></p>
<p jquery1259801054174="58">　　采用的交叉编译工具为<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="57"><font color="#0033cc">ARM</font></a>-Linux-Gcc3．4．1，这是目前比较通用支持编译2．6内核的交叉编译器，完全支持编译2．6内核，在开发平台上将交叉编译器安装好，并配置好环境变量Path=$Path：／Usr／Local／Arm／3．4．1／Bin。</p>
<p>　　<strong>2．3 解决Machine Id问题</strong></p>
<p>　　在U-Boot的代码中，支持的AT91RM9200的Machine类型为25 1、262两种，这两种在Include／asm-arm／mach-types．h定义为mach_type_AT91RM9200和mach_type_AT91RM9200dk，在U-Boot中board／AT9 1 RM9200dk／AT91 RM9200dk．c中采用的是第一种，而在Linux2．6．20内核代码中arh／Arm／Math-AT91RM9200使用的类型却为AT91RM9200DK，也就是第2种。因此在启动的时候会出现Machine不匹配的问题，解决问题的办法就是更改U-Boot或者Linux内核的代码，使其Machine类型相匹配。</p>
<p>　　<strong>2．4 Nor Flash的地址安排</strong></p>
<p>　　笔者采用的Flash为16 MB NOR Flash，为了实现层次文件系统，需要增加NOR Flash MTD驱动支持，具体地址安排，如图3所示。</p>
<p align="center"><img style="letter-spacing: normal" border="0" hspace="0" alt="NOR Flash地址安排" src="/uploadfile/qrs/uploadfile/200911/20091130084421942.jpg" width="383" height="219" /></p>
<p>　　在Dirvers／MTD／Maps／里增加AT91 RM9200．c文件，作为自己的分区代码，并且编译进内核。</p>
<p>　　<strong>2．5 编译内核</strong></p>
<p jquery1259801054174="60">　　首先要修改内核内核目录下MAKEFILE文件，编译器修改为安装好的交叉编译器，即Arch?=<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="59"><font color="#0033cc">ARM</font></a>和Cross_Compile?=<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="61"><font color="#0033cc">ARM</font></a>-Linux-，然后运行命令make AT91RM9200DK_Defconfig，配置好内核。如果需要修改一些具体的配置，可以运行makeMenuconfig命令进入如下菜单进行配置。配置好内核之后运行make Image命令，编译生成内核镜像Vmlinux，最后用Mkimage工具生成Uimage。</p>
<p align="center"><img style="letter-spacing: normal" border="0" hspace="0" alt="编译内核选项" src="/uploadfile/qrs/uploadfile/200911/20091130084422664.jpg" width="363" height="248" /></p>
<p>　　<strong>2．6 制作Ramdisk文件系统</strong></p>
<p>　　Linux采用文件系统组织系统中的文件和设备，为设备和用户程序提供统一接口，因此Linux启动还需要有根文件系统。根文件系统的作用是存放各种工具、应用程序以及必须的库文件等。Ramdisk是通过计算机的内存用作设备来创建和挂在文件系统的一种驱动机制，它通常用于无盘系统。根文件系统通常包括一下目录内容：／Dev(设备目录)；／Proe(Proe文件系统目录)；／Etc(系统配置文件)；／Sbin(系统程序的目录)；／Bin(系统应用程序，通常由busybox来实现)；／Lib(共享库文件)；／Mnt(装在其它磁盘节点的目录)；／Usr(附加应用程序的目录)。</p>
<p>　　<strong>3 结束语</strong></p>
<p jquery1259801054174="63">　　<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_02.html" target="_blank" jquery1259801054174="62"><font color="#0033cc">ARM</font></a>9作为新一代处理器有着更高的性价比、更低的功耗、执行速度更快、性能更高、应用范围更加广泛的特点；Linux以其优越的性能、源代码的开放、容易移植等特点被应用于越来越多的领域当中。基于AT91RM9200微控制器的硬件<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="64"><font color="#0033cc">嵌入式</font></a>开发平台，可以根据具体需要，应用于<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="65"><font color="#0033cc">嵌入式</font></a>教学实验以及<a class="jt" href="http://www.eeworld.com.cn" rel="http://www.eeworld.com.cn/my/keyad/ad_content_01.html" target="_blank" jquery1259801054174="66"><font color="#0033cc">嵌入式</font></a>产品开发等多种场合中，具有广阔的发展前景。</p>]]></description></item></channel></rss>