Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

Printing XDC and Sysbios exceptions to UART

Other Parts Discussed in Thread: SYSBIOS

Hello, in sysbios stack overflows, task crash and other troubles are reported during debuggin to the CIO console of CCS.

However it would be useful to have these messages printed to the UART so testers can report sporadical issues during normal operation.

Is this possible?

  • Moving to TI-RTOS forum

    Regards,
    Gigi Joseph.
  • HI Leonardo,

    Yes,  the console I/O prints from TI-RTOS can be re-routed to UART. The console I/O messages are printed using the System module which can configured to call callback functions. These callback functions should be configured to write to UART.

    For example, in your .cfg add a configuration similar to the one below:

    /* ================ System configuration ================ */

    var System = xdc.useModule('xdc.runtime.System');

    var SysCallback = xdc.useModule('xdc.runtime.SysCallback');

    SysCallback.abortFxn = "&myUARTAbort";

    SysCallback.putchFxn = "&myUARTPutch";

    SysCallback.readyFxn = "&myUARTReady";

    System.SupportProxy = SysCallback;

    And define the functions myUARTAbort, myUARTPutch and myUARTReady in your application. For details about the SysCallback module's callback function signature, please see this link.

    Vikram

  • Dear Vikram,

    it is not very clear what should be done in these callbacks... First of all: when are they called? I imagine the abort is the one that throws out the exception messages like e.g.

    ti.sysbios.knl.Task: line 374: E_stackOverflow: Task 0x20033768 stack overflow.
    xdc.runtime.Error.raise: terminating execution

    When is the putchFxn and readyFxn called?

    Second thing: what should I write inside them? I imagine something like this:

    myUARTAbort(CString str) {

    Report("Error: %s", str);

    }

    Is this valid? Should the input arguments be the same as the default callbacks (e.g. SysCallback_abort)? Can the Report function be used inside these or should I use a more low level UART approach to write strings out?

  • Leonardo,

    Sorry, I assumed you knew about the xdc.runtime.System module. Please refer to the TI-RTOS Kernel User Guide, Section 6.3 for an overview on System module.

    System module is a TI-RTOS implementation of C stdio features (printf, exit ...). Additionally, the low level functions in System module can be configured to be implemented by different support modules like SysStd (prints to console I/O), SysMin (writes to a buffer) and SysCallback (writes to a callback function).

    Leonardo Gabrielli1 said:
    First of all: when are they called

    The low level functions are called by System module (hence the function plug in the configuration that I shared earlier).

    Leonardo Gabrielli1 said:

    I imagine the abort is the one that throws out the exception messages like e.g.

    ti.sysbios.knl.Task: line 374: E_stackOverflow: Task 0x20033768 stack overflow.
    xdc.runtime.Error.raise: terminating execution

    When is the putchFxn and readyFxn called?

    In case of an exception, the TI-RTOS library will call System_abort() which internally calls abortFxn. The putchFxn/readyFxn is called when System_printf() is used in the application or the library.

    Leonardo Gabrielli1 said:

    Second thing: what should I write inside them? I imagine something like this:

    myUARTAbort(CString str) {

    Report("Error: %s", str);

    }

    Is this valid?

    Yes, that would work if Report() is your implementation of UART write.

    Leonardo Gabrielli1 said:
    Should the input arguments be the same as the default callbacks (e.g. SysCallback_abort)?

    Yes

    Leonardo Gabrielli1 said:
    Can the Report function be used inside these or should I use a more low level UART approach to write strings out?

    Report() can be called.

  • Ok, the approach is clear, however I'm looking in a way to retain all the SysMin function except Abort. I tried this approach:

    SysCallback.exitFxn = "&SysMin_exit";

    SysCallback.putchFxn = "&SysMin_putch";

    and so on... but SysMin is unknown to the cfg file at this point so it does not link well.

    Copying and pasting each one of the SysMin functions to custom defined functions seems ugly, as I lose future releases in XDC and I have to manually include a lot of stuff. Is there a prettier solution?

  • Another important thing: in void my_UARTAbort(CString str) the "str" is a line that is not very meaningful, e.g. if normally an invalid free prints out these lines:

    ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0x2003339c, size=1178
    ti.sysbios.heaps.HeapMem: line 371: assertion failure: A_invalidFree: Invalid free
    xdc.runtime.Error.raise: terminating execution

    With my_UARTAbort the string "str" contains only:
    xdc.runtime.Error.raise: terminating execution

    which does not explain the reason for the crash.
    How can I get the other two lines?
  • I even collected a memory dump after the crash, looked into the memory and could not find the string I was looking for:
    ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0x2003339c, size=1178
    ti.sysbios.heaps.HeapMem: line 371: assertion failure: A_invalidFree: Invalid free
    I only found the:
    xdc.runtime.Error.raise: terminating execution
    at the expected location. This means that probably without SysMin the useful string is not created at all?
  • Leonardo,

    Try this configuration:

    var System = xdc.useModule('xdc.runtime.System');
    var SysMin = xdc.useModule('xdc.runtime.SysMin');
    var SysCallback = xdc.useModule('xdc.runtime.SysCallback');
    
    SysCallback.exitFxn = "&xdc_runtime_SysMin_exit__E";  /* This is the generated symbol for SysMin_exit */
    SysCallback.putchFxn = "&my_UARTPutch";
    SysCallback.abortFxn = "&my_UARTAbort";

    The messages that were not printed would have been in the SysMin buffer as it didn't get flushed (generally flushed in abort fxn). Even if it is flushed, the output will printed to console I/O. To redirect those messages to UART, you will have to define my_UARTPutch and plug it to SysCallback.putchFxn. This function will be passed character at a time which has to be outputted through UART.

    Vikram

  • Thank you, I was able to do exactly what was required.

    REgards