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.

RM57L843: Errors inside HL_sys_startup.c

Part Number: RM57L843
Other Parts Discussed in Thread: HALCOGEN

Hi,

Customer is testing SafeTI Diagnostic Library demo on RM57L HDK.
At the startup, the code stops at while loop at line#204 HL_sys_startup.c.

The source code is under below folder:
\ti\Hercules\SafeTI Diagnostic Library\2.4.0\demo_app\HALCoGen\RM57L843_NoOS\source

        /* Check if there were ESM group3 errors during power-up.
         * These could occur during eFuse auto-load or during reads from flash OTP
         * during power-up. Device operation is not reliable and not recommended
         * in this case. */
        if ((esmREG->SR1[2]) != 0U)
        {
           while(1); //ESM group3 error
        }


esmREG->SR1[2] is set to 0x00000008 here.
The comment says something wrong at power-up. What is the exact cause of the error and how to avoid it?

Customer tried to write 0x00000008 to esmREG->SR1[2] to clear the error, the error never occurs until next power cycle.
But the code stops inside _SL_HoldNClear_nError() at line#445.
		/* Make sure that the CPU self-test controller can actually detect a fault inside CPU */
		stcSelfTestConfig.stcClockDiv        = 0;             /* STC Clock divider = 1 */
		stcSelfTestConfig.intervalCount     = 1;             /* One interval only */
		stcSelfTestConfig.restartInterval0     = TRUE;         /* Start from interval 0 */
		stcSelfTestConfig.timeoutCounter     = 0xFFFFFFFF;     /* Timeout counter*/
		_SL_HoldNClear_nError();


What causes this error and how to avoid it?

Thanks and regards,
Koichiro Tashiro

  • Hi Koichiro,

    Would you check if there is any possibility of customer's code reading a variable without first initializing it? Do they perform an auto-initialization of the CPU RAM before accessing it?

    Which compiler is used? 

  • Hi QJ,

    It is not quite clear what below question exactly means.

    Would you check if there is any possibility of customer's code reading a variable without first initializing it? Do they perform an auto-initialization of the CPU RAM before accessing it?

    At the beginning  of HL_sys_startup.c, RAM is accessed by switch(resetReason).
    Is this problem?

    Thanks and regards,
    Koichiro Tashiro

  • Hi Koichiro,

    Can you please declare resetReason as register?

  • Hi QJ,

    Could you explain what to do more in detail?
    resetReason is declared as below in HL_sys_startup.c line#88.

    SL_ResetReason     resetReason;        /* Reset reason */

    I do not know what is "SL_ResetReason"

    Can you please declare resetReason as register?

    Could you specify how to do that?

    Thanks and regards,
    Koichiro Tashiro

  • QJ,

    You mentioned about RAM initialization. Please tell us how to initialize RAM to avoid the issue?

    Thanks and regards,
    Koichiro Tashiro

  • Hi Koichiro,

    I am not able to reproduce this issue. I'd like to check if the following methods can resolve the issue:

    1. Initialize the MCU SRAM before checking the reset resource:

        SL_Init_Memory(RAMTYPE_RAM);

       _SL_Init_EnableEventExport();

       resetReason = SL_Init_ResetReason();

       switch(resetReason)
       {

           .....

       }

    2. Declare the resetReason as register. The keyword 'register' means that the variable is stored in a processor register instead of memory.

        register resetSource_t   rstSrc;
        rstSrc = SL_Init_ResetReason();

       switch(rstSrc)
       {
            case ...

  • The start-up sequence in the Safety Library demo app does need to be changed.

    My recommendation is :

    void _c_int00(void)

    {

        SL_Init_R5Registers();

        SL_Init_StackPointers();

        SL_Init_Memory(RAMTYPE_RAM);

        _SL_Init_EnableEventExport();

        resetReason = SL_Init_ResetReason();

    ...

    In the original sequence, _SL_Init_EnableEventExport() call may cause the double-bit ECC error. The first instruction in this function is a store to the stack, which will cause the double-bit ECC error. However since the event-bus export is not enabled at this point, there is no response or indication for this ECC error.

    The function call resetReason = SL_Init_ResetReason(); can also cause 2-bit ECC error. This is a C function, which also uses the stack to save and restore CPU registers. The double-bit ECC error caused by this stack write is now exported to the ESM. This is the cause of the ESM group 3 error that you see on power-up.

    Please call the memory initialization function before the call to enable event export. This memory initialization function in the demo app is not using stack operations as the return value is defined as a "register", so it uses a CPU register to hold this variable.

  • Hi QJ,

    Thanks. Customer will try your last recommendation.
    One question:

    This memory initialization function in the demo app is not using stack operations as the return value is defined as a "register", so it uses a CPU register to hold this variable.

    As I said, resetReason is declared as below in the demo code. SL_ResetReason is enum, not "register".

    SL_ResetReason     resetReason;        /* Reset reason */

    Is this OK to leave this as-is?
    No need to apply below changes you mentioned before?

        register resetSource_t   rstSrc;
        rstSrc = SL_Init_ResetReason();

       switch(rstSrc)
       {
            case ...


    Thanks and regards,
    Koichiro Tashiro

  • Is this OK to leave this as-is?
    No need to apply below changes you mentioned before?

    If the MCU SRAM is initialized before resetReason = SL_Init_ResetReason();, you can use it as-is.

    Or 

    you can declare resetReason as register 

    But I suggest to init SRAM before any read/write from/to the memory location.

  • QJ,

    Customer tried below changes, but it does not help.

    void _c_int00(void)

    {

        SL_Init_R5Registers();

        SL_Init_StackPointers();

        SL_Init_Memory(RAMTYPE_RAM);

        _SL_Init_EnableEventExport();

        resetReason = SL_Init_ResetReason();

    ...

    Did you try above changes worked on your side?
    Again, customer uses TI hardware(HDK) and software (HL_sys_startup.c), so it should work without an issue.
    Is there any missing initialization, etc.?

    Thanks and regards,
    Koichiro Tashiro

  • Hi QJ,

    Customer investigated it deeper and found the code does not return from SL_InitMemory(RAMTYPE_RAM); and it stops while loop at sl_init.c line#172.

    	/*SAFETYMCUSW 440 S MR: 11.3 <APPROVED> Comment_5*/
    	/*SAFETYMCUSW 9 S MR: 12.2 <APPROVED> Comment_2*/
        /*SAFETYMCUSW 28 D <APPROVED> Comment_6*/
        /*SAFETYMCUSW 134 S MR: 12.2 <APPROVED> Comment_3*/
        while (MEM_HW_INIT_COMPLETE != BF_GET(sl_systemREG1->MSTCGSTAT, BF_MINIDONE_START, BF_MINIDONE_LENGTH)) {
    
        }


    The while loop just waits for completion of memory initialization. It seems to be purely hardware mechanism. 
    What is the reason the completion bit never sets?

    Thanks and regards,
    Koichiro Tashiro

  • Tried many time, there is no problem to run RAMTYPE_RAM auto-init:

    SL_InitMemory(RAMTYPE_RAM);

  • Hi QJ,

    I see. Let me check with customer again.

    Thanks and regards,
    Koichiro Tashiro