ZYNQ-Linux Development (7) The problem that the localized Fudan Microelectronics FMQL platform uboot and kernel cannot recognize the domestic SPI Flash chip and partition

Hardware platform resources:

SOC chip: Fudan Microelectronics FMQL45t900

Flash chip: SM25QH256MX type 256Mbits SPI Flash memory of Shenzhen State Microelectronics

one. Determine whether uboot and kernel can recognize the flash chip

If the new type of flash chip cannot be recognized, the following situations will occur:

  1. Uboot cannot recognize: After uboot starts, before loading the kernel and root file system, enter the uboot command line, enter the command: sf probe, press Enter, if uboot cannot recognize the flash chip, the following print information will appear:

If uboot can recognize the flash chip, the following results will appear:

  1. The kernel cannot be recognized, and the following phenomenon will occur :

First of all, the information printed during the boot process of the Linux system will prompt that the flash chip cannot be recognized:

       If the kernel can recognize the flash chip normally, the printed information is as follows (provided that the partition information of the QSPI node has been added in the device tree):

       Secondly, if the kernel does not support the flash chip, enter the /dev/ directory to view the device node information after the Linux system starts, there will be no mtd0 node, and as a result, when programming EMMC, it cannot be programmed, and it will prompt that /dev/ cannot be found. The node of mtd0.

It can be seen from the above that uboot and kernel will initialize the spi flash chip independently, so if the system needs to support a new spi flash chip, you need to modify the configuration of uboot and kernel at the same time.

two. Modify the configuration of uboot to make uboot support the new flash chip

1. Add driver support for spi flash chip through menuconfig :

(1) cd to SDK directory --- set environment variables --- cd to uboot source code directory --- input command: make menuconfig

The uboot configuration interface will pop up:

(2) Find the corresponding path: Device Drivers ---> SPI Flash Support ---> check the support of the corresponding manufacturer's SPI Flash driver.

Take the SM25QH256MX 256Mbits SPI Flash of Shenzhen Guowei Electronics as an example. Because it is a domestic chip, there is no driver support for the corresponding brand manufacturer in uboot, but this type of chip is targeted at a foreign w25q256jve flash chip, and its manufacturer is winbond , so check the option: winbond spi flash support in uboot, so that when uboot starts, it will also load the drivers of various models of winbond manufacturers.

(3) Click save --- OK --- exit --- until you exit the uboot graphical configuration interface.

2. Repair the uboot source code and add description information such as the ID number corresponding to the spi flash chip model in the source code

(1) Enter the SDK, find the spi_flash.c file in the following directory, double-click to open it, and find the following function

Here I added a few lines of print information. What is printed is the actual ID value of the spi flash chip read after uboot starts. After the system starts, enter the uboot command and enter: sf probe to view it. There are 6 values ​​in total. There are two groups, the first three are the Manufacture ID of the flash chip, that is, 0x010219, and the last three are the value of the Device ID, that is, 0x4d0180, or 0x4d01. The specific situation is related to the model of the chip, and you can check the chip manual to determine The values ​​of the two IDs above.

Sometimes the two sets of ID values ​​read out are the same. In this case, the Manufacture ID is: 0x206019, and the Device ID is: 0x00, or check the flash chip manual to confirm.

(2) Enter the SDK, find the spi_flash_ids.c file in the following directory, double-click to open it,

Find the macro definition part of the flash chip corresponding to the manufacturer name, that is, the manufacturer configured in menuconfig just now, add winbond before, add some description information corresponding to the flash chip in the macro definition, such as Manufacture ID, Device ID, capacity, etc. , circled in red in the figure.

W25q256jve is the name of the flash chip, just write it according to the actual situation, 0x206019 and 0x0 are the Manufacture ID and Device ID, just fill in according to the ID value read out by uboot startup, or query the flash manual, followed by some capacity parameters of the flash chip, 64* 1024 is the size of each sector, there are 512 sectors in total, the total capacity is 512*64/1024=32MB, just fill in according to the chip manual.

(3) cd to the SDK directory, and enter the following command:

The following prompt appears to prove that the uboot compilation is successful:

The newly generated uboot.elf file is in the image directory:

Take it out to generate the BOOT.bin file, enter the uboot command line when the system starts, and input the command: sf probe, if the modified uboot can recognize the flash chip normally, it will print as follows:

The name of the flash chip, capacity size, etc. will be listed.

three. Modify the configuration kernel to make the kernel support new flash chips

2. Repair the kernel source code and add the ID number corresponding to the spi flash chip model in the source code

(1) Enter the SDK, find the spi-nor.c file according to the following directory, and double-click to open it:

Find the definition part of the flash ID corresponding to the flash chip manufacturer, and add the description information of the new flash chip in it (similar to that added by uboot) as follows:

Save after modification.

(2) cd to the SDK directory, and enter the following command:

The following prompt appears to prove that the kernel compilation is successful:

The newly generated uImage file is in the image directory:

Take it out for system startup. After the kernel is loaded successfully, the startup process will print the information that the spi flash chip is initialized successfully. At the same time, you can also see the mtd0 node information in the /dev/ directory, as shown below:

Four. Modify configuration device tree

1. Modify the attribute name of the spi flash chip under the QSPI node

Find the DeviceTree directory of the device tree folder generated by IAR compilation under the Procise project , find the system-top.dts file, find the qspi node, and change the previous "spansion, s25fl256s1" to "winbond, w25q256jve" .

Put the modified DeviceTree folder into the SDK of the virtual machine for compilation, so that the compiled device tree file can take effect.

Guess you like

Origin blog.csdn.net/qq_38584212/article/details/132041125