uboot adds different models of nor-flash debugging notes

Before, I designed a board by myself. The spi-flash model used was w25q128. To verify a problem, I bought a program verification board. The model of the flash above was xt25f128b, so I burned the previously compiled firmware directly. There was a problem when I entered. The error message printed by the terminal is as follows:
unrecognized JEDEC id bytes: 0b, 40, 18

The details are shown in the following figure:

Error message


According to the error message, I started a long debugging journey. First, I U-bootsearched the location of the print log under the source code, and found that spi_flash.cthe 919 line has corresponding output, as shown in the figure below;


open spi_flash.cit here to see to;


we can see from the code, this program attempts to spi_flash_idsfind whether there is this array and onboard flashcorresponding id
so I try to find the array;


It can be seen in spi_flash_ids.cthe 46 line, there has been spi_flash_idsthe definition of this array, open the file;


Find the definition of the corresponding falsh model, id, capacity and other information, just flashfill the corresponding information on the board into this array.

Take a look at INFOthis macro definition:

/* Used when the "_ext_id" is two bytes at most */
#define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)    \
        .id = {                         \
            ...
        .id_len = (!(_jedec_id) ? 0 : (3 + ((_ext_id) ? 2 : 0))),   \
        .sector_size = (_sector_size),              \
        .n_sectors = (_n_sectors),              \
        .page_size = 256,                   \
        .flags = (_flags),

Looking back at the previous error message, JEDEC idit says that it cannot be recognized. Then let's take a brief look at what is the JEDEC id?


What is JEDEC ? It
JEDECis a standard for Nor flash, and another standard is CFI.
JEDEC: The full name is Joint Electron Device Engineering Councilthe Electronic Components Industry Association.

JEDECIt is an international agreement formulated by manufacturers, mainly for memory; it is
used to help programs read the manufacturer ID and device ID of Flash to determine the size and algorithm of Flash. If the chip does not support CFI, you need to use JEDEC. .
Industry standard memory usually refers to a group of memory that meets the JEDEC standard.

The flash model on the board is xt25f128b. I found the flash id in the datasheet, which is true 0x0b4018;


because this flash is similar to w25q128fw, I copied it directly and modified the id as shown in the figure below;


recompile u-bootand burn the firmware In the flash, it successfully started this time, and the corresponding spi-flash can be recognized; the details are shown in the figure below;


however, at this time, the device tree settings in the kernel have not been modified:

Reference:
https://zhuanlan.zhihu.com/p/76221655
https://github.com/thirtythreeforty/businesscard-linux/issues/11