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.

Linux/AM5728: ARM and IPU shared memory problem

Part Number: AM5728


Tool/software: Linux

Hi,

TI,I am working for share memory between ARM and IPU1,but the ipu call Resource_physToVirt() function is failed! It say that the ipu can not get the physical address 0xa0000000.

Here the log:

root@am57xx-evm:~/tl-arm-dsp-ipu-cmem-example# cat /sys/kernel/debug/remoteproc/remoteproc0/trace0
[0][ 0.000] Watchdog disabled: TimerBase = 0x68824000 ClkCtrl = 0x6a005568
[0][ 0.000] Watchdog disabled: TimerBase = 0x68826000 ClkCtrl = 0x6a005570
[0][ 0.000] 19 Resource entries at 0x3000
[0][ 0.000] [t=0x000889ed] xdc.runtime.Main: --> main:
[0][ 0.000] registering rpmsg-proto:rpmsg-proto service on 61 with HOST
[0][ 0.000] [t=0x001897e7] xdc.runtime.Main: NameMap_sendMessage: HOST 53, port=61
[0][ 0.000] Watchdog disabled: TimerBase = 0x68824000 ClkCtrl = 0x6a005568
[0][ 0.000] Watchdog disabled: TimerBase = 0x68826000 ClkCtrl = 0x6a00550
[0][ 0.000] [t=0x001ba77d] xdc.runtime.Main: --> smain:
[0][ 0.000] [t=0x001db38f] Server: Server_create: server is ready
[0][ 0.000] [t=0x001e5d03] Server: <-- Server_create: 0
[0][ 0.000] [t=0x001edc61] Server: --> Server_exec:
[0][ 9.106] [t=0xdde0ba15] Server: Server_exec: not found resource for phys 0xa0000000
[0][ 9.106]
[0][ 9.106] [t=0xdde1eec1] Server: Server_exec: processed cmd=0x2000000
[0][ 9.106] [t=0xdde2e8bb] Server: <-- Server_exec: 0
[0][ 9.107] [t=0xdde38aad] Server: --> Server_delete:
[0][ 9.107] [t=0xdde49a13] Server: <-- Server_delete: 0
[0][ 9.107] [t=0xdde5f61d] Server: Server_create: server is ready
[0][ 9.107] [t=0xdde6b5f7] Server: <-- Server_create: 0
[0][ 9.107] [t=0xdde74cef] Server: --> Server_exec:
root@am57xx-evm:~/tl-arm-dsp-ipu-cmem-example#

use the same code,the ARM and DSP1/DSP2 are work find.

I had add the cmem configuration at rsc_table_ipu.h and config.bld.

I double the IPU memory configuartion is not right.Could you help work on it?

the file on my project is below:

ipu server:

/*
 * Copyright (c) 2013-2014, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ======== Server.c ========
 *
 */

/* this define must precede inclusion of any xdc header file */
#define Registry_CURDESC Test__Desc
#define MODULE_NAME "Server"

/* xdctools header files */
#include <xdc/std.h>
#include <xdc/runtime/Assert.h>
#include <xdc/runtime/Diags.h>
#include <xdc/runtime/Log.h>
#include <xdc/runtime/Registry.h>

#include <stdio.h>

/* package header files */
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/MultiProc.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/ipc/remoteproc/Resource.h>

/* local header files */
#include "../shared/AppCommon.h"

/* module header file */
#include "Server.h"

/* module structure */
typedef struct {
    UInt16              hostProcId;         // host processor id
    MessageQ_Handle     slaveQue;           // created locally
} Server_Module;

/* private data */
Registry_Desc               Registry_CURDESC;
static Server_Module        Module;


/*
 *  ======== Server_init ========
 */
Void Server_init(Void)
{
    Registry_Result result;

    /* register with xdc.runtime to get a diags mask */
    result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
    Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

    /* initialize module object state */
    Module.hostProcId = MultiProc_getId("HOST");
}


