NandFlash Series 2: Analysis of S3C2410 Reading and Writing Nand Flash

Publisher:EtherealGraceLatest update time:2013-03-18 Source: dzscKeywords:NandFlash  S3C2410  memory  cell Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  1. Structural analysis

  The S3C2410 processor integrates an 8-bit NandFlash controller. Currently, the common 8-bit NandFlash on the market include Samsung's k9f1208, k9f1g08, k9f2g08, etc. The data page sizes of k9f1208, k9f1g08, and k9f2g08 are 512Byte, 2kByte, and 2kByte respectively. They have certain differences in addressing methods, so the program codes are not universal. This article takes the S3C2410 processor and k9f1208 system as examples to describe the reading and writing methods of NandFlash.

  NandFlash data is stored in memory cells in bit form. Generally speaking, a cell can only store one bit. These cells are connected into bit lines in units of 8 or 16, forming the so-called byte (x8)/word (x16), which is the bit width of NAND Device. These lines form pages, and pages are organized into a block. The relevant data of k9f1208 is as follows:

  1block=32page;1page=528byte=512byte(Main Area)+16byte(Spare Area)。

  Total capacity = 4096 (number of blocks) * 32 (page/block) * 512 (byte/page) = 64Mbyte

  NandFlash reads and writes data in pages and erases data in blocks. According to the organization of k9f1208, there are four types of addresses: Column Address, halfpage pointer, Page Address, Block Address. A[0:25] indicates the address of the data in the 64M space.

  Column Address indicates the address of the data in the half page, ranging from 0 to 255, represented by A[0:7];

  The halfpage pointer indicates the position of the half page in the whole page, that is, in the 0~255 space or in the 256~511 space, represented by A[8];

  Page Address indicates the address of the page in the block, ranging from 0 to 31, represented by A[13:9];

  Block Address indicates the location of the block in the flash, with a size range of 0 to 4095, represented by A[25:14];

  2. Read Operation Process

  The addressing of K9f1208 is divided into 4 cycles: A[0:7], A[9:16], A[17:24], and A[25].

  The process of the read operation is: 1. Send the read command; 2. Send the first cycle address; 3. Send the second cycle address; 4. Send the third cycle address; 5. Send the fourth cycle address; 6. Read data to the end of the page.

  K9f1208 provides two read instructions, '0x00' and '0x01'. The difference between these two instructions is that '0x00' can set A[8] to 0, selecting the upper half of the page, while '0x01' can set A[8] to 1, selecting the lower half of the page.

  Although the reading and writing process does not need to start from the page boundary, it is recommended to start reading and writing from the page boundary to the end of the page in formal occasions. The following explains the reading process by analyzing the code for reading the page.

  static void ReadPage(U32 addr, U8 *buf) //addr indicates the page number in the flash, i.e. 'flash address >> 9'

  {

  U16 and;

  NFChipEn(); //Enable NandFlash

  WrNFCMD(READCMD0); //Send the read command '0x00'. Since it is a full page read, the command '0x00' is selected.

  WrNFAddr(0); //The first cycle of the write address, that is, Column Address, is 0 because it is a full page read.

  WrNFAddr(addr); //The second cycle of the write address, i.e. A[9:16]

  WrNFAddr(addr>>8); //The third cycle of the write address, i.e. A[17:24]

  WrNFAddr(addr>>16); //The 4th cycle of the write address, i.e. A[25].

  WaitNFBusy(); //Wait for the system to be unbusy

  for(i=0; i<512; i++)

  buf[i] = RdNFDat(); //Loop to read 1 page of data

  NFChipDs(); //Release NandFlash

  }[page]

  3. Write Operation Process

  The write operation process is: 1. Send a write start command; 2. Send the first cycle address; 3. Send the second cycle address; 4. Send the third cycle address; 5. Send the fourth cycle address; 6. Write data to the end of the page; 7. Send a write end command

  The following explains the reading and writing process by analyzing the code of the write page.

  static void WritePage(U32 addr, U8 *buf) //addr indicates the page number in the flash, i.e. 'flash address >> 9'

  {

  U32 i;

  NFChipEn(); //Enable NandFlash

  WrNFCmd(PROGCMD0); //Send write start command '0x80'

  WrNFAddr(0); //The first cycle of writing address

  WrNFAddr(addr); //The second cycle of writing address

  WrNFAddr(addr>>8); //The third cycle of the write address

  WrNFAddr(addr>>16); Write address 4th cycle

  WaitNFBusy(); //Wait for the system to be unbusy

  for(i=0; i<512; i++)

  WrNFDat(buf[i]); //Loop write 1 page of data

  WrNFCmd(PROGCMD1); //Send write end command '0x10'

  NFChipDs(); //Release NandFlash

  }

  IV. Conclusion

  This article uses the S3C2410 processor and k9f1208 system as examples to describe the read and write process of nand flash. The bad block problem is not considered in the read and write process. The ECC and bad block processing issues will be described in the next topic.

