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.

System_Printf() Messages Don't Show Up Until Execution Stops - CCS4

Other Parts Discussed in Thread: SYSBIOS, OMAP3530

I recently upgraded from CCS4.2.1 to CCS 4.2.3.  However, now, my system_printf() messages (in DSP code) dont appear in the console window until after a BIOS_exit() call.  For very quick test programs, this may be fine, but for something that I want to run for hours and show me some feedback every few minutes, this is a bit of a problem.  What must I do to get the output from system_printf() to appear reasonably quickly after the call is made in a program running under sysbios on the DSP of an OMAP3530 with a Blackhawk 560-bp 20-pin JTAG connector?

I have tried adding the line System_flush(); but all this does is cause the CCS4 debugger to generate the error message "ti.sysbios.gates.GateMutex: line 114: assertion failure: A_badContext: bad calling contet. See GateMutex API for details. xdc.runtime.Error.raise: terminating execution".

I am using a Blackhawk 560-BP 20-pin JTAG pod to talk to the DSP on an OMAP 3530.

  • Hi Ed,

    Are you making System_printf calls from Hwis or Swis? If you are not, you can use SysStd. The following three lines in your .cfg will make the change (and deleted the SysMin ones).

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

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

        System.SupportProxy = SysStd;

    Todd

  • I'm using the clock example code that can be chosen under Sys Bios as an example when you create a project.  I did not create this code.  It's the built-in example code.  The System_printf() calls are within the clk0Fxn() routine that is called as a result of a system timer going off.  I added the lines you mention, above, to the bottom of the clock.cfg file, and commented out my calls to System_flush() in the clock.c file, but I still get the same error message, "ti.sysbios.gates.GateMutex: line 114: assertion failure: A_badContext: bad calling contet. See GateMutex API for details. xdc.runtime.Error.raise: terminating execution" when I run the code in debug mode in CCS4.

  • Which version of SYS/BIOS are you using?

  • I'm running Code Composer Studio 4.2.3.0004.  I downloaded and installed it LAST WEEK. It's using sys bios 6_32_04_07.

     

  • Ed --

    I recommend using SysMin.

    Note that System_flush() internally calls C runtime library code that needs a mutex.   So, you need to make sure that your call to System_flush() is done from Task level.  You can create a Task that simply has a loop like this:

     

    for (;;) { 
        System_flush();
        Task_sleep(1000);  /* 1 second if 1ms tick */
    }

    You can also use the ROV tool (available from Tools->ROV menu) to look at SysMin buffer for every breakpoint.

    Please send BIOS version and your updated .cfg and .c files.

    -Karl-

  • The ROV tool view DOES NOT WORK! Under ROV, one can click on SysMin and then the tab Output Buffer and even click the little yellow "refresh" icon while the DSP program is running, but nothing appears in the windows except the little "task running" icon until the DSP target is either halted due to a breakpoint or it calls BIOS_exit().

     

  • In this clock example, where would I place that call to System_flush()?

  • And what header file do I need to include in order to get Task_sleep().  I tried adding "#include <ti/sysbios/knl/Task.h>" but I received dozens of error messages about symbols being redefined, whenever I have a call to Task_sleep() included anywhere in the clock.c file.

    I have ATTEMPTED TO attached the clock.c and clock.cfg files.  This clock.cfg file is the unedited file directly from the example.  The clock.c file is from the example, but I have lengthened the timers a bit so that it is obvious that the System_printf()s don't display until after the terminating call to the bios.  i WAS NOT ABLE TO ATTACH THE FILES.  HERE IS THE ERROR I GET FROM YOUR ATTACH FILES TOOL when I attempt to attach either the clock.c or clock.cfg file:

     

    Strangely enough, I was able to attach the image of the error message!

    How would you suggest that I upload the clock.c and clock.cfg files to you?  You can get them directly from the example in CCS4.  The only change I made was to add three zeros to the  time values for the periodic timer and the one-shot.

     

  • Ed Boakes said:

    I'm running Code Composer Studio 4.2.3.0004.  I downloaded and installed it LAST WEEK. It's using sys bios 6_32_04_07.

    This version doesn't match any BIOS releases.  Can you please confirm your BIOS version?  Also, which device are you running on?

    You can zip up the 2 files and attach as a .zip.  The attach tool allows .zip files.  Not sure why it filters others.

    The latest version of the examples use SysMin by default.   The problem with the Clock example is that it doesn't have any easy place to put this call to System_flush().  System_flush() calls into the RTS library and need to acquire a mutex which is not allowed from Thread level.

    I've attached updated clock.c and clock.cfg files where I added a Task that calls System_flush() every second.

    2818.clock-with-flush.zip

    -Karl-

  • Karl,

    Thanks for these files.  This certainly improves things.  

    The BIOS version is 6_31_04_07.  Sorry, but I mis-typed the "31" in my previous posting.  

    What's particularly frustrating, is that when I had had CCS 4.2.1 installed, the clock example's System_printf()s did appear very shortly after calling them.  No System_flush() or BIOS_exit() was necessary.  Due to a different issue, I updated to CCS 4.2.3.  Since the updating process produced a lengthy list of error and warning messages, I removed the entirety of all TI tools on my PC, then downloaded (on May 11, 2011) and installed CCS4.  Would you happen to know what changed in the BIOS?  Aside from again deleting my entire CCS4 and all associated tools and re-installing from my January 4, 2011 download, how would I restore the earlier behavior?

    Ed

  • Hi Ed --

    I think you mean 6.31.04.27 (not 07).  But that helps.

    There have been  2 changes since the BIOS 6.x that was provide in CCS 4.2.1.

    (1)  The examples from earlier version of BIOS were using SysStd instead of SysMin.

    (2)  The lock function that we register with the RTS library (SysStd uses putchar and requires a lock), did not have an Assert check to validate the calling context.

    The old examples were incorrectly using SysStd from Hwi and Swi level.  The calls into the RTS library were not thread safe.  And it was possible for the code to break if the lock was held by some other thread in your system that was calling into the RTS library.   If a task was calling printf() and preempted by a Swi or Hwi that called printf() (or SysStd which calls putch which needs same lock), then the Swi would call Semaphore_pend on a semphore with count of 0.  And we'd attempt to block (suspend) the ISR thread which is not allowed.    This was bad.

    System_flush() has the same limitations.  It calls into the RTS library and aquires the same lock.

    (a)  You can get back close to your prior behavior by disabling the use of the GateMutex (semaphore-based) lock within the RTS library and using no lock.   This means that the RTS calls will not be thread safe.

    System = xdc.useModule('xdc.runtime.System');
    SysStd = xdc.useModule('xdc.runtime.SysStd');
    System.SupportProxy = SysStd;

    BIOS = xdc.useModule('ti.sysbios.BIOS');
    BIOS.rtsLock = BIOS.NoLocking;

     

    (b) A better approach would be to use a Swi-based lock which will disable Swi scheduler within the RTS calls.   This is safe, but adds scheduling latency for higher priority threads, since the Swi scheduler will be disabled while in the critical sections within the RTS/CIO code.

    System = xdc.useModule('xdc.runtime.System');
    SysStd = xdc.useModule('xdc.runtime.SysStd');
    System.SupportProxy = SysStd;

    BIOS = xdc.useModule('ti.sysbios.BIOS');
    BIOS.rtsLock = BIOS.GateSwi;

     

    BTW, not sure if you know this, but the C io feature that sits below SysStd, and SysMin_flush() relies on a hidden breakpoint in the CCS environment.  So, all of the I/O is done with a hidden target breakpoint.   Using SysMin and ROV (which can only be used when target is halted) avoids this hard-to manage breakpoint.

    -Karl-