跳至主要内容

【转】Bootloader简介及UBOOT移植

1. 引言
嵌入式系统的应用程序一般都被烧录到FLASH或EEPROM或ROM中。在开发的过程中需要
不断地讲程序下载到目标板上运行调试。如果每次都要将程序烧录到FLASH中,一则FLASH
的烧录速度慢(擦除、编程),二则在FLASH中运行时,调试器无法下断点,达不到方便调
试的目的。三则频繁烧录降低FLASH的使用寿命。
一种较好的方法就是将应用程序下载到RAM中,可以解决上面的问题。有两种方法:
1) 通过JTAG将IMAGE下载到RAM中。使用这种方法的前提是目标板上的RAM已经被正确初
始化,否则无法下载。

2) 在目标板上先运行一个程序(程序在Flash中),通过这个程序以某种交互的方式从H
OST将IMAGE下载到RAM中。如通过串口、USB接口、网络接口等方式。这种方式就是boot
loader的方式。
2. bootloader介绍
玩过Linux的人都知道LILO或GRUB,两个非常有名的引导程序,用来引导操作系统。和这
里介绍的bootloader非常类似。所做的工作基本上就是进行一些简单的初始化工作,然
后将控制权转交给要运行的IMAGE(操作系统或应用程序).
一个较好的bootloader会提供一个比较好的交互式界面,并提供一些对于嵌入式开发相
当有用的工具。如查看、修改RAM中的内容,通过多种方式从HOST下载IMAGE到RAM中,能
够将配置信息保存到FLASH中。
为了提供这些功能,bootloader要实现相关设备的驱动。如如果支持从网络接口下载IM
AGE,它要实现网卡的驱动、IP协议、ARP协议、tftp协议等等。串口、FLASH的读写也是
如此。
常见的FREE的bootloader有armboot,用于采用ARM架构CPU的开发板,PPC-boot用于采用
PowerPC架构CPU的开发板。这两种bootloader目前都已停止开发。而将他们合而为一,
成为U-boot。目前版本是0.4.0,在sourceforge.net上可以下载源程序。
3. U-boot介绍
目前Rease版本的u-boot已经被移植到arm720t,arm920t,at91rm9200,i386,mips,m
pc5xx,mpc824x,mpc8260,mpc8xx,ppc4xx,pxa,sa1100平台上,支持的开发板更多
。其他的如支持哪些monitor命令,支持哪些文件系统等等,参看README
4. U-boot移植
说说主要的移植步骤:
1) 确定移植环境,也就是在Win(Cygwin)下,还是在Linux下,强烈建议在Linux进行
移植,在Win(Cygwin)下编译问题很多,非常耽误时间,对此深有体会。
2) 下载Tool Chain,安装,linux下移植到ARM平台,用arm-linux-xx(xx:gcc,objcop
y,as,ld等等)。
3) 下载U-boot,解压缩,看README,相当重要!!!了解一下目录结构。
4) 在board目录和cpu目录下找与你要移植的目标板最相近的,仔细研究。
5) 然后参照README中Building the Software部分进行移植,具体的就不写了
6) 编译完毕之后,就要通过Flash烧录工具讲uboot.bin烧录到板子上。在HOST上运行
超级终端,给板子上电,看看超级终端是否有uboot运行情况。然后重复这个过程进行调
试。
7) 记住首先把RAM初始化,UART的驱动改好超级终端上就应该有动静了。
8) 下面这段程序叫你如何入手,刚从README上看到的Smile
int main (int argc, char *argv[])
{
sighandler_t no_more_time;
signal (SIGALRM, no_more_time);
alarm (PROJECT_DEADLINE - toSec (3 * WEEK));
if (available_money > available_manpower) {
pay consultant to port U-Boot;
return 0;
}
Download latest U-Boot source;
Subscribe to u-boot-users mailing list;
if (clueless) {
email ("Hi, I am new to U-Boot, how do I get started?");
}
while (learning) {
Read the README file in the top level directory;
Read http://www.denx.de/re/DPLG.html
Read the source, Luke;
}
if (available_money > toLocalCurrency ($2500)) {
Buy a BDI2000;
} else {
Add a lot of aggravation and time;
}
Create your own board support subdirectory;
Create your own board config file;
while (!running) {
do {
Add / modify source code;
} until (compiles);
Debug;
if (clueless)
email ("Hi, I am having problems...");
}
Send patch file to Wolfgang;
return 0;
}
void no_more_time (int sig)
{
hire_a_guru();
5. 结语、感想

在移植之前,首先要知道怎么可以得到Help,之前我我进行移植时,就不知道有个
uboot的maillist,一直在摸索、对照过程中进行的。

移植、调试过程是相当琐碎的,很多细节问题也不是三言两语能说清楚的。不过移
植成功一次,在做类似的工作就很顺手了。一定要坚持,特别是面对很多你不熟悉的东
西而感到挫败时,坚持。

评论

此博客中的热门博文

【转】smb协议栈使用示例

/*  * * uncdownload.c  * *  * * Utility for downloading files from SMB shares using libsmbclient  * *  * * Copyright(C) 2006 Sophos Plc, Oxford, England.  * *  * * This program is free software; you can redistribute it and/or modify it under the terms of the  * * GNU General Public License Version 2 as published by the Free Software Foundation.  * *  * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without  * * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  * * See the GNU General Public License for more details.  * *  * * You should have received a copy of the GNU General Public License along with this program; if not,  * * write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  * *  * */ # include < sys / types . h > # include < sys / time . h > # include ...

【转】Ether Types

Ether Types (last updated 2008-09-09) NOTE: Please see [RFC5342] for current information and registration procedures. This registry will be revised soon and will be replaced with up-to-date information. Many of the networks of all classes are Ethernets (10Mb) or Experimental Ethernets (3Mb). These systems use a message "type" field in much the same way the ARPANET uses the "link" field. If you need an Ether Type, contact: IEEE Registration Authority IEEE Standards Department 445 Hoes Lane Piscataway, NJ 08854 Phone +1 732 562 3813 Fax: +1 732 562 1571 Email: <ieee-registration-authority& ieee.org > http://standards.ieee.org/regauth/index.html The following list of EtherTypes is contributed unverified information from various sources. Another list of EtherTypes is maintained by Michael A. Patton and is accessible at: <URL: http://www.cavebear.com/CaveBear/Ethernet/ > <URL: ftp://ftp.cavebear.com/pub/Ethernet-codes > Assign...

【转】udp编程实例

UDP通讯实例 2008-04-29 15:30:05 / 个人分类: linux C编程 UDP协议的几点好处: 1.UDP不要求保持一个连接; 2.UDP没有因接收方认可收到数据包(或者当数据包没有正确抵达而自动重传)而带来的开销; 3.设计UDP的目的是用于短应用和控制信息; 4.在一个数据包接一个数据包的基础上,UDP要求的 网络 带宽比TCP更小。 UDP的几个缺点: 1.程序员必须创建代码检测传输错误并进行重传(如果应用程序要求这样做); 2.程序员必须把大数据包分片。 code: <1> /* * sender.c--UDP protocol example */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> int port = 6789; int main() {     int socket_descrīptor;     int iter = 0;     char buf[80];     struct sockaddr_in address;     /* Initialize socket address structure for Interner Protocols */     bzero(&address, sizeof(address)); // empty data structure     address.sin_family = AF_INET;     address.sin_addr.s_addr = inet_addr("127.0.0.1");     address...