This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM4372: About the PDK QSPI driver S25FL.c

Part Number: AM4372

Hi all,

Souce :
PDK_INSTALL_PATH\ti\drv\spi\test\qspi_flash\src\Flash_S25FL\S25FL.c

We usually think that dummy reads are inserted before "data read",
In this program, dummy reads are inserted before "Write Address".
Is this a mistake in the program?

/* Write read command */
writeVal[0] = readCmd;
transaction.txBuf = (unsigned char *)&writeVal[0];
transaction.rxBuf = NULL;
transaction.count = 1;

transferType = SPI_TRANSACTION_TYPE_WRITE;
SPI_control(handle, SPI_V1_CMD_TRANSFERMODE_RW, (void *)&transferType);
retVal = SPI_transfer(handle, &transaction);

/* Write dummy bits for fast read if required */
if(0 != numDummyBits)
{
writeVal[0] = 0U;
transaction.txBuf = (unsigned char *)&writeVal[0];
transaction.rxBuf = NULL;
transaction.count = (numDummyBits >> 3); /* In bytes */

transferType = SPI_TRANSACTION_TYPE_WRITE;
SPI_control(handle, SPI_V1_CMD_TRANSFERMODE_RW, (void *)&transferType);
retVal = SPI_transfer(handle, &transaction);
}

/* Write Address Bytes */
/* *tempPtr = (unsigned int)srcAddr; */
/* transaction.txBuf = (unsigned char *)tempPtr; */
transaction.txBuf = (unsigned char *)srcAddr;
transaction.rxBuf = NULL;
transaction.count = addrLengthInBytes;

transferType = SPI_TRANSACTION_TYPE_WRITE;
SPI_control(handle, SPI_V1_CMD_TRANSFERMODE_RW, (void *)&transferType);
retVal = SPI_transfer(handle, &transaction);

/* Read the actual flash data */
transaction.txBuf = NULL;
transaction.rxBuf = (unsigned char *)dstOffstAddr;
transaction.count = length;

Best regards,

sasaki

  • Sasski,

    I can confirm that the issue you are reporting does seem to be a bug in the code that is not exposed since the dummy bit configuration is not used in the test code. If you are looking for correct implementation of QSPI flash test code that does read and write operations, then I would recommend that you look at the flash writer code in the the SBL/boot package provided here:

    Example for QSPI flash programming:

    • pdk_am57xx_x_x_xx\packages\ti\boot\sbl\tools\flashWriter\qspi\src

    The flash driver has been created in the board package and the source for which is located here:

    • pdk_am57xx_1_0_11\packages\ti\board\src\idkAM572x\device\qspi_flash.c
    • pdk_am57xx_x_x_xx\packages\ti\board\src\flash\nor\qspi

    Using the flash writer code has been described here:

    http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/Foundational_Components.html#id11 

  • Hi Rahul-san,

    Thank you for your support.

    I confirmed this code.
    But This code is the same as the source code I introduced above, since the dummy read is executed before the write address.

    Is this code correct?
    Can you attach it if you have the correct code?

    Best regards,

    Sasaki

  • Sasaki,

    Yes, I have confirmed with the development team that this is a bug in the flash code but this only impact if you want to use fast Read. Can you confirm that you need fast Read support that is impacted by the insertion of these dummy cycles?

    Regards,
    Rahul
  • Hi Rahul-san,

    Thank you for your support.

    Rahul Prabhu said:
    Can you confirm that you need fast Read support that is impacted by the insertion of these dummy cycles?

    I will confirm with my customer.

    By the way, if a customer needs FastRead, can you provide the corresponding source code?

    Best regards,

    Sasaki