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.

Can I map initialized global variables to L1DSRAM/L2SRAM area?

Other Parts Discussed in Thread: SYSBIOS

Hi Champ,

I'm using C6742 with SYS/BIOS, and configure L1DSRAM 16kB and L2SRAM 128kB.
So, is it allowed to map initialized global variables to these areas?

Thank you very much in advance.

Best regards,
j-breeze

  • Sure, you can use cmd file to allocate the global variable to any available space.

    Before the allocation, you may need the #pragma DATA_SECTION() to declare the sections to locate the global variables.

    BR

  • touse-san,

    Thank you for your prompt reply, and I'd like to ask you a little bit more.

    I configured L1DSRAM and L2SRAM using BIOS configuration tool and checked the initialization sequence as follows:

      1)  Load and run the program
      2)  Occur a break at a point where "initialized global variables" are initialized (use hardware breakpoint)
              -> The initialization completed
      3)  Call XDStools "runtime_startup_startMod_I" function
      4)  Call SYS/BIOS "ti_sysbios_family_c64p_cache_module_startup_E" function
      5)  Occur  a break at a point where L1DCFG and L2CFG registers are accessed  (use hardware breakpoint)

    In the above sequence, L1DSRAM and L2SRAM configuration is done after "initialized global variables" initialization.
    I wonder if there is any effects on the  initialization.

    Actually I saw sometimes that the "initialized global variables" are changed after 5) L1DCFG and L2CFG registers access when I increase or decrease the number of  variables.
     
    Any information or considerations would be appreciated.

    Best regards,
    j-breeze

  • j-breeze,

    The state of the device after reset is L1D 32KB Cache and L2 0KB Cache.  If you want some of L1D to be RAM, you can do that with some caution.
    The call sequence you stated above is correct.  This could be a problem,  namely, the L1D is not changed from Cache to RAM until the Cache startup function is called.
    This could mean that some portions of L1D that you initialized as RAM could have been used as Cache and trashed your RAM data.

    I do think there's a hole here which needs to be addressed by SYSBIOS.  For now what you can do do minimize this is the following:

    In your *.cfg file:

    var Reset = xdc.useModule('xdc.runtime.Reset');
    Reset.fxns[Reset.fxns.length++] = "&nameYourFxn";

    Then in your *.c file:

    #include <ti/sysbios/family/c64p/Cache.h>

    Void nameYourFxn()
    {
        Cache_Size size;

        size.l1pSize = Cache_L1Size_32K;
        size.l1dSize = Cache_L1Size_16K;
        size.l2Size = Cache_L2Size_128K;

    This will call your fxn earlier in the sequence to change the cache sizes before the cinit processing.

    Judah

  • You forgot to apply the cache settings

    Void nameYourFxn()
    {
        Cache_Size size;

        size.l1pSize = Cache_L1Size_32K;
        size.l1dSize = Cache_L1Size_16K;
        size.l2Size = Cache_L2Size_128K;

        Cache_setSize(&size);

    ps: what does this mean (in bold font)?

    Reset.fxns[Reset.fxns.length++]

  • Judah-san, Nikolay-san,

    Thank you so much for your suggestions.
    I'will Chek it a.s.a.p.

    Best regards,
    j-breeze

  • Hi Judah-san,

    Could you please help me with building the code that you suggested before?

    I use SYS/BIOS v6.21.03.21 and C6000 CGTools v6.1.15. My code is the following:

      - *.cfg file

        var xdc_runtime_Startup = xdc.useModule('xdc.runtime.Startup');
        xdc_runtime_Startup.resetFxn = "&nameMyFxn";

      - *.c file

        #include <ti/sysbios/family/c64p/Cache.h>

        Void nameMyFxn()
        {
            Cache_Size size;

            size.l1pSize = Cache_L1Size_32K;
            size.l1dSize = Cache_L1Size_16K;
            size.l2Size = Cache_L2Size_128K;

            Cache_setSize(&size);
        } 

    Then, I built and got three error messages below.

        - identifier "Cache_L1Size_16K" is undefined
        - identifier "Cache_L1Size_32K" is undefined
        - identifier "Cache_L2Size_128K" is undefined

    I'd like to know what I shoud do.
    I'm sorry to bother you, but I'm beginner of bios6.

    Thanks in advance for your cooperation.

    Best regards,
    j-breeze 

  • Hi,

    I think you use a target or platform which this symbols undefined. 

    Try to use some others.

    Regards, Nikolay

  • j-breeze,
    can you post all #includes at the top of your file? There could be a problem there caused by the order of different includes. Can you also try to use ti_sysbios_family_c64p_Cache_L1Size_16K just to verify that the long names for constants still work?

    Thanks,
    Sasha

  • Nikolay-san,  Sasha-san,

    Thank you so much for your advices.
    I tried the other target, the order of different includes and the long name, but still got the same error messages.

    So, I'd like to post my c code, build options and tools I use. 
    Any suggestions and advices would be appreciated.

    - My c source code (based on "Hello Example" of RTSC configuration template)

        #include <xdc/std.h>
        #include <xdc/runtime/System.h>

        #include <ti/sysbios/family/c64p/Cache.h>

        Void CacheInitFxn()
        {
            Cache_Size size;

            size.l1pSize = Cache_L1Size_32K;
            size.l1dSize = Cache_L1Size_16K;
            size.l2Size = Cache_L2Size_128K;

            Cache_setSize(&size);
        }

        Void main()
        {
            System_printf("hello world\n");
        }

    - Additinal code to common.cfg

        var xdc_runtime_Startup = xdc.useModule('xdc.runtime.Startup');
        xdc_runtime_Startup.resetFxn = "&CacheInitFxn";

    - Copiler options

        -mv6740
        -g
        --include_path="<INST_DIR>/C6000 Code Generation Tools 6.1.15"
        --include_path="<INST_DIR>/bios_6_21_03_21/packages"
        --include_path="<INST_DIR>/xdctools_3_16_05_41/packages"
        --diag_warning=255

    - Linker options

        -z
        --warn_sections
        -i"<INST_DIR>/C6000 Code Generation Tools 6.1.15/lib"
        -i"<INST_DIR>/C6000 Code Generation Tools 6.1.15/include"
        --reread_libs
        --rom_model

    - XDCtools options

        --xdcpath="<INST_DIR>/bios_6_21_03_21/packages;"
        xdc.tools.configuro
        -o "configPkg"
        -t ti.targets.C674
        -p ti.platforms.evm6747
        -r whole_program_debug
        -c "<INST_DIR>/C6000 Code Generation Tools 6.1.15"

    - Using tools

        - CCS v4.1.3.00038
        - C6000 CGTools v6.1.15
        - SYS/BIOS v 6.21.03.21
        - XDC Tools v3.16.05.41

    Best regards,
    j-breeze

  • Can you try the following:
    - click on Project->Properties->CCS Build->C6000 Compiler->Parser Preprocessing Options.
    - set Mode to "manual" and turn on the last option "Preprocess only; maintain line directives", and rebuild your project
    - that will generate a file with the extension .pp in the top project directory. Please post that file.

    Then,
    - go to the same option window and turn off  "Preprocess only; maintain line directives"
    - in the box for the option "Generate list of pre- user-defined macros", type "../hello.ppm", and rebuild your project
    - that will generate a file hello.ppm in the top project directory. Please post that file too.

    Thanks,
    Sasha

  • Sasha-san,

    Thank you for your suggestions.

    I'd like to post the files nemed hello.pp(hello_pp.txt) and hello.ppm(hello_ppm.txt) below.
    Could you please check  them out?

    Thank you very much in advance for your cooperation.

    - hello.pp

        8446.hello_pp.txt

    - hello.ppm

        4527.hello_ppm.txt

    Best regards,
    j-breeze

  • j-breeze,
    at the bottom of the first file you posted, the lines that caused the errors are different from what's in your post:
    size.l1pSize = Cashe_L1Size_32K;
    size.l1dSize = Cashe_L1Size_16K;
    size.l2Size  = Cashe_L2Size_128K;

    You have Cache spelled as Cashe.

    Please verify that your code looks like this:

    size.l1pSize = Cache_L1Size_32K;
    size.l1dSize = Cache_L1Size_16K;
    size.l2Size  = Cache_L2Size_128K;

  • Sasha-san,

    I really must apologize for my careless mistakes in the spell.  And I thank you very much for  your kindly supoort.
    I verified and re-build my code, however I got another error message below.


      - In "Problems" tab

          unresolved symbol _ti_sysbios_family_c64p_Cache_setSize__E, first referenced in ./hello.obj

      - In "Console" tab

          <Linking>

            undefined                                                                    first referenced
               symbol                                                                            in file
            ---------------                                                                  -----------------
            _ti_sysbios_family_c64p_Cache_setSize__E    ./hello.obj

          error:  unresolved symbols remain
          error:  errors encountered during linking;


    I'm very sorry for the inconvenience which it might have caused in spending your time, but I'd like to post the hello.pp (hello.ppm was not generated).
    I would appreciate it if you could check it again.

      - hello.pp

          8814.hello_pp.txt

    Best regards,
    j-breeze

  • You are most likely missing a statement in your config script that includes a Cache module. Do you have
    xdc.useModule("ti.sysbios.hal.Cache");
    somewhere in your CFG script? If you don't try adding it and rebuilding.

    When you use a module in your C code, you have to declare in the CFG script that you are using it, and then the config will generate the required data and functions. It may look incorrect that you are using ti.sysbios.family.c64p.Cache in your C code and ti.sysbios.hal in your CFG script, but the reasoning behind it is that ti.sysbios.hal is a generic cache module that will load the correct cache module for your device, in this case ti.sysbios.family.c64p.Cache. By doing so, you won't need to change the config script if you switch to another device or architecture.