Vendor ID issue in Flexspi_nor_polling_transfer SDK example for IMX93QSB

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vendor ID issue in Flexspi_nor_polling_transfer SDK example for IMX93QSB

2,155 Views
Bob_NXP_user
Contributor III

Hello everyone,

I'm using MCUXpresso for VSCode in order to test the peripherals of a custom board similar to imx93-qsb. Starting from the SDK project "flexspi_nor_polling_transfer" I would like to test the functionality of NOR flash MT25QU01GBBB8E12, very similar to the chip used in the example: MT25QU512ABB.

When it comes to the function 
flexspi_nor_get_vendor_id it gives 0xFF instead of 0x20, then it completes the last operations successfully.

 
 
 
 

Immagine1.png

I'm using the same SPI peripheral of the example (flexSPI1 on SD3 pads), I'don't understand why I'm not reading the ID vendor correctly. Can anyone help me?

 

0 Kudos
Reply
11 Replies

2,127 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

This could be caused due to not handling reset signals correctly on the SPI memory, could you share how are you connecting the memory?

If you could share an small schematic it would be really helpful.

Best regards/Saludos,
Aldo.

0 Kudos
Reply

2,093 Views
Bob_NXP_user
Contributor III

Hello Aldo,

thanks for the resoponse. These are the connections

Immagine2.png

0 Kudos
Reply

2,071 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Everything looks good on hw, could you try to add function to read vendor ID after data is programed?

Best regards/Saludos,
Aldo.

0 Kudos
Reply

2,026 Views
Bob_NXP_user
Contributor III

Yes, I added this code as you suggested:

Immagine5.jpg

unfortunately nothing has changed, as you can see:

Immagine4.jpg

@AldoG do you have other ideas?

Thanks,

Bob

0 Kudos
Reply

2,009 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Thank you for testing, then most likely is that LUT sequence is not correct when READ ID is performed, please try the following change in the LUT:

/* Read ID */
[4 * NOR_CMD_LUT_SEQ_IDX_READID] =
FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x9E, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04),

Please try it and let me know of the results.
Best regards/Saludos,
Aldo.

0 Kudos
Reply

1,963 Views
Bob_NXP_user
Contributor III

Hello Aldo,

Thanks for helping me. Unfortunately, This change on the LUT is not the solution, I'm still reading 0xff on Vendor ID. I share with you all the entire C code:

 

 

/*
 * Copyright (c) 2016, Freescale Semiconductor, Inc.
 * Copyright 2016-2018 NXP
 * All rights reserved.
 *
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

 #include "pin_mux.h"
 #include "clock_config.h"
 #include "board.h"
 #include "fsl_debug_console.h"
 #include "fsl_rgpio.h"
 #include "fsl_lpi2c.h"
 #include "fsl_iomuxc.h"
 #include "fsl_lpi2c.c"

#include "fsl_flexspi.h"
#include "app.h"
#include "fsl_debug_console.h"
#include "fsl_cache.h"

#include "pin_mux.h"
#include "clock_config.h"
#include "board.h"
#include "fsl_common.h"
/*******************************************************************************
 * Definitions
 ******************************************************************************/
/*******************************************************************************
 * Prototypes
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/
/* Program data buffer should be 4-bytes alignment, which can avoid busfault due to this memory region is configured as
   Device Memory by MPU. */
SDK_ALIGN(static uint8_t s_nor_program_buffer[256], 4);
static uint8_t s_nor_read_buffer[256];

extern status_t flexspi_nor_flash_erase_sector(FLEXSPI_Type *base, uint32_t address);
extern status_t flexspi_nor_flash_page_program(FLEXSPI_Type *base, uint32_t dstAddr, const uint32_t *src);
extern status_t flexspi_nor_get_vendor_id(FLEXSPI_Type *base, uint8_t *vendorId);
extern status_t flexspi_nor_enable_quad_mode(FLEXSPI_Type *base);
extern status_t flexspi_nor_erase_chip(FLEXSPI_Type *base);
extern void flexspi_nor_flash_init(FLEXSPI_Type *base);
/*******************************************************************************
 * Code
 ******************************************************************************/
flexspi_device_config_t deviceconfig = {
    .flexspiRootClk       = 12000000,                                                       //12 MHz, ok per noi
    .flashSize            = FLASH_SIZE,
    .CSIntervalUnit       = kFLEXSPI_CsIntervalUnit1SckCycle,
    .CSInterval           = 2,
    .CSHoldTime           = 3,
    .CSSetupTime          = 3,
    .dataValidTime        = 0,
    .columnspace          = 0,
    .enableWordAddress    = 0,
    .AWRSeqIndex          = 0,
    .AWRSeqNumber         = 0,
    .ARDSeqIndex          = NOR_CMD_LUT_SEQ_IDX_READ,
    .ARDSeqNumber         = 1,
    .AHBWriteWaitUnit     = kFLEXSPI_AhbWriteWaitUnit2AhbCycle,
    .AHBWriteWaitInterval = 0,
};

