logo资料库

ug1186-zynq-openamp-gsg.pdf

第1页 / 共89页
第2页 / 共89页
第3页 / 共89页
第4页 / 共89页
第5页 / 共89页
第6页 / 共89页
第7页 / 共89页
第8页 / 共89页
资料共89页,剩余部分请下载后查看
Libmetal and OpenAMP User Guide
Revision History
Table of Contents
Ch. 1: Overview
Introduction
Software Tools Requirements
Prerequisites
Ch. 2: Libmetal
Overview
Access Devices with Libmetal
Start Libmetal Environment, Add and Open the Devices
Register the Interrupt, Write and Read Device Registers
Close Device and Close Libmetal Environment
Access IPI and Shared Memory with Libmetal
Zynq UltraScale+ MPSoC IPI Hardware
Shared Memory
Xilinx Libmetal AMP Demo
Build Libmetal Bare-Metal Firmware with Xilinx SDK
Enable Linux Demo Application Using Libmetal with PetaLinux Tools
Build Libmetal Linux Demo in Xilinx SDK
Build the Linux Demo Application and the Linux Project
Testing on Hardware
Ch. 3: OpenAMP
Overview
Components in OpenAMP
Connection between OpenAMP and Libmetal
How to Write a Simple OpenAMP Application
OpenAMP Demos
Petalinux Images Quick Try
Building OpenAMP application for RPU Firmware
Introduction
Building Remote Applications in Xilinx SDK
Creating an Application Project for OpenAMP
OpenAMP Xilinx SDK Key Source Files
Building Linux Application that uses RPMsg in kernel space
Setting up PetaLinux with OpenAMP
Settings for the Device Tree Binary Source
Building the Applications and the Linux Project
Booting the PetaLinux Project
Booting on QEMU
Booting on Hardware
Setting Up the Board
Downloading the Images
Running the Example Applications
Running the Echo Test
Debugging an OpenAMP Application
Debugging RPU Firmware
Debugging Linux OpenAMP Application
Running the Matrix Multiplication Test
Running the Proxy Application
Building Linux Applications Using OpenAMP RPMsg in Linux Userspace
Build Linux Userspace RPMsg Demo Applications Using PetaLinux Tools
Building RPU Firmware
Testing on Hardware
Ch. 4: System Design Consideration
Supported Configuration
Other Consideration
Known Limitations
Linux RPMsg Buffer Size
Appx. A: Libmetal APIs
Libmetal API Functions
Top Level Interfaces
metal_init
Description
Arguments
Returns
Usage
metal_finish
Description
Usage
Interrupt Handling Interfaces
metal_irq_handler
Description
Arguments
Returns
Usage
metal_irq_register
Description
Arguments
Returns
Usage
metal_irq_save_disable
Description
Returns
Usage
metal_irq_restore_enable
Description
Arguments
Usage
metal_irq_enable
Description
Arguments
Usage
metal_irq_disable
Description
Arguments
Usage
Shared Memory Interfaces
metal_shmem_open
Description
Arguments
Returns
Usage
metal_shmem_register_generic
Description
Arguments
Returns
Usage
Spinlock Interfaces
metal_spinlock_init
Description
Arguments
Usage
metal_spinlock_acquire
Description
Arguments
Usage
metal_spinlock_release
Description
Arguments
Usage
Sleep Interfaces
metal_sleep_usec
Description
Arguments
Returns
Usage
Mutex Interfaces
metal_mutex_init
Description
Arguments
Usage
Description
Arguments
Usage
metal_mutex_deinit
Description
Arguments
Usage
metal_mutex_try_acquire
Description
Arguments
Returns
Usage
metal_mutex_acquire
Description
Arguments
Usage
metal_mutex_release
Description
Arguments
Usage
metal_mutex_is_acquired
Description
Arguments
Usage
I/O Interfaces
metal_io_init
Description
Arguments
Usage
metal_io_finish
Description
Arguments
Usage
metal_io_region_size
Description
Arguments
Returns
Usage
metal_io_virt
Description
Arguments
Returns
Usage
metal_io_virt_to_offset
Description
Arguments
Returns
Usage
metal_io_phys
Description
Arguments
Returns
Usage
metal_io_phys_to_offset
Description
Arguments
Returns
Usage
metal_io_phys_to_virt
Description
Arguments
Returns
Usage
metal_io_virt_to_phys
Description
Arguments
Returns
Usage
metal_io_read
Description
Arguments
Returns
Usage
metal_io_write
Description
Arguments
Usage
metal_io_block_read
Description
Arguments
Returns
Usage
metal_io_block_write
Description
Arguments
Returns
Usage
metal_io_block_set
Description
Arguments
Returns
Usage
Bus Abstraction
metal_bus_register
Description
Arguments
Returns
Usage
metal_bus_unregister
Description
Arguments
Returns
Usage
metal_bus_find
Description
Arguments
Returns
Usage
metal_register_generic_device
Description
Arguments
Returns
Usage
metal_device_open
Description
Arguments
Returns
Usage
metal_device_close
Description
Arguments
Usage
metal_device_io_region
Description
Arguments
Returns
Usage
Condition Variable Interfaces
metal_condition_init
Description
Arguments
Usage
metal_condition_signal
Description
Arguments
Returns
Usage
metal_condition_broadcast
Description
Arguments
Returns
Usage
metal_condition_wait
Description
Arguments
Returns
Usage
Allocation Interfaces
metal_allocate_memory
Description
Arguments
Returns
Usage
metal_free_memory
Description
Arguments
Usage
Libary Version Interfaces
metal_ver_major
Description
Returns
Usage
metal_ver_minor
Description
Returns
Usage
metal_ver_patch
Description
Returns
Usage
metal_ver
Description
Returns
Usage
Appx. B: OpenAMP APIs
Remoteproc APIs
Introduction
Remoteproc API Functions
remoteproc_init
Description
Usage
Arguments
Returns
remoteproc_remove
Description
Usage
Arguments
Returns
remoteproc_get_io_with_name
Usage
Arguments
Returns
remoteproc_get_io_with_pa
Usage
Arguments
Returns
remoteproc_get_io_with_da
Usage
Arguments
Returns
remoteproc_get_io_with_va
Usage
Arguments
Returns
remoteproc_mmap
Usage
Arguments
Returns
remoteproc_parse_rsc_table
Usage
Arguments
Returns
remoteproc_set_rsc_table
Usage
Arguments
Returns
remoteproc_create_virtio
Usage
Arguments
Returns
remoteproc_remove_virtio
Usage
Arguments
Returns
remoteproc_get_notification
Usage
Arguments
Returns
RPMsg Development
Introduction
RPMsg API Functions
rpmsg_send_offchannel_raw()
Description
Usage
Arguments
Returns
rpmsg_send()
Description
Usage
Arguments
Returns
rpmsg_sendto()
Description
Usage
Arguments
Returns
rpmsg_send_offchannel()
Description
Usage
Arguments
Returns
rpmsg_trysend()
Description
Usage
Arguments
Returns
rpmsg_trysendto()
Description
Usage
Arguments
Returns
rpmsg_trysend_offchannel()
Description
Usage
Arguments
Returns
rpmsg_init_ept
Description
Usage
Arguments
rpmsg_create_ept
Description
Usage
Arguments
rpmsg_destroy_ept
Description
Usage
Arguments
is_rpmsg_ept_ready
Description
Usage
Arguments
Returns
rpmsg_virtio_get_buffer_size
Description
Usage
Arguments
Returns
rpmsg_init_vdev
Description
Usage
Arguments
Returns
rpmsg_deinit_vdev
Description
Usage
Arguments
rpmsg_virtio_init_shm_pool
Description
Usage
Arguments
rpmsg_virtio_get_rpmsg_device
Description
Usage
Arguments
Returns
rpmsg_virtio_shm_pool_get_buffer
Description
Usage
Arguments
Returns
Appx. C: Additional Resources and Legal Notices
Xilinx Resources
Solution Centers
Documentation Navigator and Design Hubs
Xilinx Documentation
Please Read: Important Legal Notices
Libmetal and OpenAMP User Guide UG1186 (v2019.1) May 22, 2019
Revision History The following table shows the revision history for this document. Section Revision Summary General Updates. 05/22/2019 Version 2019.1 General Updates. Libmetal and OpenAMP UG1186 (v2019.1) May 22, 2019 www.xilinx.com 2 Send Feedback
Table of Contents Chapter 1: Overview Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Chapter 2: Libmetal Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Access Devices with Libmetal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Xilinx Libmetal AMP Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Chapter 3: OpenAMP Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Components in OpenAMP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Connection between OpenAMP and Libmetal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 How to Write a Simple OpenAMP Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 OpenAMP Demos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Chapter 4: System Design Consideration Supported Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Other Consideration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Known Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Appendix A: Libmetal APIs Libmetal API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Appendix B: OpenAMP APIs Remoteproc APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Remoteproc API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 RPMsg Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 RPMsg API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Appendix C: Additional Resources and Legal Notices Xilinx Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Solution Centers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Documentation Navigator and Design Hubs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Libmetal and OpenAMP UG1186 (v2019.1) May 22, 2019 www.xilinx.com 3 Send Feedback
Xilinx Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Please Read: Important Legal Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Libmetal and OpenAMP UG1186 (v2019.1) May 22, 2019 www.xilinx.com 4 Send Feedback
Chapter 1 Overview Introduction This user guide describes how to develop a methodology to enable communication between multiple processors on Xilinx® Zynq® and Zynq UltraScale+™ MPSoC platforms. The basic development concept is based on the principles of Interrupts and Shared Memory, two foundational principles, that of interrupts and shared memory between the communicating elements: X-Ref Target - Figure 1-1 X19939-101217 Figure 1-1: Inter Processor Communication The libmetal library provides common user APIs (Application Programming Interface), used to access devices, handle device interrupts, and request memory across different operating environments. You can use libmetal to build your own AMP (Asymmetric Multi-/Processing) solution. Xilinx uses the OpenAMP (Open Asymmetric Multi-processing) project as the default AMP solution. OpenAMP builds on top of libmetal to provide a framework for remote processor management and inter-processor communication. This document describes the relationship between Libmetal and OpenAMP in the subsequent sections. Software Tools Requirements PetaLinux and Xilinx SDK (Software Development Kit) are required in order to follow the instructions in this document to build applications. See Xilinx Documentation for more detailed information. • PetaLinux Libmetal and OpenAMP UG1186 (v2019.1) May 22, 2019 www.xilinx.com 5 Send Feedback
Chapter 1: Overview • Xilinx SDK Prerequisites To use the OpenAMP Framework effectively, you must have a basic understanding of: Linux, PetaLinux, and Xilinx SDK. • • How to boot a Xilinx board using JTAG boot. • The remoteproc, RPMsg, and virtIO components used in Linux and bare-metal. Libmetal and OpenAMP UG1186 (v2019.1) May 22, 2019 www.xilinx.com 6 Send Feedback
Chapter 2 Libmetal Overview The libmetal library is maintained by the OpenAMP open source community. It provides common user APIs to access devices, handle device interrupts, and request memory across different operating environments. libmetal is available for the following operating systems/software configurations: • • • Linux FreeRTOS Bare-metal Environments The following architecture diagram shows how a user application accesses the libmetal library: X-Ref Target - Figure 2-1 See the libmetal sources [Ref 5] for more details on the libmetal APIs. Figure 2-1: Libmetal Architecture Libmetal and OpenAMP UG1186 (v2019.1) May 22, 2019 www.xilinx.com 7 Send Feedback
Chapter 2: Libmetal Access Devices with Libmetal Libmetal allows you to access devices similarly across varying operating environments. The flow for using libmetal is as follows: 1. Start libmetal environment. 2. Add devices. 3. Open the devices. 4. Register interrupt if required. 5. Write and read device registers with libmetal API. 6. Close the device. 7. Close the libmetal environment. The above steps are explained in the following subsections. Different platforms may have different device abstractions. Following is a table to explain how libmetal manages devices differently: Table 2-1: Libmetal Devices Linux Baremetal and FreeRTOS 1. Devices are described in a device tree. 2. “platform” bus definition is in Linux kernel. It is used by Linux to present memory mapped devices. 1. Because there is no device tree abstraction, devices must be defined statically before attempting to open them. 2. No standard for bus abstraction. Libmetal library defines generic bus structure to manage devices. Start Libmetal Environment, Add and Open the Devices 1. Initialize libmetal environment with call to metal_init(). struct metal_init_params metal_param = METAL_INIT_DEFAULTS; metal_init(&metal_param); 2. Add devices: a. This step is only needed for Baremetal or FreeRTOS as there is no standard such as device tree used in baremetal to describe devices. b. Statically define the libmetal device and register it to the appropriate bus. c. The following code snippet shows how to statically define the Triple Timer Counter device for Baremetal or FreeRTOS. Libmetal and OpenAMP UG1186 (v2019.1) May 22, 2019 www.xilinx.com 8 Send Feedback
分享到:
收藏