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.

Disabling cache for DDR in C6678

Hi all,

I have built a multicore program for the C6678 (TMDSEVM6678L rev. 3B) and I would like to have a buffer in a non-cached memory section. So, I have put the buffer in DDR and I have disabled the cache for that DDR section. However, I still need to use CACHE_invL1d / CACHE_invL2  before reading the data in that buffer. Otherwise, I get the old values. These buffer is modified by SRIO (I have another DSP writing data to the buffer address by SRIO).

The code which I think is relevant is the following:

*** core 0: (at start-up)

CACHE_disableCaching (0x83000000 >> 24);


*** core 1: (long after the core 0 CACHE_disableCaching)

while (1)
{
    CACHE_invL1d((void *)&gCore1SRIOLocalMemoryBuffer[0], 32, CACHE_WAIT);
    CACHE_invL2 ((void*)&gCore1SRIOLocalMemoryBuffer[0], 32, CACHE_WAIT);
    if (gCore1SRIOLocalMemoryBuffer[0] == 0x77)
        break;
}

And the gCore1SRIOLocalMemoryBuffer buffer is declared this way:

#pragma DATA_SECTION(gCore1SRIOLocalMemoryBuffer, ".srio_DDR");
#pragma DATA_ALIGN (gCore1SRIOLocalMemoryBuffer, CACHE_L2_LINESIZE)
volatile uint8_t gCore1SRIOLocalMemoryBuffer[32] = {0};


*** mad_deployment.json:

{
    "name"        : "DDR3-NONCACHED",
    "vaddr"        :  "0x83000000",
    "paddr"        : ["0x803000000", "0x803000000", "0x803000000", "0x803000000", "0x803000000", "0x803000000", "0x803000000", "0x803000000"] ,
    "size"        :  "0x01000000",
    "secNamePat"      : [".srio_DDR"],
    "cores"        : [0,1,2,3,4,5,6,7],
    "permissions"    : ["UR", "UW", "SR", "SW"],  
    "cacheEnable"    : false,
    "prefetch"      : false,
    "priority"    : 0,
    "shared"    : true
},


The other DSP is sending a buffer which starts with 0x77 to the address 0x83000000 which is gCore1SRIOLocalMemoryBuffer address (I have checked it with printf). If I remove the CACHE_xxx calls, I never exit the while loop. With them, the loop exits. I think that, if the cache is disabled for the section where my buffer resides, the CACHE_xxx calls should have no effect.

Am I missing something? is there another way of disabling the cache or maybe a never-cached memory range in this DSP? Should I look for the problem in another part of my code?

By the way, I am using mcsdk_02_01_02_06 (bios_6_33_06_50, pdk_C6678_1_1_2_6).

Thanks!

  • Hi Alejandro,

    Please ensure that the cache is disabled for the requested memory region by reading the register MAR131.

    Please refer corepac UG: sprugw0 

    Please refer below link:  http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/p/192191/840044.aspx#840044

    Thanks.

  • Hi Rajasekaran,

    I have read the MAR register according to the thread and the document. It seems that the cache is effectively disabled:

    My code is now:

    volatile uint32_t* MAR131 = ( volatile uint32_t*)0x0184820C; //  This is MAR 131 => 8300 0000h - 83FF FFFFh

    platform_write("MAR131: 0x%08x\n", *MAR131);

    CACHE_disableCaching (0x83000000 >> 24);

    platform_write("MAR131: 0x%08x\n", *MAR131);

    And my output is:

    MAR131: 0x0000000d
    MAR131: 0x0000000c

    It shows that the PC bit has changed from 1 (cache enabled) to 0 (cache disabled). So I do not understand why I need the CACHE_xxx calls before reading the buffer.

    On the other hand, I have read the 4.3.7.3 part in sprugw0 (Core Pac User Guide). It says that some operations need to be performed for updating MAR registers at runtime. So, I have tried to call CACHE_wbInvAllL2(CACHE_WAIT) before calling CACHE_disableCaching. However, in this case, I cannot read the correct values from the buffer, even if I make the CACHE_xxx calls.

    Any idea?

    Thanks

  • Alejandro,

    If the CorePac had written data to the DDR space, then it would likely be in cache.  The SRIO writes to DDR would go directly to DDR (never being cached.)

    To me it sounds like you want the data that's out in DDR, and at this point don't care about what was modified and cached from there by the CorePac.  If this is the case then perform an Invalidate of L1D and L2 space (no WB.)  You probably want it to be local to that particular space.

    Also, you may want to figure out what is writing to the that DDR address from the CorePac, as that's the only way it would be getting a different value into the cached memory.  

    Best Regards,
    Chad