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.

TMS320F28379D: Stuck in Fapi_setActiveFlashBank

Part Number: TMS320F28379D

Hello,

We've been using Flash API library for a long time without problem.

This week without any apparent reason program gets stuck while executing Fapi_setActiveFlashBank  function

I've read other threads and verified that we run functions related to Flash in RAM memory and that interrupts are disabled.

What causes this issue and how to fix it?

P.S.: This is very important to us to be able to use Flash API and we cannot avoid using it!!!

  • Zvi,

    Thanks for reaching out, are you seeing this on multiple devices or just one device? 

    Any device history that might be relevant, i.e. fresh device from TI or device that has been in use for some time and gone though many Write/Erase cycles, etc.

    TI EVM or custom PCB, any recent BOM or design changes?

    Are you seeing this on CPU1 or CPU2, or any NMI that occurs or just "stuck" in the ActiveFlashBank function?

    To the best of my knowledge this flash API has been unchanged for some time now, but I will check on that side to see if there were any updates

    Best,
    Matthew

  • Hello Matthew,

    This issue is repeating on more than one device.

    Those devices are in use for some time but when I burn older firmware version there is no issue - the new firmware version has no changes to the code that is using the Flash API library. The new version is just additional features that are essential to the project.

    We are using custom PCB - there are no BOM or design changes.

    This problem occurs on CPU02 and after executing ActriveFlashBank function the programs jumps to ILLEGAL_ISR() and stays there.

    We had previously encountered this problem and it was "fixed" by updating compiler version from v18.12.2 to v22.6.0 - today we are using the latest version v22.6.1

    Best regards,

    Zvi.

  • Zvi,

    Would it be possible to send the .map files(should be in the same directory as the .out for the respective projects) for both the old and new FWs(and both CPUs) for me to look over to see if I can find any conflicts?

    Best,

    Matthew

  • Zvi,

    I've been made aware of a new condition regarding the use of Fapi_setActiveFlashBank() and the flash prefetch buffer.  If the flash prefetch buffer is active when Fapi_setActiveFlashBank() is called it can result in a ITRAP like you are seeing.  The reason is that Fapi_setActiveFlashBank() function disables the prefetch buffer as well, but if there are still pending instructions from the buffer we can then fetch the trap.

    The solution is to disable the pre-fetch buffer from code executing in RAM, and force a pipeline flush, so that no remaining code is in the buffer.

    I've C/P the code below for both enable and disable.  Disable needs to be called before any change in Active Flash Bank.  Enable is just to give complementary function that does the same flush, etc.

    #ifdef __cplusplus
    #pragma CODE_SECTION(".TI.ramfunc");
    #else
    #pragma CODE_SECTION(Flash_DisablePrefetch_SW_Workaround, ".TI.ramfunc");
    #endif
    void Flash_DisablePrefetch_SW_Workaround(uint32_t ctrlBase)
    {
        //
        // Check the arguments.
        //
        ASSERT(Flash_isCtrlBaseValid(ctrlBase));
    
        //
        // Disable flash prefetch
        //
        Flash_disablePrefetch(ctrlBase);
    
        //
        // Force a pipeline flush to ensure that the write to the last register
        // configured occurs before returning.
        //
        FLASH_DELAY_CONFIG;
    }
    
    /* Below is the code for Flash_EnablePrefetch_SW_Workaround()  */
    
    //*****************************************************************************
    //
    //! Enables flash prefetch mechanism and adds 7 cycle delay
    //!
    //! \param ctrlBase is the base address of the flash wrapper control registers.
    //!
    //! \return None.
    //
    //*****************************************************************************
    
    #ifdef __cplusplus
    #pragma CODE_SECTION(".TI.ramfunc");
    #else
    #pragma CODE_SECTION(Flash_EnablePrefetch_SW_Workaround, ".TI.ramfunc");
    #endif
    void Flash_EnablePrefetch_SW_Workaround(uint32_t ctrlBase)
    {
        //
        // Check the arguments.
        //
        ASSERT(Flash_isCtrlBaseValid(ctrlBase));
    
        //
        // Disable flash prefetch
        //
        Flash_enablePrefetch(ctrlBase);
    
        //
        // Force a pipeline flush to ensure that the write to the last register
        // configured occurs before returning.
        //
        FLASH_DELAY_CONFIG;
    }

    Best,
    Matthew

  • Hello Matthew,

        Thank you, I will try this workaround.

    Kind regards,

    Zvi