Study Notes --- S3C2440 NANDFLASH operation principle and test code analysis

Publisher:sigma28Latest update time:2022-04-02 Source: eefocusKeywords:S3C2440  NANDFLASH Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

First, let's take a look at the NANDFLASH interface:

As can be seen from the figure, there are only data ports and control ports, but no address lines, so it cannot be uniformly addressed like a network card or SDRAM. Its operation steps are as follows:


1 Enable chip


2 Send operation instructions (read, write, erase, reset)


3 Send operation address


5 Waiting for the busy signal to be released (read only)

6 Send data (write), receive data (read)


7 Waiting for busy signal, low level busy


8 Disable Chip


These control signal lines are all set by software registers, and then the hardware automatically generates control signals for other control lines;


The meanings of the operation signals are as follows:


R/B: Read/Busy status line


CE : Chip Select


CLE: Send command signal


ALE: Send address signal


WE: Write signal


RE: Read signal


Things to note here:


1 Data is transmitted in bytes, and there are exactly 8 data lines. The data register can be read directly to obtain data.


2 The address has 32 bits, but there are only 8-bit lines here, so an address needs to be sent multiple times to complete. For the sending rules, see the NANDFLASH chip manual, as shown below:

This chip needs to send the address in 4 cycles. The number of address lines depends on the size of the memory chip. When writing the driver, the address bits must be sent according to this table.


@******************************************************************************

@ File:head.s

@ Function: Set up SDRAM, copy the program to SDRAM, and then jump to SDRAM to continue execution

@******************************************************************************       

  

.text

.global _start

_start:

                                            @Functions disable_watch_dog, memsetup, init_nand, nand_read_ll are defined in init.c

            ldr sp, =4096 @Set up the stack 

            bl      disable_watch_dog       @关WATCH DOG

            bl memsetup @ Initialize SDRAM

            bl nand_init @Initialize NAND Flash


                                            @Copy the 1024-byte code starting at address 4096 in NAND Flash (compiled from main.c) to SDRAM

                                            The @nand_read_ll function requires 3 parameters:

            ldr r0, =0x30000000 @1. Target address = 0x30000000, which is the starting address of SDRAM

            mov r1, #4096 @2. Source address = 4096. When linking, the code in main.c is stored at the beginning of NAND Flash address 4096.

            mov r2, #1024 @3. Copy length = 1024 (bytes), which is enough for main.c of this experiment

            bl nand_read @Call C function nand_read


            ldr sp, =0x34000000 @Set up the stack

            ldr lr, =halt_loop @Set the return address

            ldr pc, =main @b instruction and bl instruction can only jump forward and backward within the range of 32M, so here we use the method of assigning value to pc to jump

halt_loop:

            b       halt_loop

Let's look at this startup code first. In order to use C language to set the watchdog and initialize SDRAM and other operations, you need to set the SP first, because the entry address and local variables of the C language function need to be stored in the stack.

After initialization, you can call the nandread function to read the NANDFLSH data. Here, you need to pass in three parameters. To pass parameters from assembly language to C language functions, you can only assign the parameters to R0-R4. Here, the first parameter corresponds to r0, and so on. The following code implements passing parameters to the nand_read function:


            ldr r0, =0x30000000 @1. Target address = 0x30000000, which is the starting address of SDRAM

            mov r1, #4096 @2. Source address = 4096. When linking, the code in main.c is stored at the beginning of NAND Flash address 4096.

            mov r2, #1024 @3. Copy length = 1024 (bytes), which is enough for main.c of this experiment

            bl nand_read @Call C function nand_read

Let's look at the prototype of nand_read:

void nand_read(unsigned char *buf, unsigned long start_addr, int size)


The first parameter needs to be an address, so the address passed in from the assembly is an address, and the LDR instruction is used to load the absolute address into r0


dr r0, =0x30000000 @1. Target address = 0x30000000, which is the starting address of SDRAM


