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.

IPC - SharedRegion

Other Parts Discussed in Thread: TMS320TCI6618

Hi,

Is it possible to use the SharedRegion section, documented in the IPC user guide on page 3-41, in a "raw" mode, withouth any other module such as ListMP or MessageQ module?

I ask this because I want to put a variable in a memory location inside the shared region.

I declared in the .cfg file a SR0 like

var SHAREDMEM           = 0x83000000;
var SHAREDMEMSIZE       = 0x00600000;

var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');

SharedRegion.numEntries = 2;  //each entry is a region of shared mem, I need only 1 for now (nr. 0)
SharedRegion.translate = false;

SharedRegion.setEntryMeta(0,
    { base: SHAREDMEM,
      len:  SHAREDMEMSIZE,
      ownerProcId: 0,
      isValid: true,
      createHeap: false,
      name: "DDR2",
    });

Now I want to put a variable in this section of memory... maybe using the #pragma DATA_SECTION () or something else. Is it possible?

P.S: wahat is the difference between a SR with createHeap: false and one with createHeap: true ?

thanks, Luca

  • It is very possible to "make a shared region" -- in fact, that's what the restriction on SharedRegion is: that it needs to be in shared memory.

    I can't remember which device you are using, but any external memory (DDR) should be shared memory. If you're using a C667x, then there should also be shared MSMCSRAM.  However, these regions are cached by default, so if you are going to do data sharing, then you must program in your own cache coherence using writebacks and invalidations.

    The method to place a variable in shared memory is that once you know the label of your memory (such as on the RTSC platform or in the MEMORY section of the linker file), you can declare a new label that you can use in your program with the #pragma DATA_SECTION so if your platform has a region called "DDR2" (note, this actually isn't the "name" in your example for the SharedRegion unless it happens to be the same as what you've defined in your memory map), then creation of a label handle you could use is:

     

    In your .cfg:

    Program.sectMap["myDDR2"] = "DDR2";

     

    In your code:

     

    int globalData[1024];

    #pragma DATA_SECTION(globalData, "myDDR2")

     

    And the variable you use needs to be in the global scope (it will still be placed in memory where it is specified, but it's "global" in the compiler sense of the term)

     

    And if I recall correctly, then SharedRegion's createHeap=true goes ahead and takes the entire memory region (minus upkeep) and turns it into a HeapMemMP. When createHeap=false, you can manage it yourself.

     

    I hope you have fun with the #pragma DATA_SECTION, I myself love it. It's very useful for keeping things in local SRAM too rather than depending on cache (but that depends on your device).

  • Thanks for the answer Tim .

    But in this way I put the variable in DDR2 memory (as defined in the linker file), not in the region of memory that I define in SharedRegion.setEntryMeta( ).

    In my lcf file there is:

    MEMORY
    {
    L2SRAM             : origin = 0x10800000 len = 0x100000
    DDR2               : origin = 0x80000000 len = 0x10000000
    }

    and if I use #pragma like:

    Tim Wentz said:

    Program.sectMap["myDDR2"] = "DDR2";

    In your code:

    int globalData[1024];

    #pragma DATA_SECTION(globalData, "myDDR2")

    globalData[ ] is @ 0x80000000.

    But I want that globalData[ ] was @ 0x83000000, namely in SharedRegion0.

    Thanks.

  • A solution would be to just make it a new region.  Those MEMORY segments don't actually have to be named anything in particular, it's just the addresses that are important.

     

    MEMORY
    {
    L2SRAM             : origin = 0x10800000 len = 0x100000 
    DDR2               : origin = 0x80000000 len = 0x03000000 
    SHARED_DATA    :origin = 0x83000000 len = 0x0D000000
    }

    SECTIONS
    {
    mySHARED > SHARED_DATA

     

    Unfortunately with this solution, you're restricting the sizes, but you'd probably end up having to do that at some level anyway.  If you really need that 1 segment at anon-start / non-end location, but you need a region that spans the entire region minus the part in the middle -- then I'm not even sure how that'd make sense from a requirement point of view, but I think there are some linking techniques that can provide splitting a region across multiple MEMORY sections.

     

    A messier cheat would be to align your variable to that size.  It would probably work for one variable, but if you want to place multiple variables in exact locations using that technique, you'd probably find it difficult.

     

    int globalData[1024];
    #pragma DATA_SECTION(globalData, "myDDR2") // if myDDR2 starts at 0x80000000, not the memory map shown above
    #pragma DATA_ALIGN(globalData, 0x83000000) // or maybe try just 0x3000000. but I haven't tested either
     

  • Tim Wentz said:

    A solution would be to just make it a new region.  Those MEMORY segments don't actually have to be named anything in particular, it's just the addresses that are important.

     

    MEMORY
    {
    L2SRAM             : origin = 0x10800000 len = 0x100000 
    DDR2               : origin = 0x80000000 len = 0x03000000 
    SHARED_DATA    :origin = 0x83000000 len = 0x0D000000
    }

    SECTIONS
    {
    mySHARED > SHARED_DATA
    }

     

    I've tryed this solution. I put the code above in my .lcf ... and then I use in my .c file

    int globalData[1024];
    #pragma DATA_SECTION(globalData, "
    mySHARED")

    but nothing happen. GlobaData wasn't in mySHARED but still in DDR2.

    Then I try to insert this rows in my .cfg file:

    Program.sectMap["mySHARED"] = new prog.SectionSpec();

    Program.sectMap["mySHARED"].loadSegment = 'SHARED_DATA';

    But when I compile the error was:

     

    memory range not found: SHARED_DATA on page 0
    >> Compilation failure
    "C:/Users/fusaril/Luca/lte_v5/LTE_ENB_PHY_DSP/trunk/Software/projects/Core1/Debug/configPkg/package/cfg/PLT_Core1_BiosConfiguration_pe66_x.xdl", line 206: error:
       no valid memory range(NULL) available for placement of "mySHARED"

     

    Any suggestions? ... I'm using a TMS320TCI6618.

     

    thanks, Luca.