跳至主要内容

【转】NAND Flash上启动U-Boot

引言
随着嵌入式系统的日趋复杂 , 它对大容量数据存储的需求越来越紧迫。而嵌入式设备低功耗、小体积以及低成本的要求 , 使硬盘无法得到广泛的应用。 NAND 闪存设备就是为了满足这种需求而迅速发展起来的。目前关于 U-BOOT 的移植解决方案主要面向的是微处理器中的 NOR 闪存,如果能在微处理器上的 NAND 闪存中实现 U-BOOT 的启动,则会给实际应用带来极大的方便。
U-BOOT 简介
U-BOOT 支持ARM PowerPC 等多种架构的处理器,也支持 Linux NetBSD VxWorks 等多种操作系统,主要用来开发嵌入式系统初始化代码 bootloader bootloader 是芯片复位后进入操作系统之前执行的一段代码,完成由硬件启动到操作系统启动的过渡,为运行操作系统提供基本的运行环境,如初始化 CPU 、堆栈、初始化存储器系统等,其功能类似于 PC 机的 BIOS U-BOOT 执行流程图如图 1 所示。
 
NAND 闪存工作原理
S3C2440 开发板的 NAND 闪存NAND 闪存控制器 ( 集成在 S3C2440 CPU ) NAND 闪存芯片 (K9F1208U0C) 两大部分组成。当要访问 NAND 闪存芯片中的数据时 , 必须通过 NAND 闪存控制器发送命令才能完成。所以 , NAND 闪存相当于 S3C2440 的一个外设 , 而不位于它的内存地址区。
NAND闪存 (K9F1208U0C) 的数据存储结构分层为: 1 设备 (Device) = 4096 (Block);1 = 32 / (Page/row);1 = 528B = 数据块 (512B) + OOB (16B)  在每一页中,最后 16 个字节 ( 又称 OOB) NAND闪存命令执行完毕后设置状态,剩余 512 个字节又分为前半部分和后半部分。可以通过 NAND闪存命令 00h/01h/50h 分别对前半部、后半部、 OOB 进行定位,通过 NAND闪存内置的指针指向各自的首地址。
NAND 闪存的操作特点为:擦除操作的最小单位是块; NAND闪存芯片每一位只能从 1 变为 0 ,而不能从 0 变为 1 ,所以在对其进行写入操作之前一定要将相应块擦除; OOB 部分的第 6 字节为坏快标志,即如果不是坏块该值为 FF ,否则为坏块;除 OOB 6 字节外,通常用 OOB 的前 3 个字节存放 NAND 闪存的硬件 ECC( 校验寄存器 ) 码;
NAND 闪存启动 U-BOOT 的设计思路
如果 S3C2440 被配置成从 NAND闪存启动 , 上电后, S3C2440 NAND闪存控制器会自动把 NAND闪存中的前 4K 数据搬移到内部 RAM , 并把 0x00000000 设置为内部 RAM 的起始地址 , CPU 从内部 RAM 0x00000000 位置开始启动。因此要把最核心的启动程序放在 NAND 闪存的前 4K 中。
由于 NAND 闪存控制器从 NAND 闪存中搬移到内部 RAM 的代码是有限的 , 所以 , 在启动代码的前 4K , 必须完成 S3C2440 的核心配置,并把启动代码的剩余部分搬到 RAM 中运行。在 U-BOOT , 4K 完成的主要工作就是 U-BOOT 启动的第一个阶段 (stage1)
根据 U-BOOT 的执行流程图,可知要实现从 NAND 闪存中启动 U-BOOT ,首先需要初始化 NAND 闪存 , 并从 NAND 闪存中把 U-BOOT 搬移到 RAM 中,最后需要让 U-BOOT 支持 NAND 闪存的命令操作。
开发环境
本设计中目标板硬件环境如下: CPU S3C2440 SDRAM HY57V561620 NAND 闪存为 64MB K9F1208U0C
主机软件环境为 fedora8 u-boot- 1.3.4 gcc 2.95.3
 
具体设计
支持 NAND 闪存的启动程序设计
2440板的NAND Flash初始化和2410基本类似,下面先以2410为例,进行介绍。
UbootSMDK2410板的NAND Flash初始化部分没有写,即lib_arm/board.c中的start_armboot函数中有这么一句:
 
#if defined(CONFIG_CMD_NAND)
    puts ("NAND:  ");
    nand_init();        /* go init the NAND */

评论

此博客中的热门博文

【转】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...

【转】tcphdr结构详解

位于:/usr/src/linux/include/linux/tcp.h struct tcphdr { __be16 source; __be16 dest; __be32 seq; __be32 ack_seq; #if defined(__LITTLE_ENDIAN_BITFIELD) __u16   res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1; #elif defined(__BIG_ENDIAN_BITFIELD) __u16   doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1; #else #error "Adjust your <asm/byteorder.h> defines"