【Xilinx-Petalinux学习】-08-OpenAMP系统实现
openAMP系统实现。
一个核跑Linux,一个核裸跑。 -----> 已经实现。
一个核跑Linux,一个核跑UCOS -----> 还未实现。
Micrium的ucos OpenAMP例子与Xilinx的例子框架结构有些不同,尝试修改共享内存基地址、改变程序结构,还未成功。先放一放,以后再来实验,或者等Micrium给出官方的例程~~~~TT
step1: openAMP框架介绍
参考文档:ug1186
step2: 创建standalone应用工程
从Vivado中Export Hardwre(Include bitstream)后,点击Launch SDK打开Xilinx SDK开发工具。
这一次我们需要实现在裸机上运行AMP架构的程序。
首先创建BSP:File -> New -> Board Support Package
对话框的选项按下面配置:
Hardware Platform :选择从vivado中输出的平台名称
CPU :选择ps7_cortexa9_1,(即第二个arm核,第一个用来运行Linux和作为AMP的主机)
BSP OS platform :选择standalone
点击Finish按键,进入BSP的详细配置界面:
Overview,库支持中选中xilopenamp
standalone选项,stdin和stdout需要选择与Linux系统(ps_uart1)不同的串口
drivers->ps7_cortexa9_1,修改 extra_compiler_flags的值,加入“-DUSE_AMP=1” #-DUSE_AMP=1说明
#Add -DUSEAMP=1 to the extra_compiler_flags to disable the definition of
#low-level read, write, and open operations.
#This also disables the vector table location in
#the tightly-coupled memory (TCM).
点击OK,BSP就配置完成了,等待Xilinx SDK自动生成各种文件。
接着,需要依赖这个BSP去创建OpenAMP的应用程序。
针对裸机standalone,软件内提供了三个例子:echo-test,matrix multiplication Demo,RPC Demo。如下图:
我们直接调用例子,生成三个OpenAMP应用程序。编译后,我们就能够在每个应用工程的Debug文件夹下,找到需要的裸机elf可执行文件。
编译时候有一些警告,官网查到说不用理会这些。警告有:
in expansion of macro 'XScuGic_EnableIntr'
in expansion of macro 'XScuGic_DisableIntr'
implicit declaration of function 'Xil_Out32' [-Wimplicit-function-declaration]
implicit declaration of function 'Xil_In32' [-Wimplicit-function-declaration]
我下载的2015.4的PetaLinux中,默认是没有OpenAMP的例子的。
因此我从别的地方拷贝了一些例子来用。
网址:https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools/2015-4.html
在里面下载Avnet-Digilent-ZedBoard BSP安装包,安装后在 ./componets/apps 和 ./componets/modules 文件夹下会有我需要用到了三个APP和两个Module
从里面直接复制以下文件夹,并粘贴到我们的PetaLinux工程相同的目录下:
/componets/apps/echo_test
/componets/apps/mat_mul_demo
/componets/apps/proxy_app
/componets/modules/rpmsg_proxy_dev_driver
/componets/modules/rpmsg_usr_dev_driver
复制完成后,每个app文件夹下还有一个“data”文件夹,这个就是我们之后OpenAMP系统中第二个内核需要加载的可执行代码。分别是:
image_echo_test , image_matrix_multiply , image_rpc_demo
这三个代码是基于ZedBoard,用FreeRTOS实现的三个例子。试验过,它们也能够在我的系统中直接使用,可以试试。
我们现在讲我们自己通过Xilinx SDK编译出的三个elf文件复制出来,分别命名为image_echo_test , image_matrix_multiply , image_rpc_demo,并复制到各自app中的data文件夹中去(提前删除或是备份原有的文件)。
这样,针对OpenAMP的准备工作就做好了,开始进行PetaLinux的配置。
step3: PetaLinux中加入OpenAMP的支持
硬件平台的内存为4Gb,即512MB。我们将低256MB作为裸机的内存,高256MB则作为Linux的内存。
下面来进行配置。
首先是地址空间配置:
petalinux-config #在选项中配置Linux内核基地址为0x10000000
Subsystem AUTO Hardware Settings --->
Memory Settings --->
(0x10000000) kernel base address
u-boot Configuration --->
(0x11000000) netboot offset
kernel配置:
petalinux-config -c kernel #手动配置
[*] Enable loadable module support --->
Device Drivers --->
Generic Driver Options --->
<*> Userspace firmware loading support
Remoteproc drivers --->
<M> Support ZYNQ remoteproc
<M> Support Microblaze remoteproc #can be unselected
Rpmsg drivers --->
<M> An rpmsg server sample
Kernel Features--->
Memory split (...)--->
(x) 2G/2G user/kernel split
[*] High Memory Support--->
rootfs配置:
petalinux-config -c rootfs #手动配置
Apps --->
[*] echo_test --->
[*] mat_mul_demo --->
[*] proxy_app --->
Modules --->
[*] rpmsg_proxy_dev_driver --->
[*] rpmsg_user_dev_driver --->
最后是修改设备树:
#创建设备树文件
gedit ./subsystem/linux/configs/device-tree/openamp-overlay.dtsi
#加入以下文本信息:
/ {
amba {
remoteproc0: remoteproc@0 {
compatible = "xlnx,zynq_remoteproc";
reg = < 0x00000000 0x10000000 >;
firmware = "firmware";
vring0 = <15>;
vring1 = <14>;
};
};
};
#保存并关闭 #添加到openamp-overlay.dtsi的引用
gedit ./subsystem/linux/configs/device-tree/system-top.dtsi
#在最后面加入下面的文本
/include/ "openamp-overlay.dtsi"
#保存并关闭
最后进行编译:
petalinux-build
生成BOOT.bin,并拷贝它和image.ub两个文件,更新我们硬件平台上的文件。重新启动运行!
step4: OpenAMP程序测试
echo_test测试:
#安装
modprobe zynq_remoteproc firmware=image_echo_test
modprobe rpmsg_user_dev_driver
#运行
echo_test
#卸载
modprobe -r rpmsg_user_dev_driver
modprobe -r zynq_remoteproc
mat_mul_demo测试:
#安装
modprobe zynq_remoteproc firmware=image_matrix_multiply
modprobe rpmsg_user_dev_driver
#运行
mat_mul_demo
#卸载
modprobe -r rpmsg_user_dev_driver
modprobe -r zynq_remoteproc
proxy_app测试:
#运行:
proxy_app -m zynq_remoteproc
出现的问题:
问题一:执行echo_test时,出现错误:Failed to open rpmsg file /dev/rpmsg0.: No such file or directory
网址:https://forums.xilinx.com/t5/OpenAMP/Failed-to-open-rmpsg-file-in-open-amp/td-p/672640
原因:没有包含openamp的设备树信息
解决:在system-top.dts文件最后面加入
/include/ "openamp-overlay.dtsi"
问题二:加载指定目录的image时,出现错误remoteproc0: Direct firmware load for /lib/firmware/test.elf failed with error -2
网址:https://forums.xilinx.com/t5/OpenAMP/remoteproc-don-t-load-pre-built-test-apps-when-specifing-full/td-p/714886
解决:需要使用相对路径
modprobe zynq_remoteproc firmware=../../myrootdir/test.elf
测试程序log:
echo_test:
root@ifc_petalinux:~# modprobe zynq_remoteproc firmware=image_echo_test
CPU1: shutdown
remoteproc0: 0.remoteproc is available
remoteproc0: Note: remoteproc is still under development and considered experimental.
remoteproc0: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn't yet guaranteed.
root@ifc_petalinux:~# remoteproc0: registered virtio0 (type 7)
remoteproc0: powering up 0.remoteproc
remoteproc0: Booting fw image image_echo_test, size 164688
root@ifc_petalinux:~# modprobe zynq_remoteproc firmware=image_echo_test remoteproc0: remote processor 0.remoteproc is now up
virtio_rpmsg_bus virtio0: rpmsg host is online
virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x1
root@ifc_petalinux:~# modprobe rpmsg_user_dev_driver
rpmsg_proxy_dev_rpmsg rpmsg0: rpmsg_user_dev_rpmsg_drv_probe
rpmsg_proxy_dev_rpmsg rpmsg0: Sent init_msg to target 0x0.
rpmsg_proxy_dev_rpmsg rpmsg0: new channel: 0x400 -> 0x1!
root@ifc_petalinux:~# echo_test Echo test start Open rpmsg dev! Query internal info ..
rpmsg kernel fifo size = 2048
rpmsg kernel fifo free space = 2048 ****************************************
Please enter command and press enter key
****************************************
1 - Send data to remote core, retrieve the echo and validate its integrity ..
2 - Quit this application ..
CMD>1 sending payload number 0 of size 9
echo test: sent : 9
received payload number 0 of size 16 sending payload number 2 of size 10
echo test: sent : 10
received payload number 2 of size 16 sending payload number 3 of size 11
echo test: sent : 11
received payload number 3 of size 16 ~~~~~~~~~~~~
sending payload number 470 of size 478
echo test: sent : 478
received payload number 470 of size 480 sending payload number 471 of size 479
echo test: sent : 479
received payload number 471 of size 480 ************************************** Test Results: Error count = 0 ************************************** ****************************************
Please enter command and press enter key
****************************************
1 - Send data to remote core, retrieve the echo and validate its integrity ..
2 - Quit this application ..
CMD>2
virtio_rpmsg_bus virtio0: destroying channel rpmsg-openamp-demo-channel addr 0x1
rpmsg_proxy_dev_rpmsg rpmsg0: rpmsg_user_dev_rpmsg_drv_remove Quitting application ..
Echo test end
root@ifc_petalinux:~# modprobe -r rpmsg_user_dev_driver
remoteproc0: stopped remote processor 0.remoteproc
root@ifc_petalinux:~# modprobe -r zynq_remoteproc
zynq_remoteproc 0.remoteproc: zynq_remoteproc_remove
zynq_remoteproc 0.remoteproc: Deleting the irq_list
remoteproc0: releasing 0.remoteproc
root@ifc_petalinux:~#
mat_mul_demo:
root@ifc_petalinux:~# modprobe zynq_remoteproc firmware=image_matrix_multiply
CPU1: shutdown
remoteproc0: 0.remoteproc is available
remoteproc0: Note: remoteproc is still under development and considered experimental.
remoteproc0: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn't yet guaranteed.
root@ifc_petalinux:~# remoteproc0: registered virtio0 (type 7)
remoteproc0: powering up 0.remoteproc
remoteproc0: Booting fw image image_matrix_multiply, size 164688
remoteproc0: remote processor 0.remoteproc is now up
virtio_rpmsg_bus virtio0: rpmsg host is online
virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x1 root@ifc_petalinux:~# modprobe rpmsg_user_dev_driver
rpmsg_proxy_dev_rpmsg rpmsg0: rpmsg_user_dev_rpmsg_drv_probe
rpmsg_proxy_dev_rpmsg rpmsg0: Sent init_msg to target 0x0.
rpmsg_proxy_dev_rpmsg rpmsg0: new channel: 0x400 -> 0x1!
root@ifc_petalinux:~# mat_mul_demo Matrix multiplication demo start Open rpmsg dev! Query internal info ..
rpmsg kernel fifo size = 2048
rpmsg kernel fifo free space = 2048 Creating ui_thread and compute_thread ... ****************************************
Please enter command and press enter key
****************************************
1 - Generates random 6x6 matrices and transmits them to remote core over rpmsg ..
2 - Quit this application ..
CMD>1 Compute thread unblocked ..
The compute thread is now blocking ona read() from rpmsg device Generating random matrices now ... Master : Linux : Input matrix 0 4 0 3 5 9 6
7 1 6 4 1 4
2 9 4 4 7 4
8 6 4 3 7 2
5 4 0 4 9 0
1 5 2 4 0 2 Master : Linux : Input matrix 1 2 9 5 0 4 6
5 8 5 1 4 4
7 2 0 2 7 0
6 3 4 6 9 5
9 0 0 1 6 0
5 0 2 0 3 6 Writing generated matrices to rpmsg rpmsg device, 296 bytes written .. Received results! - 148 bytes from rpmsg device (transmitted from remote context) Master : Linux : Printing results
170 57 52 45 154 85
114 95 64 38 128 90
184 110 79 48 162 92
165 137 86 39 159 99
135 89 61 37 126 66
75 65 50 33 80 58 ****************************************
Please enter command and press enter key
****************************************
1 - Generates random 6x6 matrices and transmits them to remote core over rpmsg ..
2 - Quit this application ..
CMD>2 Quitting application ..
virtio_rpmsg_bus virtio0: destroying channel rpmsg-openamp-demo-channel addr 0x1 rpmsg_proxy_dev_rpmsg rpmsg0: rpmsg_user_dev_rpmsg_drv_remove Quitting application ..
Matrix multiply application end
root@ifc_petalinux:~# modprobe -r rpmsg_user_dev_driver
remoteproc0: stopped remote processor 0.remoteproc
root@ifc_petalinux:~# modprobe -r zynq_remoteproc
zynq_remoteproc 0.remoteproc: zynq_remoteproc_remove
zynq_remoteproc 0.remoteproc: Deleting the irq_list
remoteproc0: releasing 0.remoteproc
root@ifc_petalinux:~#
proxy_app:
root@ifc_petalinux:~# proxy_app -m zynq_remoteproc Master>Loading remote firmware
CPU1: shutdown
remoteproc0: 0.remoteproc is available
remoteproc0: Note: remoteproc is still under development and considered experimental.
remoteproc0: THE BINARY FORMAT IS NOT YET FINALIZED, and backward compatibility isn't yet guaranteed. Master>Create rpmsg proxy device Master>Opening rpmsg proxy device
remoteproc0: powering up 0.remoteproc
remoteproc0: Booting fw image image_rpc_demo, size 181072
remoteproc0: remote processor 0.remoteproc is now up
virtio_rpmsg_bus virtio0: rpmsg host is online
remoteproc0: registered virtio0 (type 7)
virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x1
rpmsg_proxy_dev_rpmsg rpmsg0: rpmsg_proxy_dev_rpmsg_drv_probe
rpmsg_proxy_dev_rpmsg rpmsg0: Sent init_msg to target 0x1.
rpmsg_proxy_dev_rpmsg rpmsg0: new channel: 0x400 -> 0x1!
rpmsg_dev_open Master>RPC service started !! Remote>Baremetal Remote Procedure Call (RPC) Demonstration Remote>*************************************************** Remote>Rpmsg based retargetting to proxy initialized.. Remote>FileIO demo .. Remote>Creating a file on master and writing to it.. Remote>Opened file 'remote.file' with fd = 4 Remote>Wrote to fd = 4, size = 45, content = This is a test string being written to file.. Remote>Closed fd = 4 Remote>Reading a file on master and displaying its contents.. Remote>Opened file 'remote.file' with fd = 4 Remote>Read from fd = 4, size = 45, printing contents below .. This is a test string being written to file.. Remote>Closed fd = 4 Remote>Remote firmware using scanf and printf .. Remote>Scanning user input from master.. Remote>Enter name
vacajk Remote>Enter age
22 Remote>Enter value for pi
11.11 Remote>User name = 'vacajk' Remote>User age = '22' Remote>User entered value of pi = '11.110000' Remote>Repeat demo ? (enter yes or no)
no Remote>RPC retargetting quitting ... Master>RPC service exivirtio_rpmsg_bus virtio0: destroying channel rpmsg-openamp-demo-channel addr 0x1
ting !!
Master> sending shutdown signal.
rpmsg_proxy_dev_rpmsg rpmsg0: rpmsg_proxy_dev_rpmsg_drv_remove
remoteproc0: stopped remote processor 0.remoteproc
zynq_remoteproc 0.remoteproc: zynq_remoteproc_remove
zynq_remoteproc 0.remoteproc: Deleting the irq_list
remoteproc0: releasing 0.remoteproc
root@ifc_petalinux:~#
【Xilinx-Petalinux学习】-08-OpenAMP系统实现的更多相关文章
- JavaScript学习08 Cookie对象
JavaScript学习08 Cookie对象 JavaScript Cookie Cookie对象: Cookie是一种以文件的形式保存在客户端硬盘的Cookies文件夹中的用户数据信息(Cooki ...
- ThinkPhp学习08
原文:ThinkPhp学习08 一.普通查询方式 a.字符串 $arr=$m->where("sex=0 and username='gege'")->find(); ...
- Extjs的学习及MIS系统实践应用
Extjs的学习及MIS系统实践应用(系列文章) 本系列文章从Extjs的实际运用出发,结合系统开发的实践经验,详细解释Extjs的基本控件及控件扩展的用法,和在平时的学习运用中一步一步查阅的资料.积 ...
- Symfony2 学习笔记之系统路由
mfony2 学习笔记之系统路由 漂亮的URL绝对是一个严肃的web应用程序必须做到的,这种方式使index.php?article_id=57这类的丑陋URL被隐藏,由更受欢迎的像 /read/ ...
- Linux学习笔记-Linux系统简介
Linux学习笔记-Linux系统简介 UNIX与Linux发展史 UNIX是父亲,Linux是儿子. UNIX发行版本 操作系统 公司 硬件平台 AIX IBM PowerPC HP-UX HP P ...
- 创芯Xilinx Microblaze 学习系列第一集
创芯Xilinx Microblaze 学习系列第一集 Xilinx ISE Design Suite 13.2 The MicroBlaze™ embedded processor soft cor ...
- 【零基础学习FreeRTOS嵌入式系统】之一:FreeRTOS环境搭建
[零基础学习FreeRTOS嵌入式系统]之一:FreeRTOS环境搭建 一:FreeRTOS系统下载 在官网上https://www.freertos.org/,找到下载入口. 或直接进入下载地址ht ...
- Linux学习之三-Linux系统的一些重要配置文件
Linux学习之三-Linux系统的一些重要配置文件 1.网卡配置文件 /etc/sysconfig/network-scripts/ifcfg-eth0 说明: DEVICE=eth0 ...
- [业界方案] 用SOFATracer学习分布式追踪系统Opentracing
[业界方案] 用SOFATracer学习分布式追踪系统Opentracing 目录 [业界方案] 用SOFATracer学习分布式追踪系统Opentracing 0x00 摘要 0x01 缘由 &am ...
随机推荐
- java工程开发之图形化界面之(第四课)
本节中,我们将创建一个小应用程序,它使用循环生成其图案.我们将使用if语句和setColor方法.同时我们将介绍drawString方法,并使用它在小应用程序窗口中写出文本. 下面的小应用程序是显示一 ...
- 第15章 I/O(输入/输出)
在变量.数组和对象中存储的数据是暂时存在的,程序结束后它们就会丢失.为了能够永久地保存创建的数据,需要将其保存在磁盘文件中,这样就可以在其它程序中使用它们.Java的I/O技术可以将数据保存到文本文件 ...
- select标签 样式 及文本有空格
<s:select name="codeid" id="codeid" multiple="false" list="#s ...
- Android5.0 Gallery2上编译Gallery模块出错
Android5.0 Gallery2上编译Gallery模块出错 时间:2015-05-05 19:32:57 阅读:105 评论:0 收藏:0 [点我收藏+ ...
- Android传感器编程带实例(转)
源:http://www.cnblogs.com/xiaochao1234/p/3894751.html 看了程序人生 网站的 编程高手的编程感悟 深有感触,好像也是一个android 程序员写的,推 ...
- ArrayList和数组间的相互转换
开发中不免碰到List与数组类型之间的相互转换,举一个简单的例子: package test.test1; import java.util.ArrayList; import java.util.L ...
- CATranstion动画
// 1.创建过度动画 CATransition *anima = [CATransition animation]; // 2.设置动画类型 anima.type = @"cube&quo ...
- DW常用
Dreamweaver代码 基本结构标签: <HTML>,表示该文件为HTML文件 <HEAD>,包含文件的标题,使用的脚本,样式定义等 <TITLE>---< ...
- 转:lr_eval_string,lr_save_string 和 sprintf 的使用
lr_eval_string,lr_save_string和 sprintf 函数使用介绍 一.lr_eval_string 使用介绍1.函数的主要作用:返回脚本中的一个参数当前的值,返回值类型:ch ...
- SpringMvc MultipartFile 图片文件上传
spring-servlet.xml <!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 --> <bean id="multipar ...