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.

RTOS/BEAGLEBK: Debug Log Messages

Part Number: BEAGLEBK

Tool/software: TI-RTOS

Hi,

I am using the following product:

NDK 3.40.1.01

I see that in the source code of NDK, there is a use of DbgPrintf command to print a message to the global debug log buffer. I wish to use this function to print debug warnings and errors. But how can I access these printf statements? Where is the debug log recorded? How can I see this record?

Regards

Vishav

  • Hi,

    Searching NDK source code:

    void DbgPrintf(uint32_t Level, char *fmt, ... ){
    ....
    if( Level >= DBG_PRINT_LEVEL ) ======> you have print
    }

    Where Level can be:
    #define DBG_INFO 1
    #define DBG_WARN 2
    #define DBG_ERROR 3
    #define DBG_NONE 4

    Now, what is the DBG_PRINT_LEVEL ?
    It is #define DBG_PRINT_LEVEL (_oscfg.DbgPrintLevel)

    What is _oscfg.DbgPrintLevel?
    It is OSENVCFG _oscfg = { DEF_DBG_PRINT_LEVEL, DEF_DBG_ABORT_LEVEL,

    What is DEF_DBG_PRINT_LEVEL?
    It is #define DEF_DBG_PRINT_LEVEL DBG_INFO

    What is DBG_INFO?
    It is #define DBG_INFO 1

    Given 4, 3, 2, 1 >= 1. There should not be any issue to print info from NDK.

    From my own experience of using NDK 3.40.1.01, I had "TcpTimeoutRexmt: Retransmit Timeout" printed from time to time on my CCS CIO console when I had some network problem to debug. This is from DbgPrintf(DBG_INFO,"TcpTimeoutRexmt: Retransmit Timeout"); I don't need to change anything in NDK for that printing to happen.

    Regards, Eric
  • Thanks for the detailed information. In my configurations I set the debug print level to DBG_WARN. If I try to call DbgPrintf with DBG_WARN level, my application crashes. On further debugging, I found out that system is crashing at the System_printf call. I guess it is related to my .cfg file. I referred to this post () which says about allocating adequate heap memory.   I have set heap size of 0x3000. Is it adequate?

    Here is how my config file looks like:

    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    var Diags = xdc.useModule('xdc.runtime.Diags');
    var Error = xdc.useModule('xdc.runtime.Error');
    var Log = xdc.useModule('xdc.runtime.Log');
    var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
    var Main = xdc.useModule('xdc.runtime.Main');
    var Memory = xdc.useModule('xdc.runtime.Memory')
    var SysMin = xdc.useModule('xdc.runtime.SysMin');
    var System = xdc.useModule('xdc.runtime.System');
    var Text = xdc.useModule('xdc.runtime.Text');
    
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    var Clock = xdc.useModule('ti.sysbios.knl.Clock');
    var Swi = xdc.useModule('ti.sysbios.knl.Swi');
    var Task = xdc.useModule('ti.sysbios.knl.Task');
    var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
    var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
    
    /*
     * Uncomment this line to globally disable Asserts.
     * All modules inherit the default from the 'Defaults' module.  You
     * can override these defaults on a per-module basis using Module.common$. 
     * Disabling Asserts will save code space and improve runtime performance.
    Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
     */
    var socType           = "am335x";
    var devType           = "am335x";
    /*use CSL package*/
    var Csl = xdc.loadPackage('ti.csl');
    Csl.Settings.deviceType = socType;
    
    /* Load the board package */
    var Board = xdc.loadPackage('ti.board');
    Board.Settings.boardName = "bbbAM335x";
    /* Load the OSAL package */
    var osType = "tirtos"
    var Osal = xdc.useModule('ti.osal.Settings');
    Osal.osType = osType;
    
    /* Load the EMAC package */
    var Emac = xdc.loadPackage('ti.drv.emac');
    Emac.Settings.socType = socType;
    //Emac.Settings.enableProfiling = false;
    
    /* Load the uart package */
    var I2cPackage = xdc.loadPackage('ti.drv.i2c');
    
    /* Load the uart package */
    var GpioPackage = xdc.loadPackage('ti.drv.gpio');
    
    /* Load the UART package */
    var UART = xdc.loadPackage('ti.drv.uart');    
    UART.Settings.socType = devType;  
    
    
    
    
    
    /* Load the NIMU package */
    var Nimu 		= xdc.loadPackage('ti.transport.ndk.nimu');
    Nimu.Settings.socType  = socType;
    
    /*
    ** Use this load to configure NDK 2.2 and above using RTSC. In previous versions of
    ** the NDK RTSC configuration was not supported and you should comment this out.
    */
    var Ndk       = xdc.loadPackage('ti.ndk.config');
    var Global       = xdc.useModule('ti.ndk.config.Global');
    
    /* 
    ** This allows the heart beat (poll function) to be created but does not generate the stack threads 
    **
    ** Look in the cdoc (help files) to see what CfgAddEntry items can be configured. We tell it NOT
    ** to create any stack threads (services) as we configure those ourselves in our Main Task
    ** thread hpdspuaStart.
    */  
    Global.enableCodeGeneration = false;
    Global.IPv6 = false;
    /* No runtime stack checking is performed */
    Task.checkStackFlag = false;
    
    /*
     * Program.argSize sets the size of the .args section.
     * The examples don't use command line args so argSize is set to 0.
     */
    Program.argSize = 0x0;
    /*
     * Uncomment this line to keep module names from being loaded on the target.
     * The module name strings are placed in the .const section. Setting this
     * parameter to false will save space in the .const section.  Error and
     * Assert messages will contain an "unknown module" prefix instead
     * of the actual module name.
    Defaults.common$.namedModule = false;
     */
    
    /*
     * Minimize exit handler array in System.  The System module includes
     * an array of functions that are registered with System_atexit() to be
     * called by System_exit().
     */
    System.maxAtexitHandlers = 4;       
    
    /* 
     * Uncomment this line to disable the Error print function.  
     * We lose error information when this is disabled since the errors are
     * not printed.  Disabling the raiseHook will save some code space if
     * your app is not using System_printf() since the Error_print() function
     * calls System_printf().
    Error.raiseHook = null;
     */
    
    /* 
     * Uncomment this line to keep Error, Assert, and Log strings from being
     * loaded on the target.  These strings are placed in the .const section.
     * Setting this parameter to false will save space in the .const section.
     * Error, Assert and Log message will print raw ids and args instead of
     * a formatted message.
    Text.isLoaded = false;
     */
    
    /*
     * Uncomment this line to disable the output of characters by SysMin
     * when the program exits.  SysMin writes characters to a circular buffer.
     * This buffer can be viewed using the SysMin Output view in ROV.
    SysMin.flushAtExit = false;
     */
    
    /*
     * The BIOS module will create the default heap for the system.
     * Specify the size of this default heap.
     */
    BIOS.heapSize = 0x3000;
    
    /*
     * Build a custom SYS/BIOS library from sources.
     */
    BIOS.libType = BIOS.LibType_Custom;
    
    /* System stack size (used by ISRs and Swis) */
    Program.stack = 0x4000;
    
    /* Circular buffer size for System_printf() */
    SysMin.bufSize = 0x400;
    
    /* ================ Cache and MMU configuration ================ */
    
    var Cache = xdc.useModule('ti.sysbios.family.arm.a8.Cache');
    Cache.enableCache = true; 
    
    var Mmu = xdc.useModule('ti.sysbios.family.arm.a8.Mmu');
    Mmu.enableMMU = true;
    
    /* Force peripheral section to be NON cacheable strongly-ordered memory */
    var peripheralAttrs = {
        type : Mmu.FirstLevelDesc_SECTION, // SECTION descriptor
        tex: 0,
        bufferable : false,                // bufferable
        cacheable  : false,                // cacheable
        shareable  : false,                // shareable
        noexecute  : true,                 // not executable
    };
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x40300000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x44e00000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x48000000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x48100000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x48200000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x48300000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x49000000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x4a100000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    
    
    /* Define the base address of the 1 Meg page the peripheral resides in. */
    var peripheralBaseAddr = 0x4a300000;
    
    /* Configure the corresponding MMU page descriptor accordingly */
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr,
                              peripheralBaseAddr,
                              peripheralAttrs);
    /* 
     * Create and install logger for the whole system
     */
    var loggerBufParams = new LoggerBuf.Params();
    loggerBufParams.numEntries = 16;
    var logger0 = LoggerBuf.create(loggerBufParams);
    Defaults.common$.logger = logger0;
    Main.common$.diags_INFO = Diags.ALWAYS_ON;
    
    System.SupportProxy = SysMin;
    
    /* Required if using System_printf to output on the console */
    SysStd          		=   xdc.useModule('xdc.runtime.SysStd');
    System.SupportProxy     =   SysStd;
    
    /********************************************************************************************************************
    * Define hooks and static tasks  that will always be running.               										*
     ********************************************************************************************************************/
    
    /* 
    ** Create the stack Thread Task for our application.
    */
    var tskNdkStackTest  		=   Task.create("&StackTest");
    tskNdkStackTest.stackSize  	= 	0x5000;
    tskNdkStackTest.priority    = 	0x5;
    
    /* Enable BIOS Task Scheduler */
    BIOS.taskEnabled			=   true;

  • Hi,

    I compared the .cfg files of my project and an empty new project. I found out that I was using SysStd module. When I removed it from my config file, I could call system_printf(). May I know what is this module for? I might have used it based on an example project.

    Regards
    Vishav
  • Hi,

    See the explanation of SysStd and SysMin: rtsc.eclipse.org/.../Using_xdc.runtime_System

    Regards, Eric