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.

Shared memory for IPC buffers/Concerto C28

Other Parts Discussed in Thread: SYSBIOS

Dear support,
We work with concerto F28M35H52C1, MCU SDK 1.0.0.68, XDCTools 3.24.60

I defined shared memory in c28 cmd file:
    IPC_BUFFERS_SECTION     : origin = 0x00D000, length = 0x2000      /* IPC_BUFFERS_SECTION data S01SHRAM, S02SHRAM*/
    and section:
   IPC_Mem       : > IPC_BUFFERS_SECTION


   in c28-cfg file:
var heapBuf1Params = new HeapBuf.Params();
heapBuf1Params.instance.name = "PMCUMsgQHeapBuf1";
heapBuf1Params.blockSize = 96;
heapBuf1Params.numBlocks = 8;
heapBuf1Params.align = 8;
heapBuf1Params.sectionName = "IPC_Mem";

var heapBuf0Params = new HeapBuf.Params();
heapBuf0Params.instance.name = "MsgQHeapBuf0";
heapBuf0Params.blockSize = 256;
heapBuf0Params.numBlocks = 10;
heapBuf0Params.align = 8;
heapBuf0Params.sectionName = "IPC_Mem";

after start program running i see in ROV/BIOS/Scan for Errors:

,ti.sysbios.heaps.HeapBuf,Detailed,MsgQHeapBuf0,N/A,Caught exception in view init code: "D:/ti/mcusdk_1_00_00_68/products/xdctools_3_23_04_60/packages/xdc/rov/StructureDecoder.xs", line 517: java.lang.Exception: Target memory read failed at address: 0x0, length: 4This read is at an INVALID address according to the application's section map. The application is likely either uninitialized or corrupt.
,ti.sysbios.heaps.HeapBuf,Detailed,PMCUMsgQHeapBuf1,N/A,Caught exception in view init code: "D:/ti/mcusdk_1_00_00_68/products/xdctools_3_23_04_60/packages/xdc/rov/StructureDecoder.xs", line 517: java.lang.Exception: Target memory read failed at address: 0x0, length: 4This read is at an INVALID address according to the application's section map. The application is likely either uninitialized or corrupt.

In HeapBuf/Detailes I see:

,0x00009b80,MsgQHeapBuf0,0x00000a00,256,10,2560,0,10,0,0x0000d340,0x00009b8e,MsgQHeapBuf0, Size: 2560, Free: 10 / 10
,0x00009b92,PMCUMsgQHeapBuf1,0x00000300,96,8,768,0,8,0,0x0000d000,0x00009ba0,PMCUMsgQHeapBuf1, Size: 768, Free: 8 / 8


It seems that my buffers allocated in the default heap instead of new heap that i defined.
What i missed in the configurations? should i add something else here?

