Table of Contents



Document History
DateVersionAuthorDescription of Revisions
4/15/20150.1Rajesh Gugulothu & Upender CherukupallyRelease 1.0




Summary


The Zynq-7000 AP SoC has two USB2.0 On-The-Go (OTG) controllers in the Processing System. The OTG controllers can act as USB host or USB Device or dynamically changing roles between host and device. There are four primary types of communication defined by the USB protocol, based on which any required application can be built without changing the firmware or underlying hardware for different applications. These transfers types are Control Transfer, Bulk Transfer, Isochronous transfer and Interrupt transfer. These transfers types are the key abstractions for different applications development on USB with same hardware. The OTG controllers in Zynq-7000 AP SoC supports all the four types of transfers. This techtip explains how to enable all the configuration options, step by step procedure to use the Zynq-7000 AP SoC OTG controller in device mode and make use of bulk transfer type for a serial communication device abstraction using the USB. For application specific commands there are specific commands defined in the form of USB classes. The serial communication device commands are explained in the USB Communication Device Class (CDC) reference.
For complete specifications of USB protocol, class specific specifications refer: http://www.usb.org/developers/docs/

This design example covers:
  1. The CDC design example internals
  2. How to get and configure all the Zynq-7000 AP SoC Linux kernel and dependent files for the CDC class reference
  3. Bare metal CDC solution on Zynq-7000 AP SoC
  4. Demonstrating the CDC functionality with Windows as well as Linux host machine

Implementation

Implementation Details
Design TypePS only
SW TypeZynq-7000 AP SoC Linux & Zynq-7000 AP SoC Baremetal
CPUs2 ARM Cortex-A9: SMP Linux and Baremetal configurations
PS Features
  • DDR3
  • Cache
  • L1 and L2 Cache
  • OCM
  • Generic Interrupt Controller
  • USB 2.0 OTG Controller
Boards/ToolsZC702 kit
Xilinx Tools VersionSDK 2015.1 or latest
Other Details-

Files Provided
Zynq USB CDC ClassContain folders: Source, SD Card Images and Windows drivers required to follow the procedure below




Design overview:

The design explained in the below steps shows how to develop a USB system and building corresponding executable files for configuring Zynq-7000 AP SoC USB 2.0 OTG controller as a communication class device. This design shows both bare metal software running on the Zynq-7000 target as well as Linux running on Zynq-7000 AP SoC target system. Windows/Linux PC/laptop USB host controller is used for all host functionality.
The following sections describes step by step procedure to configure, develop and build the USB CDC example design using the baremetal and Linux SW running on Zynq-7000 AP SoC.
Figure 1: Zynq-7000 AP SoC USB CDC reference design block diagram

Linux: Step by Step procedure for creating Zynq-7000 AP SoC USB 2.0 controller’s communication device class functionality


This section explains the CDC Abstract Control Model (ACM) Linux gadget driver details, how to configure the Linux source to support serial gadget driver for Zynq-7000 AP SoC USB 2.0. and, also gives step by step procedure to test the Zynq-7000 AP SoC USB 2.0 communication device class functionality on windows and Linux host machines.

CDC ACM Linux gadget driver:


USB CDC ACM is a vendor-independent publicly documented protocol that can be used for emulating serial ports over USB. This allows the device to be registered on a host computer as a serial port (e.g. /dev/ttyACM0 or COM1). Linux has a generic CDC ACM host-side implementation in the kernel module __cdc_acm.ko.This protocol requires two USB interfaces: a data interface which consists of two endpoints (bulk in + bulk out) and a control interface which consists of one interrupt in endpoint. Furthermore, on EP0 the device must implement the class-specific requests defined by the CDC specification. Because this USB protocol is compliant to the CDC/ACM standard on some other operating systems (e.g. Linux, MacOS) the device can work with the default drivers if available/installed.

Configuring and building the Linux Operating System for Zynq-7000 AP SoC


Note: This tech tip is developed based on PetaLinux version 2014.4.


Figure 2: Linux kernel configuration for the USB device mode CDC ACM support


