TI工程师,你们好:
在通过ARM的linux系统加载.out文件时发现如下两份代码不能进行ARM核与DSP核之间的数据传输
dsp核代码目录:C:\ti\ipc_3_00_04_29\packages\ti\ipc\tests\messageq_single.c
代码如下:
#include <xdc/std.h>
#include <xdc/runtime/Assert.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/ipc/MessageQ.h>
#define SLAVE_MESSAGEQNAME "SLAVE"
#define MessageQ_payload(m) ((void *)((char *)(m) + sizeof(MessageQ_MsgHeader)))
/*
* ======== tsk1Fxn ========
* Receive and return messages
*/
Void tsk1Fxn(UArg arg0, UArg arg1)
{
MessageQ_Msg msg;
MessageQ_Handle messageQ;
MessageQ_QueueId remoteQueueId;
Char localQueueName[64];
UInt16 procId;
Int status;
UInt16 msgId;
UInt32 start;
UInt32 end;
Uint32 numLoops;
UInt32 print;
UInt32 *params;
/* Construct a MessageQ name adorned with core name: */
System_sprintf(localQueueName, "%s_%s", SLAVE_MESSAGEQNAME,
MultiProc_getName(MultiProc_self()));
messageQ = MessageQ_create(localQueueName, NULL);
if (messageQ == NULL) {
System_abort("MessageQ_create failed\n");
}
System_printf("tsk1Fxn: created MessageQ: %s; QueueID: 0x%x\n",
localQueueName, MessageQ_getQueueId(messageQ));
while (1) {
/* handshake with host to get starting parameters */
System_printf("Awaiting sync message from host…\n");
MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
params = MessageQ_payload(msg);
numLoops = params[0];
print = params[1];
remoteQueueId = MessageQ_getReplyQueue(msg);
procId = MessageQ_getProcId(remoteQueueId);
System_printf("Received msg from (procId:remoteQueueId): 0x%x:0x%x\n"
"\tpayload: %d bytes; loops: %d %s printing.\n",
procId, remoteQueueId,
(MessageQ_getMsgSize(msg) – sizeof(MessageQ_MsgHeader)),
numLoops, print ? "with" : "without");
MessageQ_put(remoteQueueId, msg);
start = Clock_getTicks();
for (msgId = 0; msgId < numLoops; msgId++) {//接收1000包数据
status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);//获取ARM发送的数据包
Assert_isTrue(status == MessageQ_S_SUCCESS, NULL);
if (print) {
System_printf("Got msg #%d (%d bytes) from procId %d\n",
MessageQ_getMsgId(msg), MessageQ_getMsgSize(msg), procId);
}
Assert_isTrue(MessageQ_getMsgId(msg) == msgId, NULL);
if (print) {
System_printf("Sending msg Id #%d to procId %d\n", msgId,
procId);
}
status = MessageQ_put(remoteQueueId, msg);//将数据包环回给ARM
Assert_isTrue(status == MessageQ_S_SUCCESS, NULL);
}
end = Clock_getTicks();
if (!print) {
System_printf("%d iterations took %d ticks or %d usecs/msg\n",
numLoops,
end – start, ((end – start) * Clock_tickPeriod) / numLoops);//算出1000包环回需要的时间
}
}
}
/*
* ======== main ========
*/
Int main(Int argc, Char* argv[])
{
System_printf("%s:main: MultiProc id = %d\n", __FILE__, MultiProc_self());
Task_create(tsk1Fxn, NULL, NULL);
BIOS_start();
return (0);
}
ARM核0代码所在的目录:C:\ti\ipc_3_00_04_29\linux\src\tests\MessageQBench.c
代码如下
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/param.h>
#include <ti/ipc/Std.h>
#include <ti/ipc/Ipc.h>
#include <ti/ipc/MessageQ.h>
#define MessageQ_payload(m) ((void *)((char *)(m) + sizeof(MessageQ_MsgHeader)))
#define MINPAYLOADSIZE (2 * sizeof(UInt32))
/* App defines: Must match on remote proc side: */
#define NUM_LOOPS_DFLT 1000 /* Number of transfers to be tested. */
#define HEAPID 0u
#define PROC_ID_DFLT 1 /* Host is zero, remote cores start at 1 */
#define SLAVE_MESSAGEQNAME "SLAVE"
#define MPU_MESSAGEQNAME "HOST"
long diff(struct timespec start, struct timespec end)
{
struct timespec temp;
if ((end.tv_nsec – start.tv_nsec) < 0) {
temp.tv_sec = end.tv_sec – start.tv_sec-1;
temp.tv_nsec = 1000000000UL + end.tv_nsec – start.tv_nsec;
} else {
temp.tv_sec = end.tv_sec – start.tv_sec;
temp.tv_nsec = end.tv_nsec – start.tv_nsec;
}
return (temp.tv_sec * 1000000UL + temp.tv_nsec / 1000);
}
Int MessageQApp_execute(UInt32 numLoops, UInt32 payloadSize, UInt16 procId)
{
Int32 status = 0;
MessageQ_Msg msg = NULL;
MessageQ_Params msgParams;
UInt16 i;
MessageQ_QueueId queueId = MessageQ_INVALIDMESSAGEQ;
MessageQ_Handle msgqHandle;
char remoteQueueName[64];
struct timespec start, end;
long elapsed;
UInt32 *params;
printf ("Entered MessageQApp_execute\n");
/* Create the local Message Queue for receiving. */
MessageQ_Params_init(&msgParams);
msgqHandle = MessageQ_create(MPU_MESSAGEQNAME, &msgParams);
if (msgqHandle == NULL) {
printf ("Error in MessageQ_create\n");
goto exit;
}
else {
printf ("Local MessageQId: 0x%x\n", MessageQ_getQueueId(msgqHandle));
}
sprintf(remoteQueueName, "%s_%s", SLAVE_MESSAGEQNAME,
MultiProc_getName(procId));
/* Poll until remote side has its messageQ created before we send: */
do {
status = MessageQ_open(remoteQueueName, &queueId);
sleep (1);
} while (status == MessageQ_E_NOTFOUND);
if (status < 0) {
printf("Error in MessageQ_open [%d]\n", status);
goto cleanup;
}
printf("Remote queueId [0x%x]\n", queueId);
msg = MessageQ_alloc(HEAPID, sizeof(MessageQ_MsgHeader) + payloadSize);
if (msg == NULL) {
printf("Error in MessageQ_alloc\n");
MessageQ_close(&queueId);
goto cleanup;
}
/* handshake with remote to set the number of loops */
MessageQ_setReplyQueue(msgqHandle, msg);
params = MessageQ_payload(msg);
params[0] = numLoops;
params[1] = FALSE;
MessageQ_put(queueId, msg);
MessageQ_get(msgqHandle, &msg, MessageQ_FOREVER);
printf("Exchanging %d messages with remote processor %s…\n",
numLoops, MultiProc_getName(procId));
clock_gettime(CLOCK_REALTIME, &start);
for (i = 0; i < numLoops; i++) {
MessageQ_setMsgId(msg, i);
/* Have the remote proc reply to this message queue */
MessageQ_setReplyQueue(msgqHandle, msg);
status = MessageQ_put(queueId, msg);//将数据发送给DSP
if (status < 0) {
printf("Error in MessageQ_put [%d]\n", status);
break;
}
status = MessageQ_get(msgqHandle, &msg, MessageQ_FOREVER);//获取DSP发送给ARM的数据,但此处并未拿到DSP的数据。
if (status < 0) {
printf("Error in MessageQ_get [%d]\n", status);
break;
}
else {
/* Validate the returned message. */
if ((msg != NULL) && (MessageQ_getMsgId(msg) != i)) {
printf ("Data integrity failure!\n"
" Expected %d\n"
" Received %d\n",
i, MessageQ_getMsgId (msg));
break;
}
}
}
clock_gettime(CLOCK_REALTIME, &end);
elapsed = diff(start, end);
if (numLoops > 0) {
printf("%s: Avg round trip time: %ld usecs\n",
MultiProc_getName(procId), elapsed / numLoops);
}
MessageQ_free(msg);
MessageQ_close(&queueId);
cleanup:
status = MessageQ_delete(&msgqHandle);
if (status < 0) {
printf ("Error in MessageQ_delete [%d]\n", status);
}
exit:
printf("Leaving MessageQApp_execute\n\n");
return (status);
}
int main (int argc, char * argv[])
{
Int32 status = 0;
UInt32 numLoops = NUM_LOOPS_DFLT;
UInt32 payloadSize = MINPAYLOADSIZE;
UInt16 procId = PROC_ID_DFLT;
/* Parse args: */
if (argc > 1) {
numLoops = strtoul(argv[1], NULL, 0);
}
if (argc > 2) {
payloadSize = MAX(strtoul(argv[2], NULL, 0), MINPAYLOADSIZE);
}
if (argc > 3) {
procId = atoi(argv[3]);
}
if (argc > 4) {
printf("Usage: %s [<numLoops>] [<payloadSize>] [<ProcId>]\n", argv[0]);
printf("\tDefaults: numLoops: %d; payloadSize: %d, ProcId: %d\n",
NUM_LOOPS_DFLT, MINPAYLOADSIZE, PROC_ID_DFLT);
exit(0);
}
status = Ipc_start();
if (procId >= MultiProc_getNumProcessors()) {
printf("ProcId must be less than %d\n", MultiProc_getNumProcessors());
Ipc_stop();
exit(0);
}
printf("Using numLoops: %d; payloadSize: %d, procId : %d\n",
numLoops, payloadSize, procId);
if (status >= 0) {
MessageQApp_execute(numLoops, payloadSize, procId);
Ipc_stop();
}
else {
fprintf(stderr, "Ipc_start failed: status = %d\n", status);
}
return (status);
}
问题1:是我本身理解有问题,还是文件没有找对,使发送的数据无法回环出有效的数据.
因为本身开发的LINUX ARM模块有驱动模块需要重新编译U-BOOT,内核,文件系统,
(1)u-boot-spi-keystone-evm.gph
(2)uImage-keystone-evm.bin
(3)tisdk-rootfs.cpio
问题2如何将上面三个文件制作成
keystone-evm-ubifs.ubi文件。
user5315971:
没人吗,自己顶一下