Professional Documents
Culture Documents
the Small Page (528 Byte/ 264 Word Page) NAND Flash family (NANDxxx-A) the Large Page (2112 Byte/1056 Word Page) NAND Flash family (NANDxxx-B)
The terms of Small Page and Large Page will be used to refer to the two respective families throughout the document.
INTRODUCTION
The requirements of PDA (Personal Digital Assistants) and mobile phone platforms are converging because of multimedia applications such as graphic and audio accelerators, LCDs and data and code storage. Typically these systems require a large storage capacity for Operating System (OS) images, multimedia objects such as MP3 files and applications such as Java applets. NAND Flash memories are becoming a must for these applications. Besides a high throughput, fast erasing time and high density, the cost per Byte is much lower than for NOR architecture based Flash memories. As a result NAND is the best choice to store large quantities of data and code. This Application Note shows how to use a Single Level Cell NAND Flash as the primary memory device. It also describes different ways to boot a system from a NAND device on a general purpose architecture. Since the NAND can be used in-system and easily used for booting, ST has introduced the Automatic Page 0 Read at Power-Up, where the first page is available in the NAND internal buffer after the power is supplied to device. This means that the CPU can directly download the code from page 0 by toggling the Read Enable, R, signal. Devices are shipped from factory with Block 0 always valid, so using this block to store boot code means that boot code can be read from the NAND without having to use Error Correction Code (ECC).
November 2004
1/20
TABLE OF CONTENTS
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 OVERVIEW OF TYPICAL BOOT ARCHITECTURE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Figure 1. Boot Architecture without NAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 HOW TO BOOT FROM A SINGLE LEVEL CELL NAND FLASH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Large Page and Small Page Single Level Cell NAND Flash Families . . . . . . . . . . . . . . . . . . . . . 5 Table 1. .Large Page versus Small Page NAND Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 USING BLOCK 0 TO STORE CODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Error Correction Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 2. Large Page Divided into Chunks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Bad Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Automatic Page 0 Read at Power-Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Sequential Row Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Cache Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 3. Sequential Row Read Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 4. Cache Read Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 BOOT LOADER METHOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Standard Boot Loader Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 5. Standard Boot Loader Method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Figure 6. Standard Boot Loader Method Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Two Level Boot Loader Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Case of a Small Page Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Case of a Large Page Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 7. Two Level Boot Loader Method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Figure 8. Two Level Boot Loader Method Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 BOOT ENGINE METHOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Figure 9. Boot Engine Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 NAND PROGRAMMING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 NAND PROTECTION DURING BOOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Figure 10.Connecting the NAND to the Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 CONCLUSION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 APPENDIX A.PRATICAL IMPLEMENTATION OF TWO LEVEL BOOT LOADER METHOD . . . . . . 15 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Figure 11.Reference Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Code Shadowing Performance Improvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2/20
3/20
SRAM
Working Area
Reset
Ai08646
4/20
The first is a software implementation of Code Shadowing. It uses a ROM, mapped at the top of the controller address space, that contains the Reset Code and the Boot Loader Code. The second is a hardware implementation, where a dedicated part loads the boot loader code from the NAND into the RAM, while keeps the controller in the reset state. A RAM is mapped at the top of the microcontroller address space. Large Page and Small Page Single Level Cell NAND Flash Families The feature differences between the Large Page and Small Page Single Level Cell NAND Flash families are summarized in Table 1. Table 1. .Large Page versus Small Page NAND Flash
NAND Flash Memory Large Page NAND Flash Small Page NAND Flash Number of Pages 64 32 Page Size 2112 Bytes 528 Bytes Block Size 128 KBytes 16 KBytes Features Supported Cache Read / Autoread Page 0(1) Sequential Row Read / Auto Read Page 0
Note: 1. To enable this option in Large Page NAND Flash devices, the PRL pin must be tied to VDD (if the PRL pin is High, a Blocks Unlock Command is required before writing to the NAND Flash).
5/20
Main Area, used to store the data Spare Area, used to store the ECC
When a Page is read, an ECC checks and eventually corrects the data read. This is also valid for Code Shadowing, as the code read from the NAND is copied into the RAM after the ECC check. The difference in page size (528 Bytes for the Small Page family and 2112 Bytes for the Large Page family) is not critical for the implementation of the ECC. In fact it is possible to use the same algorithm for Large Page devices as for Small Page ones. The method consists in organizing large pages as four smaller logical pages, called chunks, as shown in Figure 2. As STs Single Level Cell NAND devices are shipped from the factory with Block 0 always valid, the ECC check can be avoided for Block 0. This makes the Code Shadowing process simpler and faster and means that both the Main and Spare Areas of Block 0 can be used to store the Boot Code. Note that no ECC or BBM information can be stored in the Spare Area of Block 0. Figure 2. Large Page Divided into Chunks
2048 Bytes Main Area 64 Bytes Spare Area
Bad Blocks Other blocks in the NAND may be Bad Blocks, that is blocks that contain one or more invalid bits whose reliability is not guaranteed. Additional Bad Blocks may develop during the lifetime of the device. The Bad Block Information is written prior to shipping (refer to datasheet for more details), and the number of Bad Block will not exceed 2% of the total number of blocks. These blocks need to be managed using Bad Blocks Management, Block Replacement or Error Correction Codes (for example using the spare area). Automatic Page 0 Read at Power-Up Another feature that ST has introduced to simplify booting, is Automatic Page 0 Read at Power-Up. This feature makes the first page available in the NAND internal buffer after power-up, which allows the CPU to directly download the code from Page 0 by toggling the Read Enable, R, signal.
6/20
tBLBH1
tBLBH1
Address Inputs
7/20
tBLBH1
RB Busy I/O
00h 31h
1st page
2nd page
3rd page
last page
34h
Standard Boot Loader method, where all the Boot Loader code is stored in the ROM Two Level Boot Loader method, where part of the Boot Loader code is stored in the ROM and part in the NAND.
Standard Boot Loader Method Figure 5. shows an example of a Standard Boot Loader method for a PDA or 2,5/3G phone architecture. The code is stored in two different memories: a small ROM embedded with the microcontroller that contains the Boot Loader code and a high density NAND Flash memory that contains the OS code and the application data. The RAM may be a DRAM because of the density requirements (more RAM to manage multimedia objects). In the Standard Boot Loader Method there are three operations to perform (see Figure 6.): 1. System Initialisation: hardware initialisation of all the system functions - Execute code stored inside the ROM (Reset Vector and Boot Loader) 2. Code Shadowing: Download the code from the NAND into RAM, checking with ECC 3. Start OS: Pass execution control to the code in RAM. The embedded ROM provides random access capability, so the Boot Loader runs directly from it. After it initializes the board, the Boot Loader downloads the OS code from the NAND device into the DRAM and passes over the control. As the OS code is usually bigger than NAND Block 0, a robust Boot Loader solution has to use ECC. The ECC can be implemented in either the hardware or software. Implementing it in the hardware is the best solution for performance but not for cost, as it requires a specific hardware design. The software solution is easier to implement, but it introduces overheads in terms of execution time and memory space, as it is part of the Boot Loader that is stored in the ROM. The page read operation should use Direct Memory Access (DMA) to increase the performance. The use of DMA speeds up the data transfer and the ECC calculation by executing them in parallel. In practice,
8/20
DRAM
OS Execution
NAND
OS Code OS Code
Reset
Ai08647
Note: 1. In this example of a Standard Boot Loader method it is supposed that the ECC is implemented via software.
NO
9/20
Automatic Page 0 Read at Power-Up, where the first page is ready in the Page Buffer after powerup, so it can be read by toggling R, Sequential Row Read for all of Block 0, when a page has been read, the next page is automatically loaded into the Page Buffer and read, Block 0 Valid, no ECC is necessary, Entire Block 0 is used to store code, the Spare Area is used as Main Area, Ready/Busy, RB, pin connected to the Wait State Machine of the Memory Controller: Between two page reads, the device goes into busy state, so the memory controller waits until the device is ready, DMA controller asks for a memory access to the Memory Controller, who answers when it is ready,
Thanks to these features, the downloading process of the first level Boot Loader is simplified and consists of only three steps: 1. Set DMA registers (Main Configuration, Source Address, Destination Address and Transfer Width), 2. Start DMA, 3. Jump to Second Level Boot Loader. See Figure 8. for a practical implementation. Case of a Large Page Device. The Cache Read operation can be used, which means that once a Cache Read command has been issued and the first page has been loaded into the buffer, block 0 can be downloaded entirely with a single uninterrupted DMA request as consecutive pages are downloaded with no latency time. So for a Large Page device, the downloading process of the first level Boot Loader becomes: 1. Issue Cache Read command 2. Set DMA registers (Main Configuration, Source Address, Destination Address and Transfer Width) 3. Start DMA 4. Issue Exit Cache Read comand 5. Jump to Second Level Boot Loader. As for the Standard Boot Loader method, the page read operation should use Direct Memory Access (DMA) to increase the performance. The use of DMA speeds up the data transfer and the ECC calculation by executing them in parallel. In practice, during the software calculation of the ECC, a new page of memory is transferred from the NAND Flash to the RAM via DMA.
10/20
NAND
Boot Loader 2 & ECC algorithm OS Code
Reset
Ai08649
Note: 1. In this example of a Two Level Boot Loader method it is supposed that the ECC is implemented via software.
11/20
Reset Vector & Initial Configuration First Level Boot Loader DMA Configuration
NO
Branch at Second Level Boot Loader Second Level Boot Loader Start
NO
Ai08650
12/20
00000000h BE DRAM
OS Execution
NAND
Block 0 Reset Vector Boot Loader OS Code OS Code
CPU
Ai08651b
NAND PROGRAMMING
To be able to perform a boot from a Single Level Cell NAND Flash memory, it is necessary to program the NAND devices with the Boot code and OS code. Typically, systems with NAND devices do not have the NAND programming functionality. So it is necessary to use Programmer tools to perform this operation. NAND program operations differ according to the type of Boot Loader used:
Standard Boot Loader. Only the OS code has to be programmed in the NAND as the Boot Code, Reset Vector and ECC software are stored in a ROM Two Level Boot Loader. Boot Loader code has to be programmed in Block 0 of the NAND and the OS image in the other blocks
13/20
NAND
Ai08652
CONCLUSION
Single Level Cell NAND Flash memories (including the Small Page and the Large Page NAND Flash families) can be used as a primary non-volatile memory device in an application, and can be used to store the initializing code used to boot a system. Two different methods of the Code Shadowing technique can be used, depending on whether the performance (Boot Engine) or simplicity of the design (Boot Loader) is the most important. Due to the advantages of increased storage capability and lower cost, ST recommends to use NAND devices to boot systems. In addition, booting from a NAND Flash device increases the performance of a system thanks to the excellent throughput provided by NAND technology and the fast code execution in the RAM.
14/20
CPU 16/32 bit RISC ARM7TDMI core based DMA channel ROM/SRAM and Flash Memory Controller 8 KB Internal RAM 32 bit Timers Clock at 50MHz (20ns)
ROM memory (mapped on Bank 0) SRAM memory (mapped on Bank 1-2) Small Page NAND memory (mapped on Bank 3)
In addition, this evaluation board allows the ROM that contains the Boot code to be re-programmed. The reference architecture is shown in Figure 11. Figure 11. Reference Architecture
Memory Control
15/20
RB
I/O
Command
Data Output
16/20
DMA transfers page n+1 from NAND to external SRAM; CPU performs ECC on page n.
Note that the OS code is stored in the Main Area of the NAND pages, so each new page must be transferred into the external SRAM, starting at the end of the Main Area of the previous page (see Figure 13.). In this case it is necessary store a copy of the previous Spare Area in order to allow the ECC software to work properly. Figure 14. shows the time usage for the CPU and DMA in a single page transfer operation from NAND to RAM. The time measured for ECC execution on 528 Bytes is 250s. As previously shown, the transfer time of 528 Bytes with DMA is low compared to the ECC calculation time. Figure 13. Code Transfer to External SRAM
Page n+1
Spare Area
ECC
CPU
DMA
Ai08653
17/20
15s
500s
250s
Time
Resource
With DMA
DMA
unused Read
DMA
unused unused
CPU Command
(Page)
15s
250s
Time
ai08656
Note: The times depend on the Hardware used and the algorithms are not optimized.
REFERENCES
The following documents, related to Single Level Cell NAND Flash Memories, are available on www.st.com
NAND128-A, NAND256-A, NAND512-A, NAND01G-A, 528 Byte/ 264 Word Page datasheet NAND512-B, NAND01G-B, NAND02G-B, NAND04G-B, NAND08G-B, 2112 Byte/1056 Word Page datasheet AN1823 Error Correction Code in Single Level Cell NAND Flash Memories AN1819 Bad Block Management in Single Level Cell NAND Flash Memories
18/20
REVISION HISTORY
Table 4. Document Revision History
Date 07-May-2004 Version 1.0 First Issue Document updated to apply also to the Large Page NAND Flash family (NANDxxx-B). Large Page and Small Page Single Level Cell NAND Flash Families and Cache Read paragraphs added. Figure 2., Large Page Divided into Chunks and Figure 4., Cache Read Operation added. Two Level Boot Loader Method paragraph and BOOT ENGINE METHOD section updated. Note added to Figure 7., Two Level Boot Loader Method and Figure 5., Standard Boot Loader Method. Revision Details
12-Nov-2004
2.0
19/20
If you have any questions or suggestions concerning the matters raised in this document, please refer to the MPG request support web page: http://www.st.com/askmemory
Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in life support devices or systems without express written approval of STMicroelectronics. The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners 2004 STMicroelectronics - All rights reserved STMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com
20/20