Hello,
I have a project I have created in C++ using for the 28335 processor. I have it set up to boot out of flash and move critical time sensitive functions to RAM at runtime. I have used many of the TI guides to help me along the way, but I am having a problem I cannot wrap my head around.
Currently, if the application is running using CCS and JTAG, it flashes, boots, and runs with no issues. I can press the reset button on CCS and it will come back from that as well. I can disconnect the target, reconnect the target and it picks up running with no issues as well.
However, if I disconnect the target and then power cycle the board, when I reconnect to it I see that it is stuck in an infinite loop.
I am stuck in boot.asm in the PINIT section. Under normal (other) conditions, I see that as I go through the pinit code, it pops off an address from the pinit table and runs the constructor. It then goes back and pops another address off and runs that constructor. Finally, you get 0 from the table, and you break out of the loop and go to main.
After a power-cycle, I see the same sequence of events, however after it pops off the second address and runs that constructor, the subsequent pop goes back to the first item on the list! I am not sure what is causing this or why.
Now for the really freaky part - I moved the math libraries into RAM to speed them along in the execution. When I put them in RAM, I see the behavior I outlined above. If I leave the math library in FLASH, everything works - power cycle and all! I don't know what the location of the math libs have to do with any of the constructor stuff, but it is full repeatable and controllable.
I guess I would like to understand why this behavior is happening and also how to fix it. I need that math lib in RAM during runtime, and I also need to be able to power-cycle the processor and have it come back booting from flash. Here is the code from boot.asm that is causing the infinite loop:
****************************************************************************
* IF pinit IS NOT -1, PROCESS CONSTRUCTOR ROUTINES *
****************************************************************************
DO_PINIT:
****************************************************************************
* CLEAR THE EALLOW BIT AFTER THE CINIT TABLE IS COPIED. *
****************************************************************************
EDIS
MOV AL,#pinit
MOV AH,#hi16(pinit)
ADDB ACC,#1
B DONE_INIT,EQ ; if pinit < 0 (-1) no pinit table
****************************************************************************
* PROCESS PINIT SECTION. TABLE CONSISTS OF CONSTRUCTOR ROUTINE ADDRESSES *
* THAT POINT TO C++ INITIALIZATION FUNCTIONS. THESE ROUTINES MUST EXECUTE *
* BEFORE MAIN IS CALLED *
****************************************************************************
MOVL XAR7,#pinit ; set up pointer to initialization table
B START_PINIT, UNC ; jump to start processing
LOOP_PINIT:
ADDB XAR7,#1 ; point to next table entry
PUSH XAR7 ; save off table entry address
MOVL XAR7,ACC ; load constructor routine address
LCR *XAR7 ; execute routine
POP XAR7 ; reload table entry address
START_PINIT:
PREAD AL,*XAR7 ; unpack constructor routine address
ADDB XAR7,#1
PREAD AH,*XAR7
TEST ACC ; test for table end condition (zero)
B LOOP_PINIT,NEQ ; process table entry if not zero
****************************************************************************
* COPY CONSTANTS TO DATA MEMORY, IF NECESSARY *
****************************************************************************
Is there something that I should be doing to initialize the RAM after the power cycle perhaps? This all seems pretty early in the process, so I am not sure what could be messing that pinit list up?
Any help/pointers would be greatly appreciated!!
-Jeff