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.

What's happened when I memset the L1D cache?

Hello all

 

I'm using DM648 device and trying to allocate L1D cache as SRAM.

I edited the example project "dm648_evm_vport_st_hd_compositor_sample", and changed following steps.

  1. followed this page and set 64P L1DCFG Mode to 16KB.
  2. added the detection() into the project, and memset() is in detection().
  3. set break point at memset().
  4. run.

When this program arrive at the break point, the program stack looks like below.

detection()

test_video_compositor()

tskHdCompositor()

TSK_exit()

 

 

Then I press F10,  the program stack becomes....

detection()

0x00000000

 

What's happened when I memset the L1D cache?

 

 

 

Following is the pieces of source code.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#define MAX_CORNER_NUM 1920

#pragma DATA_SECTION(CORNER_X, "L1D_SRAM")

#pragma DATA_SECTION(CORNER_Y, "L1D_SRAM")

#pragma DATA_SECTION(OF_X, "L1D_SRAM")

#pragma DATA_SECTION(OF_Y, "L1D_SRAM")

static short CORNER_X[MAX_CORNER_NUM];

static short CORNER_Y[MAX_CORNER_NUM];

static short OF_X[MAX_CORNER_NUM];

static short OF_Y[MAX_CORNER_NUM];

#pragma DATA_SECTION(BUFFER, "L1D_SRAM")

static unsigned char BUFFER[384];

 

static void detection(ChannelInfo *inChInfo)

{

.........

memset(CORNER_X, 0, MAX_CORNER_NUM * 8);

.........

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

Best regards

  • Did you writeback the contents of your cache before you switched it to SRAM?  If your program stack was cached, you might have wiped it out if you went from bigger to smaller cache without writing it back first.

  • Dear MattLipsey:

    I was confuse about "cache set as SRAM".

    1. A cache set as SRAM meaning that range of cache will not be cached, right? Did I have to writeback the contents of cache before I switched it to SRAM?
    2. When I followed the page, Did it means that the cache was set as SRAM before program stack data came in?

    However, thank a lots about your reply.

     

    Best regards

  • Sorry, I misunderstood what you were doing.  I thought you were dynamically changing L1D between cache and SRAM.  With that said, why do you use the * 8 multiplier with memset?  You aren't guaranteed that those arrays are allocated in memory in the order that you declared them.  You should call memset with sizeof(short) * MAX_CORNER_NUM for each array instead of assuming they are allocated in any particular order.  You can check the array addresses in the debugger to see if this is what is causing your problem.

  • Dear MattLipsey:

     

    Because CORNER_X to OF_Y is continues address.


    memset(CORNER_X, 0, MAX_CORNER_NUM * 8);

    is same as

    memset(CORNER_X, 0, MAX_CORNER_NUM * sizeof(short));

    memset(CORNER_Y, 0, MAX_CORNER_NUM * sizeof(short));

    memset(OF_X, 0, MAX_CORNER_NUM * sizeof(short));  //when I write like these. It would be the same problem at this line.

    memset(OF_Y, 0, MAX_CORNER_NUM * sizeof(short));


    Best regards

     

  • Ok, well we are narrowing it down.  Have you physically checked the cache configuration registers in the debugger to verify your cache/sram settings are correct just before the failure?  Have you checked your linker command file to make sure you are not overlapping your sram section with cache?  IIRC, sram is the high side of the L1D memory, so you would have to put your L1DSRAM section at L1D base + L1D cache size.

  • Dear MattLipsey:

    I finally found that I didn't set the memory section.

    Thank a lots of your hints.