cherry-embedded/CherryUSB logo

cherry-embedded/CherryUSB

Free

CherryUSB is a tiny and beautiful, high performance and portable USB host and device stack for embedded system with USB IP

FreeFree tier
Type
Open Source

About cherry-embedded/CherryUSB

CherryUSB is an open-source, high-performance, and portable USB host and device stack designed for embedded systems with USB IP. It emphasizes ease of learning through streamlined code with simple logic and tree-structured programming, making USB fundamentals accessible. Data transmission interfaces are designed to be as easy to use as UART TX DMA/RX DMA, with no length restrictions on transmission/reception (packetization handled by porting drivers). Performance is optimized via direct register interfacing, memory zero-copy DMA mode, and interrupt-context packetization. The stack supports USB 2.0 full and high speed (USB 3.0 super speed planned) and provides a unified framework for standard device requests, class requests, vendor requests, and custom special requests. A standard DCD porting interface enables adaptation across different USB IPs.

Key Features

Streamlined code with simple logic and tree-structured programming
Templated class drivers and clear API categorization (device/host initialization, registration, callbacks, data transmission)
Data transmission interfaces equivalent to using UART TX DMA/RX DMA with no length restrictions
Porting drivers interface directly with registers (no abstraction layer) and use memory zero-copy DMA when IP supports it
Packetization handled in interrupt context for maximum performance
Supports USB 2.0 full and high speed (USB 3.0 super speed planned)
Unified framework for standard device, class, vendor, and custom special requests
Object-oriented and chained approach for easy composite device creation
Standard DCD porting interface for adapting different USB IPs

Pros & Cons

Pros
  • Easy to learn with simple logic and progressive code layers
  • High performance through zero-copy DMA and direct register access
  • No length restrictions on data transmission, simplifying user code
  • Portable across different USB IPs via standardized DCD/HCD interfaces
  • Active open-source project with documentation and demos
  • Supports composite devices with object-oriented design
Cons
  • USB 3.0 super speed support is still in development (TODO)
  • Requires manual porting for different USB IP cores (no auto-detection)
  • Limited to embedded systems with USB hardware; not a general-purpose USB library
  • Documentation may be minimal for advanced features

Best For

Embedded USB device firmware development (e.g., CDC, HID, MSC classes)Embedded USB host firmware developmentLearning USB stack internals through clean, well-documented codeRapid prototyping of USB-enabled microcontrollers with DMA supportPorting USB stacks to new or custom USB IP cores

FAQ

What is CherryUSB?
CherryUSB is an open-source, tiny, high-performance, and portable USB host and device stack for embedded systems with USB IP. It supports USB 2.0 full and high speed, and aims to be easy to learn, use, and achieve high performance.
What USB speeds are supported?
Currently supports USB 2.0 full speed (12 Mbps) and high speed (480 Mbps). USB 3.0 super speed is planned (TODO).
How do I get started with CherryUSB?
Clone the GitHub repository (cherry-embedded/CherryUSB), refer to the demo directory for example projects, and follow the documentation in the docs folder. The stack provides templated class drivers and clear API categories.
Can CherryUSB be used with any microcontroller?
CherryUSB is designed to be portable across different USB IP cores by providing a standard DCD (Device Controller Driver) and HCD (Host Controller Driver) porting interface. You need to implement the porting layer for your specific USB hardware.