Thanks,Sabina

  • Sabina,

    Screen shots would help with the errors and ROV details.  Its hard to parse the ROV details.  It does look like they are correctly created in the right memory region.

    How are you allocating your buffers, what's the call you are making look like?  You should be able to specify the heapBuf that you created.

    Judah

  • Hi Judan,

    I have the following error in the beginning of the program running:
    [C28xx_0] xdc.runtime.Memory: line 52: out of memory: heap=0x9b92, size=42
    [C28xx_0] MessageQ_alloc PMCU type failed

    Pls see our defenitions in the attached file:
    5822.L_C28.rar

     

     In the code:

    for MsgQHeapBuf0:
    typedef struct {
     MessageQ_MsgHeader  header;   // The MessageQ header
     Uint16    MsgType;  // The message type
     Uint16    Data[100];  // Message data
    } MY_M3_C28_Msg;

    for PMCUMsgQHeapBuf1:
     typedef struct {
     MessageQ_MsgHeader  header;   // The MessageQ header
     Uint16    MsgType;  // The message type
     Uint16    Data[25];  // Message data
    } PMCU_TYPE_M3_C28_Msg;

     

    void IPC_init_1(void)
    {
     Int  status;
        UInt numProcs = MultiProc_getNumProcessors(); // Number of processors, in the Concerto case = 2

        // Generate queue names based on own proc ID and total number of procs
        System_sprintf(localQueueName, "%s_queue",
                MultiProc_getName(MultiProc_self()));
        System_sprintf(remoteQueueName, "%s_queue",
                MultiProc_getName(1 - MultiProc_self()));

        // Determine which processors Notify will communicate with based on the local MultiProc id.
        srcProc = ((MultiProc_self() - 1 + numProcs) % numProcs);
        dstProc = ((MultiProc_self() + 1) % numProcs);

        // Register call back with Notify. It will be called when the processor
        // with id = srcProc sends event number EVENTID to this processor.
        status = Notify_registerEvent(srcProc, INTERRUPT_LINE, EVENTID,
                                      (Notify_FnNotifyCbck)NotifycallBackFxn, NULL);
        if (status < 0) {
            System_abort("Notify_registerEvent failed\n");
        }

        status = Notify_registerEvent(srcProc, INTERRUPT_LINE, EVENTID_ERR,
                                          (Notify_FnNotifyCbck)NotifycallBackFxn_ERR, NULL);
     if (status < 0) {
      System_abort("Notify_registerEvent failed\n");
     }

     status = Notify_registerEvent(srcProc, INTERRUPT_LINE, EVENTID_IPC,
                                           (Notify_FnNotifyCbck)NotifycallBackFxn_IPC, NULL);
      if (status < 0) {
       System_abort("Notify_registerEvent failed\n");
      }


        // Register default system heap with MessageQ
        MessageQ_registerHeap((IHeap_Handle)(MsgQHeapBuf0),HEAPID);

        // Create the local message queue
        messageQ = MessageQ_create(localQueueName, NULL);
        if (messageQ == NULL) {
            System_abort("MessageQ_create failed\n" );
        }

        // Open the remote message queue. Spin until it is ready.
        do {
            status = MessageQ_open(remoteQueueName, &remoteQueueId);
            // Sleep for 1 clock tick to avoid inundating remote processor
            // with interrupts if open failed
            if (status < 0) {
                Task_sleep(1);
            }
        } while (status < 0);

    }

    /*******************************************************************************
    Function Name : IPC_init_2
    Description :   This function init's the IPC data, for messageQ2
    *******************************************************************************/
    void IPC_init_2 (void)
    {
     Int  status;
        UInt numProcs = MultiProc_getNumProcessors(); // Number of processors, in the Concerto case = 2

        // Generate queue names based on own proc ID and total number of procs
        System_sprintf(localQueueName_tsk2, "%s2_queue",
                MultiProc_getName(MultiProc_self()));
        System_sprintf(remoteQueueName_tsk2, "%s2_queue",
                MultiProc_getName(1 - MultiProc_self()));


        // Register default system heap with MessageQ
        MessageQ_registerHeap((IHeap_Handle)(PMCUMsgQHeapBuf1), HEAPID_2);

        // Create the local message queue
        messageQ_2 = MessageQ_create(localQueueName_tsk2, NULL);
        if (messageQ_2 == NULL) {
            System_abort("MessageQ2_create failed\n" );
        }

        // Open the remote message queue. Spin until it is ready.
        do {
            status = MessageQ_open(remoteQueueName_tsk2, &remoteQueueId_2);
            // Sleep for 1 clock tick to avoid inundating remote processor
            // with interrupts if open failed
            if (status < 0) {
                Task_sleep(1);
            }
        } while (status < 0);

    }

    /*******************************************************************************
    Function Name : IPC_allocMsg
    Description :   Allocate the IPC message data,
    *******************************************************************************/
    MY_M3_C28_Msg * IPC_allocMsg ( void )
    {
     MY_M3_C28_Msg *msgAlloc;

        // Allocate a message
     msgAlloc = (MY_M3_C28_Msg *)MessageQ_alloc(HEAPID, sizeof(MY_M3_C28_Msg));
        if (msgAlloc == NULL) {
           System_abort("MessageQ_alloc failed\n" );
        }
        return(msgAlloc);
    }

    /*******************************************************************************
    Function Name : IPC_allocMsgPMCUType
    Description :   Allocate the IPC message data,
    *******************************************************************************/
    PMCU_TYPE_M3_C28_Msg * IPC_allocMsgPMCUType ( void )
    {

     PMCU_TYPE_M3_C28_Msg *msgAlloc;

     // Allocate a message
     msgAlloc = (PMCU_TYPE_M3_C28_Msg *)MessageQ_alloc(HEAPID_2, sizeof(PMCU_TYPE_M3_C28_Msg));
     if (msgAlloc == NULL) {
        System_abort("MessageQ_alloc PMCU type failed\n" );
     }
     return(msgAlloc);
    }  

    It seems that we have some problems in the buffers definitions into  the shared memory. Without shared memory using it run properly.

    Thanks, Sabina

  • Sabina,

    First, I think I understand why you are getting the ROV error.  In your .cfg file, you have not placed the "IPC_BUFFERS_SECTION".  You've created the section by the following code, but the section did not get placed and therefore gets assigned to address starting at 0x0 by default.

        var heapBuf0Params = new HeapBuf.Params();
        heapBuf0Params.instance.name = "MsgQHeapBuf0";
        heapBuf0Params.blockSize = 256;
        heapBuf0Params.numBlocks = 4;
        heapBuf0Params.align = 8;
        heapBuf0Params.sectionName = "IPC_BUFFERS_SECTION";
        Program.global.MsgQHeapBuf0 = HeapBuf.create(heapBuf0Params);

    What you need is the following additional line.  This will place the output section "IPC_BUFFERS_SECTION" to the memory segment "IPC_BUFFERS_SECTION".  I noticed this by looking at your .map file.  It shows your IPC_BUFFERS_SECTION segment is unused and shows the section IPC_BUFFERS_SECTION starts at 0x0.

        Program.sectMap["IPC_BUFFERS_SECTION"] = { loadSegment: "IPC_BUFFERS_SECTION" };

    Now don't know if this will resolve the rest of the issue.  I will continue looking at that.

    Judah

  • Sabina,

    Looks like you are running out of heap blocks on the HEAPID_2.  Are you able to monitor using ROV, the number of allocs and frees?

    I assume this probably doesn't fail right away since you have 8 blocks according to your .cfg file?  Who's calling free on the alloc'ed buffers?

    I didn't get your last statement about buffer definition into the shared memory.

    Judah

  • Hi Judah,

    The 1st point about configuration file:
    I put in the configuration file section IPC_BUFFERS_SECTION. Pls see line#91 and #157 in message_c28.cfg that I sent in L_C28.rar. But I really don't see it in the MAP file.
    May be we have any conflict between M3 and C28 configuration?
    I send you our M3 cfg , cmd and map 2022.L_M3.rar

    The 2nd point about HEAPID_2.
    We don't see any overflow in ROV during application working in the case if we don't use shared memory for IPC buffers
    we define shared memory in m3:
        RAMMReqSharedMemAccess(S0_ACCESS , SX_C28MASTER );
        RAMMReqSharedMemAccess(S1_ACCESS , SX_C28MASTER );
        RAMMReqSharedMemAccess(S2_ACCESS , SX_C28MASTER );
        RAMMReqSharedMemAccess(S3_ACCESS , SX_C28MASTER );


    Our code for allocation and free: (two tasks)

    Void Tsk_IPCMsgRecieveFromLPU(UArg arg0, UArg arg1)
    {
     MY_M3_C28_Msg  *myRcvMessage;
        // Init the IPC, M3 <-> C28x communication for MessageQ1  (LPU messages)
     IPC_init_1 ();
     System_printf("CIPCInterface (C28)::before while after IPC_init_1() \n");
        while (1)
        {
         // receive a message
         myRcvMessage = IPC_recMsgQ1 ();
         MsgType=myRcvMessage->MsgType;
         memcpy(pDataBuff,  myRcvMessage->Data, 100);
         IPC_freeMsg (myRcvMessage);
         (((CBoardSubSystem*)g_pBoard)->m_pLPUInterface)->LPUMessageHandle(MsgType, pDataBuff);
          }

    }

    Void Tsk_IPCMsgRecieveFromPMCU (UArg arg0, UArg arg1)
    {
      PMCU_TYPE_M3_C28_Msg *myRcvMessage2;
        // Init the IPC, M3 <-> C28x communication  for MessageQ2  (PMCU messages)
     IPC_init_2 ();
     System_printf("CIPCInterface (C28):: before while after IPC_init_2() \n");

        while (1)
        {
         // receive a message
         myRcvMessage2 = IPC_recMsgQ2 ();
         (((CBoardSubSystem*)g_pBoard)->m_pPMCUInterface)->PMCUMessageHandle(myRcvMessage2->MsgType, myRcvMessage2->Data);
         //Free the received message
         IPC_freeMsgPMCUType (myRcvMessage2);
        }

    }

     

    Thanks, Sabina



  • Sabina,

    I don't think you understood what I said.  I looked at your c28 files that you attached.  Doing line #91 and #157 is not enough.  Those two lines simply put those two HeapBufs in a linker output section called "IPC_BUFFERS_SECTION".

    But don't you want to put this output section into the memory segment "IPC_BUFFERS_SECTION"?  The confusing part is you have both an output section called "IPC_BUFFERS_SECTION" and a memory segment called "IPC_BUFFERS_SECTION".

    You need the additional line that I posted in order to actually place your output sectoin "IPC_BUFFERS_SECTION" into the memory segment named "IPC_BUFFERS_SECTION".

    Judah

  • Sabina,

    I looked at your M3 *.cfg file.  You have not specified who has write access to which shared memory segment.  Is the C28 supposed to have write access to some shared memory?  You need to specify this via the following config parameter.  Please see the IpcMgr.xdc file for more details.

       IpcMgr.sharedMemoryOwnerMask

    Judah

  • Hi Judah,

    Now the situation is much better! I seems that programm work properly.
    I added per your recomendation two definitions:
    1. in C28.cfg :  Program.sectMap["IPC_BUFFERS_SECTION"] = { loadSegment: "IPC_BUFFERS_SECTION" };
    2. in M3.cfg
    IpcMgr.readAddr  = 0x20008000; //sram0
    IpcMgr.readAddr  = 0x2000A000; //sram1
    IpcMgr.readAddr  = 0x2000C000; //sram2
    IpcMgr.readAddr  = 0x2000E000; //sram3
    IpcMgr.sharedMemoryOwnerMask = 0x0F;

    Attached is my updated cfg,cmd and map files
    0638.L_M3_1.rar
    6648.L_C28_1.rar

    Could you help us to resolve one additional problem in this thread (connected to IPC also)?
    I get some warning that can not understand:

     warning #339-D: linkage specification is incompatible with previous "MsgQHeapBuf0" (declared at line 23 of "../Debug/configPkg/package/cfg/BlueBox_pem3.h") ‪.xdchelp‬ ‪/L-Full_M3-1‬ 42 C/C++ Problem
     warning #339-D: linkage specification is incompatible with previous "NotifySemaphore0" (declared at line 32 of "../Debug/configPkg/package/cfg/BlueBox_pem3.h") ‪.xdchelp‬ ‪/L-Full_M3-1‬ 44 C/C++ Problem
     warning #339-D: linkage specification is incompatible with previous "PMCUMsgQHeapBuf1" (declared at line 77 of "../Debug/configPkg/package/cfg/BlueBox_pem3.h") ‪.xdchelp‬ ‪/L-Full_M3-1‬ 43 C/C++ Problem

    line 23 in BlueBox_pem3.h:  extern const ti_sysbios_heaps_HeapBuf_Handle MsgQHeapBuf0;
    line 32 in BlueBox_pem3.h: extern const ti_sysbios_knl_Semaphore_Handle NotifySemaphore0;
    line 77 in BlueBox_pem3.h: extern const ti_sysbios_heaps_HeapBuf_Handle PMCUMsgQHeapBuf1;

    The following pacage include this file if you need it.
    4606.M3configPkg.rar

    What could be the reason of these warnings?

    Thanks for your help, Sabina

     

  • Sabina,

    I don't know what's causing these warnings.  Are the warnings coming from the compiler or the linker?

    In your 'c' files that use these objects, are you declaring these objects a different way or are you simply just including the header file?

    Judah

  • Hi Judan,

    It is linkage warnings. the same warnings we get for c28 and m3

    in our c file we use include

    #include <xdc/runtime/System.h>
    #include <xdc/runtime/Memory.h>
    #include <xdc/runtime/IHeap.h>

    and don't declare objects at all.

    Thanks,Sabina

  • Sabina,

    Are you sure its the linker not the compiler giving this warning?  The warning look like a compile warning to me.

    Can you add this #include after all your other #includes into every .c file that is using one of those global objects from your .cfg file:

    #include <xdc/cfg/global.h>

    Judah

  • Hi Judan,

    The problem resolved, we had an extern in ipc.h file. now we removed these extern and added <xdc/cfg/global.h> per ypur recomendation. thanks!

    but now we have another problem
    during running program without gel file we get the following error:

    C28xx_0: Loader: One or more sections of your program falls into a memory region that is not writable.  These regions will not actually be written to the target.  Check your linker configuration and/or memory map.
    i didn't find any conflict in map file (sent you in the past it in the attached). could you see our map and cfg again.

    Thanks for your help, Sabina

  • Hi Judan,

    Pls help us to resolve one last problem that we have in this post. all work fine from the CCS debugger. But we still have problem with shared memory after starting program from the flash without debugging from CCS.. IPC doesn't work in this case - it seems that
    MessageQ_get(messageQ, &msg, MessageQ_FOREVER); and MessageQ_get(messageQ_2, &msg, MessageQ_FOREVER);
    don't returned with new message at all.
    without shared memory using we don't have this problem.

    Where could be the problem here?  

    Thanks, Sabina

  • Sabina,

    What is your gel file doing?  Is this a gel file that you authored or is it authored by TI? Can you attach the gel file here?

    Seems like the gel file must be initializing some memory which are you loading to and without this, the memory is not writable.

    This could also explain why when you run from flash its not working.  Sounds to me like whatever the gel file is doing needs to be done at runtime.

    Judah

  • Hi Judah,

    We use standard gel file from TI. Only tomorrow I could send it to you.   

    Thanks, Sabina

  • hi Judan,

    Could you answer us and help to finish this issue.

    Thanks,Sabina  

  • Sabina,

    I tried pinging Lori hoping she could answer your question since this isn't a BIOS question but more a boot up question and she knows more about it.

    My best guess to what is going on is that you need to initialize the RAM.  See M3_Ram_Init() in your gel file.  Can you put that functionality into a 'C' function and do it early on in your program?

    If that doesn't work, It probably makes sense to move this post back to the C2000 forum so someone there can better help you.

    Judah

  • H Judan,

    it didn't help.

    So i close this post and reopen another one in c2000 forum

    Thanks for your help, Sabina