USB Introduction
Overview
Supported ICs[ RTL8721Dx ][ RTL8730E ][ RTL8721F ]
USB (Universal Serial Bus) is a standard serial communication interface designed to interconnect host controllers and peripheral devices.
The complete USB specification suite, including electrical, mechanical, and protocol layer documentation, is accessible at http://www.usb.org/developers.
Features
Compatibility: Fully compliant with USB 2.0 High-speed (480 Mbps) and Full-speed (12 Mbps) specifications.
Supported USB host solutions:
CDC ACM: Enables bidirectional transparent data transmission for serial communication, data acquisition, custom protocols and etc.
CDC ECM: Interfaces with Ethernet modules to act as a Network Interface Card (NIC) or a bridge for network routing.
MSC: Supports Mass Storage Class devices (e.g., USB flash drives, card readers) for smart speakers, data logging, OTA updates and etc.
UAC: Supports USB Audio Class devices (e.g., Type-C headsets) for audio output and volume control.
UVC: Interoperates with USB cameras, supporting MJPEG, H.264, and YUV formats for image capture and video streaming in smart locks, surveillance systems and etc.
Composite hosts:
CDC ACM + CDC ECM: Supports 4G cellular modules for IoT gateways, mobile hotspots and etc.
HID + UAC: Integrates Human Interface Device and Audio control for unified inline remote and playback management.
Vendor: Allows custom driver implementation beyond standard USB classes to meet highly customized application requirements.
Supported USB device solutions:
CDC ACM: Functions as a virtual COM port for bidirectional transparent data transmission.
HID: Emulates standard peripherals like keyboards and mice for rich human-machine interaction.
MSC: Maps SD cards or Flash memory as external mass storage media.
UAC: Acts as a USB audio device for audio playback.
Composite devices:
CDC ACM + HID: Simultaneous data transmission and interaction control.
CDC ACM + MSC: Simultaneous data transmission and mass storage.
CDC ACM + UAC: Simultaneous data transmission and audio playback.
HID + UAC: Simultaneous interaction control and audio playback.
Vendor: Supports customized development for non-standard device classes.
Advanced features:
Dual-Role switching: Supports dynamic switching between USB Host and Device roles.
Highly customizable device mode: Full customization of USB descriptors, including VID/PID, string descriptors, and endpoint mapping.
Flexible host enumeration: Features customizable device matching strategies (e.g., matching by VID/PID or specific Class/Protocol), automatic descriptor parsing, and adaptive speed negotiation.
Configurable core parameters: Allows adjustment of speed modes, Data FIFO (DFIFO) depth (dedicated FIFO mode only), and scheduling priorities for the USB ISR and core threads.
Note
The RTL8721Dx supports Full-speed Device mode only.
Hardware Configurations
Supports device mode
Supports USB 2.0 full-speed (12 Mbps) mode
Supports DMA mode
Endpoint configurations:
EP0: INOUT (for Control transfer only)
EP1: IN
EP2: OUT
EP3: IN
EP4: OUT
EP5: INOUT
Note
One and only one periodic IN endpoint is supported.
Shared FIFO with following configurations:
Total FIFO depth: 768 DWORD
Shared receive FIFO: 472 DWORD (max)
Shared non-periodic transmit FIFO: 32 DWORD (max)
Dedicated periodic transmit FIFO: 256 DWORD (max)
Note
8 DWORD FIFO shall be reserved for DMA registers in DMA mode.
Supports host, device and OTG modes
Supports USB 2.0 high-speed (480 Mbps) and full-speed (12 Mbps) modes
Supports DMA mode
Endpoint configurations in device mode:
EP0: INOUT (for Control transfer only)
EP1: IN
EP2: OUT
EP3: IN
EP4: OUT
EP5: INOUT
Note
One and only one periodic IN endpoint is supported.
Supports 8 channels/pipes in host mode
Shared FIFO with following configurations:
Total FIFO depth: 1024 DWORD
Host mode:
Shared receive FIFO: 512 DWORD (max)
Shared non-periodic transmit FIFO: 256 DWORD (max)
Shared periodic transmit FIFO: 256 DWORD (max)
Device mode:
Shared RX FIFO: 512 DWORD (max)
Shared non-periodic transmit FIFO: 256 DWORD (max)
Dedicated periodic transmit FIFO: 256 DWORD (max)
Note
8 DWORD FIFO shall be reserved for DMA registers in DMA mode.
Integrated UTMI+ PHY
External hub connection support in host mode
Automatic ping in host mode
Supports host and device modes
Supports USB 2.0 high-speed (480 Mbps) and full-speed (12 Mbps) modes
Supports DMA mode
Endpoint configurations in device mode:
EP0: INOUT (for Control transfer only)
EP1: IN
EP2: INOUT
EP3: INOUT
EP4: IN
EP5: OUT
EP6: INOUT
EP7: OUT
Supports 12 channels/pipes in host mode
Shared FIFO with following configurations:
Total FIFO depth: 1024 DWORD
Host mode:
Shared receive FIFO: 1024 DWORD (max)
Shared non-periodic transmit FIFO: 1024 DWORD (max)
Shared periodic transmit FIFO: 1024 DWORD (max)
Device mode:
Shared RX FIFO: 1024 DWORD (max)
6 dedicated transmit FIFOs for device IN transfers, max depth of each Tx FIFO:
Tx FIFO 0: 32
Tx FIFO 1: 16
Tx FIFO 2: 256
Tx FIFO 3: 32
Tx FIFO 4: 256
Tx FIFO 5: 128
Note
12 DWORD FIFO shall be reserved for DMA registers in DMA mode.
Integrated UTMI+ PHY
External hub connection support in host mode
Automatic ping in host mode
Software Stack Overview
Software Architecture
The architecture of USB software stack:
Where:
USB HAL driver: Implements SoC-specific hardware driver for power management and phy calibration, exposing unified HAL API to upper-layer core drivers.
USB host/device core drivers: Integrates USB IP-specific hardware driver, host/device controller driver, enumeration state machine and transfer scheduling algorithms, exposing unified core API for designers to develop classes and applications.
USB host/device class drivers: Delivers USB-IF class-compliant drivers via class-specific API, enabling rapid deployment of standard USB solutions.
USB host/device applications: Provides reference designs for USB solutions.
USB HAL driver
USB HAL driver implements SoC-specific USB power management, interrupt handling and phy calibration interfaces, defines system-level preprocessor constants, exposes unified HAL API to upper-layer drivers.
Note
USB HAL driver is built into USB host/device/DRD core library as default and customization is not allowed.
USB PHY calibration data is determined by Realtek during manufacturing and developer-side re-calibration is not allowed, for suspected calibration-related compatibility issues (e.g., USB enumeration failures, intermittent disconnection/reconnection issues), contact Realtek FAE for help.
USB Device Core Driver
USB Host Core Driver
File Organization
USB Path Aliases
For simplicity, the following path aliases are used in the subsequent descriptions.
Alias |
Path |
|---|---|
|
{SDK}/component/soc/amebaxxx/fwlib/include |
|
{SDK}/component/usb |
|
{SDK}/component/usb/device |
|
{SDK}/component/usb/host |
|
{SDK}/component/example/usb |
|
{SDK}/component/soc/amebaxxx/project/project_xxx/lib/application |
USB HAL Driver
Path |
Description |
|---|---|
|
USB HAL API definition header file |
USB Core Driver
Path |
Description |
|
USB common core driver API definition header file |
|
USB device core driver API definition header file |
|
USB device core driver static library file |
Path |
Description |
|
USB common core driver API definition header file |
|
USB device core driver API definition header file |
|
USB host core driver API definition header file |
|
USB DRD core driver static library file for DRD solution |
|
USB device core driver static library file for device solution |
|
USB host core driver static library file for host solution |
Path |
Description |
|
USB common core driver API definition header file |
|
USB device core driver API definition header file |
|
USB host core driver API definition header file |
|
USB DRD core driver static library file for DRD solution |
|
USB device core driver static library file for device solution |
|
USB host core driver static library file for host solution |
USB Class Driver
Path |
Description |
|---|---|
|
CDC ACM device class driver |
|
Composite device class driver |
|
HID device class driver |
|
INIC device class driver (non-standard) |
|
MSC device class driver |
|
UAC device class driver |
|
Vendor-specific device class driver |
|
CDC ACM host class driver |
|
CDC ECM host class driver |
|
MSC host class driver |
|
UVC host class driver |
|
Vendor-specific host class driver |
USB Application
Path |
Description |
|---|---|
|
Transparent communication device example based on CDC ACM device class |
|
Composite device example based on CDC ACM and HID device classes |
|
Composite device example based on CDC ACM and UAC device classes |
|
Composite device example based on HID and UAC device classes |
|
HID device example |
|
INIC device example |
|
Mass storage device example based on MSC device classes |
|
Audio device example based on UAC device classes |
|
Vendor-specific device example |
|
Transparent communication host example based on CDC ACM host class |
|
Ethernet communication host example based on CDC ECM host class |
|
Mass storage host example based on MSC host classe |
|
Video host example based on UVC host classe |
|
Vendor-specific host example |
|
Ethernet communication bridge example based on CDC ECM host class |
|
DRD example based on MSC host class and MSC device classe |
Host Solutions, refer to Host Solutions
Device Solutions, refer to Device Solutions
USB Certification
USB certification generally refers to USB-IF certification, i.e. USB-IF compliance testing, which validates devices against USB-IF electrical, protocol and functional requirements to ensure interoperability, security and reliability. Certified devices are authorized to use USB logos.
While USB-IF certification is not mandatory, it is required when:
Products intend to use USB logos
Marketing materials claim USB specification compliance or certification
For certification procedures and requirements, refer to https://www.usb.org documentation or contact USB-IF authorized test labs.
Additional Compliance Requirements for USB Devices:
FCC/CE: Mandatory for USB devices sold in EU/US markets
ISO 26262: Required for automotive USB devices (functional safety)
Windows Logo Program: Necessary for “Certified for Windows” branding
MFi: Mandatory for Apple-specific USB accessories
Compliance Test Guide
Overview
The USB Electrical Compliance Test is designed to verify that the electrical characteristics of USB devices, hosts, or hubs comply with USB-IF (USB Implementers Forum) specifications, ensuring system stability and interoperability. The test scope covers key electrical performance metrics, including signal quality, power management, and timing parameters.
Official Specifications Reference: https://www.usb.org/usb2
Scope of Application
This test solution applies to the entire Ameba series platform, supporting the following operating environments:
Linux
RTOS
Zephyr
To verify whether a product meets the USB CTS (Compliance Test Suite) standards, please use the dedicated test firmware and command set provided below.
Technical Support
If you encounter any technical issues or anomalies during testing, please contact the Technical Support Team for professional assistance.
Test Firmware Preparation
Follow these steps to obtain and deploy the test firmware:
Download Firmware: Obtain the latest test image files for your specific chip model from the list below.
Flash Firmware: Refer to the Flash Programming Guide to flash the downloaded firmware onto the target device, updating it to the dedicated test version.
Test Command Set
The test commands in this section are based on the Agilent 5485xA oscilloscope. If you are using a different model for electrical characteristic verification, refer to the table below for the corresponding commands.
Type |
Command |
Description |
|---|---|---|
RESET |
reboot |
Reboot Test Environment A mandatory step before executing any test case. It clears residual states to ensure the system starts from a deterministic initial environment. |
INIT |
usbd init |
Initialize USB Device Must be executed after rebooting. Responsible for loading drivers and configuring the USB device environment, establishing the foundation for subsequent tests. |
DEINIT |
usbd deinit |
Release USB Device Resources Destroys allocated handles, memory, and interrupt resources, returning the device completely to an uninitialized state to prepare for the next reset or test cycle. |
Type |
Command |
Description |
|---|---|---|
RESET |
reboot |
Reboots Test Environment. A mandatory prerequisite for all test cases to clear residual states and ensure a known initial system environment. |
INIT |
usbh init |
Initializes the USB Host. Executed after reboot to load drivers and configure the USB Host environment, preparing for subsequent tests. |
DEINIT |
usbh deinit |
Releases USB Host resources. Destroys allocated handles, memory, and interrupt resources, returning the Host to an uninitialized state. |
TEST_J |
usbh tmod 1 |
Drives the bus continuously to the J-state. Used to measure static voltage levels on data lines when not dynamically driven. |
TEST_K |
usbh tmod 2 |
Drives the bus continuously to the K-state. Used to measure static voltage levels on data lines when not dynamically driven. |
TEST_SE0_NAK |
usbh tmod 3 |
Performs SE0 and NAK handshake testing. Verifies that the device maintains High-Speed mode stability during Endpoint 0 (EP0) communication without falsely triggering a reset due to signal anomalies. |
TEST_PACKET |
usbh tmod 4 |
Continuously transmits specific test packets. Evaluates physical layer signal quality, including eye diagram openness, jitter, and rise/fall times. |
SUSPEND |
usbh suspend |
Enters Suspend mode. The USB Host halts all bus activity. |
RESUME |
usbh resume |
Resumes Normal operation mode. The USB Host issues a wake-up signal to notify the device to resume normal communication. |
SINGLE_STEP_GET_DEV_DESC |
usbh xfer <value> |
Validates the device descriptor retrieval process in discrete steps. <value> range: 1~2 <1> Verifies the Setup stage and standard request. <2> Verifies data transmission in the Data/Status stage. |