const uint32_t customLUT[CUSTOM_LUT_LENGTH] = {
    /* Fast read quad mode -SDR */
    [4 * NOR_CMD_LUT_SEQ_IDX_READ + 0] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_4PAD, 0xEB, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 0x18),
    [4 * NOR_CMD_LUT_SEQ_IDX_READ + 1] = FLEXSPI_LUT_SEQ(
        kFLEXSPI_Command_DUMMY_SDR, kFLEXSPI_4PAD, 0x0A, kFLEXSPI_Command_READ_SDR, kFLEXSPI_4PAD, 0x04),

    /* Read status register */
    [4 * NOR_CMD_LUT_SEQ_IDX_READSTATUSREG] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_4PAD, 0xB5, kFLEXSPI_Command_DUMMY_SDR, kFLEXSPI_4PAD, 0x0),
    [4 * NOR_CMD_LUT_SEQ_IDX_READSTATUSREG + 1] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_READ_SDR, kFLEXSPI_4PAD, 0x04, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0x0),

    /* Read ID */
    [4 * NOR_CMD_LUT_SEQ_IDX_READID] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x9E, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x04), // modifica mia da 0x9F A 0X9E

    /*  Write Enable 4 pad */
    [4 * NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_OPI] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_4PAD, 0x06, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0x00),

    /*  Write Enable */
    [4 * NOR_CMD_LUT_SEQ_IDX_WRITEENABLE] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_4PAD, 0x06, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0),

    /*  Erase Sector */
    [4 * NOR_CMD_LUT_SEQ_IDX_ERASESECTOR] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_4PAD, 0x20, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 0x18),

    /*  Program */
    [4 * NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_QUAD] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_4PAD, 0x32, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 0x18),
    [4 * NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_QUAD + 1] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_WRITE_SDR, kFLEXSPI_4PAD, 0x01, kFLEXSPI_Command_STOP, kFLEXSPI_4PAD, 0),

    /* Enter Quad mode */
    [4 * NOR_CMD_LUT_SEQ_IDX_ENABLEQUAD] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x35, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0x00),

    /*  Dummy write, do nothing when AHB write command is triggered. */
    [4 * NOR_CMD_LUT_SEQ_IDX_WRITE] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0x0, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0x0),

    /*  Read status register using Qual SDR read */
    [4 * NOR_CMD_LUT_SEQ_IDX_READSTATUS_OPI] =
        FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_4PAD, 0x05, kFLEXSPI_Command_READ_SDR, kFLEXSPI_4PAD, 0x02),

};


