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.

unable to open heap with HeapBufMP_open

Other Parts Discussed in Thread: SYSBIOS

Hi,

I am trying to use IPC in order to send messages from core0  to core1.

Platform:EVM6678
XDCtools version: 3.20.08.88
IPC: 1.22.05.27
BIOS: 6.31.04.27
CCS Version: 5.0.2

My code is based on the example found in mcsdk_2_00_00_beta2\demos\image_processing

I created a shared region just like in the demo


Code for core0:

int main()
{;
    UInt16 core_id;
    EVM_init();
    core_id = (UInt16) DNUM;
    MultiProc_setLocalId(core_id);
    Ipc_start();
    BIOS_start ();
}

void OpenMSGQ1()
{
    HeapBufMP_Handle heapHandle;
    HeapBufMP_Params heapBufParams;
    Int              status;
    HeapBufMP_Params_init(&heapBufParams);
    heapBufParams.regionId       = 0;
    heapBufParams.name           = IMAGE_PROCESSING_HEAP_NAME;
    heapBufParams.numBlocks      = NUM_OF_CORES;
    heapBufParams.blockSize      = sizeof(process_message_t);
    heapHandle = HeapBufMP_create(&heapBufParams);
    if (heapHandle == NULL) {
        printf("Main: HeapBufMP_create failed\n" );
        close_n_exit();
    }
    status = MessageQ_registerHeap((IHeap_Handle)heapHandle, IMAGE_PROCESSING_HEAPID);
    if(status != MessageQ_S_SUCCESS) {
        printf("Main: MessageQ_registerHeap failed\n" );
        close_n_exit();
    }

    if (mc_process_init(NUM_OF_CORES)) {
        printf("mc_process_init returns error\n");
        close_n_exit();
    }

}

int mc_process_init (int number_of_cores)
{
    int i,j;
    HeapBufMP_Handle heapHandle;
    p_queue_msg = (process_message_t **) calloc(number_of_cores, sizeof(process_message_t *));
    if (!p_queue_msg) {
        printf("alloc_queue_message: Can't allocate memory for queue message\n");
        return -1;
    }

    for (i = 0; i < number_of_cores; i++) {
        p_queue_msg[i] =  (process_message_t *) MessageQ_alloc(IMAGE_PROCESSING_HEAPID, sizeof(process_message_t));
        if (!p_queue_msg[i]) {
            printf("alloc_queue_message: Can't allocate memory for queue message %d\n", i);
            return -1;
        }
    }

    max_core = number_of_cores;

    memset(slave_queue_name, 0, NUM_OF_CORES*16);
    for (i = 0; i < NUM_OF_CORES; i++) {
        GET_SLAVE_QUEUE_NAME(slave_queue_name[i], i);
    }

    HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle);
    h_receive_queue = MessageQ_create(slave_queue_name[0], NULL);
    if (h_receive_queue == NULL) {
        printf("MessageQ_create failed\n" );
        close_n_exit();
    }
    for (j = 0; j < number_of_cores; j++) {
        do {
            i = MessageQ_open(slave_queue_name[j], &queue_id[j]);
        } while (i < 0);
        printf("MessageQ %s opened\n",slave_queue_name[j]);
    }

    return 0;
}

 

Code for core1:

int main()
{
    UInt16 core_id = (UInt16) DNUM;
    MultiProc_setLocalId(core_id);

    Ipc_start();
    /* Start the BIOS 6 Scheduler */
    BIOS_start ();
}


void setMSGQ(void)
{
    char receive_queue_name[16];
    HeapBufMP_Handle heapHandle;

    Int status;

    GET_SLAVE_QUEUE_NAME(receive_queue_name, DNUM);

    /* Open the heap created by the other processor. Loop until opened. */
    do {
        status = HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle);
        if (status < 0) {
            Task_sleep(1);
        }
    } while (status < 0);

    /* Register this heap with MessageQ */
    MessageQ_registerHeap((IHeap_Handle)heapHandle, IMAGE_PROCESSING_HEAPID);

    /* Create the local message queue */
    h_receive_queue = MessageQ_create(receive_queue_name, NULL);
    if (h_receive_queue == NULL) {
        printf("MessageQ_create failed\n" );
        close_n_exit();
    }
    printf("MessageQ %s created\n",receive_queue_name);
}

 the problem is that core1 never returns from the line

status = HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle);

