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.

CCS/LAUNCHXL-F28379D: Break at address error when running from FLASH memory

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello,

I have a program that works when running from RAM memory, and now I'm trying to run it with FLASH memory.  However, when running with FLASH memory, I am getting a break in address error.

Stepping with the debugger, I trace the error to

  1. Inside main(), InitSysCtrl() is called which is a function in F2837xD_SysCtrl.c (this function is from C2000Ware_3_02_00_00)
  2. Inside InitSysCtrl(), InitFlash() is called
  3. Inside InitFlash(), the EALLOW command causes the following break at address error

Break at address "0x3fe468" with no debug information available, or outside of program code.

Why is it that EALLOW would be causing the break in address?  Since this error does not occur when running from RAM memory, does that mean something is setup wrong in 2837xD_FLASH_lnk_cpu1.cmd?  (I just copied this file from an example project in the Resource Explorer.)

Thanks,

Kevin 

  • Kevin,

    That address belongs to ITRAP ISR in the BootROM.

    I think you are executing the InitFlash() function from RAM before copying it from Flash to RAM using memcpy().

    Can you check whether or not memcpy() is called before executing InitFlash()?  

    InitFlash() should have been assigned to .TI.ramfunc section in your code.  This section is mapped to a Flash address for load and RAM address for run in your linker cmd file. When you call memcpy(), it would copy the contents of this section from Flash to RAM.  If memcpy() is not called, control will jump to RAM when InitFlash() is called and the RAM address will not have valid code.  Hence, an ITRAP occurs.

    Thanks and regards,
    Vamsi

  • Kevin,

    You can also look at the below wiki page and search for "Could you list the procedure involved in modifying an application from RAM based configuration to Flash based configuration in simple steps?"

    https://processors.wiki.ti.com/index.php/C2000_Flash_FAQ

    Look at the steps that I outlined for this question in above wiki page.  It would help you further. 

    Thanks and regards,

    Vamsi

  • Vamsi,

    Thanks for your reply.  The memcpy is being called before the initFlash.  See code below inside F2837xD_SysCtrl.c (this file is from C2000ware)

    void InitSysCtrl(void)
    {
    //
    // Disable the watchdog
    //
    DisableDog();

    #ifdef _FLASH
    //
    // Copy time critical code and Flash setup code to RAM. This includes the
    // following functions: InitFlash()
    //
    // The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart
    // symbols are created by the linker. Refer to the device .cmd file.
    //
    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);

    //
    // Call Flash Initialization to setup flash waitstates. This function must
    // reside in RAM.
    //
    InitFlash();
    #endif

    I also looked at the Wiki article you suggested.  I started my code from Lab 3 in the F2837xD one-day workshop.  In that project, when I go to build configurations, I actually see DEBUG/RELEASE and not FLASH/RAM.  To modify my application to flash, I copied the DEBUG configuration and called that new configuration FLASH.  For the FLASH configuration, I then added _FLASH to the predefined symbols and I changed the linker command file to be 2837xD_FLASH_lnk_cpu1.cmd (I copied this file from C2000Ware).

    It seems like I followed what was in the Wiki article.  Am I missing anything?

    One thing I noticed is that the Wiki article mentions the Flash_initModule() command whereas the F2837xD_SysCtrl.c (this file is from C2000ware) uses InitFlash().  Are InitFlash() and Flash_initModule() equivalent?

     Thanks,

    Kevin

  • Kevin,

    Thank you for the update.

    Yes, both the functions should be same (Flash_InitModule() is from driverlib in C2000Ware).

    Clearly this is ITRAP issue.  Can you attach your linker cmd file and map file?

    Thanks and regards,
    Vamsi

  • Vamsi,

    Which file is the map file?

    Thanks,

    Kevin

  • Kevin,

    Linker generates a map file (check your linker settings) - which shows where different sections/functions are mapped by the linker in the memory space defined by the linker cmd.  It should be alongside your .out file.

    Thanks and regards,
    Vamsi

  • Hi Vasmi,

    Thanks for your reply.  I've attached the 2837xD_FLASH_lnk_cpu1 file I'm using and the resulting .map file for FLASH.  I'm not sure if this is relevant or not, but I've also attached 2837xD_RAM_lnk_cpu1 file I'm using when running with RAM memory.  (Note I started from the file that was in the Lab 3 one-day workshop, but I had to move some memory around for running with RAM because I was getting a not enough memory error for .text and .ebss when compiling, so the attached 2837xD_RAM_lnk_cpu1 file is slightly different than the file from the Lab 3 one-day workshop.  For 2837xD_FLASH_lnk_cpu1, I didn't get the same error when compiling, so that file is still identical to the one from C2000 ware)

    Thanks,

    Kevin

    FLASH Files.zip

  • Kevin,

    Thank you for the files.

    Give me a day or two.  I will review them and get back to you early next week.

    Thanks and regards,

    Vamsi

  • Kevin,

    I reviewed your map file and linker cmd file.

    You have both ramfuncs and .TI.ramfunc in your code.

    InitFlash() is mapped to ramfuncs.  Since the compiler version is greater than 15.9, ramfuncs did not get allocated to Flash for load and RAM for run.  Instead, it got mapped to RAMM0 at address 0x123.  Since, it got allocated to RAM, it did not get loaded (Only flash gets loaded when using flash tools).  Please map InitFlash() to .TI.ramfunc and it will get fixed.

    Please check if anything else got mapped to ramfuncs - map them to .TI.ramfunc.

    Thanks and regards,
    Vamsi

  • Vamsi,

    Thanks for your reply.  Could you please clarify how I should "map InitFlash() to .TI.ramfunc"?  Sorry for the newbie question.

    Thanks,

    Kevin

  • Kevin,

    It is available in C2000Ware examples. Please take a look at C:\ti\c2000\C2000Ware_3_02_00_00\device_support\f2837xd\common\source\F2837xD_SysCtrl.c

    Thanks and regards,
    Vamsi

    #ifndef __cplusplus
    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    #pragma CODE_SECTION(InitFlash, ".TI.ramfunc");
    #pragma CODE_SECTION(FlashOff, ".TI.ramfunc");
    #else
    #pragma CODE_SECTION(InitFlash, "ramfuncs");
    #pragma CODE_SECTION(FlashOff, "ramfuncs");
    #endif
    #endif
    #endif