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.

LAUNCHXL-CC26X2R1: syscfg

Part Number: LAUNCHXL-CC26X2R1
Other Parts Discussed in Thread: SYSCONFIG

Is there a way to add conditional statements in syscfg file?

Something like:

#if defined DEBUG

XYZ.addr = 0x1000

#else

XYZ.addr = 0x5000

#endif

  • Hi Manoj,

    It is possible to add conditional statements when modifying SysConfig files inside of a text editor.  Here is an openthread example and my own rudimentary example:

    if(0) gpio.$name = "CONFIG_GPIO_LED_0";
    else gpio.$name = "CONFIG_GPIO_LED_HI";

    Where simply changing 0 to 1 causes the GPIO name to change from CONFIG_GPIO_LED_HI to CONFIG_GPIO_LED_0.

    Regards,
    Ryan

  • Thanks Ryan.
    I tried something similar:

    if(DEBUG)

    XYZ.addr = 0x1000

    else

    XYZ.addr = 0x5000

    But, getting error:

    ReferenceError: DEBUG is not defined
    at scriptFunc.....

    DEBUG is a predefined symbol. 

  • You've likely defined DEBUG as a pre-defined Compiler symbol, however SysConfig is run before the Compiler builds the project.  As the SysConfig environment does not expect pre-defines, you can set a constant value directly in the file instead:

    // @cliArgs --board /ti/boards/CC26X2R1_LAUNCHXL --rtos tirtos7
    
    const DEBUG = 0;
    
    /*
     *  empty.syscfg
     */
    var Power = scripting.addModule("/ti/drivers/Power");
    
    /* ======== Kernel Configuration ======== */
    system.getScript("kernel_config_release.syscfg.js");
    
    /* ======== GPIO ======== */
    var GPIO = scripting.addModule("/ti/drivers/GPIO");
    var gpio = GPIO.addInstance();
    gpio.$hardware = system.deviceData.board.components.LED0;
    if(DEBUG==0) gpio.$name = "CONFIG_GPIO_LED_0";
    else gpio.$name = "CONFIG_GPIO_LED_HI";

    Regards,
    Ryan

  • Thanks Ryan. 
    Yes, DEBUG is a predefined compiler symbol. 

    My intention is to combine two projects (and it's sysconfig files). And the only difference between the two is the symbol DEBUG. And syscfg files have some specific lines for each project, which I thought could be executed separately based on this symbol. 

    If I set the value as a constant in the file itself, then it defeats the purpose of the if-else running dynamically based on the build configuration. 

  • Would you consider using two different build configurations?  That way each can have a different SysConfig file version based on the active build configuration selected.

    Regards,
    Ryan

  • Yes, It seems like thats the option I have to choose. 
    I wanted to combine syscfg also since the difference is only couple of lines.

    Thanks

  • Hi Manoj,

    The best solution after speaking with the SysConfig Development Team is to add a scriptArgs flag to Project Properties -> CCS Build -> SysConfig -> Miscellaneous:

    --scriptArgs DEBUG

    The resultant SysConfig code configuration would appear as such:

    // @cliArgs --board /ti/boards/CC26X2R1_LAUNCHXL --rtos tirtos7
    
    console.log(argv);
    
    /*
     *  empty.syscfg
     */
    var Power = scripting.addModule("/ti/drivers/Power");
    
    /* ======== Kernel Configuration ======== */
    system.getScript("kernel_config_release.syscfg.js");
    
    /* ======== GPIO ======== */
    var GPIO = scripting.addModule("/ti/drivers/GPIO");
    var gpio = GPIO.addInstance();
    gpio.$hardware = system.deviceData.board.components.LED0;
    if(argv[1]==="DEBUG") gpio.$name = "CONFIG_GPIO_LED_0";
    else gpio.$name = "CONFIG_GPIO_LED_HI";

    Regards,
    Ryan

  • Thanks Ryan. Will look at this option.