The second and third parameters passed in are immediate values, which can be assigned directly using the following method


mov r1, #4096 @2. Source address = 4096. When linking, the code in main.c is stored at the beginning of NAND Flash address 4096.

mov r2, #1024 @3. Copy length = 1024 (bytes), which is enough for main.c of this experiment

Keywords:S3C2440  NANDFLASH Reference address:Study Notes --- S3C2440 NANDFLASH operation principle and test code analysis

Previous article:Study Notes --- S3C2440 memory device interface wiring and access principles
Next article:Study Notes --- S3C2440 DMA Operation Principle

Recommended ReadingLatest update time:2024-11-23 12:01

Detailed explanation of Uboot transplantation on S3C2440 (Part 4)
1. Transplantation Environment Host: VMWare--Fedora 9 Development board: Mini2440--64MB Nand, Kernel: 2.6.30.4 Compiler: arm-linux-gcc-4.3.2.tgz u-boot:u-boot-2009.08.tar.bz2 2. Transplantation Steps In this article, we first let the development board support CS8900 or DM9000X network car
[Microcontroller]
Detailed explanation of Uboot transplantation on S3C2440 (Part 4)
【s3c2440】Lesson 5: Timer Interrupt
Introduction to s3c2440 timer OVERVIEW   ~           ~~~~~~~~        The S3C2440A has five 16-bit timers. Timer 0, 1, 2, and 3 have Pulse Width Modulation (PWM) function. Timer 4 has an internal timer only with no output pins. The timer 0 has a dead-zone generator, which is used with a large current device.   ~       
[Microcontroller]
keil5 (MDK5) configures S3C2440 bare metal development and debugging environment
introduction There are basically three IDEs for bare metal ARM program development: MDK or Keil, IAR, and ADS. ADS has stopped updating and is not recommended. I won't go into details about them here, you can find out by searching Baidu. Since I used MDK development environment when developing c51 before, and the inte
[Microcontroller]
S3C2440 serial port learning
Serial port is a commonly used communication method in embedded systems. It uses bit-by-bit transmission and bit-by-bit reception. Serial communication. Serial port has many functions, such as printing and debugging, connecting various modules. It is safe and reliable, and easy to connect, so it is widely used. The
[Microcontroller]
S3C2440 serial port learning
View uboot information in uboot
View uboot information in uboot # bdinfo arch_number = 0x000007CF env_t       = 0x00000000 boot_params = 0x30000100 DRAM bank   = 0x00000000 - start    = 0x30000000 - size     = 0x04000000 ethaddr     = 08:00:3e:26:0a:11 ip_addr     = 192.168.1.111 baudrate    = 115200 bps #
[Microcontroller]
U-Boot-2009-03 Porting Notes (Booting from Nandflash 2)
In the U-Boot-2009-03 porting notes (booting from Nandflash 1), we wrote the nandflash read driver and tried to read u-boot itself from nandflash to sdram, and finally light up led1 and led2 at the same time. Unfortunately, the result is not what we want. This article uses the openjtag debugging method to diagnose t
[Microcontroller]
U-Boot-2009-03 Porting Notes (Booting from Nandflash 2)
S3C2440 UART driver code template (RealView MDK)
A good memory is worse than a bad pen. To facilitate code review and code reuse in the future, the S3C2440 UART driver code is posted here. The friendly MINI2440 development board is used, and the development environment is RealView MDK 4.22. It should be noted that in this code, the initialization of GPIO is complete
[Microcontroller]
S3C2440 assembly lighting
How to light a lamp Proceed as follows 1. Look at the schematic diagram to determine the pins that control the LED 2. Check the main chip manual to determine how to set/control the pins The chip of JZ2440 here is S3C2440 3. Write a program The main chip pin outputs a high level or a low level to change the LED
[Microcontroller]
S3C2440 assembly lighting
Latest Microcontroller Articles
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号