AM2754-Q1: AWE SDK (11.00.00.17) how to use OSPI_readDirect() to read flash?

Part Number: AM2754-Q1

Tool/software:

We use AM275-AWE-SDK_11.00.00.17. According to freertos_sdk_am275x\source\board\flash\ospi\flash_nor_ospi.c, there is only 

status = OSPI_readDirect(obj->ospiHandle, &transaction);
But the freertos_sdk_am275x\source\drivers\ospi\v0\ospi_v0.c offers 
int32_t OSPI_readDirect(OSPI_Handle handle, OSPI_Transaction *trans) and 
int32_t OSPI_readIndirect(OSPI_Handle handle, OSPI_Transaction *trans).
Please give samples of how to use OSPI_readIndirect() to read flash.
  • By the way, I read flash in C75 core.

  • Hi,

    Thanks for the precise question.

    I understand your requirement.

    So, when using a NOR Flash more precisely an OSPI/QSPI NOR Flash, it is always recommended to perform DAC reads as DAC reads are much faster compared to INDAC reads.

    Currently for a NOR Flash, in the SDK when you run the sample example named as "OSPI_FLASH_IO", you would see the Flash_read and Flash_write API calls.

    Flash_read leads to calling the read Direct API.

    Flash_write leads to calling the write Indirect API.

    Currently this is what the supported combination is and recommended as well from TI's SW offering point of view.

    Moreover, to know the reason why DAC writes are not supported please read the following:  RE: AM6421: Does OSPI support DMA? 

    PLEASE NOTE:

    In order to use read Indirect you would just need to replace the API call of read direct with read Indirect where it is called, no additional modification would be required apart from this. Please keep in consideration the recommendation I provided above as well.

    Thanks,

    Vaibhav

  • Actually I already tried replace OSPI_readDirect with OSPI_readIndirect, but when replaced, the thread died.

    My code 

    static int32_t Fla_norOspiRead(Flash_Config *config, uint32_t offset, uint8_t *buf, uint32_t len)
    {
        int32_t status = SystemP_SUCCESS;
        Flash_NorOspiObject *obj = (Flash_NorOspiObject *)(config->object);
        Flash_Attrs *attrs = config->attrs;

        if (obj->phyEnable)
        {
            OSPI_enablePhy(obj->ospiHandle);
        }

        /* Validate address input */
        if ((offset + len) > (attrs->flashSize))
        {
            status = SystemP_FAILURE;
        }
        if (status == SystemP_SUCCESS)
        {
            OSPI_Transaction transaction;

            OSPI_Transaction_init(&transaction);
            transaction.addrOffset = offset;
            transaction.buf = (void *)buf;
            transaction.count = len;
            transaction.dmaCopyLowerLimit = OSPI_NOR_DMA_COPY_LOWER_LIMIT;
            status = OSPI_readIndirect(obj->ospiHandle, &transaction);
        }

        if (obj->phyEnable)
        {
            OSPI_disablePhy(obj->ospiHandle);
        }

        return status;
    }
    And I use JTAG, the callstack is