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.

Compiler/TMS570LS1114: Bootloader Code Sector 13 Failure

Part Number: TMS570LS1114
Other Parts Discussed in Thread: HALCOGEN, , TMS570LC4357, TMS570LS1224

Tool/software: TI C/C++ Compiler

Hi, 

I'm generating a boot loader application which is basically working except for accessing the last sector (13) in the flash.

I've used Halcogen to produce the initialisation code, and copied part of the example 'spna192' for the flash programming API functions.

All of the Bootloader functions are executed from RAM.

I can erase and program all the flash sectors with the exception of Sector 13.

When I erase Sector 13, after the erase is completed I get a data abort exception.

I have checked my .bin file and confirm that all unused locations are set to 0xFF.

I have a suspicion the issue is to do with the ECC but don’t understand why sector 13 is behaving differently?

In the Flash Settings under debug properties I have selected “Auto ECC Generation” and “Align program segments to 64-bit regions).

Could you please comment on how to fix this crash with Sector13.

Regards

Rob

 

  • Hello Rob,

    Is the abort caused by the erasing operation or by programming operation? Is this sector (13) enabled for erase/program? Please check the value of FBSE register.

    Using this API to enable all the 13 flash sectors:

        Fapi_enableMainBankSectors(0x1FFF);

  • I can confirm that FBnkSec was programmed with 0x000F from HalCoGen. 

    Using Fapi_enableMainBankSectors(0x1FFF); correctly sets the access. 

    However I still have the same issue. 

    After I erase Sect13 program ends up at undefEntry on return from Function call to t Erase_FLASH1. 

    If I disable the function call to 

    Erase_Sector(0x000E0000U); /*Sect13*/ 

    Then the code behaves correctly and returns from my Erase_FLASH1() function.

      

    ; interrupt vectors

    resetEntry

           b   _c_int00

    undefEntry

           b   undefEntry (ß end up here when Sect13 is erased after returning from Erase_FLASH1)

     

    Another issue is when I use the debugger to step through code that is located in RAM, from time to time, I get the following message

    “CortexR4: Trouble Reading Memory Block at 0x801eafc on Page 0 of Length 0x18: (Error -1208 @ 0x20000600) Unable to access an ETM register. Check that the ETM is configured properly as a cs_child. (Emulation package 8.3.0.00003) “

     This is a hindrance to debugging. How can I debug/step code executing out of RAM without generating this error?

     At the moment I have to set a break point after the code in RAM has executed and returned back to the Flash program area.

     My code below: (note I have disabled the watchdog for the purpose of debugging)

     Note all Functions reside in RAM.

     uint8_t Erase_FLASH1(void)

    {

       uint8_t ReturnCheck = 0U;

     

       Disable_System();

     

       Fapi_enableMainBankSectors(0x1FFF);

     

       Erase_Sector(0x00080000U); /* Sect10 */

     

       Erase_Sector(0x000A0000U); /* Sect11 */

     

       Erase_Sector(0x000C0000U); /* Sect12 */

     

       Erase_Sector(0x000E0000U); /* Sect13 causes function to fail on exit, if removed functions returns OK */

     

       ReturnCheck = Test_Erased_State_Flash((int8_t *) FLASH1_START_ADDRESS_PTR, 0x074000);

     

       Enable_System();

     

       return (ReturnCheck);

    }

     

    void Disable_System(void)

    {

       _coreDisableFlashEcc_();

       _coreDisableRamEcc_();

       _disable_interrupt_();

       /*_disable_FIQ_interrupt_(); */

       rtiDisableNotification(rtiNOTIFICATION_COMPARE0);

    }

     

     

    void Enable_System(void)

    {

       /*_coreDisableFlashEcc_(); */

       /*_coreDisableRamEcc_(); */

       _enable_interrupt_();

       /*_Enable_FIQ_interrupt_(); */

       rtiEnableNotification(rtiNOTIFICATION_COMPARE0);

    }

     

    void Erase_Sector(uint32_t eraseStartAddr)

    {

       uint8_t bk = 0U;

     

    #if ENABLE_WATCHDOG

       Clear_Watch_Dog_Timer();

    #endif

     

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

     

       Fapi_setActiveFlashBank((Fapi_FlashBankType) bk);

     

       Fapi_enableMainBankSectors(0xFFFEU); /* used for API 2.01*/

     

       while ( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady)

       {

    #if ENABLE_WATCHDOG

           Clear_Watch_Dog_Timer();

    #endif

       }

     

       Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *) eraseStartAddr);

     

       while ( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy)

       {

    #if ENABLE_WATCHDOG

           Clear_Watch_Dog_Timer();

    #endif

       }

     

       while (FAPI_GET_FSM_STATUS != Fapi_Status_Success)

       {

    #if ENABLE_WATCHDOG

           Clear_Watch_Dog_Timer();

    #endif

       }

     

       Fapi_flushPipeline();

    }

     

    Also worth noting is I don’t have any executing code in FLASH1 sectors, this is reserved for my new code to be downloaded into, then moved across to FLASH0 sectors using RAM firmware update process.

     Am I using the

     Fapi_flushPipeline()

     Function correctly?

    Could you please comment on how to fix Sect13 code failures.

    Regards

    Rob

     

  • Rob,

    Please check the contents of the CPU's data fault address (DFAR) and status registers (DFSR) to identify the location being accessed that is causing the fault. The DFSR will also tell you the type of violation that caused the abort response from the CPU.

    Regards,

    Sunil

  • Sunil,

    I made an update to my code and now i am getting stuck at,

        while (FAPI_GET_FSM_STATUS != Fapi_Status_Success)

    only for Sect13 erase.

    updated code snippet:

    added 

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

    Fapi_setActiveFlashBank((Fapi_FlashBankType) bk);

    which were being intialised elsewhere...

    void Erase_Sector(uint32_t eraseStartAddr)
    {
    uint8_t bk = 0U;

    #if ENABLE_WATCHDOG
    Clear_Watch_Dog_Timer();
    #endif

    #if 0
    // e2e.ti.com/.../785064

    _coreDisableFlashEcc_();

    _setPrivilege_();
    #endif

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

    Fapi_setActiveFlashBank((Fapi_FlashBankType) bk);

    //Fapi_enableMainBankSectors(0xFFFEU); /* used for API 2.01*/
    Fapi_enableMainBankSectors(0x1FFF);

    while ( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady)
    {
    #if ENABLE_WATCHDOG
    Clear_Watch_Dog_Timer();
    #endif
    }

    Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *) eraseStartAddr);

    while ( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy)
    {
    #if ENABLE_WATCHDOG
    Clear_Watch_Dog_Timer();
    #endif
    }

    while (FAPI_GET_FSM_STATUS != Fapi_Status_Success)   /*  getting stuck here now */
    {
    #if ENABLE_WATCHDOG
    Clear_Watch_Dog_Timer();
    #endif
    }

    Fapi_flushPipeline();
    }

    Why does this code work with erasing all other sectors but fails with Sect13?

    Thankyou in advance.

    Rob

  • Hell Rob,

    The TMS570LS1114 is able to run at 180MHz and 3 wait-states. Can you provide me a memory dump of the TI OTP from location 0xF0080140-0xF0081FF? A snipping tool capture of a CCS memory window will do as long as it is readable.

    What is your PLL clock (or HCLK)? and what is the SYS_CLK_FREQ in your settings?

  • QJ,

    Thank you for your feedback.

    To answer your questions,

    HCLK 180MHz
    SYS_CLK 180MHz
    PLL1 180MHz
    PLL2 180MHz

    location 0xF0080140-0xF0081FF, i get a error: "mem map prevented reading".

    I have made some progress.

    I can now execute my ERASE Sector Functions for Sect13 without crashing.

    Seems if you try and enable sectors in Bank Sector Enable Register (FBnkSec) that are not present in the MCU causes the ABORT issues I was experiencing when executing FLASH commands.

    I cannot verify that the erase routine is actually working at the moment as the Flash is already in the erased state.

    So my problem now is that I cannot write data to Sect13.

    My code runs through the Programming Function but no data is actually written to flash in Sect13. I write to Sect1-12 with the same routine and it works perfectly.

    I have a copy function that copies code area to backup flash area and it works all the way through until it hits Sect13 then no data is written.

    FBnkSec = 0x1FFF
    #define SYS_CLK_FREQ 180

    Below is my Program_Flash() Function which is derived from the TI example Bootloader project (TMS570LC4357_UART_Boot).

    Please note, I cannot get the code to program 32 bytes in one call, only 16. I have tried both programming modes, Fapi_DataOnly, Fapi_AutoEccGeneration

    Is there any explanation on why only 16 bytes works? Discovered through trial and error.

    As I mentioned before the same programming functions are working correctly for sectors 1-12, verified.

    I set a break point when writing to Sect 13 and I have verified that FBnkSec = 0x1FFF, my data buffer (src) is full of good data but nothing is written (dst) into Sect13 (0x0E0000).

    Why is Sect13 behaving differently to the other sectors?

    Could you please shed some light on this issue.

    Regards
    Rob

    /* transfer contents of RAM Buffer (1024 bytes) to Destination Flash_Start_Address */
    uint8_t Program_Flash(uint32_t Flash_Start_Address)
    {
    register uint32_t src = (uint32_t) BUFFER_Flash_Programming;
    register uint32_t dst = Flash_Start_Address;
    register uint32_t bytes_remain = 1024U; /* = Size_In_Bytes; */
    uint8_t Flag_Programming_Pass = (uint8_t) PASS;
    uint32_t bytes = 16U;
    uint8_t bk = 0U;

    Fapi_initializeFlashBanks(SYS_CLK_FREQ);

    Fapi_setActiveFlashBank((Fapi_FlashBankType) bk);

    Fapi_enableMainBankSectors(UNLOCK_SECTORS);

    while (bytes_remain > 0U)
    {
    /* Fapi_issueProgrammingCommand((uint32_t *) dst,
    (uint8_t *) src,
    (uint32_t) bytes,
    0U,
    0U,
    Fapi_AutoEccGeneration);*/

    Fapi_issueProgrammingCommand((uint32_t *) dst,
    (uint8_t *) src,
    (uint32_t) bytes,
    0U,
    0U,
    Fapi_DataOnly);

    while ( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy)
    {
    }

    src += bytes; /*Size_In_Bytes; */
    dst += bytes; /*Size_In_Bytes; */
    bytes_remain -= bytes; /*Size_In_Bytes; */

    if (bytes_remain < 16U)
    {
    bytes = bytes_remain;
    }
    }
    return (Flag_Programming_Pass);
    }

  • QJ,

    I'm back to the original error posted now.

    As it turns out i was not enabling Sect13 after many many attempts/changes at trying to resolve this issue.

    #define UNLOCK_SECTORS          (BIT13|BIT12|BIT11|BIT10|BIT9|BIT8|BIT7|BIT6|BIT5|BIT4|BIT3|BIT2|BIT1)  /*BIT0 Sector 0 Reset Vectors*/

    When i set BIT13 and calling

    Fapi_enableMainBankSectors(UNLOCK_SECTORS);

    after calling my Erase Functions below, 

    uint8_t Erase_FLASH1(void)
    {
    uint8_t ReturnCheck = 0U;

    Disable_System();

    Fapi_DeviceInfoType a = Fapi_getDeviceInfo();

    Erase_Sector(0x00080000U); /* Sect10 */

    Erase_Sector(0x000A0000U); /* Sect11 */

    Erase_Sector(0x000C0000U); /* Sect12 */

    Erase_Sector(0x000E0000U); /* Sect13 causes a FAILURE on return of Function */

    ReturnCheck = Test_Erased_State_Flash((int8_t *) FLASH1_START_ADDRESS_PTR, 0x074000);

    Enable_System();

    return (ReturnCheck);

    }

    programs ends up at

    ; interrupt vectors

    undefEntry
    b undefEntry

    if if dont call the erase for Sect13, ie Erase_Sector(0x000E0000U)

    then the programs works OK, but obviously i need to erase Sect13.

    Why does calling  Erase_Sector(0x000E0000U) abort the program ? Why is sect13 behaviour different ? How do I fix this ?

    Do i need to use Fapi_flushPipeline(); at any point? 

    All of this code is called from RAM.

    I am using the TMS570LS1114. I am not using floating point. 

    Which .lib's should i be using

    1.

    rtsv7R4_T_be_v3D16_eabi.lib or

    rtsv7R4_T_be_eabi.lib)

    2.

    F021_API_CortexR4_BE_V3D16.lib or

    F021_API_CortexR4_BE.lib ?

    It doesnt seem to make any difference to the behaviour described above.

    ive ran out of ideas and time.  Please advise.

    Regards

    Robert

     

  • Sunil

    Im assuming these are referenced in the Debugger under System_Registers ?

    This is the state of the registers after code hits,

    ; interrupt vectors

    undefEntry
    b undefEntry

    CP15_DATA_FAULT_ADDRESS 0x08000018 Core

    CP15_DATA_FAULT_STATUS 0x00000000 Core

    What does this mean ?

    Robert

  • Update:

    If i skip over erasing Sect13 i can then proceed to program/write data to Sect13 (obviously once only as i cannot erase it).

    So to summerise,

    - i can erase any sector except for Sect13 (last Flash Sector).

    - I can write to any sector OK

    When i erase Sect13, and return from the Erase Function i get a undefEntry abort.

    uint8_t Erase_FLASH1(void)
    {
    uint8_t ReturnCheck = 0U;

    Disable_System();

    //Fapi_DeviceInfoType a = Fapi_getDeviceInfo();

    #if 0
    Erase_Sector(0x000E0000U); /* Sect13 causes an 'undefEntry' IRQ on return from Erase_FLASH1 */
    #endif

    Erase_Sector(0x000C0000U); /* Sect12 */

    Erase_Sector(0x000A0000U); /* Sect11 */

    Erase_Sector(0x00080000U); /* Sect10 */

    ReturnCheck = Test_Erased_State_Flash((int8_t *) FLASH1_START_ADDRESS_PTR, 0x074000);

    Fapi_flushPipeline();

    Enable_System();

    return (ReturnCheck);
    }

    void Erase_Sector(uint32_t eraseStartAddr)
    {
    uint8_t bk = 0U;

    Fapi_flushPipeline();

    Fapi_initializeFlashBanks(SYS_CLK_FREQ);

    Fapi_setActiveFlashBank((Fapi_FlashBankType) bk);

    Fapi_enableMainBankSectors(UNLOCK_SECTORS);

    while ( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady)
    {
    }

    Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *) eraseStartAddr);

    while ( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy)
    {
    }

    while (FAPI_GET_FSM_STATUS != Fapi_Status_Success)
    {
    }

    Fapi_flushPipeline();

    }

    All code is loaded into RAM.

    #define UNLOCK_SECTORS          (BIT13|BIT12|BIT11|BIT10|BIT9|BIT8|BIT7|BIT6|BIT5|BIT4|BIT3|BIT2|BIT1)

    Can you please makes some suggestions on how to resolve erasing Sect13 ?

    Regards

    Robert

  • Hello Robert,

    I gave you a wrong value (0x1FFF) before. To enable all the sectors (sector 0 to sector 13), 0x3FFF should be used.

    UNLOCK_SECTORS should be 0x3FFF in your function: Fapi_enableMainBankSectors(UNLOCK_SECTORS);

    1. You can use F021_API_CortexR4_BE_V3D16.lib ( floating point) or F021_API_CortexR4_BE.lib ( fix point).

    2. To read OTP memory, you need to add those two lines to your gel file (gel file is located in ccs_installation folder\ccs_base\emulation\gel\tms570ls1224.gel

    GEL_MapAdd(0xF0080000, 0, 0x00002000, 1, 0); /* TI OTP */
    GEL_MapAddStr(0xF00C0000, 0, 0x00000400, "R|AS2", 0); /* TI OTP ECC */