/*
 *  ======== Server_create ========
 */
Int Server_create()
{
    Int                 status = 0;
    MessageQ_Params     msgqParams;
    char                msgqName[32];

    /* enable some log events */
    Diags_setMask(MODULE_NAME"+EXF");

    /* create local message queue (inbound messages) */
    MessageQ_Params_init(&msgqParams);
    sprintf(msgqName, App_SlaveMsgQueName, MultiProc_getName(MultiProc_self()));
    Module.slaveQue = MessageQ_create(msgqName, &msgqParams);

    if (Module.slaveQue == NULL) {
        status = -1;
        goto leave;
    }

    Log_print0(Diags_INFO,"Server_create: server is ready");

leave:
    Log_print1(Diags_EXIT, "<-- Server_create: %d", (IArg)status);
    return (status);
}




/*
 *  ======== Server_exec ========
 */
Int Server_exec()
{
    Int                 status;
    Bool                running = TRUE;
    App_Msg *           msg;
    MessageQ_QueueId    queId;
    Int                 i, j;
    uint8_t *           data_ptr;
    UInt32              virtualAddrIn[1];
    UInt32              virtualAddrOut;
    uint32_t            dataXor;

    Log_print0(Diags_ENTRY | Diags_INFO, "--> Server_exec:");

    while (running) {

        /* wait for inbound message */
        status = MessageQ_get(Module.slaveQue, (MessageQ_Msg *)&msg,
            MessageQ_FOREVER);

        if (status < 0) {
            goto leave;
        }

        for (i = 0; i < 1; i++) {
            if(Resource_physToVirt(msg->dataInPhys[i], &virtualAddrIn[i]) != Resource_S_SUCCESS) {
                Log_print1(Diags_INFO, "Server_exec: not found resource for phys 0x%x\n",
                                        msg->dataInPhys[i]);
                continue;
            }
            Log_print4(Diags_INFO, "Server_exec: addrPhys[%d] = 0x%x addrIn[%d]=0x%x",
                       i, msg->dataInPhys[i], i, virtualAddrIn[i]);

            data_ptr = (uint8_t*)virtualAddrIn[i];

            dataXor = 0;

            for (j = 0; j < msg->dataByteSize; j++) {
                 dataXor ^= data_ptr[j];
            }

            Log_print2(Diags_INFO, "Server_exec: xorIn[%d]=0x%x", i, dataXor);
        }

        msg->outXor = dataXor;

        if (msg->cmd == App_CMD_SHUTDOWN) {
            running = FALSE;
        }

        /* process the message */
        Log_print1(Diags_INFO, "Server_exec: processed cmd=0x%x", msg->cmd);

        /* send message back */
        queId = MessageQ_getReplyQueue(msg); /* type-cast not needed */
        MessageQ_put(queId, (MessageQ_Msg)msg);

    } /* while (running) */

leave:
    Log_print1(Diags_EXIT, "<-- Server_exec: %d", (IArg)status);
    return(status);
}

/*
 *  ======== Server_delete ========
 */

Int Server_delete()
{
    Int         status;

    Log_print0(Diags_ENTRY, "--> Server_delete:");

    /* delete the video message queue */
    status = MessageQ_delete(&Module.slaveQue);

    if (status < 0) {
        goto leave;
    }

leave:
    if (status < 0) {
        Log_error1("Server_finish: error=0x%x", (IArg)status);
    }

    /* disable log events */
    Log_print1(Diags_EXIT, "<-- Server_delete: %d", (IArg)status);
    Diags_setMask(MODULE_NAME"-EXF");

    return(status);
}

/*
 *  ======== Server_exit ========
 */

Void Server_exit(Void)
{
    /*
     * Note that there isn't a Registry_removeModule() yet:
     *     https://bugs.eclipse.org/bugs/show_bug.cgi?id=315448
     *
     * ... but this is where we'd call it.
     */
}

ipu rsc_table:

1134.rsc_table_ipu.h

config.bld:

  Copyright (c) 2013-2015, Texas Instruments Incorporated
  All rights reserved.
 
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met
 
    Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
 
    Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation andor other materials provided with the distribution.
 
    Neither the name of Texas Instruments Incorporated nor the names of
     its contributors may be used to endorse or promote products derived
     from this software without specific prior written permission.
 
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 


   ======== config.bld ========
 
 
var Build = xdc.useModule('xdc.bld.BuildEnvironment');

  Memory Map for ti.platforms.evmDRA7XXdsp1 and ti.platforms.evmDRA7XXdsp2
 
   --- External Memory ---
   Virtual     Physical        Size            Comment
   ------------------------------------------------------------------------
   9500_4000   _    10_0000  (  ~1 MB) EXT_CODE
   9510_0000   _    10_0000  (   1 MB) EXT_DATA
   9520_0000   _    30_0000  (   3 MB) EXT_HEAP
   9F00_0000   9F00_0000     6_0000  ( 384 kB) TRACE_BUF
   9F06_0000   9F06_0000     1_0000  (  64 kB) EXC_DATA
   9F07_0000   9F07_0000     2_0000  ( 128 kB) PM_DATA (Power mgmt)
   A000_0000   A000_0000    C00_0000 (192 MB)  CMEM Memory (192 MB)
 

var evmDRA7XX_CMEM = {
    name CMEM, space data, access RW,
    base 0xA0000000, len 0xC000000,
    comment CMEM Memory (192 MB)
};

var evmDRA7XX_ExtMemMapDsp = {
    EXT_CODE {
        name EXT_CODE,
        base 0x95000000,
        len  0x00100000,
        space code,
        access RWX
    },
    EXT_DATA {
        name EXT_DATA,
        base 0x95100000,
        len  0x00100000,
        space data,
        access RW
    },
    EXT_HEAP {
        name EXT_HEAP,
        base 0x95200000,
        len  0x00300000,
        space data,
        access RW
    },
    TRACE_BUF {
        name TRACE_BUF,
        base 0x9F000000,
        len  0x00060000,
        space data,
        access RW
    },
    EXC_DATA {
        name EXC_DATA,
        base 0x9F060000,
        len  0x00010000,
        space data,
        access RW
    },
    PM_DATA {
        name PM_DATA,
        base 0x9F070000,
        len  0x00020000,
        space data,
        access RWX   should this have execute perm 
    },
    CMEM {
        name evmDRA7XX_CMEM.name,
        base evmDRA7XX_CMEM.base,
        len  evmDRA7XX_CMEM.len,
        space data,
        access RW
    },
};

Build.platformTable[ti.platforms.evmDRA7XXdsp1] = {
    externalMemoryMap [
        [ EXT_CODE, evmDRA7XX_ExtMemMapDsp.EXT_CODE ],
        [ EXT_DATA, evmDRA7XX_ExtMemMapDsp.EXT_DATA ],
        [ EXT_HEAP, evmDRA7XX_ExtMemMapDsp.EXT_HEAP ],
        [ TRACE_BUF, evmDRA7XX_ExtMemMapDsp.TRACE_BUF ],
        [ EXC_DATA, evmDRA7XX_ExtMemMapDsp.EXC_DATA ],
        [ PM_DATA, evmDRA7XX_ExtMemMapDsp.PM_DATA ],
        [ evmDRA7XX_CMEM.name, evmDRA7XX_ExtMemMapDsp.CMEM ],
    ],
    codeMemory EXT_CODE,
    dataMemory EXT_DATA,
    stackMemory EXT_DATA,
};
Build.platformTable[ti.platforms.evmDRA7XXdsp2] =
	Build.platformTable[ti.platforms.evmDRA7XXdsp1];



  Memory Map for ti.platforms.evmDRA7XXipu2
 
   --- External Memory ---
   Virtual     Physical        Size            Comment
   ------------------------------------------------------------------------
   0000_4000   _    5F_C000  (  ~6 MB) EXT_CODE
   8000_0000   _    60_0000  (   6 MB) EXT_DATA
   8060_0000   _   960_0000  (  86 MB) EXT_HEAP
   9F00_0000   9F00_0000     6_0000  ( 384 kB) TRACE_BUF
   9F06_0000   9F06_0000     1_0000  (  64 kB) EXC_DATA
   9F07_0000   9F07_0000     2_0000  ( 128 kB) PM_DATA (Power mgmt)
   A000_0000   A000_0000    C00_0000 (192 MB)  CMEM Memory (192 MB)
 