Figure 3: Linux kernel configuration for the User space driven configuration

Figure 4: Device Tree entries specific to this design

SD card images:


copy the following files on to the SD card

Note: For user convenience SD card images are provided along with this tech-tip. Download the design files archive released with this tech tip and extract it under the convenient location of host machine. Find the SD card images for Linux under the path CDC_Design_files/sd_card_images/Linux of your extracted directory. User can use these images for quick test .

ZC702 board setup:

Follow the below steps to make the test setup.

Testing Linux Zynq-7000 AP SoC USB 2.0 Communication device class functionality on Windows host PC:

Follow the below procedure to test the Zynq-7000 AP SoC USB 2.0 OTG controller communication device class functionality when Linux is running on the target board and windows PC as a host.
Figure 6: Mounting the SD card

Figure 7: insmod all the dependent kernel objects
Figure 8: Zynq-7000 AP SoC Linux Console after successful installation

Fig 9: ZC702 board setup with micro-USB cable connected



Installation steps for windows CDC ACM driver

Figure 10: Opening device manager
Figure 11: Selecting device manager

Figure 12: Install driver

Figure 13: command to send the data

Figure 14: Serial terminal shows the transfer of data successful

Note: If entered data in the virtual terminal is not visible then enable the local echo option in the Tera Term settings.
Figure 15: Serial terminal showing the data transfer

Testing Linux Zynq-7000 USB 2.0 Communication device class functionality on Linux host PC:


Figure 16: Inspecting the Log for successful device connection
Figure 17: Serial terminal with test data
Figure 18: Checking the data on ttyACM0
Figure 19: Sending the data back to target serial port
Figure 20: Checking the data on the target

Baremetal software for designing Zynq-7000 AP SoC USB 2.0 controller’s communication device class functionality


Application software development

This section explains about the bare-metal software development and also step by step procedure to build the system to create binaries for Zynq-7000 AP SoC CDC class device.

Application software:

It is a bare-metal software application which configures the Zynq-7000 AP SoC USB 2.0 as CDC class device and Zynq-7000 AP SoC USB 2.0 device appears as virtual serial communication port at the host side system.Whenever host sends some data to Zynq-7000 AP SoC USB 2.0 device through virtual serial communication port the application responds back to host machine with the received data.

Building Application:

After SDK launch the projects can be imported from the design files provided along with this techtip as shown below
Note: Download the Design files archive released with this tech tip and extract it under the convenient working directory of your host machine
Figure 21: Importing the SDK projects

Generating Boot File:

This tech-tip contains the cdc_application. elf and fsbl.elf binaries.Below are the steps to create BOOT.bin file.

The Create Zynq Boot Image wizard opens.
Note: Find the fsbl.elf in <SDK Workspace >\fsbl\Debug\fsbl.elf.
Note: For quick testing user may use the BOOT.bin file which is provided along with this tech-tip can be found under the path
<working_directory>/CDC_Design_files/sd_card_images/Bare-metal.

Application execution :


Follow the below procedure to test the baremetal Zynq-7000 AP SoC USB 2.0 OTG controller CDC functionality with windows/Linux (Ubuntu) as a host PC.
Figure 22: SW16 configuration
Note: If appropriate drivers are not found then the Zynq-7000 AP SoC USB device will get failed to connect to the host PC.

Testing baremetal Zynq-7000 AP SoC USB 2.0 Communication device class functionality on Windows host PC:



Figure 23: Testing the data transfer

Testing baremetal Zynq-7000 AP SoC USB 2.0 Communication device class functionality on Linux host PC:


Figure 24: Checking the log for the connection


After receiving the above sent data at the target device the bare-metal application running on the Zynq-7000 AP SoC target device will respond back with the receiving data. Read the target response using following command on Ubuntu host machine
Figure 25: Testing the data transfer

Known issue:

When the USB controller is configured in device mode, and Vbus voltage is varied such that it crosses the Vbus valid threshold multiple times, the ULPI interface becomes unresponsive.Please follow the AR#61313 for the workaround.