Keywords:NandFlash  S3C2410  memory  cell Reference address:NandFlash Series 2: Analysis of S3C2410 Reading and Writing Nand Flash

Previous article:NandFlash Series 1: NorFlash vs. NandFlash
Next article:Linux kernel support for S3C2410 sleep mode

Recommended ReadingLatest update time:2024-11-16 14:50

Design of Embedded Handheld Entertainment System
Under the UP-TECH S3C2410 DVK1.1 development platform, a touch-type embedded handheld entertainment system design is proposed. This system mainly includes the basic functions of multimedia player and game. This system can play most of the existing audio and video files; embedded games are designed to increase the ente
[Microcontroller]
Design of Embedded Handheld Entertainment System
The road to Linux device driver engineer - analysis of touch screen driver s3c2410_ts.c
1. Touch screen hardware knowledge 1. Module schematic diagram S3C2440 has 8 ADC channels, of which the touch screen controller interface XP, XM, YP, YM multiplexes four IO pins with four ADC channels. From the schematic diagram, we can see that there is only one A/D converter for the 8-channel ADC, and an
[Microcontroller]
The road to Linux device driver engineer - analysis of touch screen driver s3c2410_ts.c
Memory Problems of 51 MCU
The 51 single-chip microcomputer addresses the memory space not by bus but by instructions. 1:51 consists of the following memory modules ROM Flash RAM has------lower 128 bits of internal RAM (00-7F)           -------higher 128 bits of internal RAM (80-FF)---           -------Special Function Register (SFR) (80-FF)  
[Microcontroller]
Research and design of remote security monitoring system based on GPRS
    With the continuous development of electronic information technology in society, people use more and more electrical appliances at home, and the potential safety hazards brought about by this have also increased significantly. Once some abnormalities occur in these electrical appliances, it will cause great losses
[Microcontroller]
Research and design of remote security monitoring system based on GPRS
With more than 90% external dependence, the domestic storage industry faces a thorny road
According to IC insights, the global memory chip market size reached $162 billion in 2018, of which the global NOR Flash market size was about $2.6 billion (accounting for 1.6%), the global NAND Flash market size was about $61 billion (accounting for 37.65%), and the global DRAM market size was about $96 billion (acco
[Embedded]
With more than 90% external dependence, the domestic storage industry faces a thorny road
S3C2440 memory initialization
It is divided into three parts:  ①2440 address space  ②Memory and chip hardware connection  ③Storage controller register S3C2440 Address Space S3C2440 provides 27 address lines to the outside. With only 27 pins on the chip, it can only access 128MB of peripheral space.  In order to expand the access range of peripher
[Microcontroller]
Redmi K40 pushes MIUI 12.5.14 stable version update: supports memory expansion function
      According to feedback from netizens on IT Home, Redmi K40 has now pushed the MIUI 12.5.14 stable version update.   In addition to optimizing and fixing issues in the lock screen, status bar, notification bar, etc., in the MIUI 12.5.14 stable version, Redmi K40 supports memory expansion function.   When the mem
[Mobile phone portable]
Redmi K40 pushes MIUI 12.5.14 stable version update: supports memory expansion function
iPhone 13 memory decryption: Apple wants to reproduce the madness of the new iPad
Apple has never been aggressive enough when it comes to the memory size of the iPhone, which can be seen as the confidence they have in optimizing their own iOS system. According to the latest news, Apple may increase the memory size of the iPhone 13. If it does so, the model that will benefit will be the top-end v
[Mobile phone portable]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号