TMS320F28388S: FLASH initialization function going into Error handling for Assert violation.

Part Number: TMS320F28388S
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi Team,

As my code size increased, the memory bank .sysmem : > RAMLS5 got exhausted. So, I changed the initial setting from .data : > RAMLS5 to .data : > RAMLS6.

After this change, the function call:

Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES);

started hitting the __error__() handler:

void __error__(const char *filename, uint32_t line) { // ASSERT condition failed. Use filename and line to debug. ESTOP0; }

What could be the root cause of this issue, and how can I resolve it?
Added initial error snip below .

After changing .data 




Another strange point is I also tried with increase the length of RAMLS5 , from length = 0x000800 to length = 0x001800, It started working . But when I add more buffers as my application need, then it again started going into 

 __error__() handler:

.
I did some more debugging and found from device_init() function call of driverlib of C2000 sdk  into Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES) call .
Then it should go into function definition inside flash.c   but It is going some commented line // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR in line no 31 in flash.c .
After continuous step in in debugger I again found It is going into error from ASSERT(EPWM_isBaseValid(base)); from function call
EPWM_setCounterCompareValue(uint32_t base, EPWM_CounterCompareModule compModule,
uint16_t compCount).
But same function is working when I am using single phase with single buffer [256]. I am really what exactly going wrong .

I badly need expert help .
  • Hi,

    Have you aligned your data buffer secion with ALIGN directive?

    Regards,

    Rajeshwary

  • Hi Rajeshwary,

    Thanks for the response.
    But C2000 sdk  2838x_FLASH_lnk_cpu1.cmd file doesn't have this type of command .
    I provided complete linker file for your reference .

    Regards,
    Ramakrishna

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    MEMORY
    {
    /* BEGIN is used for the "boot to Flash" bootloader mode */
    BEGIN : origin = 0x080000, length = 0x000002
    BOOT_RSVD : origin = 0x000002, length = 0x0001AF /* Part of M0, BOOT rom will use this for stack */
    RAMM0 : origin = 0x0001B1, length = 0x00024F
    RAMM1 : origin = 0x000400, length = 0x0003F8 /* on-chip RAM block M1 */
    // RAMM1_RSVD : origin = 0x0007F8, length = 0x000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    RAMD0 : origin = 0x00C000, length = 0x000800
    RAMD1 : origin = 0x00C800, length = 0x000800
    RAMLS0 : origin = 0x008000, length = 0x000800
    RAMLS1 : origin = 0x008800, length = 0x000800
    RAMLS2 : origin = 0x009000, length = 0x000800
    RAMLS3 : origin = 0x009800, length = 0x000800
    RAMLS4 : origin = 0x00A000, length = 0x000800
    RAMLS5 : origin = 0x00A800, length = 0x001800
    //RAMLS6 : origin = 0x00B000, length = 0x000800
    //RAMLS7 : origin = 0x00B800, length = 0x000800
    RAMGS0 : origin = 0x00D000, length = 0x001000
    RAMGS1 : origin = 0x00E000, length = 0x001000
    RAMGS2 : origin = 0x00F000, length = 0x001000
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



  • Apologies, If you are not using flash api library then this is not required.

    After this change, the function call:

    Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES);

    started hitting the __error__() handler:

    void __error__(const char *filename, uint32_t line) { // ASSERT condition failed. Use filename and line to debug. ESTOP0; }

    Can you check the filename and line number from where it is going to _error_()?

    Regards,

    Rajeshwary

  • Hi Rajeshwary,

    Thanks for the response.

    C2000 sdk device_init()  function call have Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES) inside it .
    You are suggesting to comment out it ?? But when buffer size is less same call was working good .

    By commenting out Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES) also return same error .

    Can you check the filename and line number from where it is going to _error_()?

    Yes, 

    "filename char * 0x00090196 "/home/ubnu..." Register XAR4

    line unsigned long 33 Register AL
    "
    But this is very unclear .

    If you want I can provide previous version, current version of my code .where I only added more buffers of size 256 .
    Initially I used single buffer of 256 as I am testing for single phase, that time same program was working fine.
    Then as my application require 3 phase , i simply added 2 more buffer with 256 sizes. After that same issue started .

    I  found by debugging more deep in working program  when from device.c function call Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES) passing values of cntrlbase and ecc base as defined in .h file like below.
    #define FLASH0CTRL_BASE 0x0005F800U
    #define FLASH0ECC_BASE 0x0005FB00U

    But in new program ctrlBase and eccBase passed as 0x0000F800 and 0x00000000 .
    Most of the base addresses of memory and peripherals from HW_MEMMAP_H were affected in runtime after the function call of memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);

    Regards,
    Ramakrishna  

  • Hi

    Yes, FLASH0CTRL_BASE  as 0x0005F800U is the correct value and is same in C200ware example that you are testing. Which C2000ware version you are using where you see values as 0x0000F800 and 0x00000000?

    Regards,

    Rajeshwary

  • Hi Rajeshwary,

    In both cases, the C2000Ware version is 5.4.0.0, as the codebase is the same.
    The only difference is the increased code size — no changes were made to settings or background libraries.

    By the way, I’ve identified the root cause — it was due to a stack overflow.

    Regards,
    Ramakrishna