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.

SYS/BIOS crash on startup

Other Parts Discussed in Thread: SYSBIOS

I have a strange crash shortly after launching SYS/BIOS.

The main code sets up the PLL's, EDC, DDR, UART and GPIO's, then prints a welcome message, then creates two tasks and then calls BIOS_start.

By changing the length of any string constant anywhere in the program by +/- 4 bytes, the code will either run without incident or hang forever shortly after starting the first task.  All that the task has executed by then is one System_printf - and not the string whose length was changed.  The next instruction is another System_printf, which never executes. From the stack dump, it appears to be hanging in ti_sysbios_knl_Clock_workFunc, called from ti_sysbios_BIOS_Module__state__V.  Nothing beyond that on the stack.

I can put breakpoints at both System_printf calls.  The first one executes, but appears to corrupt the stack, so never returns.  With the breakpoint in place, I don't see the result of the even the first System_printf.

Looking at the map file, all sections are identical except the length of .const (the next section ends up at the same start address, because they appear to be aligned to a 16-byte boundary), and the only difference in .const is that a number of items have shifted address by 4 bytes.  The order of some items changes, principally sysbios objects, but everything remains aligned to 4-byte boundaries.

It looks as if something in .const must be wrongly aligned - perhaps something needs to be on 8 or 16 byte boundaries and ends up on an odd 4-byte boundary?

I'm running xdc version 3.23.3.53 on a C6678

  • Single-stepping through the call to System_printf, it does the following:

    the task calls System_printf - resolved to xdc_runtime_System_printf__E

    which calls xdc_runtime_System_vprintf__F

    which calls xdc_runtime_System_SupportProxy_ready__E

    which calls xdc_runtime_SysStd_ready__E

    which calls xdc_runtime_SysStd_ready__F

    xdc_runtime_SysStd_ready__F returns - stack OK

    xdc_runtime_SysStd_ready__E returns - stack corrupted, so the return address from xdc_runtime_System_SupportProxy_ready__E is now garbage (0xBEBEBEBE)

  • OK - the analysis above is a red-herring: that's just where the shrapnel lands.  Adding a busy loop ahead of the System_printf makes it crash at the busy loop.  The problem still goes away if I make any string constant anywhere in the project 4 bytes longer or shorter.

  • Paul,

    The behavior could be explained by a stack overflow occurring within the task that is invoking System_printf().

    System_printf() is a pretty heavy stack user, and when a Clock interrupt goes off within System_printf(), this is often the scenario of the worst case task stack burden.

    On the other hand, you say that the problem occurs even before the call to System_printf()...

    What stack size are you using for your tasks? Can you try making them a little larger and see if that helps things?

    If you have ROV working with CCS you can use the detailed Task view to see how deep the stacks have been. That might give us a clue to whats going on.

    Alan

  • I had considered stack overflow, and did try making all of the stacks enormous - no improvement.

    The real problem was that one of the functions being called from main, prior to launching BIOS, was calling Thread_sleep.  That function worked normally and returned, but seems to have left a time-bomb that would crash whichever task was operating a short time after launch.

    I still don't understand how the length of unreferenced string constants could change whether the crash happens or not, but it hasn't happened since removing the call to Thread_sleep.

    Paul

  • I assume Thread_sleep() calls Task_sleep().

    Task_sleep() called from within main() will indeed leave a time bomb by scribbling randomly on low memory due to derefencing a null pointer.

    The consequential damage caused by this scribbling is hard to predict and probably not worth trying to track down.

    Alan