int main(void)
{
    uint32_t i = 0;
    status_t status;
    uint8_t vendorID = 0;

    pcal6524_handle_t handle;
    /* clang-format off */
    const clock_root_config_t lpi2cClkCfg = {
        .clockOff = false,
        .mux = 0, // 24MHz oscillator source
        .div = 1
    };
    /* clang-format on */

    BOARD_ConfigMPU();
    BOARD_InitBootPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();

    CLOCK_SetRootClock(BOARD_PCAL6524_I2C_CLOCK_ROOT, &lpi2cClkCfg);
    CLOCK_EnableClock(BOARD_PCAL6524_I2C_CLOCK_GATE);

    /* Set 3.3V for M.2 nor flash card */
    BOARD_InitPCAL6524(&handle);
    PCAL6524_SetDirection(&handle, (1 << BOARD_PCAL6524_EXT1_PWREN), kPCAL6524_Output);
    PCAL6524_SetPins(&handle, (1 << BOARD_PCAL6524_EXT1_PWREN));

    flexspi_nor_flash_init(EXAMPLE_FLEXSPI);

    PRINTF("\r\nFLEXSPI example started!\r\n");

    /* Get vendor ID. */
    status = flexspi_nor_get_vendor_id(EXAMPLE_FLEXSPI, &vendorID);
    if (status != kStatus_Success)
    {
        return status;
    }
    PRINTF("Vendor ID: 0x%x\r\n", vendorID);

#if !(defined(XIP_EXTERNAL_FLASH))
    /* Erase whole chip . */
    PRINTF("Erasing whole chip over FlexSPI...\r\n");

    status = flexspi_nor_erase_chip(EXAMPLE_FLEXSPI);
    if (status != kStatus_Success)
    {
        return status;
    }
    PRINTF("Erase finished !\r\n");

#endif

    /* Enter quad mode. */
    status = flexspi_nor_enable_quad_mode(EXAMPLE_FLEXSPI);
    if (status != kStatus_Success)
    {
        return status;
    }

    /* Erase sectors. */
    PRINTF("Erasing Serial NOR over FlexSPI...\r\n");
    status = flexspi_nor_flash_erase_sector(EXAMPLE_FLEXSPI, EXAMPLE_SECTOR * SECTOR_SIZE);
    if (status != kStatus_Success)
    {
        PRINTF("Erase sector failure !\r\n");
        return -1;
    }

    memset(s_nor_program_buffer, 0xFFU, sizeof(s_nor_program_buffer));

    DCACHE_InvalidateByRange(EXAMPLE_FLEXSPI_AMBA_BASE + EXAMPLE_SECTOR * SECTOR_SIZE, FLASH_PAGE_SIZE);

    memcpy(s_nor_read_buffer, (void *)(EXAMPLE_FLEXSPI_AMBA_BASE + EXAMPLE_SECTOR * SECTOR_SIZE),
           sizeof(s_nor_read_buffer));

    if (memcmp(s_nor_program_buffer, s_nor_read_buffer, sizeof(s_nor_program_buffer)))
    {
        PRINTF("Erase data -  read out data value incorrect !\r\n ");
        return -1;
    }
    else
    {
        PRINTF("Erase data - successfully. \r\n");
    }

    for (i = 0; i < 0xFFU; i++)
    {
        s_nor_program_buffer[i] = i;
    }

    status =
        flexspi_nor_flash_page_program(EXAMPLE_FLEXSPI, EXAMPLE_SECTOR * SECTOR_SIZE, (void *)s_nor_program_buffer);
    if (status != kStatus_Success)
    {
        PRINTF("Page program failure !\r\n");
        return -1;
    }

    DCACHE_InvalidateByRange(EXAMPLE_FLEXSPI_AMBA_BASE + EXAMPLE_SECTOR * SECTOR_SIZE, FLASH_PAGE_SIZE);

    memcpy(s_nor_read_buffer, (void *)(EXAMPLE_FLEXSPI_AMBA_BASE + EXAMPLE_SECTOR * SECTOR_SIZE),
           sizeof(s_nor_read_buffer));

    if (memcmp(s_nor_read_buffer, s_nor_program_buffer, sizeof(s_nor_program_buffer)) != 0)
    {
        PRINTF("Program data -  read out data value incorrect !\r\n ");
        return -1;
    }
    else
    {
        PRINTF("Program data - successfully. \r\n");
    }
    status = flexspi_nor_get_vendor_id(EXAMPLE_FLEXSPI, &vendorID);
    if (status != kStatus_Success)
    {
        return status;
    }
    PRINTF("Vendor ID: 0x%x\r\n", vendorID);
    PRINTF("Status: %d\r\n", status);

    while (1)
    {
    }
}
0 Kudos
Reply

1,955 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Thank you for sharing, I will check it carefully.
Meanwhile is there any way for you to check the signals on the hardware?

Best regards/Saludos,
Aldo.

0 Kudos
Reply

1,944 Views
Bob_NXP_user
Contributor III

Hello,

I'm pretty sure the Flash memory is working well because I've been able to put a bootloader targeting nor-flash with this UUU command:

uuu.exe -b qspi imx-boot-imx93-11x11-lpddr4x-evk-sd.bin-flash_singleboot

Setting the boot configuration in FlexSPI Serial NOR, I can see that the bootloader is running correctly. But I still don't understand why there are issues using this project in MCUXpresso for VScode.

Please let me know if you can help me, I need to work also with iMX93's M33 core.

Thanks,

Bob

0 Kudos
Reply

1,933 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

I see that you are using exactly the example as it is, asde from the addition I have recommended.

I do not think that the memory is not working correctly, more than the LUT command to get the ID is not working correctly this is why I mentioned if it is possible to check if it is being sent correctly.

Best regards/Saludos,
Aldo.

0 Kudos
Reply

1,906 Views
Bob_NXP_user
Contributor III

Hello @AldoG ,

I tried to put some PRINTF command inside the flexspi_nor_get_vendor_id fuction in order to understand what's going on with vendorID value.

Bob_NXP_user_0-1741957491653.png

The output is this:

Bob_NXP_user_2-1741957546022.png

I tried also to change flashXfer.seqIndex to 4 * NOR_CMD_LUT_SEQ_IDX_READID and the output changed:

Bob_NXP_user_3-1741958011862.png

 

I don't know if it could be helpful to go over and over inside the functions. Maybe the problem is seqIndex value itself. Let me know your thoughts.

Regards,

Bob

0 Kudos
Reply

1,034 Views
tbonkers
Contributor III
For what it's worth, I also have issues with the Read ID command 0x9E when using IS25WX256 in extended SPI mode. The command is `FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x9e, kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 4),`. Each time I use it I read `0x888cadce`.
0 Kudos
Reply