What is wrong?

 

  • Do you have Ipc_procSync_ALL set in the cfg?  I believe the default is procSync_PAIR, which requires you to do "Ipc_attach()" for all processors. Only when doing procSync_ALL is Ipc_attach() automatically included -- which lets all cores know of all other cores (specifically NameServer, which is what HeapBufMP_open uses)

  • Yes. I have this in both *.cfg files:

    var Ipc          = xdc.useModule('ti.sdo.ipc.Ipc');

    Ipc.procSync = Ipc.ProcSync_ALL;

     

  • Ya,

    I believe doing the following in main() is too late.  I also think you don't need to do this.

        MultiProc_setLocalId(core_id);

    You are doing something very similar to the MessageQ example that is part of the IPC product.  You should be able to use that example as a reference.

    Judah

  • I dont understand. Is it done too late or is it unnecessary?

     

    I am using it as a reference. The code is very similar.

  • I was trying to convey that its "both".

    For the device you are on you don't need it because IPC does it for you early on.

    If you actually did need it, doing this in main() is too late.

    Whats your MultiProc.setConfig look like in your *.cfg file?

    Judah

  • For  core0:

    MultiProc.setConfig("CORE0", ["CORE0", "CORE1"]);

    and for core1:

    MultiProc.setConfig("CORE1", ["CORE0", "CORE1"]);

     

    I also tried with

    MultiProc.setConfig(null, ["CORE0", "CORE1"]);

    in both cores.

  • I just tried it in a simulation and it works well. any ideas?

  • Ya,

    Since it works on Simulator but not on real hardware I wonder if has something to do with the state of the hardware.  Can you try the following in your .cfg files?  All I'm suggesting is moving the IPC interrupt from the default interrupt vector 5 to interrupt vector 6.

    var NotifySetup = xdc.useModule('ti.sdo.ipc.family.c647x.NotifySetup');

    NotifySetup.dspIntVectId = 6;

    Judah

  • Judah,

    Still not working.

     

    EDIT:

    If I hit pause,it seems that core1 is stuck at:

    ti_sysbios_hal_Hwi_checkStack() at Hwi_stack.c:99 0x0C11B220

  • I was just about to ask you what each core is doing.

    Core1 being in ti_sysbios_hal_Hwi_checkStack() means its in the idle loop which is okay.

    Are you familiar with ROV tool?  You can use that to see which Hwi is plugged.  The IPC is typically plugged to Hwi vector 5.  Would be 6 if you followed my suggestion on the last post.  Can you try to see if you are getting an IPC interrupt from the remote processor.

    Try putting a breakpoint on the label:  'ti_sysbios_family_c64p_Hwi5' if using vector 5.  Do this on both cores.

    Judah

  • This is for core1:

     

    Is it ok?

    I am not sure how to put a breakpoint on that label.

  • Ya,

    Your ROV screen shot looks fine.  It says that the SYSBIOS Timer is plugged into Hwi14 and the Ipc interrupt is plugged into Hwi6.

    When core1 is in the checkstacks function that you see or in the idle loop, what is the value of IER?  IER should be enabled for Hwi14 and Hwi6.

    Since you are familiar with ROV, can you make sure your HeapBufMP is created on Core0?  Also there should be a NameServer instance associated with the HeapBufMP with the associated Name/Value for the instance you created.

    To put a breakpoint on a label.  Put the label into your "Dissassembly" window.  Then double click the very left edge of the Dissassembly window right before the address of the function.

    Judah

     

  • I looked at the IER. interrupt 6 is enabled in both cores.

    The HeapBUfMP looks fine (only on core0).

    The NameServer also looks fine on both cores.

     

    I put the breakpoints as you said. nothing happens, it keeps running.

  • Ya,

    Nothing happens explains why the HeapBufMP_open would not succeed.

    Are you sure that you are building for the evm6678 and running on the evm6678?  Make sure you aren't building for evm6670 and trying to run for evm6678 or vice versa.  I can't really think of another reason why this wouldn't be working.  It looks to me like all the right interrupts are being plugged and the right instances are being created.

    Could you zip up the .c and the exectuable (*.out) files and attach it here.  I have evm6678 on my end and could try out your .out files.

    Judah

  • Judah,

    I attached the zip file.

    Thank you for your effort

    5775.IPC.zip

  • Ya,

    The version of the MCSDK that you are using is pre-production / Beta quality. Please upgrade the software to the production release or, better yet, a maintenance update. The latest version can be found here:
    http://software-dl.ti.com/sdoemb/sdoemb_public_sw/bios_mcsdk/latest/index_FDS.html

    Raj

  • I have a similar program like your, but I use the Ipc.ProcSync_PAIR mode. In the task function, do the ipc_attach first and don't change the Multicore setup.

  • Hi judahvang:

    I meet the same problem as Ya's.I use the  MessageQ example in the IPC module as a reference.The difference is that I use the different exectuable (*.out)  files on different cores.

    in my project, core0 send message Q to core1.Some code is below:

    core0 task:

    {

    ·······························

    HeapBufMP_Params_init(&heapBufParams);
    heapBufParams.regionId = 0;
    heapBufParams.name = HEAP_NAME;
    heapBufParams.numBlocks = 1;
    heapBufParams.blockSize = sizeof(MessageQ_MsgHeader);
    heapHandle = HeapBufMP_create(&heapBufParams);


    /* Register this heap with MessageQ */
    MessageQ_registerHeap((IHeap_Handle)heapHandle, HEAPID);

    ·····················

    }

    core1 task:

    {

    ··············

    do
    {
    status = HeapBufMP_open(HEAP_NAME, &heapHandle);
    } while (status < 0);

    ``````````````````

    }

    the problem is that core1 can't open the heap, I want to ask what should I notice before I call the HeapBufMP_open()?

    Thank you very much!