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.

6670 Local to Global memory mapping

Hi,

I'm using user defined memory map and allocated default heap to the DDR3(16MB) because lack of memory of L2SRAM.

And, have a problem to convert local memory to global while using BCP.

To use BCP, data buffer should be allocated and converted to the global address(You can find this at the BCP example, function name allocate_fdq in the file named bcp_wimax.c )

In the function, Bcp_osalMalloc function assigns data buffer according to buffSize. Of course Bcp_osalMalloc uses Memory_alloc function.

Basically the pointer of the data buffer is assigned in the memory map of L2SRAM. And then converted to the global address. It is because the default heap is assigned on L2SRAM.

In my case, because of the default heap is assigned on DDR3(16 times larger than L2SRAM), converted global address points reserved area of global address.

 

At this point,

1. Can I use local address(DDR3) instead of global address for data buffer of BCP?

2. Can I force to move global address in the reserved area to the usable area by simply add address offset? Is there any chance to make unwilling problems?

3. Is there any API to solve this problem?

 

Regards.

Hoon Lee.

  • All DDR3 address is global.  Only the memories local to the L1D/L1P/L2 SRAMs are going to have Local and Global Addresses. 

    Best Regards,

    Chad

  • Thanks, Chad.

    I know that the DDR3 address is global.

    In my case, whole the DDR3 is divided into blocks and assigned to the each Cores to use some of them as a local memory. And, I used one of them a default Heap area.

    In this case, BCP example code assigned the Heap memory on the DDR3(Physically global, but the code assumes as Local such as L2SRAM)

    The results are what I mentioned.

    BCP code allocates dynamic memory for the pDataBuffer on the DDR3 and convert the address to global.

    It causes the global address of the pDataBuffer memory be assigned to reserved area of the physical memory.

    As I memtioned, I can handle this by just add memory address offset to the converted memory address or not convert local to global address converting.

    What I am really want to know is, Are the 2 solutions mentioned above reliable? stable? make any problemes in the future when mixed with other code?

     

    Regards.

    Hoon Lee.

  • I guess part of my confusion is you're referring to the 'Reserved for CoreX' DDR Memory as local memory and stating it has a local address.  It's not local in any sense of the term.  You're just reserving this.  If you did actually reserve it with Linker Command file to be for a specific space, then it will not be allocating dynamic memory to this space.

    Just to make sure, you are not using MPAX to re-map the addressing of the DDR that you're calling reserved, correct?

    This extra information is needed to be able to understand if it would be stable/reliable.

    Best Regards,

    Chad

  • Yes Chad.

    I did not use MPAX to re-map the address.

    Just what I did is, divide DDR3 into 4 blocks(to assign a block for each core) and one of the cores allocate default Heap to the assigned block of DDR3

    Regards,

    Hoon Lee.

  • Ok, I guess I'm confused as to what the real issue is here.  There is no local DDR3, there is no local address of DDR3, there is only reserved spaces for DDR3.

    With this in mind, can you ask again what you're trying to achieve?  I would think that the Malloc function could Malloc the memory where you wanted, there is not local/global addressing to be done.

    Best Regards,
    Chad

  • Chad,

    1. I made my own platform with memory map as below

    MEMORY CONFIGURATION

             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      L2SRAM                00800000   00100000  00096638  000699c8  RW X
      MSMCSRAM              0c000000   00200000  001037fc  000fc804  RW X
      DDR3_C0               80000000   04000000  00000000  04000000  RW X
      DDR3_C1               84000000   04000000  00ff0a78  0300f588  RW X
      DDR3_C2               88000000   04000000  00000000  04000000  RW X
      DDR3_C3               8c000000   04000000  00000000  04000000  RW X
      DDR3_TX               90000000   04000000  00000000  04000000  RW X
      DDR3_RX               94000000   04000000  00000000  04000000  RW X
      DDR3_IF_C0            98000000   02000000  00000000  02000000  RW X
      DDR3_IF_C1            9a000000   02000000  00000000  02000000  RW X
      DDR3_IF_C2            9c000000   02000000  00000000  02000000  RW X
      DDR3_IF_C3            9e000000   02000000  00000000  02000000  RW X

    2. Create a default system heap on the DDR3_C1 using cfg. file because lack of L2SRAM memory.

    var heapMemParams                   = new HeapMem.Params;
    heapMemParams.size                  = 0xF42400;      // 16MBytes
    heapMemParams.sectionName           = "systemHeap";
    Memory.defaultHeapInstance          = HeapMem.create(heapMemParams);
    Program.sectMap["systemHeap"]       = "DDR3_C1";

    3. Run Bcp example on Core #1 with change of allocate_fdq(), deallocate_fdq().

    allocate_fdq()

         pCppiDesc = (Void*) (QMSS_DESC_PTR (pCppiDesc));   
            if ((pDataBuffer =   (uint8_t *) Bcp_osalMalloc (buffSize, TRUE)) == NULL)
            {
             System_printf ("OOM error while allocating buffers\n");
                break;               
            }

         pDataBuffer |= 0x00800000;

    deallocate_fdq()

         pCppiDesc = (Void*) (QMSS_DESC_PTR (pCppiDesc));   
            Cppi_getData (Cppi_DescType_HOST, pCppiDesc, &pDataBuffer, &dataBufferLen);
            Cppi_setDataLen (Cppi_DescType_HOST, pCppiDesc, buffSize);

         pDataBuffer |= 0x00800000;

            Bcp_osalFree (pDataBuffer, buffSize, TRUE);

    The reason of doing 3 is,

    3.1 original allocate_fdq() allocate memory for pDataBuffer at the reserved global address such as 0x110BXXXXX.

    3.2 So, I force the allocated memory address move to the CorePa1 L2SRAM global address such as 0x118BXXXXX.

    And, it works.

    The thing I want to know is, the approach I did has any chance to make problems I didn't expect.

     

    Regards,

    Hoon Lee

  • This looks to me like you're allocated pDataBuffer from the Heap that's in DDR3, and then you're adding an offset of 0x00800000.  You're doing this so that you can use the Bcp_osalFree frucntion to give you a 'Global Address' for this.  But this IS NOT a global address for the pDataBuffer.  It's some random address in your local L2 space that if you masked off the upper 8 bits of the DDR space and replaced them w/ 0x11.  This DOES NOT point to DDR memory, so doing this makes no sense.

    There are two major issues here.

    1.) You are allocating pDataBuffer into a space that you don't know what is necessarily there.

    2.) Your use Bcp_osalFree to change the address of pDataBuffer to 'Global Address' is actually changing it to a different physical memory. At best you got lucky before and didn't overwrite other critical memory in the L2 space by doing this.

    Don't try to translate the DDR address to a 'Global Address'  just use the address as it was allocated period.

    Best Regards,
    Chad

  • Thanks Chad,

    It shouldn't be coverted to global address(actually not global address for the Heap in DDR3)

    And, the BCP works well when local to global address coverting function in alloc_fdq() and dealloc_fdq().

     

    Regards,

    Hoon Lee.