RT1021 NOR flash FlexSpi driver bug?

cancel
Showing results for 
Search instead for 
Did you mean: 

RT1021 NOR flash FlexSpi driver bug?

428 Views
rshipman
Contributor V

Hi,

File: fsl_flexspi_nor_flash.c

In the function Nor_Flash_Init, is the following line:

flexspiMemHandle.configuredFlashSize = memConfig->deviceConfig.flashSize;

On the right, the flashSize field is in kbytes. See flexspi_device_config_t:

uint32_t flashSize; /*!< Flash size in KByte. */

On the left the configuredFlashSize appears to be used as bytes (the units are not specified). See function FLEXSPI_NOR_ParseSFDP:

if ((flexspiMemHandle.configuredFlashSize > MAX_24BIT_ADDRESSING_SIZE) && (tbl->has_4b_addressing_inst_table))

And:

#define MAX_24BIT_ADDRESSING_SIZE (16UL * 1024UL * 1024UL)

I believe the fix is to change the line in Nor_Flash_Init to be:

flexspiMemHandle.configuredFlashSize = memConfig->deviceConfig.flashSize * 1024;

So configuredFlashSize is now in bytes. Please confirm this is correct, or am I missing something here?

Note that the flashSize field is used by the FlexSPI driver to set the FLSHA1CR0/FLSHA2CR0/FLSHB1CR0/FLSHB2CR0 registers. See FLEXSPI_SetFlashConfig:

base->FLSHCR0[port] = config->flashSize;

The register field FLSHSZ takes kbytes, so flashSize needs to be in kbytes (although, personally, I would have defined the flashSize field as bytes, and made the conversion to kbytes in the FLEXSPI_SetFlashConfig function).

Kind regards,

Ronnie

 

Labels (1)
Tags (4)
0 Kudos
4 Replies

418 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Ronnie, 

What version of the SDK are you using? I checked in the flexspi_nor_polling_transfer example of SDK v2.10.0, and I wasn't able to find the lines of code that you mentioned. 

Regards,
Victor 

0 Kudos

413 Views
rshipman
Contributor V

Hi Victor,

MCUXpresso IDE v11.4.0 [Build 6224] [2021-07-15]

SDK 2.10.0

The demo I originally looked at is evkmimxrt1020_flash_component_nor, which contains a folder called nor_flash. That is where the code I refer to is located.

It is interesting that the evkmimxrt1020_flexspi_nor_polling_transfer demo does not use this evkmimxrt1020_flash_component_nor/nor_flash driver, but instead contains its own in the file flexspi_nor_flash_ops.c, and sets up its own LUT etc as well. Is that the preferred method and we should not be using the driver in evkmimxrt1020_flash_component_nor/nor_flash?

Kind regards,

Ronnie

0 Kudos

392 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hi Ronnie

Thanks for the clarification! Now I see what you mentioned before. I'm checking this internally. I will give you an update as soon as possible.

Regards,
Victor 

0 Kudos

381 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hi Ronnie, 

For the first question, there is an error in the unit that is being compared. The number that your customer mentions is 8thousand kilobytes compared to 16 million bytes. In this case, this comparison is not valid and needs to be fixed. This has been reported. The code that  I used to convert the value to 8 million bytes, is the one also found in the "FLEXSPI_NOR_GetPageSectorBlockSizeFromSFDP" function. Essentially I added the variable, the conversion, and replaced it.

uint32_t flashSize;

if (flashDensity != 0x00U)
{
    if ((flashDensity & (1UL << 0x1F)) != 0x00U)
    {
        /* Flash size >= 4G bits */
        flashSize = 1UL << (flashDensity & ~(1UL << 0x1F));
    }
    else
    {
        /* Flash size < 4G bits */
        flashSize = flashDensity + 1U;
    }

    /* Convert to bytes. */
    flashSize >>= 3;
    handle->bytesInMemorySize = flashSize;
}

if ((flashSize > MAX_24BIT_ADDRESSING_SIZE) && (tbl->has_4b_addressing_inst_table))
{
    address_bits = 32;
}

For your second question, I found that this was created to be able to satisfy the need to use any flash nor device. This example demonstrated how to use an external component, in this case, a flash nor device. Many configurations are involved in setting it correctly that are available in the folder you mention. You will find that these settings are not available in the flexspi_nore example, since this was created to work with the onboard flash on the given port. 

You may or may not use the same memory device that is on the EVK. Depending on what you use then you can use either example accordingly.

Regards,
Victor 

0 Kudos