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.

RTOS/AM5728: memory_alloc fails with 1GB but not with 1GB-128B ?

Part Number: AM5728
Other Parts Discussed in Thread: SYSBIOS, BEAGLEBOARD-X15

Tool/software: TI-RTOS

Hi Champs

My customer is using the AM5728 and running ti rtos on the DSP's. What they are trying to do is memory_alloc when they try to get 1GB it returns null. But if they request 1GB-128B then it works. Why would it fail for the 1GB? Below is more details as to how they partition  their memory. Any info or why this does not work would be great.

Yes, we are using Linux on the ARM side, but we are NOT using MMU on the DSP side.

 Our DSP approach is straight-forward and very similar to our traditional and discretely targeted DSP’s on previous products such as DM647_8 and C665x devices in regards to HEAP and memory allocation.

 The board being targeted has a AM572x device being configured with 2 GiB of DDR with base address of 0x8000 0000 extending through 0xFFFF FFFF.

 The DSP HEAP being defined and in question here starts at address 0xC000 0000 with size/length of 0x4000 0000.

 Basically, this memory region is defined within RTSC Target Platform for AM57xx/DRA7xx of size 1 GiB (0x4000 0000) with starting address 0xC000 0000 and length 0x4000 0000.  Additionally, the build configuration (.cfg) statically defines a HEAP of size 0x4000 0000 at memory region starting at 0xC000 0000

 var heapMem3Params = new HeapMem.Params();

heapMem3Params.instance.name = "CAPTURE_HEAP";

heapMem3Params.size = 0x40000000;

heapMem3Params.align = 128;

heapMem3Params.minBlockAlign = 128;

heapMem3Params.sectionName = "DDR3_CAPTURE";

heapMem3Params.buf = 0xC0000000;

Program.global.CAPTURE_HEAP = HeapMem.create(heapMem3Params);

 

Here’s call to Memory_alloc() failing with NULL being returned…

 

Ptr pCaptureBuffer = NULL;

Error_Block eb;

 

pCaptureBuffer = Memory_alloc(CAPTURE_HEAP,0x40000000, 128,&eb);

/* This return NULL Ptr */

 

Here’s call to Memory_alloc() succeeding with non-NULL pointer being returned…

 

Ptr pCaptureBuffer = NULL;

Error_Block eb;

 

pCaptureBuffer = Memory_alloc(CAPTURE_HEAP,0x3FFFFF80, 128,&eb);

/* This returns non-NULL Ptr, i.e. 0xC0000000 */

 

Thanks

Regards