var evmDRA7XX_ExtMemMapIpu2 = {
    EXT_CODE {
        name EXT_CODE,
        base 0x00004000,
        len  0x005FC000,
        space code,
        access RWX
    },
    EXT_DATA {
        name EXT_DATA,
        base 0x80000000,
        len  0x00600000,
        space data,
        access RW
    },
    EXT_HEAP {
        name EXT_HEAP,
        base 0x80600000,
        len  0x09600000,
        space data,
        access RW
    },
    TRACE_BUF {
        name TRACE_BUF,
        base 0x9F000000,
        len  0x00060000,
        space data,
        access RW
    },
    EXC_DATA {
        name EXC_DATA,
        base 0x9F060000,
        len  0x00010000,
        space data,
        access RW
    },
    PM_DATA {
        name PM_DATA,
        base 0x9F070000,
        len  0x00020000,
        space data,
        access RWX   should this have execute perm 
    },

    CMEM {
        name evmDRA7XX_CMEM.name,
        base evmDRA7XX_CMEM.base,
        len  evmDRA7XX_CMEM.len,
        space data,
        access RW
    },

};

Build.platformTable[ti.platforms.evmDRA7XXipu2] = {
    externalMemoryMap [
        [ EXT_CODE, evmDRA7XX_ExtMemMapIpu2.EXT_CODE ],
        [ EXT_DATA, evmDRA7XX_ExtMemMapIpu2.EXT_DATA ],
        [ EXT_HEAP, evmDRA7XX_ExtMemMapIpu2.EXT_HEAP ],
        [ TRACE_BUF, evmDRA7XX_ExtMemMapIpu2.TRACE_BUF ],
        [ EXC_DATA, evmDRA7XX_ExtMemMapIpu2.EXC_DATA ],
        [ PM_DATA, evmDRA7XX_ExtMemMapIpu2.PM_DATA ],
         [ evmDRA7XX_CMEM.name, evmDRA7XX_ExtMemMapIpu2.CMEM ], 
    ],
    codeMemory EXT_CODE,
    dataMemory EXT_DATA,
    stackMemory EXT_DATA,
};

  Memory Map for ti.platforms.evmDRA7XXipu1
 
   --- External Memory ---
   Virtual     Physical        Size            Comment
   ------------------------------------------------------------------------
   0000_4000   _     F_C000  (  ~1 MB) EXT_CODE
   8000_0000   _    20_0000  (   2 MB) EXT_DATA
   8020_0000   _    30_0000  (   3 MB) EXT_HEAP
   9F00_0000   9F00_0000     6_0000  ( 384 kB) TRACE_BUF
   9F06_0000   9F06_0000     1_0000  (  64 kB) EXC_DATA
   9F07_0000   9F07_0000     2_0000  ( 128 kB) PM_DATA (Power mgmt)
   A000_0000   A000_0000    C00_0000 (192 MB)  CMEM Memory (192 MB)
 
