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.

TMS570LS1227: Execution of TI FEE Driver from RAM

Part Number: TMS570LS1227

Hi,

We encounter an exception when using the TI FEE Driver Code with our existing implementation in which the F021 Flash APIs are executed from RAM. The TI FEE Driver code is executed from Flash. Our understanding is that since the TI FEE Driver code invokes the F021 Flash APIs, it needs to be executed from RAM as well. If this is accurate, can you please share the changes required for executing the TI FEE Driver code from RAM? If not, request you to let us know the possible reasons for this issue.

Thanks and Regards,

Vimal

  • Hi Vimal,

    I started working on your issue and i will get back to you with an update soon.

    --
    Thanks & Regards,
    Jagadish.

  • Hi Vimal,

    Is it possible to share your code?

    If it is not possible, then can you share more details of the problem like which exception you are getting and where (which API) exactly in your application you are getting exception?

    --
    Thanks & Regards,
    Jagadish.

  • Hi Jagadish,

    We get a prefetch abort when the TI_FeeInternal_PollFlashStatus() function is called from TI_Fee_WriteSync() as part of the following block:

    while(TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16BlockSize!=0U)
    {
    u8WriteCount = TI_FeeInternal_WriteDataF021(FALSE,(uint16)TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16BlockSize, u8EEPIndex);
    /* To avoid MISRA warning */
    u8WriteCount=u8WriteCount;
    /*SAFETYMCUSW 91 D MR:16.10 <APPROVED> "Reason - Return value is not required."*/
    (void)TI_FeeInternal_PollFlashStatus();
    if(TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16BlockSize <= 0x8U)
    {
    TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16BlockSize = 0x0U;
    }
    else
    {
    TI_Fee_GlobalVariables[u8EEPIndex].Fee_u16BlockSize-=u8WriteCount;
    }
    }

    The following snapshot has some debug information:

    Please let me know if any other details are required.

    Thanks and Regards,

    Vimal

  • Hi Vimal,

    The EEPROM or FEE is Flash BANK 7, and your code is stored in Flash BANK 0. You don't need to run the FEE code from SRAM.

  • Hi QJ Wang,

    Part of our code is performing read/write/erase operations on a Bank0 sector. To facilitate this, the F021 Flash APIs are executed from SRAM. Since the FEE code makes F021 calls, does it have to be executed from SRAM?

    Not sure if this helps but another observation is that prior to the exception, a call to TI_FeeInternal_StartProgramBlock() and TI_FeeInternal_WriteBlockHeader() from TI_Fee_WriteSync() when writing the first block results in the FMSTAT being set to 0x4010 i.e. an Illegal Address and Command Status Failure. The prefetch abort happens thereafter when calling TI_FeeInternal_PollFlashStatus() as mentioned in the previous response.

    Thanks and Regards,

    Vimal

  • To program data to sectors in Bank 0, the F021 Flash APIs and the functions which call the APIS directly MUST be executed out of SRAM.

    To program data to EEPROM (Bank 7), the F021 Flash APIs and FEE drivers can be executed from Flash Bank 0 or from SRAM. 

    If your project programs data to both sectors in Flash Bank 0 and EEPROM (bank 7), the he F021 Flash APIs Must be run from SRAM, but the FEE driver can be executed from Flash 0.

    Can you please share your linker cmd file, and code showing how you init FEE and program data to FEE?

    BTW, TMS570LS1227 has three flash banks: two program flash banks (Bank 0 and Bank 1), and one flash bank (bank 7, EEPROM). If you don't want to copy the Flash APIs to SRAM, you can store the data to the sectors of BANK1 instead of Bank 0.

  • I just wrote an example for your reference. This example was test on LS1224 device which has only one Program Flash Bank (Bank 0).

    1. 8 bytes of data is programmed to sector 2 of Bank 0:

    2. b bytes of data is programmed to Block #1 in FEE:

  • Attached please find the linker cmd script, and main() function:

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/908/5342.sys_5F00_link.cmd

    /** @file sys_main.c 
    *   @brief Application main file
    *   @date 11-Dec-2018
    *   @version 04.07.01
    *
    *   This file contains an empty main function,
    *   which can be used for the application.
    */
    
    /* 
    * Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com 
    * 
    * 
    *  Redistribution and use in source and binary forms, with or without 
    *  modification, are permitted provided that the following conditions 
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright 
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the 
    *    documentation and/or other materials provided with the   
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    /* Include Files */
    
    #include "sys_common.h"
    
    /* USER CODE BEGIN (1) */
    /* USER CODE END */
    
    /** @fn void main(void)
    *   @brief Application main function
    *   @note This function is empty by default.
    *
    *   This function is called after startup.
    *   The user can use this function to implement the application.
    */
    
    /* USER CODE BEGIN (2) */
    #include "ti_fee.h"
    
    #include "bl_flash.h"
    #include "F021.h"
    
    extern unsigned int apiLoadStart;
    extern unsigned int apiLoadSize;
    extern unsigned int apiRunStart;
    
    uint16 u16JobResult,Status;
    Std_ReturnType oResult=E_OK;
    unsigned char read_data[100]={0};
    
    uint8 SpecialRamBlock[100];
    
    unsigned char pattern;
    uint16 u16writecounter;
    
    unsigned int  FeeVirtualSectorNumber;
    unsigned char VsState, u8EEPIndex;
    unsigned char u8VirtualSector;
    uint8 Test_Recovery;
    uint8 Test_Cancel;
    
    
    void delay(void)
    {
        unsigned int dummycnt=0x0000FFU;
        do
        {
            dummycnt--;
        }
        while(dummycnt>0);
    }
    /* USER CODE END */
    
    int main(void)
    {
    /* USER CODE BEGIN (3) */
        uint32_t status, i;
    
        unsigned int BlockNumber;
        unsigned int BlockOffset, Length;
        unsigned char *Read_Ptr=read_data;
    
        unsigned int loop;
    
        memcpy(&apiRunStart, &apiLoadStart, (uint32)&apiLoadSize);
    
        uint32_t Success[] = {0xbd0400ea, 0x12345678,
                              0x5a5a5a5a, 0x37373737,
                              0x19191919, 0x28282828,
                              0xabababab, 0xcdcdcdcd,
                              0x38b50546, 0x0c46062d,
                              0x05d0082d, 0x03d00e2d,
                              0x18bf0520, 0x08d11020,
                              0x00f034fa, 0x03480460};
    
        for(i=0; i<1; i++){
            status = Fapi_BlockErase(0x80000, 8);
    
            //make sure "Fapi_AutoEccGeneration" is used in Flash API call, bl_flash.c
            status = Fapi_BlockProgram(0x80000, (unsigned long)&Success, 8);
        }
    
        /* Initialize RAM array.*/
        for(loop=0;loop<100;loop++)SpecialRamBlock[loop] = loop;
    
        /* Initialize FEE. This will create Virtual sectors, initialize global variables etc.*/
        TI_Fee_Init();
        do
        {
            TI_Fee_MainFunction();
            delay();
            Status=TI_Fee_GetStatus(0 );
        }
        while(Status!= IDLE);
    
        /* Write the block into EEP Asynchronously. Block size is configured in ti_fee_cfg.c file. Default Block size is
           8 bytes */
        BlockNumber=0x1;
        TI_Fee_WriteAsync(BlockNumber, &SpecialRamBlock[0]);
        do
        {
            TI_Fee_MainFunction();
            delay();
            Status=TI_Fee_GetStatus(0);
        }
        while(Status!=IDLE);
    
    
        /* Write the block into EEP Synchronously. Write will not happen since data is same. */
        TI_Fee_WriteSync(BlockNumber, &SpecialRamBlock[0]);
    
        /* Read the block with unknown length */
         BlockOffset = 0;
         Length = 0xFFFF;
         oResult=TI_Fee_Read(BlockNumber,BlockOffset,Read_Ptr,Length);
         do
         {
             TI_Fee_MainFunction();
             delay();
             Status=TI_Fee_GetStatus(0);
         }
        while(Status!=IDLE);
    
        /* Invalidate a written block  */
        TI_Fee_InvalidateBlock(BlockNumber);
        do
        {
            TI_Fee_MainFunction();
            delay();
            Status=TI_Fee_GetStatus(0);
        }
        while(Status!=IDLE);
    
        /* Format bank 7 */
        TI_Fee_Format(0xA5A5A5A5U);
    
    
    
    /* USER CODE END */
    
        return 0;
    }
    
    
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    

  • Hi QJ Wang,

    The issue was originally resolved by invoking TI_Fee_MainFunction() before each TI_Fee_WriteSync() call. This worked for a while but the code seems to be crashing again.

    In the sample code shared, TI_Fee_MainFunction() is called after the TI_Fee_Init() and the asynchronous FEE Read/Write functions. The synchronous functions do not require subsequent calls to TI_Fee_MainFunction(). Can you please clarify why the TI_Fee_MainFunction() needs to be called after TI_Fee_Init() since the flowchart doesn't mention the same? We use the TI_Fee_Init(), TI_Fee_ReadSync(), TI_Fee_WriteSync(), TI_FeeErrorCode() and TI_Fee_ErrorRecovery() functions in our code (apart from TI_Fee_GetStatus() and TI_Fee_GetJobResult()). Since the TI_Fee_ErrorRecovery() function can sometimes invoke TI_Fee_Init(), do we need to call TI_Fee_MainFunction() after TI_Fee_ErrorRecovery() as well?

    Thanks and Regards,

    Vimal

  • Hi Vimal,

    TI_Fee_MainFunction() function should be called at regular intervals after an asynchronous operation is called. 

    TI_Fee_MainFunction() function should be called after TI_Fee_Init() is called, otherwise the Virtual Sector Information Record (2nd 64 bit word, highlighted section in my snapshot)) is not programmed to FEE. 

  • Hi QJ Wang,

    Thanks for clarifying the reason for invoking TI_Fee_MainFunction() after TI_Fee_Init().

    We have observed that TI_Fee_MainFunction() needs to be called before each TI_Fee_WriteSync() call. The first call seems to write the third 64-bit word to the FEE. Without this TI_Fee_MainFunction() call, the code gets stuck when executing first synchronous write call. While debugging in CCS, it was noticed that stepping-over does not exit the TI_Fee_WriteSync() function. On pausing code execution, the prefetch abort code is seen to be hit. Would appreciate your thoughts on this.

    Thanks and Regards,

    Vimal

  • Calling TI_Fee_MainFunction() is not required before and after the FEE sync write operation. If there is a async operation before sync write, the TI_Fee_MainFunction() should be called after async operation until the status becomes IDLE.

    All prefetch aborts are synchronous. The reason for Prefetch Abort can be analyzed by reading the Instruction Fault Status Register (IFSR), the Instruction Fault Address Register (IFAR). 

  • While debugging in CCS, it was noticed that stepping-over does not exit the TI_Fee_WriteSync() function. On pausing code execution, the prefetch abort code is seen to be hit. Would appreciate your thoughts on this.

    In CCS/RM46L852: jump to prefetchEntry when used Fapi_issueProgrammingCommand it was found that the functions which call the FAPI functions also need to run from RAM, to avoid getting prefetch aborts.

    Are the functions which call the FAPI functions in FLASH or RAM?

  • Hi QJ Wang,

    The code works as expected when the following sequence is used (as shared in the sample code):

    1. Initialize Flash (Fapi_initializeFlashBanks, ....)

    2. Write to Flash (Bank 0)

    3. Initialize FEE (TI_Fee_Init, ...)

    4. Write to FEE (TI_Fee_WriteSync)

    The issue arises with the following sequence:

    1. Initialize Flash (Fapi_initializeFlashBanks, ....)

    2. Initialize FEE (TI_Fee_Init, ...)

    3. Write to Flash (Bank 0)

    4. Write to FEE (TI_Fee_WriteSync)

    Would appreciate your thoughts on the possible reasons for this.

    Thanks and Regards,

    Vimal

  • Hi Chester,

    The functions which call the FAPI functions are run from RAM. Appreciate your input.

    Thanks and Regards,

    Vimal

  • Hi,

    I tried the following sequence, there si no issue to write data to FEE:

    The Data block 0 is written to FEE, it's 8-bytes data array.

    Fapi_Init_QJ() in my test initializes the flash bank only:

    uint32_t Fapi_Init_QJ()
    {
    uint32_t status;

    status=Fapi_initializeFlashBanks((uint32_t)SYS_CLK_FREQ); /* used for API Rev2.01 */

    Fapi_setActiveFlashBank((Fapi_FlashBankType)0);
    Fapi_enableMainBankSectors(0xFFFF); /* used for API 2.01*/

    while( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady );
    return (status);
    }

  • Hi QJ Wang,

    In the code snapshot, there doesn't seem to be a call to write to Flash Bank 0. We do not use asynchronous write calls in our code. The issue occurs when there is a write to Flash Bank 0 after TI_Fee_Init() and prior to TI_Fee_WriteSync() in the following sequence:

    1. Initialize Flash (Fapi_initializeFlashBanks, ....)

    2. Initialize FEE (TI_Fee_Init, ...)

    3. Write to Flash (Bank 0)

    4. Write to FEE (TI_Fee_WriteSync)

    Sample code which reproduces the issue as well as the linker command script are attached herewith. Please let me know if any other details are required. Would appreciate your help to resolve this.

    Thanks and Regards,

    Vimal

    /** @file HL_sys_main.c 
    *   @brief Application main file
    *   @date 07-July-2017
    *   @version 04.07.00
    *
    *   This file contains an empty main function,
    *   which can be used for the application.
    */
    
    /* 
    * Copyright (C) 2009-2016 Texas Instruments Incorporated - www.ti.com  
    * 
    * 
    *  Redistribution and use in source and binary forms, with or without 
    *  modification, are permitted provided that the following conditions 
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright 
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the 
    *    documentation and/or other materials provided with the   
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    /* Include Files */
    
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    #include "sys_common.h"
    
    /* USER CODE BEGIN (1) */
    #include "sys_core.h"
    #include "system.h"
    #include "ti_fee.h"
    /* USER CODE END */
    
    /** @fn void main(void)
    *   @brief Application main function
    *   @note This function is empty by default.
    *
    *   This function is called after startup.
    *   The user can use this function to implement the application.
    */
    
    /* USER CODE BEGIN (2) */
    extern uint32_t RamfuncsLoadStart;
    extern uint32_t RamfuncsLoadSize;
    extern uint32_t RamfuncsRunStart;
    
    
    void Delay(void);
    void FEE_Init(void);
    void FEE_Write(void);
    Fapi_StatusType Flash_Init(void);
    
    
    void Delay(void)
    {
    	volatile uint32_t i;
    
    	for (i = 0U; i < 100U; i++)
    	{
    	}
    }
    
    void FEE_Init(void)
    {
    	TI_FeeModuleStatusType status;
    
    	/* Initialize the TI FEE */
    	TI_Fee_Init();
    
    	/* Wait till the FEE is in IDLE State */
    	do
    	{
    		TI_Fee_MainFunction();
    		Delay();
    		status = TI_Fee_GetStatus(0U);
    	} while (status != IDLE);
    }
    
    void FEE_Write(void)
    {
    	Std_ReturnType result = (Std_ReturnType)E_OK;        /* Variable to hold the return value of the write function */
    	TI_FeeJobResultType jobstatus;                      /* Variable to hold the last job result */
    	TI_FeeModuleStatusType status;
    	uint8_t feedata[64] = {0xAAU, 0xBBU, 0xCCU, 0xDDU, 0xEEU, 0xFFU, 0x11U, 0x22U};
    
    	/* Write the block into the EEP Synchronously */
    	result = TI_Fee_WriteSync(1U, feedata);
    	if (result == (Std_ReturnType)E_OK)
    	{
    		status = TI_Fee_GetStatus(0U);
    		jobstatus = TI_Fee_GetJobResult(0U);
    		if ((status != IDLE) || (jobstatus != JOB_OK))
    		{
    			/* Operation failed */
    			result = (Std_ReturnType)E_NOT_OK;
    		}
    	}
    }
    
    #pragma CODE_SECTION(Flash_Init, ".TI.ramfunc");
    Fapi_StatusType Flash_Init(void)
    {
    	Fapi_StatusType ret;
    
    	/* Disable Interrupts */
    	_disable_IRQ_interrupt_();
    
    	/* Initialize the Flash Memory Banks before performing any operation */
    	ret = Fapi_initializeFlashBanks((uint32_t)HCLK_FREQ);
    
    	/* Enable Interrupts */
    	_enable_interrupt_();
    
    	return ret;
    }
    
    
    #pragma CODE_SECTION(Flash_Write, ".TI.ramfunc");
    Fapi_StatusType Flash_Write(void)
    {
    	Fapi_StatusType ret;
    	uint8_t data[8] = {0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U, 0x08U};
    
    	/* Disable Interrupts */
    	 _disable_IRQ_interrupt_();
    
    	ret = Fapi_setActiveFlashBank((Fapi_FlashBankType)0);
    	ret = Fapi_enableMainBankSectors(0xFFFF);
    
    	while (FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady);
    
    	ret = Fapi_issueProgrammingCommand((uint32_t *)0x80000U, data, (uint8_t)8U, NULL, 0U, Fapi_AutoEccGeneration);
    
    	while (FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy);
    	while (FAPI_GET_FSM_STATUS != Fapi_Status_Success);
    
    	/* Enable Interrupts */
    	_enable_interrupt_();
    
    	return ret;
    }
    
    /* USER CODE END */
    
    int main(void)
    {
    /* USER CODE BEGIN (3) */
    	memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
    
        Flash_Init();
        FEE_Init();
    
        Flash_Write();
        FEE_Write();
    
    	for (;;)
    	{
    	}
    /* USER CODE END */
    
        return 0;
    }
    
    
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    
    
    
    /*----------------------------------------------------------------------------*/
    /* sys_link.cmd                                                               */
    /*                                                                            */
    /* 
    * Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com  
    * 
    * 
    *  Redistribution and use in source and binary forms, with or without 
    *  modification, are permitted provided that the following conditions 
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright 
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the 
    *    documentation and/or other materials provided with the   
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    /*                                                                            */
    /*----------------------------------------------------------------------------*/
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Linker Settings                                                            */
    
    --retain="*(.intvecs)"
    
    /* USER CODE BEGIN (1) */
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */
    
    MEMORY
    {
    	/* Add a vfill directive to the end of each line that maps to Flash */
        VECTORS (X)  : origin=0x00000000 length=0x00000020 vfill = 0xffffffff
        FLASH0  (RX) : origin=0x00000020 length=0x0013FFE0 vfill = 0xffffffff
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x0002EB00
    /* USER CODE BEGIN (2) */
    	/* Add memory regions corresponding to the ECC area of the flash bank */
    	ECC_VEC (R) : origin=(0xf0400000 + (start(VECTORS) >> 3))
    	length=(size(VECTORS) >> 3)
    	ECC={algorithm=algoL2R5F021, input_range=VECTORS}
    	ECC_FLA0 (R) : origin=(0xf0400000 + (start(FLASH0) >> 3))
    	length=(size(FLASH0) >> 3)
    	ECC={algorithm=algoL2R5F021, input_range=FLASH0 }
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (3) */
    /* Add an ECC {} directive describing the algorithm that matches the device */
    ECC
    {
    	algoL2R5F021 : address_mask = 0xfffffff8 /*Address Bits 31:3 */
    	hamming_mask = R4 /*Use R4/R5 build in Mask */
    	parity_mask = 0x0c /*Set which ECC bits are Even & Odd parity */
    	mirroring = F021 /*RM57Lx and TMS570LCx are build in F021*/
    }
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    
    SECTIONS
    {
        .intvecs : {} > VECTORS
        .text    : {} > FLASH0 
        .const   : {} > FLASH0 
        .cinit   : {} > FLASH0 
        .pinit   : {} > FLASH0 
        .bss     : {} > RAM
        .data    : {} > RAM
        .sysmem  : {} > RAM
        
        FEE_TEXT_SECTION : {} > FLASH0 
        FEE_CONST_SECTION : {} > FLASH0
        FEE_DATA_SECTION : {} > RAM
    
    /* USER CODE BEGIN (4) */
        .TI.ramfunc align(32) : {	-l F021_API_CortexR4_BE_V3D16.lib(.text) }
    								LOAD=FLASH0, RUN=RAM,
    								LOAD_START(RamfuncsLoadStart),
    								RUN_START(RamfuncsRunStart),
    								SIZE(RamfuncsLoadSize)
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (5) */
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Misc                                                                       */
    
    /* USER CODE BEGIN (6) */
    /* USER CODE END */
    /*----------------------------------------------------------------------------*/
    

  • I have figured out what causes the problem.

    1. FEE_Init() enables the bank 7 is enabled, and disable other flash banks. Only one bank can be enabled at a time.

    2. After Flash_Write() is called, flash bank 7 is enabled and bank 0 is disabled

    So the data wont be written to FEE.

    Please add this statement in your code to enable bank 7 manually:

        flashWREG->FMAC = 0x7;

  • Hi QJ Wang,

    Appreciate your help in resolving this issue. Will try the same and revert with results. But this would mean that if our code has interleaved writes to Flash and FEE, we would need to use this statement prior to every write to Bank 7. Is this understanding accurate?

    Thanks and Regards,

    Vimal

  • Hi Vimal,

    It is correct. Only one bank can be enabled at a time.

  • Hi QJ Wang,

    We have used the following statement instead of the one mentioned (flashWREG->FMAC = 0x7) prior to the TI_Fee_WriteSync() call and the code works as expected:

    (void)Fapi_setActiveFlashBank(Fapi_FlashBank7);

    Please confirm that this is okay. Appreciate all the help you have provided to resolve this issue.

    Thanks and Regards,

    Vimal

  • Hi Vimal,

    It is fine.