【Xilinx】基于MPSoC的OpenAMP实现(二)
前言
参考前文
【Xilinx】基于MPSoC的OpenAMP实现(一)
在上一篇文章里面主要是采用Xilinx提供的现成的openamp.dtsi和已经编译好的image_echo_test固件、echo_test应用程序进行快速测试验证,目的是证明软件环境、硬件环境都能够正常运行OpenAMP。
以此作为基线,我们进一步研究如何修改定制image_echo_test、echo_test、openamp.dtsi,以及内部工作原理。
一、修改echo_test
1、查找源代码
首先我们先找到源代码
xlx@u16:/opt/work/p202/xilinx-zcu106-2020.2$ find . -name echo_test.c
./components/yocto/layers/meta-openamp/recipes-openamp/rpmsg-examples/rpmsg-echo-test/echo_test.c
cd ./components/yocto/layers/meta-openamp/recipes-openamp/rpmsg-examples/
xlx@u16:/opt/work/p202/xilinx-zcu106-2020.2/components/yocto/layers/meta-openamp/recipes-openamp/rpmsg-examples$ tree
.
├── rpmsg-echo-test
│ ├── echo_test.c
│ ├── LICENSE
│ └── Makefile
├── rpmsg-echo-test_1.0.bb
├── rpmsg-mat-mul
│ ├── LICENSE
│ ├── Makefile
│ └── mat_mul_demo.c
├── rpmsg-mat-mul_1.0.bb
├── rpmsg-proxy-app
│ ├── LICENSE
│ ├── Makefile
│ ├── proxy_app.c
│ └── proxy_app.h
└── rpmsg-proxy-app_1.0.bb
可以看到3个测试例子都在components/yocto/layers/meta-openamp/recipes-openamp/rpmsg-examples目录下,代码结构很简单,一个makefie加上一个c文件
Makefile如下
APP = echo_test
APP_OBJS = echo_test.o
# Add any other object files to this list below
all: $(APP)
$(APP): $(APP_OBJS)
$(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)
clean:
rm -rf $(APP) *.o
%.o: %.c
$(CC) -c $(CFLAGS) -o $@ $<
echo_test.c
/*
* echo_test.c
*
* Created on: Oct 4, 2014
* Author: etsam
*/
/*
* Test application that data integraty of inter processor
* communication from linux userspace to a remote software
* context. The application sends chunks of data to the
* remote processor. The remote side echoes the data back
* to application which then validates the data returned.
*/
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <time.h>
#include <fcntl.h>
#include <string.h>
#include <linux/rpmsg.h>
struct _payload {
unsigned long num;
unsigned long size;
char data[];
};
static int charfd = -1, fd = -1, err_cnt;
struct _payload *i_payload;
struct _payload *r_payload;
#define RPMSG_GET_KFIFO_SIZE 1
#define RPMSG_GET_AVAIL_DATA_SIZE 2
#define RPMSG_GET_FREE_SPACE 3
#define RPMSG_HEADER_LEN 16
#define MAX_RPMSG_BUFF_SIZE (512 - RPMSG_HEADER_LEN)
#define PAYLOAD_MIN_SIZE 1
#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
#define RPMSG_BUS_SYS "/sys/bus/rpmsg"
static int rpmsg_create_ept(int rpfd, struct rpmsg_endpoint_info *eptinfo)
{
int ret;
ret = ioctl(rpfd, RPMSG_CREATE_EPT_IOCTL, eptinfo);
if (ret)
perror("Failed to create endpoint.\n");
return ret;
}
static char *get_rpmsg_ept_dev_name(const char *rpmsg_char_name,
const char *ept_name,
char *ept_dev_name)
{
char sys_rpmsg_ept_name_path[64];
char svc_name[64];
char *sys_rpmsg_path = "/sys/class/rpmsg";
FILE *fp;
int i;
int ept_name_len;
for (i = 0; i < 128; i++) {
sprintf(sys_rpmsg_ept_name_path, "%s/%s/rpmsg%d/name",
sys_rpmsg_path, rpmsg_char_name, i);
printf("checking %s\n", sys_rpmsg_ept_name_path);
if (access(sys_rpmsg_ept_name_path

本文以前文基于MPSoC的OpenAMP实现测试为基线,介绍如何修改定制相关程序。首先讲述查找echo_test源代码,接着说明创建自己的app,包括新建app和编译代码,编译可采用petalinux - build或创建sdk编译,最后提及需要注意的地方,后续还将讲如何修改image_echo_test。
&spm=1001.2101.3001.5002&articleId=132993211&d=1&t=3&u=b00b86c02a7d48d2bc0ffdffe400959c)
2625

被折叠的 条评论
为什么被折叠?