var evmDRA7XX_ExtMemMapIpu1 = {
    EXT_CODE {
        name EXT_CODE,
        base 0x00004000,
        len  0x000FC000,
        space code,
        access RWX
    },
    EXT_DATA {
        name EXT_DATA,
        base 0x80000000,
        len  0x00200000,
        space data,
        access RW
    },
    EXT_HEAP {
        name EXT_HEAP,
        base 0x80200000,
        len  0x00300000,
        space data,
        access RW
    },
    TRACE_BUF {
        name TRACE_BUF,
        base 0x9F000000,
        len  0x00060000,
        space data,
        access RW
    },
    EXC_DATA {
        name EXC_DATA,
        base 0x9F060000,
        len  0x00010000,
        space data,
        access RW
    },
    PM_DATA {
        name PM_DATA,
        base 0x9F070000,
        len  0x00020000,
        space data,
        access RWX   should this have execute perm 
    },
    CMEM {
        name evmDRA7XX_CMEM.name,
        base evmDRA7XX_CMEM.base,
        len  evmDRA7XX_CMEM.len,
        space data,
        access RW
    },
};

Build.platformTable[ti.platforms.evmDRA7XXipu1] = {
    externalMemoryMap [
        [ EXT_CODE, evmDRA7XX_ExtMemMapIpu1.EXT_CODE ],
        [ EXT_DATA, evmDRA7XX_ExtMemMapIpu1.EXT_DATA ],
        [ EXT_HEAP, evmDRA7XX_ExtMemMapIpu1.EXT_HEAP ],
        [ TRACE_BUF, evmDRA7XX_ExtMemMapIpu1.TRACE_BUF ],
        [ EXC_DATA, evmDRA7XX_ExtMemMapIpu1.EXC_DATA ],
        [ PM_DATA, evmDRA7XX_ExtMemMapIpu1.PM_DATA ],
        [ evmDRA7XX_CMEM.name, evmDRA7XX_ExtMemMapIpu1.CMEM ],
    ],
    codeMemory EXT_CODE,
    dataMemory EXT_DATA,
    stackMemory EXT_DATA,
};

Host code:

/*
 * Copyright (c) 2013-2014, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ======== App.c ========
 *
 */

/* host header files */
#include <stdio.h>
#include <unistd.h>

/* package header files */
#include <ti/ipc/Std.h>
#include <ti/ipc/MessageQ.h>

/* cmem header file */
#include <ti/cmem.h>

/* local header files */
#include "../shared/AppCommon.h"
#include "App.h"

/* module structure */
typedef struct {
    MessageQ_Handle         hostQue;    // created locally
    MessageQ_QueueId        slaveQue;   // opened remotely
    UInt16                  heapId;     // MessageQ heapId
    UInt32                  msgSize;
} App_Module;

/* private data */
static App_Module Module;


#define PAYLOADSIZE        (0x100000 * 16) // 16MB

/*
 *  ======== App_create ========
 */

Int App_create(UInt16 remoteProcId)
{
    Int                 status = 0;
    MessageQ_Params     msgqParams;
    char                msgqName[32];

    printf("--> App_create:\n");

    status = CMEM_init();

    if (status < 0) {
        printf("CMEM_init failed\n");
        goto leave;
    }
    else {
        printf("CMEM_init success\n");
    }

    /* setting default values */
    Module.hostQue = NULL;
    Module.slaveQue = MessageQ_INVALIDMESSAGEQ;
    Module.heapId = App_MsgHeapId;
    Module.msgSize = sizeof(App_Msg);

    /* create local message queue (inbound messages) */
    MessageQ_Params_init(&msgqParams);

    Module.hostQue = MessageQ_create(App_HostMsgQueName, &msgqParams);

    if (Module.hostQue == NULL) {
        printf("App_create: Failed creating MessageQ\n");
        status = -1;
        goto leave;
    }

    /* open the remote message queue */
    sprintf(msgqName, App_SlaveMsgQueName, MultiProc_getName(remoteProcId));

    do {
        status = MessageQ_open(msgqName, &Module.slaveQue);
        sleep(1);
    } while (status == MessageQ_E_NOTFOUND);

    if (status < 0) {
        printf("App_create: Failed opening MessageQ\n");
        goto leave;
    }

    printf("App_create: Host is ready\n");

leave:
    printf("<-- App_create:\n");
    return(status);
}