Mohsen

  • Mohsen Khayami said:
    What they are trying to do is memory_alloc when they try to get 1GB it returns null. But if they request 1GB-128B then it works. Why would it fail for the 1GB?

    Internally the heap has to maintain a free list and a list of allocations. These lists use some of the heap.

    Since heapMem3Params sets the alignment to 128 bytes, it makes sense that with a heap size of 1GB the maximum size of a single allocation is 1GB-128B.

  • Hi,

    We need to create a CCS project and RTSC platform to reproduce this. Will update you.

    Regards, Eric
  • Hi,

    It would be good for you to provide your CCS project to show the problem, so I can reproduce.

    I tried to create a heap of 1GB, the SYSBIOS doesn't support it, it only supports 512MB-1 bytes. So I tested with 256MB heap allocated from DDR, and I put all the code/data into the L2. My platform limited the DDR as 256MB starting from 0x8000_0000.

    I didn't see any issue. I saw pCaptureBuffer is 0x8000_0000. Also it is good to isolate if problem related to Linux or not by not using it.

    Below is my platform:

    Attached is the my CCS project. You will see the .cfg file and .c code also the map file. You may change it based on my CCS project if it is easier to show your issue.

    hello_AM5728_C66XX.zip

    Regards, Eric

  • Hi Eric

    thanks for creating the project. The thing that does not make sense is that why is it limited to 512MB? I would imagine it should let you assign the 1GB.  Also why it does not let you get the full 512MB when the heap is set to 512MB. Can you find this out please.

    Thanks

  • Mohsen Khayami said:
    The thing that does not make sense is that why is it limited to 512MB? I would imagine it should let you assign the 1GB.

    It is because:

    a. The C6000 compiler currently has a limitation in that the maximum object size is < 512MB.

    b. By default SYS/BIOS creates an array (object) of the specified heap size to allocate space for the heap.

    See Compiler/EVMK2H: Why does the C6000 v8.2.2 compiler truncate the size of objects >= 512Mbyte ? for some background information, and a work-around on how to create a heap >= 512MB.

    Notes on changes to C6000 compiler behaviour:

    1. When I reported the issue with C6000 compiler v8.2.2 the object used for the heap was silently truncated.

    2. CODEGEN-449 was implemented to report a compile error if the size of an object is >= 512MB. E.g. with C6000 compiler v8.3.2 get the following error when attempt to create a 1GB heap in SYS/BIOS without the work-around mentioned in the referenced thread:

    "/home/mr_halfword/ti/bios_6_46_01_38/packages/ti/sysbios/heaps/HeapMem.h", line 90 (col. 18): error: Object size 1073741824 bytes is greater than maximum supported size 536870911 bytes
    1 error detected in the compilation of "package/cfg/app_pe66.c".

    3. CODEGEN-4042 was raised to allow the compiler to create objects >= 512MB. CODEGEN-4042 is reported as fixed in C6000 compiler v8.4.0 but that version doesn't appear to be released yet.

  • Chester,

    Thanks for sharing your knowledge here! The "1073741824 bytes is greater than maximum supported size 536870911 bytes" is the exact error I saw here. I used CGT 8.3.2.

    Mohsen,
    It is good for your customer to share their CCS project or updating my one to show the problem. I need to reproduce locally, or directly ask the RTOS team for clarification.

    Regards, Eric
  • Chester Gillon said:
    Internally the heap has to maintain a free list and a list of allocations. These lists use some of the heap.

    I was wrong about that.

    Having created a test program have seen that with a 1GB heap can actually perform allocations which use all the heap.

    Example output from the test program show this:

    [C66xx_DSP1] enter main()
    Test iteration 0 using 1 allocations
      Requested alloc_size=0x40000000  actual alloc_size=0x40000000  buffer=@c0000000
    Test iteration 1 using 2 allocations
      Requested alloc_size=0x20000000  actual alloc_size=0x20000000  buffer=@c0000000
      Requested alloc_size=0x20000000  actual alloc_size=0x20000000  buffer=@e0000000
    Test iteration 2 using 3 allocations
      Requested alloc_size=0x10000000  actual alloc_size=0x10000000  buffer=@c0000000
      Requested alloc_size=0x20000000  actual alloc_size=0x20000000  buffer=@d0000000
      Requested alloc_size=0x10000000  actual alloc_size=0x10000000  buffer=@f0000000
    Test iteration 3 using 4 allocations
      Requested alloc_size=0x10000000  actual alloc_size=0x10000000  buffer=@c0000000
      Requested alloc_size=0x08000000  actual alloc_size=0x08000000  buffer=@d0000000
      Requested alloc_size=0x20000000  actual alloc_size=0x20000000  buffer=@d8000000
      Requested alloc_size=0x08000000  actual alloc_size=0x08000000  buffer=@f8000000
    Test complete

    The test program runs SYS/BIOS 6.73.1.01 on a BeagleBoard-X15 and define the heap in such a way to work-around the problem on the compiler not being able to create an object >= 512MB.

    AM5728_C66_SYSBIOS_1GB_heap.zip

  • Mohsen,

    You can share the project developed by Chester with your customer and I am closing the thread.

    Chester,
    Thanks very much for providing many details and a solution!

    Regards, Eric
  • Chester

    thanks for the project and the clarification.