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.

PROCESSOR-SDK-C6748: Logging statements in PDK drivers using UIA

Part Number: PROCESSOR-SDK-C6748
Other Parts Discussed in Thread: OMAPL138, SYSBIOS

I would like to display the log statements that are found in the PDK drivers.  As just one of the many examples, in I2C_v0.c:

I2C_drv_log1("\n I2C: Object created 0x%x \n", hwAttrs->baseAddr);

I2C_drv_log.h contains the following:

#ifdef CIO_DRV_CONSOLE
#define I2C_drv_log            printf
#define I2C_drv_log1           printf
#define I2C_drv_log2           printf
#define I2C_drv_log3           printf
#else
#define I2C_drv_log(x)
#define I2C_drv_log1(x,y)
#define I2C_drv_log2(x,y,z)
#define I2C_drv_log3(x,y,z,l)
#endif

Which can be configured to route these to "printf", and also something else.  It looks to me like the second set of #define's is missing something?  I would like to use the UIA instrumentation package, but I don't understand what to do at this point.  I have tried to include the UIA Log_info0() function in this header, but I am then not sure how to (re)build the driver with the correct XDC paths.  The following does NOT work as an edit to I2C_drv_log.h:

#include <xdc/runtime/Log.h>
#include <xdc/runtime/Diags.h>
…
#define I2C_drv_log(x)      Log_info0(x)

Note, that I am able to use the UIA Log_info0() and Log_print0() functions successfully in my custom code, otherwise.  I am so far not able to get the instrumentation that exists in the PDK drivers working, however.  For reference, my logging cfg:

/* Load the Unified Instrumentation Architecture */
var LoggingSetup = xdc.useModule('ti.uia.sysbios.LoggingSetup');
	LoggingSetup.loggerType = LoggingSetup.LoggerType_JTAGRUNMODE;
var Diags = xdc.useModule('xdc.runtime.Diags');
var Load = xdc.useModule('ti.sysbios.utils.Load');
	Task.common$.diags_USER1 = Diags.ALWAYS_OFF;
	Task.common$.diags_USER2 = Diags.ALWAYS_OFF;
	Main.common$.diags_USER1 = Diags.ALWAYS_ON;
	Main.common$.diags_USER2 = Diags.ALWAYS_ON;

CCS Version: 9.2.0.00013

pdk_omapl138_1_0_10

  • Hi Jason,

    Which example are you trying to run?

    As for the printf, you need to include the standard headers (should be supported by the compiler) and your messages should appear in CCS console. You could also use System_print() function to print debug messages on CCS console.

    Best Regards,
    Yordan

  • Hi Yordan,

    Thanks for the response.  I am not running any of the examples.  I am using the PDK drivers, as built from TI, with my own code and board otherwise.  To clarify, this question is to find out what I need to successfully compile and view the logging messages that exist in the TI PDK drivers (I2C, for example).

    I actually do have system_printf() and the UIA module working in my main and other custom code.  I have so far been using system_printf() successfully, but I would like to avoid the overhead of that.  (In any case, I actually run into an issue when trying to use it within the PDK drivers).


    As far as I can tell, one of my fundamental questions is (perhaps) how to rebuild a driver with my own edits AND include the proper compile paths for the additional XDC header files, when rebuilding with gmake.  Whether I decide to use system_printf() or tie in the UIA Log_info0() and Log_print0() functions into the PDK drivers, should I be editing I2C_drv_log.h?  Or there is something fundamental (and perhaps simple) that I am not understanding in my configuration or otherwise to enable the logging statements in the PDK drivers?

    Maybe I could start off with this question; could you help me to successfully view the I2C_drv_log1() statements in the I2C driver?  Are edits to the PDK driver required to do so?

  • To get that I2C_drv_log, the simplest way would be to add the -DCIO_DRV_CONSOLE to the CFLAGS in the makefile rules_674.mk under the path pdk_omapl138_1_x_x\packages\ti\build\makerules. Then build the I2C driver using

    cd pdk_omapl138_1_x_x\packages

    gmake -j4 i2c 

    Then recompile the application to see the output using CCS Console where the printf will be redirected to. The drivering logging was create to work with standard printf or using UART_printf and should also work with System_printf in SYSBIOS. I am not sure if this has been tested with Log_info as that is not something that we typically use for debugging.

    Please look at the following article to enable logging using UIA in the SYSBIOS configuration:

    http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/index_how_to_guides.html#logging-and-trace

    For System_printf based debug logging, you can look at http://dev.ti.com/tirex/content/simplelink_academy_cc13x2sdk_2_10_02_10/modules/debug/debugging_output/debugging_output.html#system_printf

    This does require you to update tI2C_drv_log.h to update the defines in the #else for the driver to use this mechanism from the RTOS application .

  • Hi Rahul,

    Thanks for the help!  Could you provide some context (or documentation), on what is occurring when adding -DCIO_DRV_CONSOLE?  Is this bringing in supporting code for printf() to route to the console?  Is it needed for system_printf(), as well?  In fact, what are the differences between the two functions in this context?

    To clarify, should -DCIO_DRV_CONSOLE be added here (line 100 of rules_674.mk):

    CFLAGS_INTERNAL = -mv6740 $(CSWITCH_FORMAT) -q -mi10 -mo -pden -pds=238 -pds=880 -pds1110 --program_level_compile -g --endian=$(ENDIAN) -eo.$(OBJEXT) -ea.$(ASMEXT)  -DCIO_DRV_CONSOLE

    Finally, if you have a chance, could you help me to better understand what would be required to #include the UIA functions in the driver (such as the following), specifically, what is the proper way to provide the proper path to XDC and UIA modules when rebuilding the driver... does that require a change in a makefile or rulesfile somewhere?

    #include <xdc/runtime/Log.h>
    
    #include <xdc/runtime/Diags.h>
    
    …
    
    #define I2C_drv_log(x)      Log_info0(x)
    

    I'm afraid I might be missing some significant larger context in regards to rebuilding the drivers.  Hopefully you could point me in the right direction :)

    Thanks again for your help, Rahul!

    -Jason

  • I got it working.  To follow up on any open questions above, and to update with some additional things one needs to get this working...

    -  That was the correct place to add -DCIO_DRV_CONSOLE.  However, I did find that re-compiling from there didn't change anything.  I ended up having to make (any) change to  I2C_drv_log.h, I assume to trigger the compiler to recognize the update and rebuild.

    -  For the I2C driver to use printf(), you need to #include <stdio.h> in  I2C_drv_log.h.

    -  printf() calls are in the I2C driver, but you need to flush these to the console in your own code.  Use:

    System_flush(); //printf's to console

    I still don't know the difference between Printf() and  System_printf().  Maybe they route to the same thing in my case, but I haven't dug into that yet.

    -  The gmake option -DCIO_DRV_CONSOLE does the same thing as #include CIO_DRV_CONSOLE in C code  (it's a GNU compiler option -D, so for that I just needed to learn me some GNU)

    -  I still don't know how to give the command line GNU compiler additional path's (in case I wanted to use the  Log_info() w/ #include <xdc/runtime/Log.h> in the I2C driver), but maybe it can be done in the "makefile rules_674.mk under the path pdk_omapl138_1_x_x\packages\ti\build\makerules", as mentioned.  This is probably basic compiler stuff that I haven't gotten into yet, maybe someone could point me towards their favorite source of documentation.

    -Jason

  • Thanks for the update Jason. Glad to know you have the UIA setup working on C6748 with Processor SDK RTOS driver setup.