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.

HeapMem question

Dear all ,

When you define a new heapmem you should define a section name.  Should this section be defined in the cmd file , or not ?

For example 

var heapMemParamsCM_Env = new HeapMem.Params;
heapMemParamsCM_Env.size = 0x00030000 ;
heapMemParamsCM_Env.align = 32;
heapMemParamsCM_Env.sectionName = "cmHeapsection";
heapMemParamsCM_Env.instance.name = "cmEnvironHandle";
Program.global.cmEnvironHandle = HeapMem.create(heapMemParamsCM_Env);
Program.sectMap["cmHeapsection"] = "EDRAM";

Should the cmHeapSection be deifned in the cmd file, or no?

Then I cannot understand ,  when I define a new module , for example a task, what I must choose to set,  a section or a heapMem. Must the section be the same with the section that is used for the definion of the heapMem that is used for this module?

I try to define a new logBuffer, I have define the heapMem for this and in the ROV I notice that heapMem is not used 

var heapMemParamsLOGRAM = new HeapMem.Params;
heapMemParamsLOGRAM.size = 0x00e7FF00;
heapMemParamsLOGRAM.align = 32;
heapMemParamsLOGRAM.sectionName = "logRamHeapsection";
heapMemParamsLOGRAM.instance.name = "logRamSection_handle";
Program.global.logRamSection_handle = HeapMem.create(heapMemParamsLOGRAM);
Program.sectMap["logRamHeapsection"] = "LOGRAM";

var loggerBuf0Params = new LoggerBuf.Params();
loggerBuf0Params.instance.name = "DBG_traceLogHandle";
loggerBuf0Params.bufHeap = Program.global.logRamSection_handle;
loggerBuf0Params.bufType = LoggerBuf.BufType_CIRCULAR;
loggerBuf0Params.exitFlush = true;
loggerBuf0Params.numEntries = 64;
Program.global.DBG_traceLogHandle = LoggerBuf.create(loggerBuf0Params);

Could you please clarify the aforementioned points?

Best regards 

George

  • Hi George,

        The answer to your first question is No. You don't have to define the heap section in your linker command file.  The line:

          Program.sectMap["cmHeapSection"] = "EDRAM"

    ensures that the section is created as part of the generated linker command file. If you want your Tasks to use this heap, you'll have to set it as the default Heap instance. To do this include:

         var Memory = useModule("xdc.runtime.Memory");

         Memory.defaultHeapInstance = Program.global.cmEnvironHandle;


    I haven't seen anything wrong with the Loggerbuf code you included. I see you created your heap and correctly assigned it as the heap for Loggerbuf. Can you share the ROV views you're looking at to confirm that your heap isn't used by Loggerbuf?

    Thanks,

    Moses

  • Hello,

    Thank you for the prompt answer.

    Have look in the images that I have attached.

    I  did some changes in the definition of the logBuffer:

    var loggerBuf0Params = new LoggerBuf.Params();
    loggerBuf0Params.instance.name = "DBG_traceLogHandle";
    loggerBuf0Params.bufSection = ".log_section";
    loggerBuf0Params.bufHeap = Program.global.edramHeapSectionHandle;
    loggerBuf0Params.bufType = LoggerBuf.BufType_CIRCULAR;
    loggerBuf0Params.exitFlush = true;
    loggerBuf0Params.numEntries = 64;
    Program.global.DBG_traceLogHandle = LoggerBuf.create(loggerBuf0Params);

    The edramHeapSectionHandle is used as heap and .log_section as the section for the static instances. 

    I noticed that when an new entry is recorded in the ROV the currEntry is in the log section and the heap is not used for the allocation

    Best regards

    George

  • Hi George,
    Can you share your project so I can see more of what's going on? Also where did you halt the application to get the ROV view, before or after BIOS_start?

    Thanks,
    Moses
  • Hello

    Unfortunately the project is too big to attach here.

    The first record takes place before the BIOS Start.

    As I mentioned the log_section is used instead of heap.

    Is this problem?

    When the heap is used and when the section is used when a  new record is stored in ROV?

  • Hi Giorgos,
    I've just realized that the edramHeapSectionHandle heap that you assign to the bufHeap field isn't being used because you created your LoggerBuf statically. Creating it statically means you created it in your cfg file which means the memory needed for the module is allocated at build time. For statically created LoggerBuf modules, the bufSection field is what's used.
    On the other hand if you created your Heap dynamically that is, in your c file, then bufHeap will be used for the loggerBuf. That said you don't need to set both bufSection and bufHeap. You should set only one of the two depending on if you're creating your LoggerBuf statically or dynamically.

    Let me know if this helps.

    Moses