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.
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
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Talk: Small capital investment
- 555 Timer Circuit Design Software
- Where does the EG8010 dead time go?
- Focus on the three major DSP application markets
- Downloads|Selected Courseware & Latest Materials from Tektronix 2019 Semiconductor Seminar
- Which version of ESP32 do you think is more suitable?
- Maintenance of Fukang LPG dual fuel car
- GaN Power HEMT > 650 V: Parametric Analysis and Comparison with SiC MOSFET
- Voltage controlled current source composed of opa547
- [GUIX①, one of threadX components] guix text button