Analysis of nandflash initialization process in u-boot

Publisher:Xingfu8888Latest update time:2024-07-25 Source: cnblogsKeywords:u-boot  nandflash Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The following is an analysis of the nand flash initialization code nand_init():
1. If (CONFIG_COMMANDS & CFG_CMD_NAND) is defined and (CFG_NAND_LEGACY) is not defined, then start_armboot() calls nand_init() in driver/nand/nand.c, otherwise if (CONFIG_COMMANDS & CFG_CMD_NAND) is defined and CFG_NAND_LEGACY is defined, then call the self-defined nand_init(). In my current scenario, nand_init() in driver/nand/nand.c is used.

2.nand_init() calls nand_init_chip() in this file to initialize nand.

3.nand_init_chip() first calls board_nand_init().

4.board_nand_init() is a function that needs to be added by yourself. The main function of this function is to assign values ​​to the function pointers of the struct nand_chip structure, so that they point to some functions written by yourself for the nand driver. For unassigned pointers, uboot will assign general nand driver function pointers to them later.

5.nand_init_chip() then calls nand_scan().

6.nand_scan() is defined in drivers/nand/nand_base.c file. It first assigns the pointer in struct nand_chip structure that is not assigned in board_nand_init() function to the general nand driver function pointer.

7. The function pointer assigned to the struct nand_chip structure by the general nand driver function nand_select_chip() is used to turn on or off the nand chip, 0 for on, 1 for off. In this function, the hwcontrol function pointer in the nand_chip structure is called, and the function pointed to by this pointer needs to be written by yourself. This function pointer is assigned in the board_nand_init() function. The main function is to send some nand flash on and off commands to the nand flash.

8. The rest of nand_scan() initializes the nand_chip and mtd_info structures.

9.nand_scan() finally calls nand_default_bbt() in drivers/nand/nand_bbt.c file when returning.

10.nand_default_bby() selects a bad block description table and calls nand_scan_bbt() in this file when returning.

11.nand_scan_bbt() searches for and creates a bad block description table.

12. Finally, return to nand_init(), and the initialization of the nand driver is completed.

The following is an analysis of the execution process of the command nand read addr ofs size:
1. The function of the nand read addr ofs size command is to read data of length size bytes from the offset ofs of the nand flash address and store it at the memory address addr.

2. main_loop() in the common/main.c file mainly executes read_line() to read the command line.

3. After read_line() reads the command line, it calls run_command() in the common/main.c file.

4.run_command() calls find_cmd() in the common/command.c file to find the cmd_tbl_t structure of the command in the .u_boot_cmd segment and returns the structure after finding it. The structure of the command is registered in the .u_boot_cmd segment through the macro definition U_BOOT_CMD defined in include/command.h.

5. After run_command() finds the cmd_tbl_t structure of the command, it executes the function corresponding to the command. In this scenario, it is the function do_nand() corresponding to the nand command.

6. There are two versions of do_nand(), one with CFG_NAND_LEGACY defined. The other without CFG_NAND_LEGACY defined. Both versions are defined in the common/cmd_nand.c file. For this scenario, use the do_nand() function without CFG_NAND_LEGACY defined. To use do_nand(), you must also define the macros CONFIG_COMMANDS&CFG_CMD_NAND. (If CFG_NAND_LEGACY is not defined, the functions called by the do_nand() function in this scenario are all defined in the drivers/nand_legacy/nand_legacy.c file).

7. For our scenario do_nand() will call nand_read() which is defined in include/nand.h file.

8.nand_read() calls the read pointer of the nand_info_t structure corresponding to this nand chip. The read pointer in nand_scan() points to the nand_read() function in the same file (drivers/nand/nand_base.c).

9. The nand_read() function will eventually call the cmdfunc pointer in the nand_chip structure and send a command to the nand flash chip through the function pointed to by this pointer, thus completing the execution of the entire command.


Keywords:u-boot  nandflash Reference address:Analysis of nandflash initialization process in u-boot

Previous article:Platform bus globalfifo driver
Next article:u-boot transplant summary (I) start.S analysis

Recommended ReadingLatest update time:2024-11-23 11:19

s3c2440 burns the entire system (and uses Jlink to download u-boot)
s3c2440 burns the entire system Divided into two parts Flash the kernel file Flash the file system Each part is divided into three steps a. Download the file to the development board (tftp method) b. Erase partition c. Set environment variables d. Burn 1. Burn the kernel file a. Download the file to the developm
[Microcontroller]
OK6410A development board (three) 8 u-boot-2021.01 boot analysis SPL image running part
url : git@github.com:lisider/u-boot.git branch : ok6410a commit id : e63a4077ad3aea53107495b0b68b95e720fe6033 config : ok6410a_mini_defconfig // There are 67 .S .s .c files involved From the entrance to the exit // Run at 0x0c00 0000 reset arch/arm/cpu/arm1176/start.S 39 lowlevel_init(108) board/samsung/ok6
[Microcontroller]
U-boot-2014.04 ported to MINI2440 (2) Readme translation and analysis
Why do we need to read README? I think it is to make it easier for us to understand U-BOOT, especially to grasp the overall situation. Of course, the developers wrote more than 200,000 characters and a total of more than 6,000 lines of README. There are many parts involving specific configuration and usage. In fact, t
[Microcontroller]
U-boot-2014.04 ported to MINI2440 (2) Readme translation and analysis
u-boot-2009.11 transplantation on mini2440
I've been learning u-boot recently. After a week of constant tinkering, I finally successfully transplanted u-boot to the mini2440 development board. I admit that I'm a novice. I took a lot of detours in the middle. First, the Norflash failed to burn, resulting in the loss of the original u-boot, and my own U-boot cou
[Microcontroller]
u-boot-2009.11 transplantation on mini2440
s3c2440 bare metal-nandflash programming (1. Introduction to nandflash principle and structure)
1.The schematic diagram of nandflash is as follows: The pin attributes are shown in the table below: Pin name Pin function 100~107 Data input and output (command, address, data share data bus) CLE Command enable BUT Address enable /THIS Chip enable (chip select) /RE Read enable /WE Write enable R/B Ready/
[Microcontroller]
s3c2440 bare metal-nandflash programming (1. Introduction to nandflash principle and structure)
u-boot-2011.03 porting on mini2440/micro2440 supports DM9000
3.1 include/configs/micro2440.h delete #define CONFIG_CS8900  /* we have a CS8900 on-board */ #define CONFIG_CS8900_BASE 0x19000300 #define CONFIG_CS8900_BUS16 /* the Linux driver does accesses as shorts */ #define CONFIG_NETMASK          255.255.255.0 #define CONFIG_IPADDR  10.0.0.110
[Microcontroller]
u-boot-2011.03 porting on mini2440/micro2440 supports DM9000
U-Boot transplantation (6) summarizes the overall structure of the U-Boot project
1. Source code organization For ARM, the main directories are as follows: The board platform depends on storing directory files related to circuit boards. Each set of boards corresponds to a directory. Such as smdk2410(arm920t)                                                                                            
[Microcontroller]
ok6410 nandflash 2
/********************************************** function:         ok6410 nand flash operation sdrom ic: K9XXG08UXM 2g  author: lvtory date: 2013.4.13 **********************************************/ #define MEM_SYS_CFG     (*((volatile unsigned long *)0x7E00F120)) #define NFCONF          (*((volatile unsi
[Microcontroller]
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号