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.

How to reference memory segments in sysbios

Other Parts Discussed in Thread: SYSBIOS

Hi

I have a question regarding Legacy support for MEM_Stat, MBX_create and TSK_create after migrating from DSPBIOS5 to SYSBIOS 6_33_06_50

In my source I used to have the following references to memory segments

extern uint32 SDRAM;
extern uint32 IRAM;

That are used in the source code in the following way:

OS_HMbx OS_MbxCreate(int iMsgSize, int iBufferLength) 
{
  MBX_Attrs attrs;
  attrs.segid = SDRAM;    
  return (OS_HMbx)MBX_create(iMsgSize, iBufferLength, &attrs);
}
 
OS_HTask OS_TaskCreate(const char* szTaskName, OS_ETaskPriority eTaskPrio, OS_ETaskStackSize eStackSize, OS_TaskEntryPointType pfnEntryPoint, void *pvArgument)
{
  STask* pstTask = (STask*) malloc(sizeof(STask));

  pstTask->pfnEntryPoint = pfnEntryPoint;
  pstTask->pvArgument = pvArgument;  
  pstTask->hExitSignal = OS_SemCreate(0);
  if (pstTask->hExitSignal != NULL)
  {
    // configure the stTskAttrs struct
    pstTask->stTskAttrs.priority = iTaskPrio[eTaskPrio];
    pstTask->stTskAttrs.stack = NULL;
    pstTask->stTskAttrs.stacksize = iStackSize[eStackSize];
    pstTask->stTskAttrs.stackseg = SDRAM;     pstTask->stTskAttrs.environ = NULL;
    pstTask->stTskAttrs.exitflag = TRUE;
    pstTask->stTskAttrs.name = (String) malloc(strlen(szTaskName) + 1);
    if (pstTask->stTskAttrs.name != NULL)
    {
      // copy task name
      strcpy(pstTask->stTskAttrs.name, szTaskName);
      
      // create the task
      pstTask->hTask = TSK_create((Fxn)TaskEntryWrapper, &pstTask->stTskAttrs, pstTask);
      if (pstTask->hTask != NULL)
      {
        TaskList_Insert(pstTask->hTask, eTaskPrio, eStackSize);
        return pstTask;
      }
    }
  }

  return NULL;
}

void OnFdspMemShow(uint32 uiSender)
{
  MEM_Stat stat;
  MEM_stat(IRAM, &stat);   DEBUG("IRAM\n");
  DEBUG("Size   : %d\n", stat.size);
  DEBUG("Used   : %d\n", stat.used);
  DEBUG("Free   : %d\n", stat.size-stat.used);
  DEBUG("Length : %d\n", stat.length);
  MEM_stat(SDRAM, &stat);   DEBUG("SDRAM\n");
  DEBUG("Size   : %d\n", stat.size);
  DEBUG("Used   : %d\n", stat.used);
  DEBUG("Free   : %d\n", stat.size-stat.used);
  DEBUG("Length : %d\n", stat.length);
}

After I have migrated to SYSBIOS the linker fails because the two memory segments IRAM and SDRAM are unresolved.

 So the questions that I have are

  1. How do I set the segid to SDRAM when I dynamically create a Mailbox using the legacy API MBX_create in a SYSBIOS application?
  2. How do I set the stackseg to SDRAM when I dynamically create a Task using the legacy API TSK_create in a SYSBIOS application?
  3. How do I use the legacy API MEM_stat in a SYSBIOS application

In addition to the switch from DSPBIOS to SYSBIOS I have also changed DSP from C6713 to C6657 so obviously the SDRAM memory segment needs to be renamed to DDR3 and IRAM shall be renamed to L2SRAM.

I have attached my sysbios configuration file .CFG  and the old dspbios configurations file .TCF

6332.4530.app.zip

Jens

 

  • Hi Jens,

    I will move your thread to TI-RTOS(BIOS) to get appropriate response.

    Thanks.

  • Jens,
    you don't really create any heaps using the DSP/BIOS 5 object MEM, the DSP/BIOS 5 C code doesn't know about these heaps and can't define segment IDs for them. What you need to do is to call the function MEM.addMemHeap for each HeapMem heap. Here is the documentation for that function from ti.bios.MEM.xdc:
    /*!
     * List of "other" HeapMem instances who requires a segId
     *
     * When a HeapMem instance is created by a call to HeapMem.create()
     * and when this HeapMem instance needs to be used by legacy code
     * calling MEM_alloc() it needs a segment Id.
     * Adding the HeapMem instance by calling this function allows MEM
     * to assign it a segId.
     */
    metaonly MEM.Instance addHeapMem(HeapMem.Handle handle, String name);

    So, what you need to do is to add that call right after you create Program.global.DDR3. But before you do that, you probably need to rename that Program.global variable, if you are also going to use DDR3 as a segment ID. Program.global.DDR3 will create a global HeapMem handle named DDR3, and you can't also have a segment ID, which is an int, with the same name. You'll have to rename Program.global variable to "DDR3handle" for example, and don't forget to change all other references to that variable in your config script:
    Program.
    global.DDR3handle = HeapMem.create(heapMemParams);
    MEM.addHeapMem(Program.global.DD3handle, "DDR3");

    As for L2SRAM, I don't see that you are creating any heaps there, so I am not sure what's the point of calling MEM_stat() on it. If you end up setting up a heap in L2SRAM, use the same function to add a heap id.

  • Thanks for the help that was excactly what I was looking for.

    Regarding MEM_stat on IRAM, I think the meaning was to have a simple way to see how much memory was left in the IRAM.

    If there is a way to see the amount of free memory in the L2SRAM using sysbios API then it would be a nice feature. otherwise we will have to look in the generated map file to see how mucg L2SRAM we use, since we do not allocate any ram dynamically.

  • Jens,
    MEM_stat is for heap stats only. You'll have to check the map file to find out how much RAM was used. That info is not available at runtime, so SYS/BIOS can't report it.