﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客网-嵌入式-文章分类-U-Boot相关方面的资料</title><link>http://www.cnitblog.com/zouzheng/category/6841.html</link><description>要像阿甘一直向前奔跑！</description><language>zh-cn</language><lastBuildDate>Thu, 27 Mar 2008 10:23:58 GMT</lastBuildDate><pubDate>Thu, 27 Mar 2008 10:23:58 GMT</pubDate><ttl>60</ttl><item><title>uboot patch for QT2410 and GTA01/02</title><link>http://www.cnitblog.com/zouzheng/articles/41560.html</link><dc:creator>zz</dc:creator><author>zz</author><pubDate>Thu, 27 Mar 2008 07:41:00 GMT</pubDate><guid>http://www.cnitblog.com/zouzheng/articles/41560.html</guid><wfw:comment>http://www.cnitblog.com/zouzheng/comments/41560.html</wfw:comment><comments>http://www.cnitblog.com/zouzheng/articles/41560.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zouzheng/comments/commentRss/41560.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zouzheng/services/trackbacks/41560.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>Bootloader/zh cn <a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn">http://wiki.openmoko.org/wiki/Bootloader/zh_cn</a></h1>
<div id=bodyContent>
<h3 id=siteSub>From OpenMoko</h3>
<div id=contentSub></div>
<div id=jump-to-nav>Jump to: <a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#column-one"><u><font color=#0000ff>navigation</font></u></a>, <a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#searchInput"><u><font color=#0000ff>search</font></u></a></div>
<!-- start content -->
<div class="thumb tright">
<div style="WIDTH: 302px"><a class=internal title=Neo1973控制台上的u-boot href="http://wiki.openmoko.org/wiki/Image:Uboot-s3c2410fb.jpg"><u><font color=#0000ff><img height=450 alt=Neo1973控制台上的u-boot src="http://wiki.openmoko.org/images/thumb/4/47/Uboot-s3c2410fb.jpg/300px-Uboot-s3c2410fb.jpg" width=300 longDesc=/wiki/Image:Uboot-s3c2410fb.jpg></font></u></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=Enlarge href="http://wiki.openmoko.org/wiki/Image:Uboot-s3c2410fb.jpg"><img height=11 alt=Enlarge src="http://wiki.openmoko.org/skins/common/images/magnify-clip.png" width=15></a></div>
Neo1973控制台上的u-boot</div>
</div>
</div>
<div class="thumb tright">
<div style="WIDTH: 302px"><a class=internal title=Neo1973上的u-boot引导菜单 href="http://wiki.openmoko.org/wiki/Image:Neo1973_uboot_splash_closeup.jpg"><img height=385 alt=Neo1973上的u-boot引导菜单 src="http://wiki.openmoko.org/images/thumb/e/e5/Neo1973_uboot_splash_closeup.jpg/300px-Neo1973_uboot_splash_closeup.jpg" width=300 longDesc=/wiki/Image:Neo1973_uboot_splash_closeup.jpg></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=Enlarge href="http://wiki.openmoko.org/wiki/Image:Neo1973_uboot_splash_closeup.jpg"><img height=11 alt=Enlarge src="http://wiki.openmoko.org/skins/common/images/magnify-clip.png" width=15></a></div>
Neo1973上的u-boot引导菜单</div>
</div>
</div>
<table class=toc id=toc summary=Contents>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>Contents</h2>
            <span class=toctoggle>[<a class=internal id=togglelink href="javascript:toggleToc()"><u><font color=#0000ff>hide</font></u></a>]</span></div>
            <ul lastCheckbox="null">
                <li class=toclevel-1><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E6.A6.82.E8.BF.B0"><u><font color=#0000ff><span class=tocnumber>1</span> <span class=toctext>概述</span></font></u></a>
                <li class=toclevel-1><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F.E6.BA.90.E4.BB.A3.E7.A0.81"><u><font color=#0000ff><span class=tocnumber>2</span> <span class=toctext>引导装载程序源代码</span></font></u></a>
                <li class=toclevel-1><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F.E4.BA.8C.E8.BF.9B.E5.88.B6.E6.96.87.E4.BB.B6"><u><font color=#0000ff><span class=tocnumber>3</span> <span class=toctext>引导装载程序二进制文件</span></font></u></a>
                <li class=toclevel-1><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F.E5.BC.80.E5.8F.91"><u><font color=#0000ff><span class=tocnumber>4</span> <span class=toctext>引导装载程序开发</span></font></u></a>
                <ul lastCheckbox="null">
                    <li class=toclevel-2><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#QT2410"><u><font color=#0000ff><span class=tocnumber>4.1</span> <span class=toctext>QT2410</span></font></u></a>
                    <li class=toclevel-2><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#GTA01"><u><font color=#0000ff><span class=tocnumber>4.2</span> <span class=toctext>GTA01</span></font></u></a>
                    <ul>
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E4.BD.BF.E7.94.A8JTAG.E4.BB.8ERAM.E5.90.AF.E5.8A.A8"><u><font color=#0000ff><span class=tocnumber>4.2.1</span> <span class=toctext>使用JTAG从RAM启动</span></font></u></a> </li>
                    </ul>
                    </li>
                </ul>
                <li class=toclevel-1><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.BB.BA.E7.AB.8B.E5.8F.AF.E5.BC.95.E5.AF.BC.E7.9A.84.E6.98.A0.E5.83.8F.E6.96.87.E4.BB.B6"><u><font color=#0000ff><span class=tocnumber>5</span> <span class=toctext>建立可引导的映像文件</span></font></u></a>
                <li class=toclevel-1><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.BC.95.E5.AF.BC.E8.8F.9C.E5.8D.95"><u><font color=#0000ff><span class=tocnumber>6</span> <span class=toctext>引导菜单</span></font></u></a>
                <ul lastCheckbox="null">
                    <li class=toclevel-2><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E8.BF.9B.E5.85.A5.E5.BC.95.E5.AF.BC.E8.8F.9C.E5.8D.95"><u><font color=#0000ff><span class=tocnumber>6.1</span> <span class=toctext>进入引导菜单</span></font></u></a>
                    <li class=toclevel-2><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E4.BD.BF.E7.94.A8.E5.BC.95.E5.AF.BC.E8.8F.9C.E5.8D.95"><u><font color=#0000ff><span class=tocnumber>6.2</span> <span class=toctext>使用引导菜单</span></font></u></a>
                    <li class=toclevel-2><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E7.BB.99.E5.BC.95.E5.AF.BC.E8.8F.9C.E5.8D.95.E5.A2.9E.E5.8A.A0.E9.A1.B9.E7.9B.AE"><u><font color=#0000ff><span class=tocnumber>6.3</span> <span class=toctext>给引导菜单增加项目</span></font></u></a> </li>
                </ul>
                <li class=toclevel-1><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F.E5.91.BD.E4.BB.A4.E6.8F.90.E7.A4.BA.E8.A1.8C"><u><font color=#0000ff><span class=tocnumber>7</span> <span class=toctext>引导装载程序命令提示行</span></font></u></a>
                <ul lastCheckbox="null">
                    <li class=toclevel-2><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#Accessing_the_bootloader_prompt"><u><font color=#0000ff><span class=tocnumber>7.1</span> <span class=toctext>Accessing the bootloader prompt</span></font></u></a>
                    <ul lastCheckbox="null">
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#Using_usbtty_from_Linux"><u><font color=#0000ff><span class=tocnumber>7.1.1</span> <span class=toctext>Using usbtty from Linux</span></font></u></a>
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#Typical_u-boot_prompt"><u><font color=#0000ff><span class=tocnumber>7.1.2</span> <span class=toctext>Typical u-boot prompt</span></font></u></a> </li>
                    </ul>
                    <li class=toclevel-2><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#Commands_on_the_bootloader_prompt"><u><font color=#0000ff><span class=tocnumber>7.2</span> <span class=toctext>Commands on the bootloader prompt</span></font></u></a>
                    <ul lastCheckbox="null">
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E8.87.AA.E5.8A.A8.E5.BC.95.E5.AF.BC"><u><font color=#0000ff><span class=tocnumber>7.2.1</span> <span class=toctext>自动引导</span></font></u></a>
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E7.8E.AF.E5.A2.83.E5.8F.98.E9.87.8F"><u><font color=#0000ff><span class=tocnumber>7.2.2</span> <span class=toctext>环境变量</span></font></u></a>
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#MMC.2FSD.E5.8D.A1"><u><font color=#0000ff><span class=tocnumber>7.2.3</span> <span class=toctext>MMC/SD卡</span></font></u></a>
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#NAND"><u><font color=#0000ff><span class=tocnumber>7.2.4</span> <span class=toctext>NAND</span></font></u></a>
                        <ul lastCheckbox="null">
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E4.BB.8E_NAND_.E5.8A.A0.E8.BD.BD.E5.86.85.E6.A0.B8"><u><font color=#0000ff><span class=tocnumber>7.2.4.1</span> <span class=toctext>从 NAND 加载内核</span></font></u></a>
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.90.91_NAND_.E5.86.99.E6.96.B0.E7.9A.84.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F"><u><font color=#0000ff><span class=tocnumber>7.2.4.2</span> <span class=toctext>向 NAND 写新的引导装载程序</span></font></u></a>
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.90.91_NAND_.E5.86.99.E5.86.85.E6.A0.B8"><u><font color=#0000ff><span class=tocnumber>7.2.4.3</span> <span class=toctext>向 NAND 写内核</span></font></u></a>
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.90.91_NAND_.E5.86.99.E6.A0.B9.E6.96.87.E4.BB.B6.E7.B3.BB.E7.BB.9F"><u><font color=#0000ff><span class=tocnumber>7.2.4.4</span> <span class=toctext>向 NAND 写根文件系统</span></font></u></a> </li>
                        </ul>
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#Neo1973_.E7.9B.B8.E5.85.B3.E7.9A.84.E5.91.BD.E4.BB.A4"><u><font color=#0000ff><span class=tocnumber>7.2.5</span> <span class=toctext>Neo1973 相关的命令</span></font></u></a>
                        <ul lastCheckbox="null">
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.85.B3.E6.9C.BA"><u><font color=#0000ff><span class=tocnumber>7.2.5.1</span> <span class=toctext>关机</span></font></u></a>
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.85.85.E7.94.B5.E5.99.A8.E7.9B.B8.E5.85.B3"><u><font color=#0000ff><span class=tocnumber>7.2.5.2</span> <span class=toctext>充电器相关</span></font></u></a>
                            <ul lastCheckbox="null">
                                <li class=toclevel-5><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E6.9F.A5.E8.AF.A2.E5.85.85.E7.94.B5.E5.99.A8.E7.8A.B6.E6.80.81"><u><font color=#0000ff><span class=tocnumber>7.2.5.2.1</span> <span class=toctext>查询充电器状态</span></font></u></a>
                                <li class=toclevel-5><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E7.A6.81.E7.94.A8.E5.85.85.E7.94.B5.E5.99.A8"><u><font color=#0000ff><span class=tocnumber>7.2.5.2.2</span> <span class=toctext>禁用充电器</span></font></u></a>
                                <li class=toclevel-5><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E5.BC.BA.E5.88.B6.E5.BF.AB.E9.80.9F.E5.85.85.E7.94.B5"><u><font color=#0000ff><span class=tocnumber>7.2.5.2.3</span> <span class=toctext>强制快速充电</span></font></u></a>
                                <li class=toclevel-5><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E4.BD.BF.E8.83.BD.2F.E7.A6.81.E7.94.A8.E8.87.AA.E5.8A.A8.E5.BF.AB.E9.80.9F.E5.85.85.E7.94.B5"><u><font color=#0000ff><span class=tocnumber>7.2.5.2.4</span> <span class=toctext>使能/禁用自动快速充电</span></font></u></a> </li>
                            </ul>
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E8.83.8C.E5.85.89.E7.81.AF"><u><font color=#0000ff><span class=tocnumber>7.2.5.3</span> <span class=toctext>背光灯</span></font></u></a>
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E6.8C.AF.E5.8A.A8"><u><font color=#0000ff><span class=tocnumber>7.2.5.4</span> <span class=toctext>振动</span></font></u></a> </li>
                        </ul>
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#S3C2410_.E4.B8.93.E7.94.A8.E5.91.BD.E4.BB.A4"><u><font color=#0000ff><span class=tocnumber>7.2.6</span> <span class=toctext>S3C2410 专用命令</span></font></u></a>
                        <ul>
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#266MHz.E6.97.B6.E9.92.9F"><u><font color=#0000ff><span class=tocnumber>7.2.6.1</span> <span class=toctext>266MHz时钟</span></font></u></a> </li>
                        </ul>
                        <li class=toclevel-3><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#QT2410.E4.B8.8A.E7.9A.84TFTP"><u><font color=#0000ff><span class=tocnumber>7.2.7</span> <span class=toctext>QT2410上的TFTP</span></font></u></a>
                        <ul>
                            <li class=toclevel-4><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#TFTP_kernel_download"><u><font color=#0000ff><span class=tocnumber>7.2.7.1</span> <span class=toctext>TFTP kernel download</span></font></u></a> </li>
                        </ul>
                        </li>
                    </ul>
                    </li>
                </ul>
                <li class=toclevel-1><a href="http://wiki.openmoko.org/wiki/Bootloader/zh_cn#.E8.AE.BE.E5.A4.87.E5.9B.BA.E4.BB.B6.E5.8D.87.E7.BA.A7"><u><font color=#0000ff><span class=tocnumber>8</span> <span class=toctext>设备固件升级</span></font></u></a> </li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<script type=text/javascript> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 概述" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=1"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E6.A6.82.E8.BF.B0></a>
<h2>概述 </h2>
<p>GTA01使用了<a class="external text" title=http://u-boot.sourceforge.net/ href="http://u-boot.sourceforge.net/" rel=nofollow><u><font color=#810081>u-boot</font></u></a>引导装载程序。 </p>
<p>关于u-boot的更多信息可以在下列地方找到 </p>
<ul lastCheckbox="null">
    <li><a class="external free" title=http://www.denx.de/wiki/DULG href="http://www.denx.de/wiki/DULG" rel=nofollow><u><font color=#0000ff>http://www.denx.de/wiki/DULG</font></u></a>
    <li><a class="external free" title=http://www.gumstix.org/tikiwiki/tiki-index.php?page=U-Boot href="http://www.gumstix.org/tikiwiki/tiki-index.php?page=U-Boot" rel=nofollow><u><font color=#0000ff>http://www.gumstix.org/tikiwiki/tiki-index.php?page=U-Boot</font></u></a>
    <li><a class="external free" title=http://linuxdevices.com/articles/AT5085702347.html href="http://linuxdevices.com/articles/AT5085702347.html" rel=nofollow><u><font color=#810081>http://linuxdevices.com/articles/AT5085702347.html</font></u></a> </li>
</ul>
<p>但是，未经修改的u-boot不支持GTA01所需要的许多特性，比如 </p>
<ul lastCheckbox="null">
    <li>利用<a title="S3C2410 Steppingstone/zh cn" href="http://wiki.openmoko.org/wiki/S3C2410_Steppingstone/zh_cn"><u><font color=#810081>S3C2410 Steppingstone</font></u></a>从NAND闪存启动
    <li>从SD/Transflash读取内核/initrd
    <li>S3C2410 NAND闪存
    <li>通过S3C2410 USB Device控制器下载程序
    <li>S3C2410 Framebuffer启动logo/状态显示 </li>
</ul>
<p><a title=User:HaraldWelte href="http://wiki.openmoko.org/wiki/User:HaraldWelte"><u><font color=#0000ff>Harald Welte</font></u></a>正在为这些解决问题而工作，并且实际上它们中的大多数已经得到了实现。 </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 引导装载程序源代码" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=2"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F.E6.BA.90.E4.BB.A3.E7.A0.81></a>
<h2>引导装载程序源代码 </h2>
<p>从 <a class="external free" title=http://svn.openmoko.org/trunk/src/target/u-boot/patches/ href="http://svn.openmoko.org/trunk/src/target/u-boot/patches/" rel=nofollow><u><font color=#0000ff>http://svn.openmoko.org/trunk/src/target/u-boot/patches/</font></u></a> 可以获得当前的引导装载程序的补丁。 </p>
<p>Untar the sources, apply the patch. run "make gta01bv3_config" (or gta01bv2_config, or whatever hardware revision you have), run "make". You will get a resulting "u-boot.bin" image, which you can directly flash (either using existing bootloader or <a title=Sjf2410-linux href="http://wiki.openmoko.org/wiki/Sjf2410-linux"><u><font color=#0000ff>sjf2410-linux</font></u></a>) into NAND. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 引导装载程序二进制文件" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=3"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F.E4.BA.8C.E8.BF.9B.E5.88.B6.E6.96.87.E4.BB.B6></a>
<h2>引导装载程序二进制文件 </h2>
<p>最新的引导装载程序二进制文件可以从 <a class="external free" title=http://buildhost.openmoko.org/tmp/gta01/deploy/images/ href="http://buildhost.openmoko.org/tmp/gta01/deploy/images/" rel=nofollow><u><font color=#0000ff>http://buildhost.openmoko.org/tmp/gta01/deploy/images/</font></u></a> 网站找到。它应该写到 NAND flash 0x00000000 (size 0x30000) 地址处。 </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 引导装载程序开发" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=4"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F.E5.BC.80.E5.8F.91></a>
<h2>引导装载程序开发 </h2>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: QT2410" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=5"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=QT2410></a>
<h3>QT2410 </h3>
<p>If you want to do bootloader development on the QT2410, it's easier to work with a bootloader image that can be downloaded via USB into RAM instead of flashing. </p>
<p>为了做到这一点，你需要编辑 u-boot/include/configs/qt2410.h 文件，将32行的 "if 0" 改为 "if 1"，然后用 "make" 重新编译。 </p>
<p>The resulting "u-boot.bin" is _NOT SUITABLE_ for NAND flash, but only for direct execution from within ram, e.g. by using the <a title="S3c2410 boot usb" href="http://wiki.openmoko.org/wiki/S3c2410_boot_usb"><u><font color=#0000ff>s3c2410_boot_usb</font></u></a> program. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: GTA01" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=6"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=GTA01></a>
<h3>GTA01 </h3>
<p>Doing bootloader development on the GTA01 is a bit more tricky. first, we don't have any NOR flash. Second, there is no other way to boot _but_ from NAND. Therefore, we also don't have a USB downloader like the QT2410. </p>
<p>The main problem is: The <a title="S3C2410 Steppingstone" href="http://wiki.openmoko.org/wiki/S3C2410_Steppingstone"><u><font color=#0000ff>S3C2410 Steppingstone</font></u></a> unconditionally copies the first 4k of flash into its internal SRAM. That SRAM segment stays unconditionally mapped at physical address zero. How do we get around this </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 使用JTAG从RAM启动" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=7"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E4.BD.BF.E7.94.A8JTAG.E4.BB.8ERAM.E5.90.AF.E5.8A.A8></a>
<h4>使用JTAG从RAM启动 </h4>
<p>So how can we boot from RAM? We use JTAG / OpenOCD to </p>
<ul>
    <li>reset and halt the cpu at PC=0 </li>
</ul>
<pre>&gt; reset halt
target halted in ARM state due to debug request, current mode: Supervisor
cpsr: 0x400000d3 pc: 0x00000000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
</pre>
<ul>
    <li>download a small piece of code for low-level SDRAM timing initialization (overwrite 4k SRAM of steppingstone) </li>
</ul>
<pre>&gt; load_binary /space/misc/gta01/u-boot.git/foo.bin 0
downloaded 332 byte in 0s 21899us
</pre>
<ul>
    <li>assert a break point at address 0x33f80000 (which indicates that the low-level code has finished) </li>
</ul>
<pre>&gt; bp 0x33f80000 4 hw
breakpoint added at address 0x33f80000
</pre>
<ul>
    <li>run the code up to the break point </li>
</ul>
<pre>&gt; resume
Target 0 resumed
&gt; Target 0 halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x600000d3 pc: 0x33f80000
MMU: disabled, D-Cache: disabled, I-Cache: enabled
</pre>
<ul>
    <li>download the u-boot RAM image to 0x33f80000 </li>
</ul>
<pre>&gt; load_binary /space/misc/gta01/u-boot.git/u-boot.bin 0x33f80000
downloaded 135692 byte in 6s 567264us
</pre>
<ul>
    <li>resume processing </li>
</ul>
<pre>&gt; resume
Target 0 resumed
</pre>
<p>At this point, the display backlight gets bright and we see the following familiar prompt on the serial console: </p>
<pre>U-Boot 1.1.6 (Jan 13 2007 - 23:44:23)
DRAM:  128 MB
NAND:  64 MiB
*** Warning - bad CRC or NAND, using default environment
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
GTA01Bv2 #
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 建立可引导的映像文件" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=8"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.BB.BA.E7.AB.8B.E5.8F.AF.E5.BC.95.E5.AF.BC.E7.9A.84.E6.98.A0.E5.83.8F.E6.96.87.E4.BB.B6></a>
<h2>建立可引导的映像文件 </h2>
<p>u-boot needs bootable images (such as kernels, but also initrd and others) in form of a so-called <em>uImage</em>. In order to create a <em>uImage</em> from e.g. a <em>vmlinux</em> kernel image, you can proceed as follows: </p>
<pre>objcopy -O binary -R .note -R .comment -S vmlinux linux.bin
gzip -9 linux.bin
u-boot/tools/mkimage -A arm -O linux -T kernel -C gzip -a 30008000 -e 30008000 -n "Kernel Image QT2410" -d linux.bin.gz uImage
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 引导菜单" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=9"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.BC.95.E5.AF.BC.E8.8F.9C.E5.8D.95></a>
<h2>引导菜单 </h2>
<div class="thumb tright">
<div style="WIDTH: 402px"><a class=internal title="u-boot boot menu on Neo1973" href="http://wiki.openmoko.org/wiki/Image:Neo1973_uboot_menu.jpg"><img height=267 alt="u-boot boot menu on Neo1973" src="http://wiki.openmoko.org/images/thumb/2/22/Neo1973_uboot_menu.jpg/400px-Neo1973_uboot_menu.jpg" width=400 longDesc=/wiki/Image:Neo1973_uboot_menu.jpg></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=Enlarge href="http://wiki.openmoko.org/wiki/Image:Neo1973_uboot_menu.jpg"><img height=11 alt=Enlarge src="http://wiki.openmoko.org/skins/common/images/magnify-clip.png" width=15></a></div>
u-boot boot menu on Neo1973</div>
</div>
</div>
<p>As of the Phase-0 release, our u-boot version now features an on-screen boot menu. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 进入引导菜单" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=10"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E8.BF.9B.E5.85.A5.E5.BC.95.E5.AF.BC.E8.8F.9C.E5.8D.95></a>
<h3>进入引导菜单 </h3>
<p>You can access the boot meny by pressing and holding the <a title="Neo1973 AUX Button" href="http://wiki.openmoko.org/wiki/Neo1973_AUX_Button"><u><font color=#0000ff>Neo1973 AUX Button</font></u></a> together with the power button while switching the phone on. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 使用引导菜单" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=11"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E4.BD.BF.E7.94.A8.E5.BC.95.E5.AF.BC.E8.8F.9C.E5.8D.95></a>
<h3>使用引导菜单 </h3>
<p>By pressing the <a title="Neo1973 AUX Button" href="http://wiki.openmoko.org/wiki/Neo1973_AUX_Button"><u><font color=#0000ff>Neo1973 AUX Button</font></u></a> you can cycle through the menu items. Use the <em>POWER</em> button to select one item. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 给引导菜单增加项目" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=12"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E7.BB.99.E5.BC.95.E5.AF.BC.E8.8F.9C.E5.8D.95.E5.A2.9E.E5.8A.A0.E9.A1.B9.E7.9B.AE></a>
<h3>给引导菜单增加项目 </h3>
<p>You can add items to the boot menu by setting environment variables. FIXME. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 引导装载程序命令提示行" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=13"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F.E5.91.BD.E4.BB.A4.E6.8F.90.E7.A4.BA.E8.A1.8C></a>
<h2>引导装载程序命令提示行 </h2>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Accessing the bootloader prompt" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=14"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=Accessing_the_bootloader_prompt></a>
<h3>Accessing the bootloader prompt </h3>
<p>The bootloader prompt is available either on the serial console (via <a title="Debug Board" href="http://wiki.openmoko.org/wiki/Debug_Board"><u><font color=#0000ff>Debug Board</font></u></a>), or as virtual USB Serial device (USB CDC_ACM). Whether the serial port or usb i used depends on the u-boot environment variables <strong>stdin</strong>, <strong>stdout</strong> and <strong>stderr</strong>. </p>
<p>Whether or not you use usbtty, the first couple of messages will always be displayed on the serial console. </p>
<p>The bootloader is currently configured to waid for three seconds. If a key press on the <strong>stdin</strong> is received within those three seconds, auto-boot is aborted. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Using usbtty from Linux" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=15"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=Using_usbtty_from_Linux></a>
<h4>Using usbtty from Linux </h4>
<p>Just by connecting the phone in u-boot mode to your Linux pc should make it detect a <a title="CDC ACM" href="http://wiki.openmoko.org/wiki/CDC_ACM"><u><font color=#0000ff>CDC ACM</font></u></a> device, and you should get a new tty device called /dev/ttySAC0. Use your favourite terminal emulator (minicom, cu, zc, ...) to access it like any other serial port. </p>
<p>First, you should try to check whether the USB device shows up in 'lsusb' while you're running in u-boot mode: </p>
<pre># lsusb -d 1457:5119
Bus 005 Device 079: ID 1457:5119
</pre>
<pre># lsusb -v -d 1457:5119
Bus 005 Device 079: ID 1457:5119
Device Descriptor:
bLength                18
bDescriptorType         1
bcdUSB               1.10
bDeviceClass            2 Communications
bDeviceSubClass         0
bDeviceProtocol         0
bMaxPacketSize0        16
idVendor           0x1457
idProduct          0x5119
bcdDevice            0.00
iManufacturer           1 OpenMoko, Inc
iProduct                2 Neo1973 Bootloader U-Boot 1.2.0-g6c7cac8c-dirty-moko3
iSerial                 3 0000000
bNumConfigurations      1
Configuration Descriptor:
bLength                 9
bDescriptorType         2
wTotalLength           85
bNumInterfaces          3
bConfigurationValue     1
iConfiguration          4 TTY via USB
bmAttributes         0xc0
Self Powered
MaxPower                0mA
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        0
bAlternateSetting       0
bNumEndpoints           1
bInterfaceClass         2 Communications
bInterfaceSubClass      2 Abstract (modem)
bInterfaceProtocol      1 AT-commands (v.25ter)
iInterface              6 Control Interface
CDC Header:
bcdCDC               0.6e
CDC Call Management:
bmCapabilities       0x00
bDataInterface          1
CDC ACM:
bmCapabilities       0x00
CDC Union:
bMasterInterface        0
bSlaveInterface         1
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x81  EP 1 IN
bmAttributes            3
Transfer Type            Interrupt
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0010  1x 16 bytes
bInterval             255
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        1
bAlternateSetting       0
bNumEndpoints           2
bInterfaceClass        10 CDC Data
bInterfaceSubClass      0 Unused
bInterfaceProtocol      0
iInterface              5 Bulk Data Interface
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x02  EP 2 OUT
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0010  1x 16 bytes
bInterval             255
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x83  EP 3 IN
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0010  1x 16 bytes
bInterval             255
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        2
bAlternateSetting       0
bNumEndpoints           0
bInterfaceClass       254 Application Specific Interface
bInterfaceSubClass      1 Device Firmware Update
bInterfaceProtocol      1
iInterface              7 USB Device Firmware Upgrade
Device Status:     0x0001
Self Powered
</pre>
<p>Next, you can access it using your favourite terminal program. </p>
<p>Then, if the environment is not set correctly, you will need to use the current console (e.g. serial console) to set </p>
<pre>GTA01Bv2 # setenv stderr usbtty
GTA01Bv2 # setenv stdout usbtty
GTA01Bv2 # setenv stdin usbtty
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Typical u-boot prompt" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=16"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=Typical_u-boot_prompt></a>
<h4>Typical u-boot prompt </h4>
<pre>U-Boot 1.2.0-moko1 (Feb 16 2007 - 00:36:13)
DRAM:  128 MB
NAND:  64 MiB
Found Environment offset in OOB..
Video: 640x480x8 31kHz 59Hz
USB:   S3C2410 USB Deviced
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
GTA01Bv3 #
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Commands on the bootloader prompt" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=17"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=Commands_on_the_bootloader_prompt></a>
<h3>Commands on the bootloader prompt </h3>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 自动引导" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=18"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E8.87.AA.E5.8A.A8.E5.BC.95.E5.AF.BC></a>
<h4>自动引导 </h4>
<p>Auto-boot executes the command[s] specified in the <em>bootcmd</em> environment variable. The default configuration is: </p>
<pre>GTA01Bv3 # printenv
bootcmd=setenv bootargs ${bootargs_base} ${mtdparts}; nand read.e 0x32000000 kernel; bootm 0x32000000
</pre>
<p>This basically tells us that it will load the content of the NAND partition <strong>kernel</strong> to memory address 0x32000000 and then try to boot it. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 环境变量" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=19"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E7.8E.AF.E5.A2.83.E5.8F.98.E9.87.8F></a>
<h4>环境变量 </h4>
<p>u-boot is configured to manage a non-volatile environment that is stored in NAND flash. You can use the commands to read/alter/store the environment in the following example: </p>
<pre>GTA01Bv2 # printenv
baudrate=115200
bootargs=rootfstype=jffs2 root=/dev/mtdblock4 console=ttySAC0,115200 console=tty0 loglevel=8 dyntick=enable lpj=252416
usbtty=cdc_acm
bootdelay=10
stdout=serial
stderr=serial
stdin=serial
mtdparts=mtdparts=neo1973-nand:0x00030000(u-boot),0x0000c000(u-boot_env),0x00200000(kernel),0x00130000(splash),0x03c94000(rootfs)
mtdids=nand0=neo1973-nand
bootargs_base=rootfstype=jffs2 root=/dev/mtdblock4 console=ttySAC0,115200 console=tty0 loglevel=8 dyntick=enable lpj=252416
bootcmd=setenv bootargs ${bootargs_base} ${mtdparts}; nand read.e 0x32000000 kernel; bootm 0x32000000
pcf50606_int1=0x40
filesize=160C000
partition=nand0,0
mtddevnum=0
mtddevname=u-boot
Environment size: 670/16380 bytes
GTA01Bv3 # setenv bootdelay 10
GTA01Bv3 # printenv bootdelay
bootdelay=10
GTA01Bv3 # saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done
GTA01Bv3 #
</pre>
<p>Note: When setting multiple commands, e.g. for bootcmd, you need to escape the ';', for instance </p>
<pre>GTA01Bv3 # setenv bootcmd mmcinit\; ext2load mmc 0 0x32000000 uImage\; bootm 0x32000000
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: MMC/SD卡" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=20"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=MMC.2FSD.E5.8D.A1></a>
<h4>MMC/SD卡 </h4>
<p>in order to initialize a MMC/SD card, you have to use the ``mmcinit<em> command.</em> </p>
<pre>GTA01Bv3 # mmcinit
trying to detect SD Card...
MMC found. Card desciption is:
Manufacturer ID = 58d564
HW/FW Revision = 3 8
Product Name = 21DN!@X�
Serial Number = 445303
Month = 5
Year = 2000
READ_BL_LEN=15, C_SIZE_MULT=7, C_SIZE=3197
size = 4208984064
GTA01Bv3 #
</pre>
<p>afterwards, you can read ext2 filesystems like: </p>
<pre>GTA01Bv3 # ext2ls mmc 0
&lt;DIR&gt;       1024 .
&lt;DIR&gt;       1024 ..
&lt;DIR&gt;      12288 lost+found
1544788 uImage
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: NAND" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=21"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=NAND></a>
<h4>NAND </h4>
<pre>GTA01Bv3 # help nand
nand info                  - show available NAND devices
nand device [dev]     - show or set current device
nand read[.jffs2]     - addr off size
nand write[.jffs2]    - addr off size - read/write `size' bytes starting
at offset `off' to/from memory address `addr'
nand erase [clean] [off size] - erase `size' bytes from
offset `off' (entire device if not specified)
nand bad - show bad blocks
nand dump[.oob] off - dump page
nand scrub - really clean NAND erasing bad blocks (UNSAFE)
nand markbad off - mark bad block at offset (UNSAFE)
nand biterr off - make a bit error at offset (UNSAFE)
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 从 NAND 加载内核" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=22"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E4.BB.8E_NAND_.E5.8A.A0.E8.BD.BD.E5.86.85.E6.A0.B8></a>
<h5>从 NAND 加载内核 </h5>
<pre>GTA01Bv3 # nand read 0x32000000 kernel
NAND read: device 0 offset 212992, size 2097152 ...  2097152 bytes read: OK
GTA01Bv3 # bootm 0x32000000
## Booting image at 32000000 ...
Image Name:   OpenMoko Kernel Image Neo1973
Created:      2007-02-15  23:54:18 UTC
Image Type:   ARM Linux Kernel Image (gzip compressed)
Data Size:    1546258 Bytes =  1.5 MB
Load Address: 30008000
Entry Point:  30008000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Starting kernel ...
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 向 NAND 写新的引导装载程序" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=23"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.90.91_NAND_.E5.86.99.E6.96.B0.E7.9A.84.E5.BC.95.E5.AF.BC.E8.A3.85.E8.BD.BD.E7.A8.8B.E5.BA.8F></a>
<h5>向 NAND 写新的引导装载程序 </h5>
<p>The following set of commands loads the file u-boot.bin from ext2/mmc and flashes it into the bootloader flash partition: </p>
<pre>GTA01Bv3 # ext2load mmc 0 0x32000000 u-boot.bin
GTA01Bv3 # nand erase u-boot
GTA01Bv3 # nand write 0x32000000 u-boot ${filesize}
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 向 NAND 写内核" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=24"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.90.91_NAND_.E5.86.99.E5.86.85.E6.A0.B8></a>
<h5>向 NAND 写内核 </h5>
<p>The following set of commands loads the file uImage from ext2/mmc and flashes it into the kernel flash partition: </p>
<pre>GTA01Bv3 # ext2load mmc 0 0x32000000 uImage
GTA01Bv3 # nand erase kernel
GTA01Bv3 # nand write.e 0x32000000 kernel ${filesize}
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 向 NAND 写根文件系统" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=25"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.90.91_NAND_.E5.86.99.E6.A0.B9.E6.96.87.E4.BB.B6.E7.B3.BB.E7.BB.9F></a>
<h5>向 NAND 写根文件系统 </h5>
<p>The following set of commands loads the file rootfs.jffs2 from ext2/mmc and flashes it into the rootfs flash partition: </p>
<pre>GTA01Bv3 # ext2load mmc 0 0x32000000 rootfs.jffs2
GTA01Bv3 # nand erase rootfs
GTA01Bv3 # nand write.e 0x32000000 rootfs ${filesize}
</pre>
<p>Please note that this will only work with root file system sizes that are smaller than the amount of memory above 0x32000000, which in the case of 64MB SDRAM is something like 32MB. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: Neo1973 相关的命令" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=26"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=Neo1973_.E7.9B.B8.E5.85.B3.E7.9A.84.E5.91.BD.E4.BB.A4></a>
<h4>Neo1973 相关的命令 </h4>
<p>我们的 u-boot 支持几个 Neo1973 专用命令： </p>
<pre>GTA01Bv2 # help neo1973
neo1973 neo1973 info - display phone informantion
neo1973 power-off - switch off the phone
neo1973 charger status - display charger status
neo1973 charger autofast - enable automatic fast (500mA) charging
neo1973 charger&nbsp;!autofast - disable automatic fast (500mA) charging
neo1973 charger fast - enable fast (500mA) charging
neo1973 charger off - disable charging
neo1973 backlight (on|off) - switch backlight on or off
neo1973 vibrator (on|off) - switch vibrator on or off
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 关机" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=27"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.85.B3.E6.9C.BA></a>
<h5>关机 </h5>
<p>使用 </p>
<pre>neo1973 power-off
</pre>
<p>you can switch the device off from the bootloader prompt. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 充电器相关" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=28"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.85.85.E7.94.B5.E5.99.A8.E7.9B.B8.E5.85.B3></a>
<h5>充电器相关 </h5>
<p>For a detailed description of the charger basics, see <a title="Neo1973 Battery Charger" href="http://wiki.openmoko.org/wiki/Neo1973_Battery_Charger"><u><font color=#0000ff>Neo1973 Battery Charger</font></u></a>. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 查询充电器状态" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=29"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E6.9F.A5.E8.AF.A2.E5.85.85.E7.94.B5.E5.99.A8.E7.8A.B6.E6.80.81></a>
<h6>查询充电器状态 </h6>
<p>You can get the current charger status by issuing </p>
<pre>neo1973 charger status
</pre>
<p>The following modes are possible: </p>
<ul lastCheckbox="null">
    <li>idle - no charging
    <li>trickle - FIXME
    <li>pre - Slow (100mA) charging, works in hardware.
    <li>fast_cccv - Fast (500mA) charging, using Constant-Current followed by Constant Voltage (Li-Ion) </li>
</ul>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 禁用充电器" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=30"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E7.A6.81.E7.94.A8.E5.85.85.E7.94.B5.E5.99.A8></a>
<h6>禁用充电器 </h6>
<p>You can disable battery charging (until the next reboot) by issuing </p>
<pre>neo1973 charger off
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 强制快速充电" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=31"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E5.BC.BA.E5.88.B6.E5.BF.AB.E9.80.9F.E5.85.85.E7.94.B5></a>
<h6>强制快速充电 </h6>
<p>使用 </p>
<pre>neo1973 charger fast
</pre>
<p>you can force the PMU to try to do a fast (500mA) charge of the battery. It will abort if the battery is in over temperature or some other error condition occurs. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 使能/禁用自动快速充电" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=32"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E4.BD.BF.E8.83.BD.2F.E7.A6.81.E7.94.A8.E8.87.AA.E5.8A.A8.E5.BF.AB.E9.80.9F.E5.85.85.E7.94.B5></a>
<h6>使能/禁用自动快速充电 </h6>
<p>Autofast is a feature of the PCF50606 PMU. It means that the fast_cccv mode will be automatically selected if a charger with suitable voltage is plugged in, and the battery not in over temperature condition. </p>
<table style="BORDER-RIGHT: #606060 1px solid; BORDER-TOP: #606060 1px solid; MARGIN: 1em 5%; BORDER-LEFT: #606060 1px solid; COLOR: #ff0000; BORDER-BOTTOM: #606060 1px solid; BACKGROUND-COLOR: #ddddee">
    <tbody>
        <tr>
            <td style="PADDING-RIGHT: 0.5em; PADDING-LEFT: 0.5em; PADDING-BOTTOM: 0.5em; PADDING-TOP: 0.5em"></td>
            <td style="PADDING-RIGHT: 0.5em; PADDING-LEFT: 0.5em; PADDING-BOTTOM: 0.5em; PADDING-TOP: 0.5em"><strong>WARNING:</strong> This is potentially dangerous. Only enable autofast if you ARE SURE that you can draw 500mA from the USB connector. This is the case with a wall outlet charger, or if you are attached to a self-powered hub or a desktop PC root hub. Bus powered hubs and some laptops only provide 100mA on their USB ports and can thus not support fast charging </td>
        </tr>
    </tbody>
</table>
<p>You can enable or disable autofast by </p>
<pre>neo1973 charger autofast
</pre>
<p>and </p>
<pre>neo1973 charger&nbsp;!autofast
</pre>
<p>respectively. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 背光灯" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=33"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E8.83.8C.E5.85.89.E7.81.AF></a>
<h5>背光灯 </h5>
<p>You can switch the backlight on and off by using </p>
<pre>neo1973 backlight on
</pre>
<p>and </p>
<pre>neo1973 backlight off
</pre>
<p>respectively. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 振动" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=34"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E6.8C.AF.E5.8A.A8></a>
<h5>振动 </h5>
<p>You can switch the vibrator on and off by using </p>
<pre>neo1973 vibrator on
</pre>
<p>and </p>
<pre>neo1973 vibrator off
</pre>
<p>respectively. </p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: S3C2410 专用命令" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=35"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=S3C2410_.E4.B8.93.E7.94.A8.E5.91.BD.E4.BB.A4></a>
<h4>S3C2410 专用命令 </h4>
<pre>GTA01Bv2 # help s3c2410
s3c2410 speed get - display current PLL speed config
s3c2410 speed list - display supporte PLL speed configs
s3c2410 speed set - set PLL speed
GTA01Bv2 # s3c2410 speed list
50 MHz
101 MHz
202 MHz
266 MHz
GTA01Bv2 # s3c2410 speed get
FCLK = 202 MHz, HCLK = 101 MHz, PCLK = 50 MHz
GTA01Bv2 # s3c2410 speed set 101
GTA01Bv2 # s3c2410 speed get
FCLK = 101 MHz, HCLK = 50 MHz, PCLK = 50 MHz
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 266MHz时钟" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=36"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=266MHz.E6.97.B6.E9.92.9F></a>
<h5>266MHz时钟 </h5>
<p>You can re-configure the <a title=S3C2410 href="http://wiki.openmoko.org/wiki/S3C2410"><u><font color=#0000ff>S3C2410</font></u></a> PLL to generate a 266 MHz core cpu clock (rather than the 200MHz default) by using </p>
<pre>GTA01Bv2 # s3c2410 speed set 266
</pre>
<p>and </p>
<pre>GTA01Bv2 # s3c2410 speed set 202
</pre>
<p>respectively. </p>
<table style="BORDER-RIGHT: #606060 1px solid; BORDER-TOP: #606060 1px solid; MARGIN: 1em 5%; BORDER-LEFT: #606060 1px solid; COLOR: #ff0000; BORDER-BOTTOM: #606060 1px solid; BACKGROUND-COLOR: #ddddee">
    <tbody>
        <tr>
            <td style="PADDING-RIGHT: 0.5em; PADDING-LEFT: 0.5em; PADDING-BOTTOM: 0.5em; PADDING-TOP: 0.5em"></td>
            <td style="PADDING-RIGHT: 0.5em; PADDING-LEFT: 0.5em; PADDING-BOTTOM: 0.5em; PADDING-TOP: 0.5em"><strong>WARNING:</strong> The current hardware (as of GTA01Bv3) only runs stable at 266MHz if you do not attach aynthing (esp. the FPC / <a title="Debug Board" href="http://wiki.openmoko.org/wiki/Debug_Board"><u><font color=#0000ff>Debug Board</font></u></a> to the Debug Port </td>
        </tr>
    </tbody>
</table>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: QT2410上的TFTP" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=37"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=QT2410.E4.B8.8A.E7.9A.84TFTP></a>
<h4>QT2410上的TFTP </h4>
<p>The QT2410 cs8900a Ethernet can be used to download images via network. </p>
<p>First, you have to make sure that <em>ipaddr</em>, <em>serverip</em>, <em>ethaddr' and </em>netmaskk<em> are set correctly in the environment:</em> </p>
<pre>QT2410 # printenv
ethaddr=00:01:02:03:04:05
netmask=255.255.255.0
ipaddr=192.168.100.100
serverip=192.168.100.1
</pre>
<p><br></p>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: TFTP kernel download" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=38"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=TFTP_kernel_download></a>
<h5>TFTP kernel download </h5>
<pre>QT2410 # tftpboot 0x32000000
*** Warning: no boot file name; using 'C0A86464.img'
TFTP from server 192.168.100.1; our IP address is 192.168.100.100
Filename 'C0A86464.img'.
Load address: 0x32000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
##########################################
done
Bytes transferred = 1544788 (179254 hex)
</pre>
<p>you can then commence booting via </p>
<pre>QT2410# bootm 0x32000000
</pre>
<div class=editsection style="FLOAT: right; MARGIN-LEFT: 5px">[<a title="Edit section: 设备固件升级" href="http://wiki.openmoko.org/index.php?title=Bootloader/zh_cn&amp;action=edit&amp;section=39"><u><font color=#0000ff>edit</font></u></a>]</div>
<a name=.E8.AE.BE.E5.A4.87.E5.9B.BA.E4.BB.B6.E5.8D.87.E7.BA.A7></a>
<h2>设备固件升级 </h2>
<p>Our version of u-boot also implements <a title="USB DFU" href="http://wiki.openmoko.org/wiki/USB_DFU"><u><font color=#0000ff>USB DFU</font></u></a>. </p>
<p>To find out whether your version of u-boot supports this, use the output of </p>
<pre>$ lsusb -v -d 1457:5119
</pre>
<p>while the phone is in u-boot mode. </p>
<p>If it supports DFU, you should see the following snippet towards the end of the output: </p>
<pre>    Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        2
bAlternateSetting       0
bNumEndpoints           0
bInterfaceClass       254 Application Specific Interface
bInterfaceSubClass      1 Device Firmware Update
bInterfaceProtocol      1
iInterface              0
</pre>
<p>关于如何进行固件升级的信息，请看<a title="Dfu-util/zh cn" href="http://wiki.openmoko.org/wiki/Dfu-util/zh_cn"><u><font color=#0000ff>dfu-util</font></u></a>。 </p>
</div>
<img src ="http://www.cnitblog.com/zouzheng/aggbug/41560.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zouzheng/" target="_blank">zz</a> 2008-03-27 15:41 <a href="http://www.cnitblog.com/zouzheng/articles/41560.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>将ppcboot2.0.0移植到s3c2410平台</title><link>http://www.cnitblog.com/zouzheng/articles/41212.html</link><dc:creator>zz</dc:creator><author>zz</author><pubDate>Thu, 20 Mar 2008 01:21:00 GMT</pubDate><guid>http://www.cnitblog.com/zouzheng/articles/41212.html</guid><wfw:comment>http://www.cnitblog.com/zouzheng/comments/41212.html</wfw:comment><comments>http://www.cnitblog.com/zouzheng/articles/41212.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zouzheng/comments/commentRss/41212.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zouzheng/services/trackbacks/41212.html</trackback:ping><description><![CDATA[<div class=content id=fontzoom>
<p>
<div><span class=post_user>思考树整理，转载注明出处。<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#117;&#101;&#116;&#105;&#97;&#110;&#116;&#105;&#97;&#110;&#64;&#49;&#54;&#51;&#46;&#99;&#111;&#109;"><u><font color=#0000ff>yuetiantian@163.com</font></u></a></span></div>
<div><span class=post_user></span><br>1.修改Makefile<br>ifeq($(ARCH),arm)<br>#CROSS-COMPILE = arm-linux-<br>CROSS-COMPILE = /opt/host/armv4l/bin/armv4l-unknown-linux-<br>即修改arm cpu的交叉编译器为你现有可用交叉编译工具链<br>2.修改vi inclue/configs/smdk2410.h<br>(1)修改网卡信息<br>#define CONFIG_DRIVER_CS8900<br>改成#define CONFIG_DRIVER_DM9000<br>#define CS8900 0x19000300<br>改成#define DM9000 0X08000300<br>#define CS8900_BUS16<br>改成#define DM9000_BUS16<br>(2)修改网络地址<br>#define CONFIG_IPADDR 192.168.2.120<br>#define CONFIG_IPSERVERIP 192.168.2.25<br>(3)修改提示符<br>#define CFG_PROMPT "zyt#"<br>(4)修改flash容量<br>vi inclue/configs/smdk2410.h<br>#ifdef CONFIG_AMD_LV400<br>#define PHYS_FLASH_SIZE 0x00080000 /* 512KB */<br>改成<br>#ifdef CONFIG_AMD_LV400<br>#define PHYS_FLASH_SIZE 0x01000000 /* 16M */<br>#define CFG_MEMTEST_END 0x33A00000 /*63M in<br>DRAM*/<br>改成#define CFG_MEMTEST_END 0x33A00000 /*58M in<br>DRAM*/<br>3.修改给u-boot 预留空间大小vi board/s3c2410/config.mk<br>调整TEXT_BASE值为0x33A00000<br>4.修改cpu第10个寄存器为0x31<br>vi board/s3c2410/memsetup.S<br>倒数第三行0x32 -&gt;0x31<br>5.添加网卡驱动<br>拷贝dm9000x.c到 drivers目录<br>拷贝net.h到drivers目录<br>vi Makefile<br>将dm9000x.o 替换掉目标文件中的cs8900.o<br>6.编译<br>#make distclean<br>#make smdk2410_config<br>#make all<br>报一个错误<br>'true' undeclared<br>进入tools/gdb/ 编辑 astest.c 修改dfdp-&gt;cacheable= true 为dfdp-&gt;cacheable= 1；<br>保存<br>再编译，通过，ok<br>烧写到flash后，启动板子，tftp 0x30008000 zImage<br>########################</div>
<div class=post_content>ok！</div>
<p>&#160;</p>
</div>
<img src ="http://www.cnitblog.com/zouzheng/aggbug/41212.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zouzheng/" target="_blank">zz</a> 2008-03-20 09:21 <a href="http://www.cnitblog.com/zouzheng/articles/41212.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>u-boot在s3c2410开发板上移植过程</title><link>http://www.cnitblog.com/zouzheng/articles/41186.html</link><dc:creator>zz</dc:creator><author>zz</author><pubDate>Wed, 19 Mar 2008 11:55:00 GMT</pubDate><guid>http://www.cnitblog.com/zouzheng/articles/41186.html</guid><wfw:comment>http://www.cnitblog.com/zouzheng/comments/41186.html</wfw:comment><comments>http://www.cnitblog.com/zouzheng/articles/41186.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zouzheng/comments/commentRss/41186.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zouzheng/services/trackbacks/41186.html</trackback:ping><description><![CDATA[<div class=content id=fontzoom>
<p>
<p><font size=3><strong>1）</strong>u-boot版本1.1.3，gcc version 3.3.3 (DENX ELDK 3.1.1 3.3.3-9)</font></p>
<p><font size=3><strong>2）</strong>在Makefile中加入<br>bks2410_config&nbsp;:&nbsp;unconfig<br>&nbsp;@./mkconfig $(@:_config=) arm arm920t bks2410 NULL s3c24x0<br>我把我的板子起名叫bks2410，可以依自己的喜好修改</font></p>
<p><font size=3><strong>3）</strong>建立board/bks2410目录，拷贝board/smdk2410下的文件到board/bks2410目录，将smdk2410.c更名为bks2410.c</font></p>
<p><font size=3><strong>4）</strong>cp include/configs/smdk2410.h include/configs/bks2410.h</font></p>
<p><font size=3><strong>5）</strong>将arm-linux-gcc的目录加入到PATH环境变量中，我的是目录/opt/eldk/usr/bin:/opt/eldk/bin</font></p>
<p><font size=3><strong>6）</strong>测试编译能否成功：<br>make bks2410_config<br>make all ARCH=arm<br>生成u-boot.bin就OK了</font></p>
<p><font size=3><strong>7）</strong>依照你自己开发板的内存地址分配情况修改board/bks2410/memsetup.S文件，我的程序：<br>#include &lt;config.h&gt;<br>#include &lt;version.h&gt;</font></p>
<p><font size=3>#define BWSCON&nbsp;0x48000000</font></p>
<p><font size=3>/* BWSCON */<br>#define DW8&nbsp;&nbsp; &nbsp;(0x0)<br>#define DW16&nbsp;&nbsp; &nbsp;(0x1)<br>#define DW32&nbsp;&nbsp; &nbsp;(0x2)<br>#define WAIT&nbsp;&nbsp; &nbsp;(0x1&lt;&lt;2)<br>#define UBLB&nbsp;&nbsp; &nbsp;(0x1&lt;&lt;3)</font></p>
<p><font size=3>#define B1_BWSCON&nbsp;&nbsp; &nbsp;(DW32)<br>#define B2_BWSCON&nbsp;&nbsp; &nbsp;(DW16)<br>#define B3_BWSCON&nbsp;&nbsp; &nbsp;(DW16 + WAIT + UBLB)<br>#define B4_BWSCON&nbsp;&nbsp; &nbsp;(DW16)<br>#define B5_BWSCON&nbsp;&nbsp; &nbsp;(DW16)<br>#define B6_BWSCON&nbsp;&nbsp; &nbsp;(DW32)<br>#define B7_BWSCON&nbsp;&nbsp; &nbsp;(DW32)</font></p>
<p><font size=3>/* BANK0CON */<br>#if 0<br>#define B0_Tacs&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B0_Tcos&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B0_Tacc&nbsp;&nbsp; &nbsp;0x7&nbsp;/* 14clk */<br>#define B0_Tcoh&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B0_Tah&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B0_Tacp&nbsp;&nbsp; &nbsp;0x0<br>#define B0_PMC&nbsp;&nbsp; &nbsp;0x0&nbsp;/* normal */<br>#endif</font></p>
<p><font size=3>#define B0_Tacs&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 0clk */<br>#define B0_Tcos&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 0clk */<br>#define B0_Tacc&nbsp;&nbsp; &nbsp;0x7&nbsp;/* 14clk */<br>#define B0_Tcoh&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 0clk */<br>#define B0_Tah&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 0clk */<br>#define B0_Tacp&nbsp;&nbsp; &nbsp;0x1<br>#define B0_PMC&nbsp;&nbsp; &nbsp;0x0&nbsp;/* normal */</font></p>
<p><font size=3>/* BANK1CON */<br>#if 0<br>#define B1_Tacs&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B1_Tcos&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B1_Tacc&nbsp;&nbsp; &nbsp;0x7&nbsp;/* 14clk */<br>#define B1_Tcoh&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B1_Tah&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B1_Tacp&nbsp;&nbsp; &nbsp;0x0<br>#define B1_PMC&nbsp;&nbsp; &nbsp;0x0<br>#endif</font></p>
<p><font size=3>#define B1_Tacs&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 0clk */<br>#define B1_Tcos&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 0clk */<br>#define B1_Tacc&nbsp;&nbsp; &nbsp;0x7&nbsp;/* 14clk */<br>#define B1_Tcoh&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 0clk */<br>#define B1_Tah&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 0clk */<br>#define B1_Tacp&nbsp;&nbsp; &nbsp;0x3<br>#define B1_PMC&nbsp;&nbsp; &nbsp;0x0</font></p>
<p><font size=3>#define B2_Tacs&nbsp;&nbsp; &nbsp;0x0<br>#define B2_Tcos&nbsp;&nbsp; &nbsp;0x0<br>#define B2_Tacc&nbsp;&nbsp; &nbsp;0x7<br>#define B2_Tcoh&nbsp;&nbsp; &nbsp;0x0<br>#define B2_Tah&nbsp;&nbsp; &nbsp;0x0<br>#define B2_Tacp&nbsp;&nbsp; &nbsp;0x0<br>#define B2_PMC&nbsp;&nbsp; &nbsp;0x0</font></p>
<p><font size=3>#if 0<br>#define B3_Tacs&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B3_Tcos&nbsp;&nbsp; &nbsp;0x3&nbsp;/*&nbsp; 4clk */<br>#define B3_Tacc&nbsp;&nbsp; &nbsp;0x7&nbsp;/* 14clk */<br>#define B3_Tcoh&nbsp;&nbsp; &nbsp;0x1&nbsp;/*&nbsp; 1clk */<br>#define B3_Tah&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B3_Tacp&nbsp;&nbsp; &nbsp;0x3&nbsp;&nbsp;&nbsp;&nbsp; /*&nbsp; 6clk */<br>#define B3_PMC&nbsp;&nbsp; &nbsp;0x0&nbsp;/* normal */<br>#endif</font></p>
<p><font size=3>#define B3_Tacs&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B3_Tcos&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 4clk */<br>#define B3_Tacc&nbsp;&nbsp; &nbsp;0x7&nbsp;/* 14clk */<br>#define B3_Tcoh&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 1clk */<br>#define B3_Tah&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B3_Tacp&nbsp;&nbsp; &nbsp;0x0&nbsp;&nbsp;&nbsp;&nbsp; /*&nbsp; 6clk */<br>#define B3_PMC&nbsp;&nbsp; &nbsp;0x0&nbsp;/* normal */</font></p>
<p><font size=3>#define B4_Tacs&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B4_Tcos&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B4_Tacc&nbsp;&nbsp; &nbsp;0x7&nbsp;/* 14clk */<br>#define B4_Tcoh&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B4_Tah&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B4_Tacp&nbsp;&nbsp; &nbsp;0x0<br>#define B4_PMC&nbsp;&nbsp; &nbsp;0x0&nbsp;/* normal */</font></p>
<p><font size=3>#define B5_Tacs&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B5_Tcos&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B5_Tacc&nbsp;&nbsp; &nbsp;0x7&nbsp;/* 14clk */<br>#define B5_Tcoh&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B5_Tah&nbsp;&nbsp; &nbsp;0x0&nbsp;/*&nbsp; 0clk */<br>#define B5_Tacp&nbsp;&nbsp; &nbsp;0x0<br>#define B5_PMC&nbsp;&nbsp; &nbsp;0x0&nbsp;/* normal */</font></p>
<p><font size=3>#define B6_MT&nbsp;&nbsp; &nbsp;0x3&nbsp;/* SDRAM */<br>#define B6_Trcd&nbsp; &nbsp; &nbsp;0x1<br>#define B6_SCAN&nbsp;&nbsp; &nbsp;0x1&nbsp;/* 9bit */</font></p>
<p><font size=3>#define B7_MT&nbsp;&nbsp; &nbsp;0x3&nbsp;/* SDRAM */<br>#define B7_Trcd&nbsp;&nbsp; &nbsp;0x1&nbsp;/* 3clk */<br>#define B7_SCAN&nbsp;&nbsp; &nbsp;0x1&nbsp;/* 9bit */</font></p>
<p><font size=3>/* REFRESH parameter */<br>#define REFEN&nbsp;&nbsp; &nbsp;0x1&nbsp;/* Refresh enable */<br>#define TREFMD&nbsp;&nbsp; &nbsp;0x0&nbsp;/* CBR(CAS before RAS)/Auto refresh */<br>#define Trp&nbsp;&nbsp; &nbsp;0x0&nbsp;/* 2clk */<br>#define Trc&nbsp;&nbsp; &nbsp;0x3&nbsp;/* 7clk */<br>#define Tchr&nbsp;&nbsp; &nbsp;0x2&nbsp;/* 3clk */<br>#define REFCNT&nbsp;&nbsp; &nbsp;1113&nbsp;/* period=15.6us, HCLK=60Mhz, (2048+1-15.6*60) */<br>/**************************************/</font></p>
<p><font size=3>_TEXT_BASE:<br>&nbsp;.word&nbsp;TEXT_BASE</font></p>
<p><font size=3>.globl memsetup<br>memsetup:<br>&nbsp;/* memory control configuration */<br>&nbsp;/* make r0 relative the current location so that it */<br>&nbsp;/* reads SMRDATA out of FLASH rather than memory ! */<br>&nbsp;adr&nbsp;&nbsp;&nbsp;&nbsp; r0, SMRDATA<br>&nbsp;/*ldr&nbsp;r1, _TEXT_BASE*/<br>&nbsp;/*sub&nbsp;r0, r0, r1*/<br>&nbsp;ldr&nbsp;r1, =BWSCON&nbsp;/* Bus Width Status Controller */<br>&nbsp;add&nbsp;&nbsp;&nbsp;&nbsp; r2, r0, #13*4<br>0:<br>&nbsp;ldr&nbsp;&nbsp;&nbsp;&nbsp; r3, [r0], #4<br>&nbsp;str&nbsp;&nbsp;&nbsp;&nbsp; r3, [r1], #4<br>&nbsp;cmp&nbsp;&nbsp;&nbsp;&nbsp; r2, r0<br>&nbsp;bne&nbsp;&nbsp;&nbsp;&nbsp; 0b</font></p>
<p><font size=3>&nbsp;/* everything is fine now */<br>&nbsp;mov&nbsp;pc, lr</font></p>
<p><font size=3>&nbsp;.ltorg<br>/* the literal pools origin */</font></p>
<p><font size=3>SMRDATA:<br>&nbsp;&nbsp;&nbsp; .word (0+(B1_BWSCON&lt;&lt;4)+(B2_BWSCON&lt;&lt;8)+(B3_BWSCON&lt;&lt;12)+(B4_BWSCON&lt;&lt;16)+(B5_BWSCON&lt;&lt;20)+(B6_BWSCON&lt;&lt;24)+(B7_BWSCON&lt;&lt;28))<br>&nbsp;&nbsp;&nbsp; .word ((B0_Tacs&lt;&lt;13)+(B0_Tcos&lt;&lt;11)+(B0_Tacc&lt;&lt;8)+(B0_Tcoh&lt;&lt;6)+(B0_Tah&lt;&lt;4)+(B0_Tacp&lt;&lt;2)+(B0_PMC))<br>&nbsp;&nbsp;&nbsp; .word ((B1_Tacs&lt;&lt;13)+(B1_Tcos&lt;&lt;11)+(B1_Tacc&lt;&lt;8)+(B1_Tcoh&lt;&lt;6)+(B1_Tah&lt;&lt;4)+(B1_Tacp&lt;&lt;2)+(B1_PMC))<br>&nbsp;&nbsp;&nbsp; .word ((B2_Tacs&lt;&lt;13)+(B2_Tcos&lt;&lt;11)+(B2_Tacc&lt;&lt;8)+(B2_Tcoh&lt;&lt;6)+(B2_Tah&lt;&lt;4)+(B2_Tacp&lt;&lt;2)+(B2_PMC))<br>&nbsp;&nbsp;&nbsp; .word 0x1f7c/*((B3_Tacs&lt;&lt;13)+(B3_Tcos&lt;&lt;11)+(B3_Tacc&lt;&lt;8)+(B3_Tcoh&lt;&lt;6)+(B3_Tah&lt;&lt;4)+(B3_Tacp&lt;&lt;2)+(B3_PMC))*/<br>&nbsp;&nbsp;&nbsp; .word ((B4_Tacs&lt;&lt;13)+(B4_Tcos&lt;&lt;11)+(B4_Tacc&lt;&lt;8)+(B4_Tcoh&lt;&lt;6)+(B4_Tah&lt;&lt;4)+(B4_Tacp&lt;&lt;2)+(B4_PMC))<br>&nbsp;&nbsp;&nbsp; .word ((B5_Tacs&lt;&lt;13)+(B5_Tcos&lt;&lt;11)+(B5_Tacc&lt;&lt;8)+(B5_Tcoh&lt;&lt;6)+(B5_Tah&lt;&lt;4)+(B5_Tacp&lt;&lt;2)+(B5_PMC))<br>&nbsp;&nbsp;&nbsp; .word ((B6_MT&lt;&lt;15)+(B6_Trcd&lt;&lt;2)+(B6_SCAN))<br>&nbsp;&nbsp;&nbsp; .word ((B7_MT&lt;&lt;15)+(B7_Trcd&lt;&lt;2)+(B7_SCAN))<br>&nbsp;&nbsp;&nbsp; .word ((REFEN&lt;&lt;23)+(TREFMD&lt;&lt;22)+(Trp&lt;&lt;20)+(Trc&lt;&lt;18)+(Tchr&lt;&lt;16)+REFCNT)<br>&nbsp;&nbsp;&nbsp; .word 0x31<br>&nbsp;&nbsp;&nbsp; .word 0x30<br>&nbsp;&nbsp;&nbsp; .word 0x30<br>&nbsp;&nbsp;&nbsp; <br><strong>8）</strong>在board/bks2410加入NAND Flash读函数，建立nand_read.c，加入如下内容(copy from vivi)：<br>#include &lt;config.h&gt;</font></p>
<p><font size=3>#define __REGb(x)&nbsp;(*(volatile unsigned char *)(x))<br>#define __REGi(x)&nbsp;(*(volatile unsigned int *)(x))<br>#define NF_BASE&nbsp;&nbsp;0x4e000000<br>#define NFCONF&nbsp;&nbsp;__REGi(NF_BASE + 0x0)<br>#define NFCMD&nbsp;&nbsp;__REGb(NF_BASE + 0x4)<br>#define NFADDR&nbsp;&nbsp;__REGb(NF_BASE + 0x8)<br>#define NFDATA&nbsp;&nbsp;__REGb(NF_BASE + 0xc)<br>#define NFSTAT&nbsp;&nbsp;__REGb(NF_BASE + 0x10)</font></p>
<p><font size=3>#define BUSY 1<br>inline void wait_idle(void) {<br>&nbsp;&nbsp;&nbsp; int i;</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp; while(!(NFSTAT &amp; BUSY))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(i=0; i&lt;10; i++);<br>}</font></p>
<p><font size=3>#define NAND_SECTOR_SIZE&nbsp;512<br>#define NAND_BLOCK_MASK&nbsp;&nbsp;(NAND_SECTOR_SIZE - 1)</font></p>
<p><font size=3>/* low level nand read function */<br>int<br>nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)<br>{<br>&nbsp;&nbsp;&nbsp; int i, j;</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp; if ((start_addr &amp; NAND_BLOCK_MASK) || (size &amp; NAND_BLOCK_MASK)) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;&nbsp;/* invalid alignment */<br>&nbsp;&nbsp;&nbsp; }</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp; /* chip Enable */<br>&nbsp;&nbsp;&nbsp; NFCONF &amp;= ~0x800;<br>&nbsp;&nbsp;&nbsp; for(i=0; i&lt;10; i++);</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp; for(i=start_addr; i &lt; (start_addr + size);) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* READ0 */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NFCMD = 0;</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Write Address */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NFADDR = i &amp; 0xff;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NFADDR = (i &gt;&gt; 9) &amp; 0xff;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NFADDR = (i &gt;&gt; 17) &amp; 0xff;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NFADDR = (i &gt;&gt; 25) &amp; 0xff;</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wait_idle();</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(j=0; j &lt; NAND_SECTOR_SIZE; j++, i++) {<br>&nbsp;*buf = (NFDATA &amp; 0xff);<br>&nbsp;buf++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp; /* chip Disable */<br>&nbsp;&nbsp;&nbsp; NFCONF |= 0x800;&nbsp;/* chip disable */</font></p>
<p><font size=3>&nbsp;&nbsp;&nbsp; return 0;<br>}</font></p>
<p><font size=3><strong>9）</strong>修改board/bks2410/Makefile为<br>OBJS&nbsp;:= bks2410.o flash.o nand_read.o</font></p>
<p><font size=3><strong>10）</strong>修改cpu/arm920t/start.S文件<br>在ldr&nbsp;pc, _start_armboot之前加入：<br>#ifdef CONFIG_S3C2410_NAND_BOOT<br>&nbsp; bl&nbsp;&nbsp;&nbsp; copy_myself<br>&nbsp; <br>&nbsp; @ jump to ram<br>&nbsp; ldr&nbsp;&nbsp; r1, =on_the_ram<br>&nbsp; add&nbsp; pc, r1, #0<br>&nbsp; nop<br>&nbsp; nop<br>&nbsp; 1:&nbsp;&nbsp;&nbsp; b&nbsp;&nbsp;&nbsp;&nbsp; 1b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ infinite loop<br>&nbsp; <br>on_the_ram:<br>#endif</font></p>
<p><font size=3>在_start_armboot:&nbsp;.word start_armboot之后加入：<br>#ifdef CONFIG_S3C2410_NAND_BOOT<br>copy_myself:<br>&nbsp; mov r10, lr<br>@ reset NAND<br>&nbsp; mov r1, #NAND_CTL_BASE<br>&nbsp; ldr&nbsp;&nbsp; r2, =0xf830&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ initial value<br>&nbsp; str&nbsp;&nbsp; r2, [r1, #oNFCONF]<br>&nbsp; ldr&nbsp;&nbsp; r2, [r1, #oNFCONF]<br>&nbsp; bic&nbsp; r2, r2, #0x800&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ enable chip<br>&nbsp; str&nbsp;&nbsp; r2, [r1, #oNFCONF]<br>&nbsp; mov r2, #0xff&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ RESET command<br>&nbsp; strb r2, [r1, #oNFCMD]<br>&nbsp; mov r3, #0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ wait</font></p>
<p><font size=3>1:add&nbsp; r3, r3, #0x1<br>&nbsp; cmp r3, #0xa<br>&nbsp; blt&nbsp;&nbsp; 1b<br>2:ldr&nbsp;&nbsp; r2, [r1, #oNFSTAT]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ wait ready<br>&nbsp; tst&nbsp;&nbsp;&nbsp; r2, #0x1<br>&nbsp; beq&nbsp; 2b<br>&nbsp; ldr&nbsp;&nbsp; r2, [r1, #oNFCONF]<br>&nbsp; orr&nbsp; r2, r2, #0x800&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ disable chip<br>&nbsp; str&nbsp;&nbsp; r2, [r1, #oNFCONF]</font></p>
<p><font size=3>@ get read to call C functions (for nand_read())<br>&nbsp; ldr&nbsp;&nbsp; sp, DW_STACK_START&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ setup stack pointer<br>&nbsp; mov fp, #0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ no previous frame, so fp=0</font></p>
<p><font size=3>@ copy vivi to RAM<br>&nbsp; ldr&nbsp;&nbsp; r0, =UBOOT_RAM_BASE<br>&nbsp; mov&nbsp;&nbsp;&nbsp;&nbsp; r1, #0x0<br>&nbsp; mov r2, #0x20000<br>&nbsp; bl&nbsp;&nbsp;&nbsp; nand_read_ll<br>&nbsp; tst&nbsp;&nbsp;&nbsp; r0, #0x0<br>&nbsp; beq&nbsp; ok_nand_read</font></p>
<p><font size=3>#ifdef CONFIG_DEBUG_LL<br>&nbsp; bad_nand_read:<br>&nbsp; ldr&nbsp;&nbsp; r0, STR_FAIL<br>&nbsp; ldr&nbsp;&nbsp; r1, SerBase<br>&nbsp; bl&nbsp;&nbsp;&nbsp; PrintWord<br>1:b&nbsp;&nbsp;&nbsp;&nbsp; 1b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @ infinite loop<br>&nbsp; #endif</font></p>
<p><font size=3>ok_nand_read:<br>#ifdef CONFIG_DEBUG_LL<br>&nbsp; ldr&nbsp;&nbsp; r0, STR_OK<br>&nbsp; ldr&nbsp;&nbsp; r1, SerBase<br>&nbsp; bl&nbsp;&nbsp;&nbsp; PrintWord<br>#endif</font></p>
<p><font size=3>@ verify<br>&nbsp; mov r0, #0<br>&nbsp; ldr&nbsp;&nbsp; r1, =UBOOT_RAM_BASE<br>&nbsp; mov r2, #0x400&nbsp;&nbsp;&nbsp;&nbsp; @ 4 bytes * 1024 = 4K-bytes<br>go_next:<br>&nbsp; ldr&nbsp;&nbsp; r3, [r0], #4<br>&nbsp; ldr&nbsp;&nbsp; r4, [r1], #4<br>&nbsp; teq&nbsp;&nbsp; r3, r4<br>&nbsp; bne&nbsp; notmatch<br>&nbsp; subs r2, r2, #4<br>&nbsp; beq&nbsp; done_nand_read<br>&nbsp; bne&nbsp; go_next</font></p>
<p><font size=3>notmatch:<br>#ifdef CONFIG_DEBUG_LL<br>&nbsp; sub&nbsp; r0, r0, #4<br>&nbsp; ldr&nbsp;&nbsp; r1, SerBase<br>&nbsp; bl&nbsp;&nbsp;&nbsp; PrintHexWord<br>&nbsp; ldr&nbsp;&nbsp; r0, STR_FAIL<br>&nbsp; ldr&nbsp;&nbsp; r1, SerBase<br>&nbsp; bl&nbsp;&nbsp;&nbsp; PrintWord<br>#endif<br>1:b&nbsp;&nbsp;&nbsp;&nbsp; 1b<br>done_nand_read:<br>#ifdef CONFIG_DEBUG_LL<br>&nbsp; ldr&nbsp;&nbsp; r0, STR_OK<br>&nbsp; ldr&nbsp;&nbsp; r1, SerBase<br>&nbsp; bl&nbsp;&nbsp;&nbsp; PrintWord<br>#endif<br>&nbsp; mov pc, r10<br>@ clear memory<br>@ r0: start address<br>@ r1: length<br>&nbsp; mem_clear:<br>&nbsp; mov r2, #0<br>&nbsp; mov r3, r2<br>&nbsp; mov r4, r2<br>&nbsp; mov r5, r2<br>&nbsp; mov r6, r2<br>&nbsp; mov r7, r2<br>&nbsp; mov r8, r2<br>&nbsp; mov r9, r2</font></p>
<p><font size=3>clear_loop:<br>&nbsp; stmia&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r0!, {r2-r9}<br>&nbsp; subs r1, r1, #(8 * 4)<br>&nbsp; bne&nbsp; clear_loop<br>&nbsp; mov pc, lr</font></p>
<p><font size=3>#endif @ CONFIG_S3C2410_NAND_BOOT</font></p>
<p><font size=3>在文件的最后加入：<br>&nbsp; &nbsp;.align&nbsp;&nbsp;&nbsp;&nbsp; 2<br>DW_STACK_START:<br>&nbsp;.word&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; STACK_BASE+STACK_SIZE-4</font></p>
<p><font size=3><strong>11）</strong>修改include/configs/bks2410.h文件，添加如下内容：<br>/*<br>&nbsp;* Nandflash Boot<br>&nbsp;*/<br>#define CONFIG_S3C2410_NAND_BOOT 1<br>#define STACK_BASE &nbsp;&nbsp; 0x33f00000<br>#define STACK_SIZE &nbsp;&nbsp; 0x8000<br>#define UBOOT_RAM_BASE &nbsp;&nbsp; 0x33f80000<br>/* NAND Flash Controller */<br>#define NAND_CTL_BASE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x4E000000<br>#define bINT_CTL(Nb)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __REG(INT_CTL_BASE + (Nb))<br>/* Offset */<br>#define oNFCONF&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x00<br>#define oNFCMD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x04<br>#define oNFADDR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x08<br>#define oNFDATA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x0c<br>#define oNFSTAT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x10<br>#define oNFECC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x14</font></p>
<p><font size=3><strong>12）</strong>重新编译u-boot<br>make all ARCH=arm</font></p>
<p><font size=3><strong>13）</strong>通过jtag将u-boot烧写到flash中就可以从NAND flash启动了<br></font></p>
<p><font size=3><strong>我的u-boot启动信息：</strong></font></p>
<p><font size=3>U-Boot 1.1.3 (May&nbsp; 6 2006 - 18:13:59)</font></p>
<p><font size=3>U-Boot code: 33F80000 -&gt; 33F967C4&nbsp; BSS: -&gt; 33F9AAAC<br>RAM Configuration:<br>Bank #0: 30000000 64 MB<br>Flash: 512 kB<br>*** Warning - bad CRC, using default environment</font></p>
<p><font size=3>In:&nbsp;&nbsp;&nbsp; serial<br>Out:&nbsp;&nbsp; serial<br>Err:&nbsp;&nbsp; serial<br>BKS2410 # </font></p>
<p>&nbsp;</p>
</div>
<img src ="http://www.cnitblog.com/zouzheng/aggbug/41186.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zouzheng/" target="_blank">zz</a> 2008-03-19 19:55 <a href="http://www.cnitblog.com/zouzheng/articles/41186.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>U-Boot的移植U-Boot Practically Porting Guide（转）</title><link>http://www.cnitblog.com/zouzheng/articles/40300.html</link><dc:creator>zz</dc:creator><author>zz</author><pubDate>Fri, 29 Feb 2008 07:56:00 GMT</pubDate><guid>http://www.cnitblog.com/zouzheng/articles/40300.html</guid><wfw:comment>http://www.cnitblog.com/zouzheng/comments/40300.html</wfw:comment><comments>http://www.cnitblog.com/zouzheng/articles/40300.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zouzheng/comments/commentRss/40300.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zouzheng/services/trackbacks/40300.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: U-Boot的移植之(一)基础篇：添加新的目标板定义本文使用最新的U-Boot-1.3.0-rc2。U-Boot本身支持很多开发板，在其源代码中，每个板子都对应一个board/目录下的文件夹(笔者注：这并不确切，因为有的文件夹是供应商名称，下面可以有多个目标板目录，这里只考虑最简单的情况)，以及include/configs/目录下的目标板配置头文件。因此，要添加U-Boot对我们的目标板的支...&nbsp;&nbsp;<a href='http://www.cnitblog.com/zouzheng/articles/40300.html'>阅读全文</a><img src ="http://www.cnitblog.com/zouzheng/aggbug/40300.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zouzheng/" target="_blank">zz</a> 2008-02-29 15:56 <a href="http://www.cnitblog.com/zouzheng/articles/40300.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Blackfin上移植u-boot</title><link>http://www.cnitblog.com/zouzheng/articles/40217.html</link><dc:creator>zz</dc:creator><author>zz</author><pubDate>Wed, 27 Feb 2008 09:05:00 GMT</pubDate><guid>http://www.cnitblog.com/zouzheng/articles/40217.html</guid><wfw:comment>http://www.cnitblog.com/zouzheng/comments/40217.html</wfw:comment><comments>http://www.cnitblog.com/zouzheng/articles/40217.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zouzheng/comments/commentRss/40217.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zouzheng/services/trackbacks/40217.html</trackback:ping><description><![CDATA[<p>本文介绍的移植过程基于华恒科技提供的软件包（用于HHBF531-StartKIT-R1开发板）。我<br>们的硬件平台是：<br>CPU：BF533<br>FLASH：S29AL004D-512KB<br>SDRAM：HY57V281620-16MB<br>下面我们分成以下几个步骤进行介绍：<br>一， 建立交叉编译开发环境：<br>1， 安装（虚拟）linux系统：<br>&nbsp;&nbsp;&nbsp; 移植uclinux要在linux系统环境下交叉编译，所以需要一个linux系统。可以安装一个<br>完整的linux操作系统，也可以在windows系统下利用虚拟软件运行linux系统。本人不习惯<br>使用linux操作系统，所以在windows环境下安装了一个虚拟linux——colinux。本人下载<br>的colinux安装包是colinux_installer_v0.95.zip ，安装包内包含blackfin交叉编译工具<br>链，利用此工具包安装的虚拟linux系统内已经带有blackfin交叉编译工具链，下载地址为<br>：<a href="http://blackfin.uclinux.org/gf/project/bfin-colinux/frs/。" target=_blank><u><font color=#0000ff>http://blackfin.uclinux.org/gf/project/bfin-colinux/frs/。</font></u></a><br>安装colinux的方法很简单，和一般的windows软件安装相同，全部采用默认值即可。唯一<br>要注意的是，要保证安装盘（比如说c盘）有足够的空间（大约需要3.5GB）。<br>安装成功后，点击你桌面上的blackfin-colinux图标就可以运行colinux了。Colinux默认<br>已经建立两个用户：root和uclinux，密码均为bf533。查看linux根目录下有没有/opt/uC<br>linux/bfin-elf、/opt/uClinux/bfin-linux-uclibc、/opt/uClinux/bfin-uclinux三个目<br>录，有的话blackfin交叉工具链已经安装成功，但不一定适用于本文的源码编译；因为某<br>些变量定义不一致可能导致华恒提供的源码编译错误，所以要使用华恒提供的软件包附带<br>的交叉编译工具链。<br>更多资料参见：<a href="http://blackfin.uclinux.org/。" target=_blank><u><font color=#0000ff>http://blackfin.uclinux.org/。</font></u></a><br><br>2， 安装blackfin交叉编译工具链：<br>解压华恒软件包HHBF531-R1-v1.0.0-070327.tgz：<br>#tar jxvf HHBF531-R1-v1.0.0-070327.tgz<br>生成HHBF531-R1文件夹，内包含交叉编译工具链、uboot源码包、uclinux源码包、jtag工<br>具和源码镜像。<br>进入交叉编译工具链目录：<br>#cd HHBF531-R1/toolchains<br>交叉编译工具链是一个tgz压缩包gcc-bfin-3.4.tgz，包含的用于交叉编译的可执行文件，<br>直接解压到相应目录即可以使用，无需安装。<br>#tar jxvf gcc-bfin-3.4.tgz /usr/local/<br>设置编译工具目录：<br>#PATH=&#8221;/usr/local/gcc-bfin-3.4-uclinux/bin:$PATH&#8221;<br>这样，交叉编译环境就建立好了。开始华恒提供的源码吧，看看你的环境是否建立正确！<br>如果出现错误，仔细检查以上过程。<br><br>二， 移植u-boot：<br>uclinux启动离不开引导程序，这个引导程序叫作bootloader。Bootloader是在操作系统运<br>行之前执行的一段小程序。通过这段小程序，我们可以初始化硬件设备、建立内存空间的<br>映射表，从而建立适当的系统软硬件环境，为最终调用操作系统内核做好准备。<br>U-Boot是一种通用的Bootloader，可以方便地移植到各种硬件平台上。<br>华恒提供的u-boot在HHBF531-R1/u-boot目录下，支持blackfin系列DSP和常用开发板。<br><br>我们这里把U-Boot的移植分成两个部分。第一部分是为我们的新开发板在目录/board/下建<br>立一个新目录，并拷贝最类似的开发板源码到该目录，做一些配置修改，对我们的新开发<br>板进行配置并编译通过；第二部分是针对我们的新开发板的特点修改相关源码文件的内容<br>，使其能在我们的新开发板上运行。<br>1， 第一部分：<br>我们的新开发板基于BF533，与U-Boot中的hhbf开发板最类似，我们以hhbf开发板为模板修<br>改得到我们新开发板的移植代码。<br>进入u-boot目录：<br>#cd HHBF531-R1/u-boot<br>注意要让uclinux用户用于读写操作的权限，否则下面操作时报&#8220;Permition denied.&#8221;错<br>误。简单点，我们直接用root用户登陆。<br>进入开发板目录，建立对应于我们开发板的文件目录，这里命名为naribf533。<br>#cd board<br>#cp &#8211;R hhbf naribf533<br>#cd naribf533<br>#mv hhbf.c naribf533.c（修改文件名）<br>删除不需要的文件：<br>#mv &#8211;r hhbf*<br>#mv psd4256.h<br>这样我们新开发板的文件目录和文件都有了（现在还不能在我们开发板上运行）。然后修<br>改naribf533目录下的Makefile和u-boot.lds，把其中的hhbf全部修改为naribf533，后面<br>编译过程中如果报找不到hhbf的错误也把相应的hhbf改为naribf533。<br>再加入一个头文件：<br>#cd include/configs<br>#cp hhbf.h naribf533.h<br>这个头文件中有很多内容要修改，我们将在第二部分中予以修改。<br>修改顶层目录下的Makefile，找到以下内容：<br>hhbf533_config : unconfig<br>@ &gt; include/config.h<br>@echo &#8220;#define CONFIG_HHBF&nbsp; 1&#8221; &gt;&gt; include/config.h<br>@echo &#8220;#define CONFIG_BF533 1&#8221; &gt;&gt; include/config.h<br>@./mkconfig &#8211;a $(@:_config=) blackfin bf533 hhbf533 #hhtech<br>模仿上述语句，在下面增加以下内容：<br>naribf533_config : unconfig<br>@ &gt; include/config.h<br>@echo &#8220;#define CONFIG_HHBF&nbsp; 1&#8221; &gt;&gt; include/config.h<br>@echo &#8220;#define CONFIG_BF533 1&#8221; &gt;&gt; include/config.h<br>@./mkconfig &#8211;a $(@:_config=) blackfin bf533 naribf533<br>切记在&#8220;@./mkconfig &#8211;a $(@:_config=) blackfin bf533 naribf533&#8221;前面的是Tab来的<br>，万万不能用空格代替，因为它是靠这个来识别命令的！<br>最后编译u-boot，<br>#make distclean<br>#make naribf533_config（就是在Makefile里添加的config）<br>#make<br>看看有没有错，有错的话按着提示来改，如果没错的话应该就能生成u-boot.bin这个文件<br>。现在还不能使用，因为这只是hhbf的一个仿制品而已。<br>编译正确生成u-boot.bin文件，这一部分就算完成了。下面我们尝试修改相应的源代码。<br><br><br>2， 第二部分：<br>&nbsp;&nbsp;&nbsp; 该部分主要是修改开发板配置文件以及flash驱动。<br>我们先来修改开发板配置文件，让u-boot能运行起来。修改的主要内容包括：串口设置、<br>时钟设置、flash设置和SDRAM设置。我们的开发板上目前还没有网络功能，先不设置该内<br>容。<br>将以下设置替换原开发板配置文件相应部分即可。<br>串口设置，将波特率设置为115200。<br>#define CONFIG_BAUDRATE 115200<br>时钟设置，根据开发板晶振频率和系统需要的工作频率设置，我们开发板的晶振为27MHz，<br>内核时钟为输入时钟的22倍频，系统时钟为内核时钟的5分频，所以如下设置。<br>#ifdef CONFIG_BF533<br>&nbsp;&nbsp;&nbsp; #define CONFIG_CLKIN_HZ 27000000<br>#endif//CONFIG_BF533<br>#ifdef CONFIG_BF561<br>&nbsp;&nbsp;&nbsp; #define CONFIG_CLKIN_HZ 33000000<br>#endif//CONFIG_BF561<br><br>/* CONFIG_CLKIN_HALF controls what is passed to PLL 0=CLKIN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1=CLKIN/2&nbsp;&nbsp;&nbsp; */<br>#define CONFIG_CLKIN_HALF&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br><br>/* CONFIG_PLL_BYPASS controls if the PLL is used 0=don't bypass&nbsp; */<br>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1=bypass PLL&nbsp;&nbsp;&nbsp; */<br>#define CONFIG_PLL_BYPASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<br><br>/* CONFIG_VCO_MULT controls what the multiplier of the PLL is.&nbsp;&nbsp; */<br>/* Values can range from 1-64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>#ifdef CONFIG_BF533<br>&nbsp;&nbsp;&nbsp; #define CONFIG_VCO_MULT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12<br>#endif//CONFIG_BF533<br>#ifdef CONFIG_BF561<br>&nbsp;&nbsp;&nbsp; #define CONFIG_VCO_MULT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10<br>#endif//CONFIG_BF561<br><br>/* CONFIG_CCLK_DIV controls what the core clock divider is&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>/* Values can be 1, 2, 4, or 8 ONLY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>#define CONFIG_CCLK_DIV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br><br>/* CONFIG_SPI_BAUD controls the SPI peripheral clock divider&nbsp;&nbsp;&nbsp;&nbsp; */<br>/* Values can range from 2-65535&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>/* SCK Frequency = SCLK / (2 * CONFIG_SPI_BAUD)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>#define CONFIG_SPI_BAUD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2<br><br><br>/* CONFIG_SCLK_DIV controls what the peripheral clock divider is */<br>/* Values can range from 1-15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */<br>#define CONFIG_SCLK_DIV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4<br>flash设置，根据你的开发板flash容量和起始地址定制，我们的开发板flash容量为512KB<br>，起始地址为0x20000000。<br>#ifdef CONFIG_BF533<br>#define CFG_MAX_FLASH_BANKS 1 //flash只有一段<br>#define CFG_MAX_FLASH_SECT 11 //flash一共有11个sector<br>#endif//CONFIG_BF533<br><br>#ifdef CONFIG_BF533<br>#define CFG_ENV_ADDR 0x20020000<br>#define CFG_ENV_SECT_SIZE 0x10000<br>#endif//CONFIG_BF533<br><br>#ifdef CONFIG_BF533<br>#define FLASH_SIZE 0x80000<br>#define CFG_FLASH_SIZE 0x80000 //容量为512KB<br>#endif//CONFIG_BF533<br>SDRAM设置，根据你的开发板SDRAM容量和起始地址定制，我们的开发板SDRAM容量为16MB，<br>列地址宽度为9，起始地址为0x00000000。<br>#define CFG_LARGE_IMAGE_LEN 0x1000000&nbsp;&nbsp; /* Large Image Length */<br><br>#ifdef CONFIG_BF533<br>#define CONFIG_MEM_SIZE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* 128, 64, 32, 16 */<br><br>#endif//CONFIG_BF533<br><br>#define CONFIG_MEM_ADD_WDTH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* 8, 9, 10, 11&nbsp;&nbsp;&nbsp; */<br><br>#define CFG_MEMTEST_START 0x00100000 /* memtest works on */<br>#define CFG_MEMTEST_END 0x00f00000 /* 1..15 MB in DRAM */<br><br>#define CFG_SDRAM_BASE 0x00000000<br>#ifdef CONFIG_BF533<br>#define CFG_MAX_RAM_SIZE 0x01000000<br>#endif//CONFIG_BF533<br>如上设置后，重新编译u-boot，发现出现错误#error "CFG_MONITOR_BASE != TEXT_BASE"<br>，原因是TEXT_BASE设置值与配置文件不一致，主要是由于我们修改了SDRAM的容量。到b<br>oard/naribf533目录下修改config.mk文件，将TEXT_BASE的地址修改为0x0fc0000。接下来<br>编译应该没有任何错误了。<br>编译生成的u-boot.bin下载到开发板即可以运行了，应该能看到串口返回的u-boot成功运<br>行的信息。这样第一步修改就完成了。<br>在上面看到的u-boot运行信息里，你会发现有很多关于华恒的信息，可能你很不愿意显示<br>这些内容。这是因为你还没有修改flash驱动，里面显示的还是华恒提供的flash驱动显示<br>的内容。而且此时还不能下载uclinux镜像，因为华恒提供的flash驱动不一定适合你的开<br>发板，不能对你的开发板flash进行写操作。所以，我们接下来修改flash驱动。<br>flash驱动对应的文件是board/naribf533/flash.c，它主要包括以下几个函数：<br>unsigned long flash_init (void )，Flash初始化； <br>&nbsp;&nbsp;&nbsp; void flash_print_info (flash_info_t *info)，打印Flash信息； <br>&nbsp;&nbsp;&nbsp; int flash_erase (flash_info_t *info， int s_first， int s_last)，Flash擦除<br>； <br>&nbsp;&nbsp;&nbsp; volatile static int write_dword (flash_info_t *info， ulong dest， ulong d<br>ata)，Flash写入； <br>&nbsp;&nbsp;&nbsp; int write_buff (flash_info_t *info， uchar *src， ulong addr， ulong cnt)，<br>从内存复制数据。<br>Flash驱动修改要根据你使用的flash特性进行，参考flash的文档。主要修改内容包括：f<br>lash操作命令、flash扇区分配和一些打印信息。<br>另外，还有SDRAM的配置。除了再(board).h文件中的配置以外，如果你使用的SDRAM的刷新<br>频率不同于hhbf531学习板上使用的，还必须到include/asm-blackfin/mem_init.h文件中<br>去修改SDRAM_Tref和SDRAM_NRA两个参数。<br><br>3， 测试U-boot：<br>如果以上修改内容都做到了，编译得到的u-boot应该没有什么问题了，但测试还是必要的<br>。<br>u-boot能正确打印启动信息，不代表u-boot完全正确了，比如说flash不能正确擦写、SDR<br>AM不能正确操作等问题都可能存在。这里分一下几项内容测试u-boot。<br>1）测试u-boot所有命令：<br>在u-boot的monitor下，键入help，会显示u-boot支持的所有命令。依次测试各命令，检查<br>是否正确。<br>2）测试flash驱动：<br>通过u-boot的loadb和go命令，下载一个可执行程序到某个未使用的地址空间，检查是否正<br>确运行，以测试flash能否正确读写。<br>3）测试SDRAM：<br>SDRAM的测试往往被人忽略，其实该部分是很重要的，一旦错误可能给后面的内核移植带来<br>很多问题，本人就遇到这样的问题。<br>测试SDRAM主要包括空间的连续性和是否有空间重叠现象。<br>连续性测试可以通过md命令，从低地址到高地址依次打印内存信息，检查打印的地址是否<br>连续。<br>内存空间是否重叠可以通过对每MB空间写入特定数，检查各MB空间的数据是否重复，重复<br>则可能因为空间重叠。<br>除以上测试内容外，可能还有其他小问题，视情况另做测试。<br>通过以上测试后，你的u-boot基本就没有问题了，可以放心地利用它下载运行linux了。</p>
<p>&nbsp;</p>
<p>U-Boot在基于ADSP BF533的嵌入式Linux系统上的移植<br><br></p>
<p><strong>1 引言</strong></p>
<p>Boot Loader(内核引导程序)是在操作系统内核运行之前运行的一段自举程序，用于初始化硬件设备、改变处理器运行模式、重组中断向量和建立内存空间映射图，从而将系统的软硬件带到一个合适的状态或者用户定制的特定状态，以便为最终加载操作系统内核准备好正确的环境[1]。</p>
<p>嵌入式Linux系统常用的Boot Loader有arm-boot、redboot、U-Boot等。U-Boot (全称Universal Boot Loader)是当前比较流行的遵循GPL条件的开放源码项目。U-Boot具有源码公开的特点，开发人员可根据自身需要进行裁减；支持多种处理器和嵌入式操作系统内核；具有多种设备驱动源码：支持种引导方式；具有功能强大且成熟、稳定等诸多优点，故在嵌入式系统开发过程中广泛采用。U-Boot严重依赖于底层硬件，不同的CPU或嵌入式板极设备需要不同的U-Boot，因此，在嵌入式系统中建立通用的U-Boot是非常困难的，故U-Boot需针对开发板量身定做。</p>
<p><strong>2 开发平台</strong></p>
<p>2.1 BF533简介</p>
<p>Blackfin系列DSP是ADI公司与Intel联合开发推出的第一款高性能、低功耗第四代定点DSP产品，融合了Analog Devices/Intel公司的微信号结构(MSA)。它将一个32位RISC型指令集和双16位乘法累加(MAC)信号处理功能与通用型微控制器所具有的易用性组合在一起。这种组合使Blackfin处理器能够在信号处理和控制处理应用中发挥最佳的性能。且Blackfin处理器通过将工业标准接口与高性能的信号处理内核相结合在一起,用户可以快速设计出节省成本的解决方案，而且无需昂贵的外部组件。</p>
<p>本开发系统采用BF533，BF533是主频高达600 MHz、峰值处理能力为1.2 GMI/s的高性能Blackfin处理器。BF533内核包含2个16位MAC、2个40位ALU、4个8位视频ALU以及1个40位移位器。另外，BF533还包括1个UART口、1个SPI口、2个串行口(SPORT)、4个通用定时器(其中3个具有PWM功能)、1个实时时钟、看门狗定时器以及1个并行外设接口。外部存储器控制器可与SDRAM、SRAM、Flash和ROM实现无缝连接[2]。</p>
<p>2.2 系统硬件平台简介</p>
<p>本系统的开发板硬件系统如图1所示。<br><br></p>
<p align=center><img height=225 src="http://news.eeworld.com.cn/pic/20070913/20070913112424.bmp" width=420></p>
<p>目标板以Blackfin嵌入式处理器为核心，数据地址线复用到SDRAM、Flash、USB、Ethernet，并通过FPGA实现逻辑控制。此外，将UART端口转换为RS232端口引出。其中SDRAM的地址为0x00000000～0x02000000，Flash的地址为0x20000000～0x20300000。</p>
<p>宿主机采用Window和Suse10.0双操作系统，采用串行接口和以太网连接宿主机和目标板，程序先在宿主机上编译，然后下载至目标板上运行，目标板的终端被重定向到串行接口，由宿主机输出。</p>
<p>2.3 开发环境的建立</p>
<p>2.3.1 在宿主机上设置终端</p>
<p>大部分嵌入式系统在宿主机大多都采用kermit或minaicom实现与目标板的通信，本系统采用inicom。minicom是Linux下一个类似于Windows超级终端的友好串口通信程序。在终端输入bash#minicom-s进入minicom设置画面，设置串口波特率、有效数据位、停止位以及奇偶校验位分别为57 600、8 bit、1位停止位以及无奇偶校验位等。</p>
<p>2.3.2安装交叉编译器</p>
<p>交叉编译是在一个架构下编译另外一个架构的目标文件。要从http：//blackfin.uclinux.org网站上下载Blackfin ToolChain，然后安装并修改环境变量PATH，使其包含ToolChain的安装目录。<br><br><img src="http://news.eeworld.com.cn/pic/20070913/20070913112445.jpg"></p>
<p><strong>3 U-Boot启动两阶段</strong></p>
<p>U-Boot代码一般分为stage1和stage2两大部分。stage1依赖于cpu体系结构如设备初始化代码，常用汇编语言编写以达到短小精悍,提高系统运行效率的目的。它主要包括cpu/bf533目录下的start.s。stage2一般采用C语言编写实现复杂功能，这样代码则具有更好的可读性和可移植性，主要包括lib blackfin/board.c文件和common/main．c文件中main_loop函数。</p>
<p>stagel从cpu入口函数cpu/bf533/start.s开始,通常包含以下步骤：</p>
<p>(1)基本硬件的初始化，为随后执行kernel准备好基本的硬件环境。包括：屏蔽所有中断，引导装载程序的执行过程中不必执行任何中断，中断屏蔽可通过写cpu的中断屏蔽寄存器或状态寄存器实现；设置cpu的速度和时钟频率，初始化pll；RAM初始化，初始化内存控制器的各个寄存器；初始化UART，向串口打印U-Boot的字符信息；关闭cpu内部指令，数据cache。</p>
<p>(2) 为加载U-Boot的stage2准备RAM空间，通常将stage2置于整个RAM空间的最顶层1 MB空间。</p>
<p>(3)拷贝U-Boot的stage2到RAM。判断是否是Flash运行,如果是就将stage2的代码拷贝到TEXT BASE处。将stage2安排到RAM空间的最顶层1 MB是较推荐的方法。</p>
<p>(4)设置堆栈指针sp为C语言代码执行做好准备。</p>
<p>(5)跳转到stage2的C语言代码入口点。</p>
<p>stage2主要包括lib-blackfin/board.c中board_init_f、board_init_r函数以及common/main.C中main_loop函数。通常包含以下步骤：</p>
<p>(1)初始化此阶段需用的硬件设备，由board_init_f和board_init_r函数实现。 <br><br><img src="http://news.eeworld.com.cn/pic/20070913/20070913112503.jpg"></p>
<p>(2)内存映射检测。</p>
<p>(3)加载内核并为内核设置启动参数。</p>
<p>(4)调用内核。</p>
<p><strong>4 U-BOOt的移植</strong></p>
<p>4.1 U-Boot方法与要点</p>
<p>移植U-Boot简便的方法是从U-Boot支持的开发板中选择一个与其目标板接近的开发板进行修改。需修改的是与硬件相关的部分,涉及到两个层面：针对CPU的移植，由于U-Boot_1.1.3支持BF533，故只需做第二层面的移植：针对目标板硬件的移植。在移植前，需仔细阅读U-Boot/readme文件，该文件对目录结构和如何移植作了简要介绍。从移植U-Boot的最小要求、U-Boot能够正常启动的角度出发,选择BF533的STAMP板为模板,相关源代码在/board/stamp目录下，结合U-Boot的启动流程，主要修改文件如下：</p>
<p>(1)与目标板相关的代码部分：在board下创建mybf533目录，无需从头开始，参考与目标板相似的STAMP板在mybf533目录下创建mybf533.c、mybf533.h、flash.c、config.mk、Makefie等文件。需要修改/board/mybf533/config.mk：<br><br><img src="http://news.eeworld.com.cn/pic/20070913/20070913112520.jpg"></p>
<p>TFEXT_BASE用于设置程序编译链接的起始地址即将U-Boot的stage2拷贝到SDRAM的TEXT_BASE处，即SDRAM最顶层一段存储区。修改board/mybf533/Makefile： <br><br><img src="http://news.eeworld.com.cn/pic/20070913/20070913112536.jpg"><br><br>(2)与CPU相关的代码部分：U-Boot_1.1.3/epu文件中含有BF533的目录，其中包含start.s、cpu.c、cpu.h、interrupt.c、init_sdram.s等。故不需要建立与cpu相关的文件目录。</p>
<p>(3)与头文件相关的代码：在include/configs创建mybf533.h，参考include/configs/stamp.h，如下：<br><br><img src="http://news.eeworld.com.cn/pic/20070913/20070913112557.jpg"><br><br>Flash的修改与具体型号和容量有关，修改过程中参考Flash擦除数据命令、特定寄存器的写入地址以及扇区的大小和位置。</p>
<p>与SDRAM相关设置：<br><br><img src="http://news.eeworld.com.cn/pic/20070913/20070913112615.jpg"><br><img height=245 src="http://news.eeworld.com.cn/pic/20070913/20070913112714.jpg" width=400><br><br>注意：最后一行要用Tab键开头表示命令。其中blackfin表示CPU的种类.bf533是cpu bf533对应的代码目录，mybf533是目标板对应的目录。这样可使用make mybf533_config配置自身的开发板。</p>
<p>其他修改视情况而定。如根据SDRAM大小修改cplb表，根据需要修改堆栈大小。如drivers/cfi_flash.c中flash_init()函数,cpu/bf533/ints.c中init_IRQ()函数等。</p>
<p>修改完毕后就可以采用如以下命令编译U-Boot：bash＄&gt;make clean，bash＄&gt;make mrproper，bash＄&gt;make mybf533_config，bash＄&gt;make。</p>
<p>编译完后U-Boot_1.1.3生成U-Boot的二进制文件U-Boot.bin(U-Boot.bin只能用于更新)。执行bash＄&gt;bfin-uclinux-objcopy-I binary-Oihex U-Boot.bin,生成可在Windows下首次烧写到Flash的十六进制文件U-Boot.hex。 <br><br>4.2 U-Boot的烧写</p>
<p>第一次下载U-Boot到目标板或者当U-Boot不能正常启动时。必须通过JTAG或者ADI ICE将U-Boot下载到目标板。在此可将ADI公司的仿真器与Visual DSP++环境相连,通过Visual DSP++,在TOOLS--&gt;Flash Programmer下执行Flash驱动程序M25P64.dxe，选择"Erase all"--&gt;Load Flie烧写U-Boot.hex文件到Flash中。</p>
<p>移植成功后，打开终端minicom复位开发板，若串口能输出正确的启动信息．则表明移植基本成功。启动后，如果在设定的时间内，串口没有接收到按键。U-Boot将自动加载操作系统内核和文件系统。若设定时间内串口接收到按键，则U-Boot停止自动加载,进入命令行，可看到U-Boot的提示符"mybf533&gt;"，查看Flash信息，调试或手动加载内核。</p>
<p>生成新的U-Boot.bin文件后。可通过Ethernet或者串口更新U-Boot。因为网络的传输速度远比串口快，故一般选择网络传输。将新生成的U-Boot.bin拷贝到宿主机根目录下的tftpboot目录(前提是已经创建tftp sever),在目标板出现U-Boot提示符后。按任意键进入下载模式：<br>mybf533&gt;tftp 0x1000000 U-Boot.bin</p>
<p>0x1000000为SDRAM默认的下载地址空间,用于U-Boot的升级、调试。当需要升级或者修改U-Boot,可将新的U-Boot从SDRAM烧写到。Flash,覆盖原来的U-Boot，以减少烧写Flash的次数。在烧写以前最好测试一下所下载的U-Boot能否正常运行：<br><br><img height=215 src="http://news.eeworld.com.cn/pic/20070913/20070913112738.jpg" width=400></p>
<p>如果不正确，应重复执行Erase all和Copy命令，直到正确为止。至此，U-Boot移植的步骤已基本完成。</p>
<p><strong>5 结束语</strong></p>
<p>U-Boot是一个功能强大的Boot loader。前期移植工作是嵌入式系统开发的首要环节。但其移植不可避免的存在一些难以预料的问题。嵌入式开发人员应该在了解U-Boot的工作机理、移植条件后,根据目标板和具体情况灵活裁减U-Boot以提高操作系统移植的稳定性，缩短移植周期，降低产品成本。</p>
<p>本文结合U-Boot的运行机理以及U-Boot移植的基本要求，研究了U-Boot在基于BF533的嵌入式系统上的移植。本文的移植是在不改变U-Boot框架前提下，对嵌入式目标板和CPU相关代码进行修改，实现了成功移植且移植后的U-Boot能够在目标板上稳定运行，为后续开发奠定了良好的基础。</p>
<p><br>基于Blackfin嵌入式系统的U-boot分析与调试<br></p>
<p><strong>引言</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>Boot loader代码是CPU芯片复位后进入操作系统之前执行的一段代码，主要用于完成硬件启动到操作系统启动的过渡，从而为操作系统提供基本的运行环境。Boot loader代码与CPU的内核结构、具体型号、应用系统配置及操作系统有关，其功能类似于PC机的BIOS程序。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>Blackfin DSP是美国模拟器件公司与Intel联合开发的第4代DSP产品，是专为通信和互联网应用而设计的通用DSP芯片，适合处理互联网中的大量图像、声音、文本和数据流，以及汽车电子中的可视系统、宽带无线系统、消费类多媒体电子、数字摄像机、多通道VoIP、安全和监督、机顶盒和视频电话会议等。 本文对基于Blackfin 561微处理器构建的嵌入式开发板EZKIT561的U-boot第一和第二阶段的具体工作流程进行了分析，画出了各阶段的流程图，同时在U-boot第一阶段代码中加入LED指示程序来跟踪第一阶段的执行情况；而在U-boot第二阶段，则在代码的相应位置添加了向串口的打印信息，以跟踪U-boot在此阶段的执行情况。</p>
<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 Blackfin DSP简介</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>ADI公司推出的Blackfin处理器是专为嵌人式音频、视频、通信计算要求和功耗约束条件而设计的新型16～32位嵌入式处理器。Blackfin处理器由ADI和Intel联合开发，主要基于微信号架构(MSA)。它将一个32位RISC型指令集和双16位乘法累加(MAC)信号处理功能与通用型微控制器所具有的易用性组合在一起。这种处理特征使得Blackfin处理器在信号处理和控制处理应用中均能发挥上佳作用，因而在许多场合可免除增设单独异类处理器。</p>
<p>&nbsp;&nbsp;<strong>&nbsp;&nbsp;&nbsp;&nbsp; 2 Boot loader及U-boot简介</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>2．1 Boot loader简介</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>Boot loader是用于初始化目标板硬件，可给嵌入式操作系统提供板上硬件资源信息，并进行装载、引导嵌人式操作系统运行的固件。最终，Boot Loader会把操作系统内核映像加载到RAM中，并将系统控制权传递给它。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>大多数Boot Loader都包含两种不同的操作模式： "启动加载"模式和"下载模式"。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>启动加载(Boot loading)模式也称"自主"(Autonomous)模式。即Boot Loader从目标机上的某个固态存储设备上将操作系统加载到RAM中运行。这种模式是Boot Loader的正常工作模式，因此在嵌入式产品发布的时侯，Boot Loader显然必须工作在这种模式下。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>在下载(Downloading)模式下，目标机上的Boot Loader将通过串口连接或网络连接等手段从主机(Host)下载内核映像和根文件系统映像等。从主机下载的文件通常先被Boot Loader保存到目标机的RAM，然后再被Boot Loader写到目标机的FLASH等固态存储设备中。Boot Loader的这种模式通常在第一次安装内核与根文件系统时使用；此外，以后的系统更新也会使用Boot Loader的这种模式。工作于这种模式下的Boot Loader通常都会向它的终端用户提供一个简单的命令行接口。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>2．2 U-boot简介<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>U-Boot(全称U niversal Boot Loader)是遵循GPL条款的开放源码项目。其源码目录和编译形式与Linux内核相似。事实上，不少U-Boot源码就是相应的Linux内核源程序的简化，尤其是一些设备的驱动程序，这一点从U-Boot源码的注释中就能体现。目前支持的目标操作系统有OpenBSD，NetBSD，FreeBSD，4．4BSD，Linux，SVR4，Esix，Solaris，Irix，VxWorks，LynxOS，pSOS，QNX，RTEMS，ARTOS；这是U-Boot中Universal的一层含义，另外一层含义是U-Boot除了支持PowerPC系列处理器外，还能支持Black-fin、MIPS、x86、ARM、NIOS、XScale等诸多处理器。上述两个特点正是U-Boot项目的开发目标，即支持尽可能多的嵌入式处理器和嵌人式操作系统。U-Boot的主要目录结构如表1所列。</p>
<p>&nbsp;&nbsp;<strong>&nbsp;&nbsp;&nbsp;&nbsp; 3 基于Blackfin DSP的U-boot运行分析</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>大多数Boot loader都分为stagel和stage2两大部分，U-boot也是如此。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>3．1 U-boot的stagel阶段</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>依赖于CPU体系结构的代码(比如设备初始化代码等)，通常都放在stage1中，该代码可用blackfin DSP汇编语言来实现，以达到短小精悍的目的。实际操作可在位于U-boot 1．1．3＼cpu＼bf533中的Start．S和Startl．S文件中实现，而且是从Start．S开始运行，此阶段的程序流程图如图1所示。<br></p>
<p>
<table cellSpacing=0 cellPadding=0 width=675 border=0>
    <tbody>
        <tr>
            <td>
            <p align=center><img height=362 src="http://image.mcuol.com/News/070927152338460.jpg" width=300></p>
            <div align=center><br><img height=491 src="http://image.mcuol.com/News/070927152338821.jpg" width=320> </div>
            </td>
        </tr>
    </tbody>
</table>
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>stage1的步骤以执行的先后主要包括硬件设备初始化、为加载Boot Loader的stage2准备RAM空间、拷贝Boot Loader的stage2到RAM空间、设置堆栈、跳转到stag2的C入口等。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>3．2 U-boot的stage2阶段</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>通常stage2可用C语言来实现更复杂的功能，该代码具有更好的可读性和可移植性。Stage2实现的主要功能包括初始化本阶段要使用到的硬件设备，检测系统内存映射(memory map)，将ker-nel映像和根文件系统映像从flash上读到RAM空间中，为内核设置启动参数，以及调用内核等。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>而基于ADSP-BF561 EZKIT-Lite评估板的U-boot在该阶段的启动时，首先在第一阶段结束后，调用＼U-boot 1．1．3＼1ib_blackfin＼board．c文件中的board_init_f()函数并执行。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>然后再调用board．c文件中的board_init_r()函数并按先后顺序执行，其流程图如图2所示。<br></p>
<p>
<table cellSpacing=0 cellPadding=0 width=675 border=0>
    <tbody>
        <tr>
            <td>
            <div align=center><img height=393 src="http://image.mcuol.com/News/070927152338982.jpg" width=320></div>
            </td>
        </tr>
    </tbody>
</table>
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>之后，再在board_init_r函数的最后调用＼U-boot 1．1．3＼common＼main．c中的main_loop()函数。在执行过程中，系统会首先对自动启动内核进行倒计时，倒计时的时间由环境变量bootdelay的设定值决定。由于先前已经对串口进行了初始化，所以会在windows超级终端打印"ezkit：&gt;"，这样，mainloop()函数的执行将产生两条分支：一是等待u-boot的自启动命令执行，即执行bootcmd环境变量所设定的自动运行的命令(比如setenvbootcmd bootm 0x2000 0000)，引导flash特定地址中的嵌入式操作系统；二是在u-boot的自启动命令执行前按下任意键，以进入u-boot的命令行。在此状态下可以查看和修改环境变量、下载更新U-boot和内核镜像文件、对flash进行擦写操作或通过命令启动操作系统(如bootm 0x2000 0000)；</p>
<p>&nbsp;<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 基于评估板的U-boot启动跟踪调试</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>4．1 第一阶段跟踪调试</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>由于U-boot的启动过程分为两个阶段，第一阶段在串口初始化之前无法获得字符串提示信息。这样，第一阶段的运行过程似乎就没办法掌握．但是，EZKIT561开发板提供16个用户可编程的LED，所以就可以通过这16个LED来了解u-boot在第一阶段的具体执行过程，即在U-boot第一阶段的几个不同的代码处添加LED指示程序。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>ADSP-BF561有48个双向通用可编程I／O引脚。这些可编程引脚具有实现SPI接口的特殊功能。每一个可编程引脚均能通过操作一系列的标志控制寄存器、标志状态寄存器和标志中断寄存器来进行独立控制。由于一共有48个通用可编程I／O引脚，所以可将以上寄存器分成三组，每组可对16个通用可编程I／O引脚进行操作。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>通过参考EZKIT56 1原理图可知，LED 5～20与PF 32～47 pins相连，可以跟踪堆栈配置。设计时可使用以下寄存器进行控制。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>(1)FIO2_DIR寄存器</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>这是一个16位寄存器，若将其中的某一位设置为1，那么相应的PF引脚就可作为输出；反之，则为输入。其相关设置代码如下：<br></p>
<p><img height=128 src="http://image.mcuol.com/News/070927152339093.jpg" width=293> </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>(2)FIO2_FLAG_D</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>这也是一个16位寄存器，对其写操作时，可指定相应的PF引脚状态；而当进行读操作时，则返回相应的PF引脚的值。它的每一位都控制着一个LED灯。其相关设置代码如下：<br></p>
<p><img height=57 src="http://image.mcuol.com/News/070927152339154.jpg" width=250> </p>
<p>w [p0]=r0；<br>ssync；</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>添加的跟踪堆栈配置程序的流程图如图3所示。修改代码后即可在U-boot文件夹路径下依次输入以下命令：make clean、make mrproper、make ezkit561 config和make，然后再利用bfin-u．clinux-objcopy将生成的U-boot．bin转换为U-boot．hex，最后通过VDSP＋＋开发环境中TOOL下的flashprogrammer将u-boot．hex烧写到flash中，同时进行复位操作以观察LED的变化。</p>
<p>&nbsp;</p>
<p>
<table cellSpacing=0 cellPadding=0 width=675 border=0>
    <tbody>
        <tr>
            <td>
            <p align=center><img height=272 src="http://image.mcuol.com/News/070927152339215.jpg" width=220></p>
            </td>
        </tr>
    </tbody>
</table>
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>本设计希望在堆栈配置前使LED 13、LED 14亮，其它LED灭，持续时间为1 s；而在堆栈分配之后使LED 11、LED 12亮，其它LED灭，持续时间为1 s。其实际的观察结果是，在复位之后，LED 13、LED 14持续亮1 s，接着LED 11、LED 12持续亮1秒，可见其完全达到了预期目标。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>4．2 第二阶段跟踪调试</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>第二阶段是在进人C函数之后，就进行串口的初始化。之后，便可通过向串口打印信息来实时跟踪所启动的执行流程，以了解程序目前执行的具体部分或运行到哪一个阶段出现了问题。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>下面以打印串口初始化完成信息为例。首先在U-boot第二阶段找到串口初始化的代码，即U-boot／lib-blackfin／board．c文件的serial．init()函数，然后在此函数之后添加printf("serial initializationis ok!＼n")以实现打印。其程序代码如下：<br></p>
<p><img height=107 src="http://image.mcuol.com/News/070927152339316.jpg" width=300> </p>
<p><img height=114 src="http://image.mcuol.com/News/070927152339397.jpg" width=330> </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>修改代码后的编译和下载步骤如前所示，调试时使用的串行通信软件是windows自带的"超级终端"程序，所选择的"每秒位数" (即波特率)为57600，传输文件使用的通信协议为Kermit协议。配置好超级终端后，按下开发板上的复位键．终端便可显示出系统启动过程的相关信息。系统复位后，第一行显示的是"serial initializa-tion is ok!"。这便是自行添加的打印语句，其主要功能是提示串口初始化已完成。 </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>由于第二阶段可以通过串口打印信息，且在相关的每一阶段均可添加相关的printf句来实现打印提示信息，所以跟踪及调试都比较容易。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>&nbsp; 5 结束语</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong> </strong>通过分析基于Blackfin 561微处理器构建的嵌入式开发板EZKIT561的U-boot代码，以期对Boot Loader的启动过程有一个比较深入的理解，文章还通过一些调试方法对其运行阶段进行跟踪，以便对将来在开发板上的ucLinux移植和进一步的视频编解码工作进行准备。<br></p>
<img src ="http://www.cnitblog.com/zouzheng/aggbug/40217.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zouzheng/" target="_blank">zz</a> 2008-02-27 17:05 <a href="http://www.cnitblog.com/zouzheng/articles/40217.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DENX U-Boot及Linux使用手册</title><link>http://www.cnitblog.com/zouzheng/articles/40215.html</link><dc:creator>zz</dc:creator><author>zz</author><pubDate>Wed, 27 Feb 2008 08:45:00 GMT</pubDate><guid>http://www.cnitblog.com/zouzheng/articles/40215.html</guid><wfw:comment>http://www.cnitblog.com/zouzheng/comments/40215.html</wfw:comment><comments>http://www.cnitblog.com/zouzheng/articles/40215.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zouzheng/comments/commentRss/40215.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zouzheng/services/trackbacks/40215.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;1. 概要这是嵌入式PowerPC, ARM和MIPS系统中使用DENX U-Boot和Linux的指导手册。文档中描述了如何在嵌入式PowerPC, ARM和MIPS系统上配置、编译、使用Das U-Boot（常常缩写为&#8220;U-Boot&#8221;）和Linux操作系统。本文档写于2005年一月至四月四日十四点十五分。2. 绪论本文档描述了如何在嵌...&nbsp;&nbsp;<a href='http://www.cnitblog.com/zouzheng/articles/40215.html'>阅读全文</a><img src ="http://www.cnitblog.com/zouzheng/aggbug/40215.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/zouzheng/" target="_blank">zz</a> 2008-02-27 16:45 <a href="http://www.cnitblog.com/zouzheng/articles/40215.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>u-boot启动过程分析——基于lpc2210的移植代码</title><link>http://www.cnitblog.com/zouzheng/articles/40174.html</link><dc:creator>zz</dc:creator><author>zz</author><pubDate>Tue, 26 Feb 2008 06:51:00 GMT</pubDate><guid>http://www.cnitblog.com/zouzheng/articles/40174.html</guid><wfw:comment>http://www.cnitblog.com/zouzheng/comments/40174.html</wfw:comment><comments>http://www.cnitblog.com/zouzheng/articles/40174.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/zouzheng/comments/commentRss/40174.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/zouzheng/services/trackbacks/40174.html</trackback:ping><description><![CDATA[<p><em>作者：华清远见嵌入式培训中心（</em><em>转载请注明出处）</em>
<p>&nbsp;</p>
<div>u-boot是一种普遍用于嵌入式系统中的Bootloader。 </div>
<p>&nbsp;</p>
<div><strong><font color=#0938f7>Bootloader介绍</font></strong> </div>
<p>&nbsp;</p>
<div>Bootloader的定义：<u>Bootloader是在操作系统运行之前执行的一小段程序，通过这一小段程序，我们可以初始化硬件设备、建立内存空间的映射表，从而建立适当的系统软硬件环境，为最终调用操作系统内核做好准备</u>。意思就是说如果我们要想让一个操作系统在我们的板子上运转起来，我们就必须首先对我们的板子进行一些基本配置和初始化，然后才可以将操作系统引导进来运行。具体在Bootloader中完成了哪些操作我们会在后面分析到，这里我们先来回忆一下PC的体系结构：<u>PC机中的引导加载程序是由BIOS和位于硬盘MBR中的OS Boot Loader（比如LILO和GRUB等）一起组成的，BIOS在完成硬件检测和资源分配后，将硬盘MBR中的Boot Loader读到系统的RAM中，然后将控制权交给OS Boot Loader。Boot Loader的主要运行任务就是将内核映象从硬盘上读到RAM中，然后跳转到内核的入口点去运行，即开始启动操作系统</u>。在嵌入式系统中，通常并没有像BIOS那样的固件程序（注：有的嵌入式cpu也会内嵌一段短小的启动程序），因此整个系统的加载启动任务就完全由Boot Loader来完成。比如在一个基于ARM7TDMI core的嵌入式系统中，系统在上电或复位时通常都从地址0x00000000处开始执行，而在这个地址处安排的通常就是系统的Boot Loader程序。（<em>先想一下，通用PC和嵌入式系统为何会在此处存在如此的差异呢</em>？） </div>
<p>&nbsp;</p>
<div>Bootloader是基于特定硬件平台来实现的，因此几乎不可能为所有的嵌入式系统建立一个通用的Bootloader，不同的处理器架构都有不同的Bootloader，Bootloader不但依赖于cpu的体系结构，还依赖于嵌入式系统板级设备的配置。对于2块不同的板子而言，即使他们使用的是相同的处理器，要想让运行在一块板子上的Bootloader程序也能运行在另一块板子上，一般也需要修改Bootloader的源程序。 </div>
<p>&nbsp;</p>
<div><strong><font color=#0000ff>Bootloader的启动方式</font></strong> </div>
<p>&nbsp;</p>
<div>Bootloader的启动方式主要有网络启动方式、磁盘启动方式和Flash启动方式。 </div>
<p>&nbsp;</p>
<div><strong>1、网络启动方式</strong> </div>
<p align=center><a id=ImgSpan href="http://www.farsight.com.cn/FarsightBBS/UploadFile/2007-12/20071271619932958.gif" target=_blank><img alt=按此在新窗口浏览图片 src="http://www.farsight.com.cn/FarsightBBS/UploadFile/2007-12/20071271619932958.gif" onload="return imgzoom(this,550)" border=0></a></p>
<div><br></div>
<p align=center>图1&nbsp;&nbsp;Bootloader网络启动方式示意图
<p>&nbsp;</p>
<div>如图1所示，里面主机和目标板，他们中间通过网络来连接，首先目标板的DHCP/BIOS通过BOOTP服务来为Bootloader分配IP地址，配置网络参数，这样才能支持网络传输功能。我们使用的u-boot可以直接设置网络参数，因此这里就不用使用DHCP的方式动态分配IP了。接下来目标板的Bootloader通过TFTP服务将内核映像下载到目标板上，然后通过网络文件系统来建立主机与目标板之间的文件通信过程，之后的系统更新通常也是使用Boot Loader的这种工作模式。工作于这种模式下的Boot Loader通常都会向它的终端用户提供一个简单的命令行接口。 </div>
<p>&nbsp;</p>
<div><strong>2、磁盘启动方式</strong> </div>
<p>&nbsp;</p>
<div>这种方式主要是用在台式机和服务器上的，这些计算机都使用BIOS引导，并且使用磁盘作为存储介质，这里面两个重要的用来启动linux的有LILO和GRUB，这里就不再具体说明了。 </div>
<p>&nbsp;</p>
<div><strong>3、Flash启动方式</strong> </div>
<p>&nbsp;</p>
<div>这是我们最常用的方式。Flash有NOR Flash和NAND Flash两种。NOR Flash可以支持随机访问，所以代码可以直接在Flash上执行，Bootloader一般是存储在Flash芯片上的。另外Flash上还存储着参数、内核映像和文件系统。这种启动方式与网络启动方式之间的不同之处就在于，在网络启动方式中，内核映像和文件系统首先是放在主机上的，然后经过网络传输下载进目标板的，而这种启动方式中内核映像和文件系统则直接是放在Flash中的，这两点在我们u-boot的使用过程中都用到了。 </div>
<p>&nbsp;</p>
<div><strong><font color=#0000ff>U-boot的定义</font></strong> </div>
<p>&nbsp;</p>
<div>U-boot，全称Universal Boot Loader，是由DENX小组的开发的遵循GPL条款的开放源码项目，它的主要功能是完成硬件设备初始化、操作系统代码搬运，并提供一个控制台及一个指令集在操作系统运行前操控硬件设备。U-boot之所以这么通用，原因是他具有很多特点：开放源代码、支持多种嵌入式操作系统内核、支持多种处理器系列、较高的稳定性、高度灵活的功能设置、丰富的设备驱动源码以及较为丰富的开发调试文档与强大的网络技术支持。另外u-boot对操作系统和产品研发提供了灵活丰富的支持，主要表现在：可以引导压缩或非压缩系统内核，可以灵活设置/传递多个关键参数给操作系统，适合系统在不同开发阶段的调试要求与产品发布，支持多种文件系统，支持多种目标板环境参数存储介质，采用CRC32校验，可校验内核及镜像文件是否完好，提供多种控制台接口，使用户可以在不需要ICE的情况下通过串口/以太网/USB等接口下载数据并烧录到存储设备中去（这个功能在实际的产品中是很实用的，尤其是在软件现场升级的时候），以及提供丰富的设备驱动等。 </div>
<p>&nbsp;</p>
<div><strong><font color=#0000ff>u-boot源代码的目录结构</font></strong> </div>
<p>&nbsp;</p>
<div>1、board中存放于开发板相关的配置文件，每一个开发板都以子文件夹的形式出现。<br>2、Commom文件夹实现u-boot行下支持的命令，每一个命令对应一个文件。<br>3、cpu中存放特定cpu架构相关的目录，每一款cpu架构都对应了一个子目录。<br>4、Doc是文档目录，有u-boot非常完善的文档。<br>5、Drivers中是u-boot支持的各种设备的驱动程序。<br>6、Fs是支持的文件系统，其中最常用的是JFFS2文件系统。<br>7、Include文件夹是u-boot使用的头文件，还有各种硬件平台支持的汇编文件，系统配置文件和文件系统支持的文件。<br>8、Net是与网络协议相关的代码，bootp协议、TFTP协议、NFS文件系统得实现。<br>9、Tooles是生成U-boot的工具。 </div>
<p>&nbsp;</p>
<div>对u-boot的目录有了一些了解后，分析启动代码的过程就方便多了，其中比较重要的目录就是/board、/cpu、/drivers和/include目录，如果想实现u-boot在一个平台上的移植，就要对这些目录进行深入的分析。 </div>
<p>&nbsp;</p>
<div><strong><font color=#0000ff>u-boot的启动过程</font></strong> </div>
<p>&nbsp;</p>
<div>系统启动的入口点。既然我们现在要分析u-boot的启动过程，就必须先找到u-boot最先实现的是哪些代码，最先完成的是哪些任务。另一方面一个可执行的image必须有一个入口点，并且只能有一个全局入口点，所以要通知编译器这个入口在哪里。由此我们可以找到程序的入口点是在/board/lpc2210/u-boot.lds中指定的，其中ENTRY(_start)说明程序从_start开始运行，而他指向的是cpu/arm7tdmi/start.o文件。因为我们用的是ARM7TDMI的cpu架构，在复位后从地址0x00000000取它的第一条指令，所以我们将Flash映射到这个地址上，这样在系统加电后，cpu将首先执行u-boot程序。 </div>
<p>&nbsp;</p>
<div>u-boot的启动过程是多阶段实现的，分了两个阶段。依赖于cpu体系结构的代码（如设备初始化代码等）通常都放在stage1中，而且通常都是用汇编语言来实现，以达到短小精悍的目的。而stage2则通常是用C语言来实现的，这样可以实现复杂的功能，而且代码具有更好的可读性和可移植性。 </div>
<p>&nbsp;</p>
<div>下面我们先详细分析下stage1中的代码，如图2所示：</div>
<p align=center><a id=ImgSpan href="http://www.farsight.com.cn/FarsightBBS/UploadFile/2007-12/200712716213266446.gif" target=_blank><img alt=按此在新窗口浏览图片 src="http://www.farsight.com.cn/FarsightBBS/UploadFile/2007-12/200712716213266446.gif" onload="return imgzoom(this,550)" border=0></a></p>
<div align=center>图2&nbsp;&nbsp;Start.s程序流程 </div>
<p>&nbsp;</p>
<div align=center>代码真正开始是在_start，设置异常向量表，这样在cpu发生异常时就跳转到/cpu/arm7tdmi/interrupts中去执行相应得中断代码。在interrupts文件中大部分的异常代码都没有实现具体的功能，只是打印一些异常消息，其中关键的是reset中断代码，跳到reset入口地址。 </div>
<p>&nbsp;</p>
<div>reset复位入口之前有一些段的声明。