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.

ospi flash write

Hi Aakash,

I'm back with the writing to flash problem.

You've suggested to use other API for writing the flash so I've used  example from TI's SDK and it works.

TI's example ospi_flash_io - works ok I can erase write and read the flash.

When I do the same code in my project - only erase and read work. When I write it fails.

It fails after  ospi_v0.c  :1464

1464  OSPI_writeFifoData(attrs->dataBaseAddr, pSrc, wrBytes);

1465

1466  pSrc += wrBytes;
1467  remainingSize -= wrBytes;
1468 }

1469

1470 if(wrFlag == 0U && OSPI_waitIndWriteComplete(pReg) != 0)
1471 {
1472 wrFlag = 1U;
1473 status = -1;
1474 }

OSPI_waitIndWriteComplete(pReg) returns -1;

Please advice how to proceed ?

Thanks,

Best Regards,

Eli

  • Hi ,

    In your project are you using the Flash APIs used in the ospi_flash_io or are you using the OSPI APIs ?

    Best Regards,
    Aakash

  • Hi Aakash,

    Here is the code in both projects:

    int main(void)

    {

    #define APP_OSPI_FLASH_OFFSET_BASE (0x600000U)
    #define APP_OSPI_DATA_SIZE (256) 

    System_init();
    Board_init();

    Drivers_open();
    Board_driversOpen();

    int32_t status = SystemP_SUCCESS;
    uint8_t gOspiTxBuf[APP_OSPI_DATA_SIZE]={0};
    uint32_t offset = APP_OSPI_FLASH_OFFSET_BASE;

    status = Flash_write(gFlashHandle[CONFIG_FLASH0], offset, gOspiTxBuf, APP_OSPI_DATA_SIZE);

    return 0;

    }//main

    in the example all works in my code  fails at  sdk 1464  OSPI_writeFifoData(attrs->dataBaseAddr, pSrc, wrBytes);

    What can be wrong ? How to proceed ?

    Thanks,

    Best Regards,

    Eli

  • Hi ,

    For the safety purpose, can you try "erase" operation before any subsequent "writes" ?

    Best Regards,
    Aakash

  • Hi Aakash,

    I did with erase and without erase , with read and without read.

    Still the CLANG project always succeeds writing  - status=0; the GCC project always fails writing - status= -1

    Please help me  debug further.

    Thanks,

    Best Regards,

    Eli

  • Hi Eli,

    So this sounds like a compiler problem. You should've mentioned the same before, we could have debugged it much faster.

    Let me come back with a solution in a day.

    Best Regards,
    Aakash

  • Hi Aakash,

    Thanks !

    Best Regards,

    Eli

  • Hi Eli,

    Can you try the following steps and check if it works:

    1) Try reducing the optimization flag level to -O1 or -O0 and rebuild your example

    2) Check if the base address & offset used in write operation is correct

    Which version of MCU+SDK are you using?

  • Hi,

    I've set the optimization to  -O0 on both projects.

    I'm using the mcu_plus_sdk_am243x_08_06_00_43 on both projects.

    Same code on both projects (as far as I can see) 

    In GCC compiled project -> The problem occurs at line 1386:  int32_t OSPI_writeIndirect(OSPI_Handle handle, OSPI_Transaction *trans) finction

    1408: const CSL_ospi_flash_cfgRegs *pReg = (const CSL_ospi_flash_cfgRegs *)attrs->baseAddr;   <--- baseAddr=0x0FC40000

    1464: OSPI_writeFifoData(attrs->dataBaseAddr, pSrc, wrBytes);  <--fails      <--  attrs->dataBaseAddr=0x60000000

    I have two projects which seems to have  same code , same sdk , same syscfg.

    The projects runs on same board - same flash device

    First compiled with CLANG - all works erase write read

    Second compiled with GCC - erase read  write - fails

    Maybe  if Base Address or offset were not correct the CLANG would not have been working .

    What can I possibly check to find the difference or why the GCC project fails to write ?

    Is there any workaround ?

    Thanks,

    Eli

  • Hi ,

    Can you try writing only 4 bytes of data ? Does that work or not ? Also please share the project with us so we can replicate the issue.

    Best Regards,
    Aakash

  • Hi Aakash,

    I've tried with 1,2 and 4 bytes of data - same results.

    I'm compiling with GCC - so you need all my files including the sdk with it's makefiles - correct ?

    Thanks,

    Best Regards,

    Eli 

  • Hi Aakash,

    The FLASH problem occurs on our board - not the EVM !

    Thanks,

    Best Regards,

    Eli

  • Hi Aakash,

    I'll try to attach my project (7zipped) - I cannot see it attached - maybe it's too big 140Kbytes

    Thanks,

    Best Regards,

    Eli

  • Hi Eli

    It should be possible to attach a 140KB project, just try drag and drop to see if it works.

    If not, please share this directly over email.

    Regards

    Karan

  • Hi Karan,

    I've tried to drag and tried over e-mail but it seems to be to big.

    I'll ask my boss how to send it.

    Basically is the sdk flash_io example with my json file  for the gd25q64e flash device (1s-1s-4s configuration)

    It works fine with CLANG , but only the write function fails in GCC.

    It happens on my board - I don't know yet what happens on the EVM -  maybe it's the next step.

    Thanks,

    Best Regards,

    Eli

  • Hi Eli,

    We have a planned debug session for 03/01/2024. Let's try to identify the issue here.

    Best Regards,
    Aakash

  • Notes from 3/1 debug meeting

    Aakash, Anand, Sanmveg. Vaibhav & Karan from TI joined the debug call to support the issue. Root cause was not OSPI memory space not mapped as strongly ordered from R5F MPIU. After changing memory attributes to strongly ordered, things started working at Eli's setup.

    Customer is unblocked now.

    Open question: Why the same settings worked with TI ARM CLANG.

    Regards

    Karan