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.

How to configure assert messages in SYS/BIOS

Other Parts Discussed in Thread: CCSTUDIO, SYSBIOS

Hi everybody

I am trying to use assertion mechanism provided by xdc.runtime.Assert package.

XDC Help shows how to setup assert identifiers and corresponding messages :

HELP_START

The following example shows how to use and configure an assert ID that is declared by a module. It adds that assert to the application's C source code, and configures the application to execute the assert.
This is part of the XDC file for the module that declares an Assert Id:
  // Mod.xdc
  import xdc.runtime.Assert;
  import xdc.runtime.Diags;

  config Assert.Id A_nonZero = {
      msg: "A_nonZero: value must be non-zero"
  };
This is part of the C code for the application:
  // Mod.c
  #include <xdc/runtime/Assert.h>

  Assert_isTrue(x != 0, Mod_A_nonZero);
This is part of the XDC configuration file for the application:
  // program.cfg
  var Diags = xdc.useModule('xdc.runtime.Diags');
  var Mod = xdc.useModule('my.pkg.Mod');
  Mod.common$.diags_ASSERT = Diags.ALWAYS_ON;

HELP_END

I've created file named errmsg.xdc in project directory with following contents:

import xdc.runtime.Assert;
import xdc.runtime.Diags;

config Assert.Id A_nonZero = { msg: "A_nonZero: value must be non-zero" };
config Assert.Id A_noMemory = { msg: "A_noMemory: cannot allocate memory" };
config Assert.Id A_outOfRng = { msg: "A_outOfRng: value out of range" };

then inserted following Assert_isTrue() calls to my application code:

#include <xdc/runtime/Assert.h>

Assert_isTrue(now <= 1000, A_outOfRng);
Assert_isTrue(BepTaskEventDispatcher != NULL, A_noMemory);

and inserted following statement into app configuration file app.cfg

var ErrMsg = xdc.useModule('errmsg');

after building the project I got following errors:

Description    Resource    Path    Location    Type
#20 identifier "A_noMemory" is undefined    main.c    /BootRouter    line 66    C/C++ Problem
#20 identifier "A_outOfRng" is undefined    main.c    /BootRouter    line 27    C/C++ Problem
xdc.MODULE_NOT_FOUND: xdc.module: no module named 'errmsg' in the package xconfig_app    app.cfg    /BootRouter    Configuration Validation    XDCTools Configuration Marker
xdc.module: no module named 'errmsg' in the package configPkg    app.cfg    /BootRouter    19    C/C++ Problem

The questions are:
how to configure CCS project to use my own xdc file with assert messages definitions?
how to configure step-by-step Sys/bios based project to define assertions and associated error messages?

My SYS/BIOS configuration:
target: Cortex M-3
CCS version 5.2
SYS/BIOS: 6.33.5.46
XDC tools: 3.23.3.53
  • As the Asserts were defined in your  'errmsg' module, the names of the Asserts should be "errmsg_A_noMemory" and "errmsg_A_outOfRng". These symbol definitions should appear in the generated errmsg.h file which you'll need to include in your application's C file.

    The module not found error is probably due to the argument passed to xdc.useModule() not including the package path to the errmsg module. The directory containing the errmsg module is usually the package name. So something like xdc.useModule('mypackage.errmsg") will be required.

    Alan

  • Hi Alan

    Thanks for quick response, now I understand that xdc files must be processed by xdc engine to generate source files for use in target application. I focused on creating a package on basis of errmsg.xdc file contents. I used two ways:

    1. In project directory I found \.config\xconfig_app\ subfolder where, I guess, custom application configuration should be located, I tried to insert my code from errmsg.xdc file in \.config\xconfig_app\package.xdc file and inserted following line in app.cfg file

    var ErrMsg = xdc.useModule('xconfig_app.errmsg');

    but during project build I got 2 errors:

    Description    Resource    Path    Location    Type
    can't locate the package 'xconfig_app' along the path: 'C:/CCStudio_v5.0/bios_6_33_05_46/packages;C:/CCStudio_v5.0/ccsv5/ccs_base;C:/CCStudio_v5.0/xdctools_3_23_03_53/packages;..;'. Ensure that the package path is set correctly.    app.cfg    /BootRouter    19    C/C++ Problem
    xdc.MODULE_NOT_FOUND: xdc.module: no module named 'errmsg' in the package xconfig_app    app.cfg    /BootRouter    Configuration Validation    XDCTools Configuration Marker

    2. I created by own subfolder 'mycfg' in project directory and inserted there errmsg.xdc file and inserted following line in app.cfg file

    var ErrMsg = xdc.useModule('mycfg.errmsg');

    but this time I also got 2 errors during compilation:

    Description    Resource    Path    Location    Type
    can't locate the package 'mycfg' along the path: 'C:/CCStudio_v5.0/bios_6_33_05_46/packages;C:/CCStudio_v5.0/ccsv5/ccs_base;C:/CCStudio_v5.0/xdctools_3_23_03_53/packages;..;'. Ensure that the package path is set correctly.    app.cfg    /BootRouter    19    C/C++ Problem
    xdc.PACKAGE_NOT_FOUND: can't locate the package 'mycfg' along the path: 'C:/CCStudio_v5.0/bios_6_33_05_46/packages;C:/CCStudio_v5.0/ccsv5/ccs_base;D:/Projects/Components/BootRouter/.config/;C:\CCStudio_v5.0\xdctools_3_23_03_53\packages;'. Ensure that the package path is set correctly.    app.cfg    /BootRouter    Configuration Validation    XDCTools Configuration Marker

    It seems to me that \.config\xconfig_app\ subfolder and its contents was created to provide extra configuration to aplication but I found no word of explanation how to use it in CCS SYS/BIOS project - where can I find it?

    It would be very helpful to find information how xdc engine generates source files for compilation starting from creation and location of xdc files including syntax and available options and going to resulted source files with explanation of prefixes, directory names etc.

    Gregor

  • Gregor,

    I've asked a local CCS project expert about how to add a RTSC module to a CCS project. There seems to be some missing pieces.

    Alan

  • Very few people are brave enough to attempt to create their own RTSC module.

    Apparently it is possible to do this within CCS but there is a trick to it.

    I think the module has to be in its own CCS project and then referenced by your main application in another project.

    If you're willing, please share your module's Mod.* files and I'll see if I can make it work and then report back to you.

    Alan

  • Hi Alan - thanks for info about RTSC module.

    So it looks that configuration of assert messages in CCS project is not an easy thing to do and it requires some tricks and creation of own RTSC module.

    I think that the best solution for all developers reading this topic would be presentation of simple CCS project or solution using custom locally defined assert messages. Please use your contacts to CCS experts and ask them to prepare such example - it could be presented on TI wiki page to help people understand the mechanism of generation of library code or just be able to use full functionality of assertions provided with SYSBIOS.

    Please let me know if this is feasible

    with regards Gregor