/*
 *  ======== App_delete ========
 */
Int App_delete(Void)
{
    Int         status;

    printf("--> App_delete:\n");

    /* close remote resources */
    status = MessageQ_close(&Module.slaveQue);

    if (status < 0) {
        goto leave;
    }

    /* delete the host message queue */
    status = MessageQ_delete(&Module.hostQue);

    if (status < 0) {
        goto leave;
    }

leave:
    printf("<-- App_delete:\n");
    return(status);
}


/*
 *  ======== App_exec ========
 */
Int App_exec(Void)
{
    Int         status = 0;
    Int         i, j;
    App_Msg *   msg;
    CMEM_AllocParams        cmemAttrs;

    cmemAttrs.type = CMEM_HEAP;
    cmemAttrs.flags =  CMEM_NONCACHED;
    cmemAttrs.alignment = 0;

    printf("--> App_exec:\n");

    /* allocate message */
    msg = (App_Msg *)MessageQ_alloc(Module.heapId, Module.msgSize);

    if (msg == NULL) {
        status = -1;
        goto leave;
    }

    msg->dataByteSize = PAYLOADSIZE;

    for (i = 0; i < 1; i++) {
        msg->dataIn[i] = CMEM_allocPool(CMEM_getPool(PAYLOADSIZE), &cmemAttrs);
         if (msg->dataIn[i] == NULL) {
             printf("CMEM_alloc() failed (returned NULL)\n");
             status = -1;
             goto leave;
         }
         msg->dataInPhys[i] = CMEM_getPhys(msg->dataIn[i]);

         printf("user: %p phys: 0x%x\n", msg->dataIn[i], msg->dataInPhys[i]);

         uint8_t *dataIn = (uint8_t*)msg->dataIn[i];

         msg->inXor[i] = 0;

         for (j = 0; j < PAYLOADSIZE; j++) {
             dataIn[j] = rand();
             msg->inXor[i] ^= dataIn[j];
         }
    }

    /* set the return address in the message header */
    MessageQ_setReplyQueue(Module.hostQue, (MessageQ_Msg)msg);

    /* fill in message payload */
    msg->cmd = App_CMD_SHUTDOWN;

    MessageQ_put(Module.slaveQue, (MessageQ_Msg)msg);

    /* wait for return message */
    status = MessageQ_get(Module.hostQue, (MessageQ_Msg *)&msg,
        MessageQ_FOREVER);

    if (status < 0) {
        goto leave;
    }

    printf("The size of data is %d MB\n", PAYLOADSIZE / 1024 / 1024);
    printf("slave data xor result 0x%x, host(arm) 0x%x\n", msg->outXor, msg->inXor[0]);

    CMEM_free(msg->dataIn[0], &cmemAttrs);
    MessageQ_free((MessageQ_Msg)msg);

leave:
    printf("<-- App_exec: %d\n", status);
    return(status);
}

By the way,the other file is from ex02messageq project.

BR,

