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.

Stuck in _memoryInit_ loop

Other Parts Discussed in Thread: HALCOGEN, TMS570LS20216

I need help with my first Halcogen-generated project which is now getting stuck in an infinite loop in _memoryInit_ on the RM48 USB Stick. Previously it used to run and I cannot determine what I changed to cause this issue. Here is the memoryInit function as generated by Halcogen:

.def _memoryInit_
.asmfunc

_memoryInit_

stmfd sp!, {r0-r2}
ldr r2, regMinitGcr ; MINITGCR register pointer
mov r0, #0xA
str r0, [r2]
ldr r0, ramInitMask ; load RAM initialization mask
str r0, [r2, #4]
mloop
ldr r1, [r2, #12]
tst r1, #0x100
beq mloop
mov r0, #5
str r0, [r2]
ldmfd sp!, {r0-r2}
bx lr

ramInitMask .word 0x1C57F
regMinitGcr .word 0xFFFFFF5C

.endasmfunc

  • Marius,

    Can you try something quick? Try changing the first instruction after mloop from ldr r1, [r2, #12] to ldr r1, [r2, #8].

    Regards,

    TI Forum Support

  • I have not been able to replicate the issue anymore. The only change I made was to shut down my computer and start it again. If I encounter the problem again, I will try your suggestion.

    Thanks,

    Marius

  • The problem started happening again, consistently. Again I'm not sure what I did to trigger it. I tried your suggestion and I saw no change. I tried re-generating Halcogen code, same result. I unplugged the RM48USB stick and plugged it back in, same result. I restarted Code Composer, rebuilt my project, same result. I rebooted my computer, same result.

    The following day I was working with a TMS570 HDK and using a different PC, and after about 1 hour this system also started getting stuck in _MemoryInit_. Just as before, I'm not sure if my actions caused it, it just seemed to happen "out of the blue".  The source code for the memory init function in this TMS570 project is very similar:

    .def _memoryInit_
    .asmfunc

    _memoryInit_

    stmfd sp!, {r0-r2}
    ldr r2, regMinitGcr ; MINITGCR register pointer
    mov r0, #0xA
    str r0, [r2]
    ldr r0, ramInitMask ; load RAM initialization mask
    str r0, [r2, #4]
    mloop
    ldr r1, [r2, #12]
    tst r1, #0x100
    beq mloop
    mov r0, #5
    str r0, [r2]
    ldmfd sp!, {r0-r2}
    bx lr

    ramInitMask .word 0x1E57F
    regMinitGcr .word 0xFFFFFF5C

    .endasmfunc

    Trying your suggested change, I see no change. After I pressed the PORRST button on the HDK board, I can't even load code on the board anymore, I'm always getting the following error:

    CortexR4: Trouble Writing Memory Block at 0x0 on Page 0 of Length 0x3568
    CortexR4: GEL: File: <...>\workspace\RTI Test\Debug\RTI Test.out: Load failed.

    After this, turned off power to the HDK board, disconnected the debugger USB cable, shut down Code Composer, then connected a J-link debugger, started IAR EWARM, powered the board, loaded a known good project in EWARM and was able to upload it to flash and run it in debug mode, no more problems.

    Finally, I reverted back to using Code Composer Studio (v. 5.2 beta) with the integrated XDS100 debugger, and loaded the original project I was having problems with and now I was able to load it and run it, no more problems with loading code or with the memory test loop, using exactly the same project binary as previously.

    At this point I suspect the problem is caused either by the 5.2 beta version of Code Composer, or by the XDS100 JTAG debugger. 

    Thanks,

    Marius

  • Marius,

    Device Errata 152 could create this problem (meminit hanging) when a RAM's power domain is powered down.  The reset creates the possibility that this problem is generated.

    This problem is fixed so that when you order parts for production, you will not run into this problem.

    Regards,

    TI Forum Support

  • Hi,

    I have seen the same problem with TMS570 MCU developement kit that we are using. The processor is TMs570LS20216.

    Let me know whether the same reason (device errata 152) for this device getting stuck in meminit function ?

  • Hello,

    I do not think that the same errata applies to 570LS20216. Can you send some details on how you are configuring the meminit function?

    Regards,

    Forum Support

  •  

    I am using the code generated from HALCogen. Below is the code. Please let me know what is the issue with code.

     

    ; Initialize memory

        .global  _memoryInit_
        .asmfunc

    _memoryInit_:
           
            ldr   v9, regMinitGcr    ; MINITGCR register pointer
            mov   v1, #0xA
            str   v1, [v9]
            mov   v1, #0x657F
            str   v1, [v9, #4]
    mloop:
            ldr   v2, [v9, #12]
            tst   v2, #0x100
            beq   mloop
            mov   v1, #5
            str   v1, [v9]
            bx    lr
       
    regMinitGcr:   .word 0xFFFFFF5C

        .endasmfunc

     

  • Hello,

    What device are you initializing?

    Regards,

    Forum Support