vefone

  • The whole project:

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/arm_2D00_dsp_2D00_ipu_2D00_cmem_2D00_example.7z

  • Hi,

    If I understand correctly you want to run these rtos binaries under linux, right?
    Can you share the am57xx-evm-cmem.dtsi content?

    Best Regards,
    Yordan
  • Hi,

    Yordan,

    The cmem configuration like that:

    BR,

    vefone

  • Hi,
    Yordan, is there any progress in this problem? The ipu1/IpuAmmu.cfg had configure like that:
    /* TILER & DMM regions: Large page (512M); cacheable */
    /* config large page[3] to map 512MB VA 0xA0000000 to L3 0xA0000000 */
    AMMU.largePages[3].pageEnabled = AMMU.Enable_YES;
    AMMU.largePages[3].logicalAddress = 0xA0000000;
    AMMU.largePages[3].translationEnabled = AMMU.Enable_NO;
    AMMU.largePages[3].size = AMMU.Large_512M;
    AMMU.largePages[3].L1_cacheable = AMMU.CachePolicy_CACHEABLE;
    AMMU.largePages[3].L1_posted = AMMU.PostedPolicy_POSTED;

    The ipu1 should can access the physical address 0x80000000. What is the reason,and how to solve the problem?

    BR,
    vefone
  • Hi,

    So the ipuAmmu.cfg file configures the following:
    /* config large page[3] to map 512MB VA 0xA0000000 to L3 0xA0000000 */
    This is part of the ddr and it complies with the definitions in am57xx-evm-cmem.dtsi file:
    cmem_block_mem_0: cmem_block_mem@a0000000 {
    reg = <0x0 0xa0000000 0x0 0x0c000000>;
    no-map;
    status = "okay";
    };
    and with am57xx-beagle-x15-common.dtsi:
    &ipu1 {
    status = "okay";
    memory-region = <&ipu1_cma_pool>;
    mboxes = <&mailbox5 &mbox_ipu1_ipc3x>;
    timers = <&timer11>;
    watchdog-timers = <&timer7>, <&timer8>;
    };
    ipu1_cma_pool: ipu1_cma@9d000000 {
    compatible = "shared-dma-pool";
    reg = <0x0 0x9d000000 0x0 0x2000000>;
    reusable;
    status = "okay";
    };

    How are you accessing the ram at address 0x80000000? Maybe you need some translation first.

    Best Regards,
    Yordan
  • Hi,

    Yordan, here the code of Host(A15):

    msg->dataIn[i] = CMEM_allocPool(CMEM_getPool(PAYLOADSIZE), &cmemAttrs);
    if (msg->dataIn[i] == NULL) {
    printf("CMEM_alloc() failed (returned NULL)\n");
    status = -1;
    goto leave;
    }
    msg->dataInPhys[i] = CMEM_getPhys(msg->dataIn[i]);

    printf("user: %p phys: 0x%x\n", msg->dataIn[i], msg->dataInPhys[i]);

    uint8_t *dataIn = (uint8_t*)msg->dataIn[i];

    msg->inXor[i] = 0;

    for (j = 0; j < PAYLOADSIZE; j++) {
    dataIn[j] = rand();
    msg->inXor[i] ^= dataIn[j];
    }

    Here are the code of IPU1(M4):

    while (running) {

    /* wait for inbound message */
    status = MessageQ_get(Module.slaveQue, (MessageQ_Msg *)&msg,
    MessageQ_FOREVER);

    if (status < 0) {
    goto leave;
    }

    for (i = 0; i < 1; i++) {
    if (Resource_physToVirt(msg->dataInPhys[i], &virtualAddrIn[i]) != Resource_S_SUCCESS) {
    Log_print1(Diags_INFO, "Server_exec: not found resource for phys 0x%x\n",
    msg->dataInPhys[i]);
    continue;
    }
    Log_print4(Diags_INFO, "Server_exec: addrPhys[%d] = 0x%x addrIn[%d]=0x%x",
    i, msg->dataInPhys[i], i, virtualAddrIn[i]);

    data_ptr = (uint8_t*)virtualAddrIn[i];

    dataXor = 0;

    for (j = 0; j < msg->dataByteSize; j++) {
    dataXor ^= data_ptr[j];
    }

    Log_print2(Diags_INFO, "Server_exec: xorIn[%d]=0x%x", i, dataXor);
    }

    msg->outXor = dataXor;

    if (msg->cmd == App_CMD_SHUTDOWN) {
    running = FALSE;
    }

    The Host will post the msg->dataInPhys to IPU1,then the ipu1 use Resource_physToVirt function get the virtual address of physical address(0xA0000000).Now the error show me that the ipu1 can not access the 0xA0000000,but ipuAmmu.cfg had mapped 512MB VA 0xA0000000 to L3 0xA0000000.