<a href="https://github.com/cherry-embedded/CherryUSB/releases"><img src="https://img.shields.io/github/release/cherry-embedded/CherryUSB.svg"><a>
<a href="https://github.com/cherry-embedded/CherryUSB/blob/master/LICENSE"><img src="https://img.shields.io/github/license/cherry-embedded/CherryUSB.svg?style=flat-square"></a>
<a href="https://github.com/cherry-embedded/CherryUSB/actions/workflows/deploy-docs.yml"><img src="https://github.com/cherry-embedded/CherryUSB/actions/workflows/deploy-docs.yml/badge.svg"> </a>
<a href="https://discord.com/invite/wFfvrSAey8"><img src="https://img.shields.io/badge/Discord-blue?logo=discord&style=flat-square"> </a>
CherryUSB is a tiny and beautiful, high performance and portable USB host and device stack for embedded system with USB IP.
In order to make it easier for users to learn USB basics, enumeration, driver loading and IP drivers, the code has been written with the following advantages:
In order to facilitate the use of the USB interface and to take into account the fact that users have learned about uart and dma, the following advantages have been designed for the data sending and receiving class of interface:
Taking into account USB performance issues and trying to achieve the theoretical bandwidth of the USB hardware, the design of the data transceiver class interface has the following advantages:
Directory | Description |
---|---|
class | usb class driver |
common | usb spec macros and utils |
core | usb core implementation |
demo | usb device and host demo |
osal | os wrapper |
platform | class support for other os |
docs | doc for guiding |
port | usb dcd and hcd porting |
tools | tool url |
CherryUSB Device Stack provides a unified framework of functions for standard device requests, CLASS requests, VENDOR requests and custom special requests. The object-oriented and chained approach allows the user to quickly get started with composite devices without having to worry about the underlying logic. At the same time, a standard dcd porting interface has been standardised for adapting different USB IPs to achieve ip-oriented programming.
CherryUSB Device Stack has the following functions:
CherryUSB Device Stack resource usage (GCC 10.2 with -O2):
file | FLASH (Byte) | No Cache RAM (Byte) | RAM (Byte) | Heap (Byte) |
---|---|---|---|---|
usbd_core.c | ~4400 | 512(default) + 320 | 0 | 0 |
usbd_cdc_acm.c | ~400 | 0 | 0 | 0 |
usbd_msc.c | ~3800 | 128 + 512(default) | 16 | 0 |
usbd_hid.c | ~360 | 0 | 0 | 0 |
usbd_audio.c | ~1500 | 0 | 0 | 0 |
usbd_video.c | ~2600 | 0 | 84 | 0 |
usbd_rndis.c | ~2100 | 2 * 1580(default)+156+8 | 76 | 0 |
The CherryUSB Host Stack has a standard enumeration implementation for devices mounted on roothubs and external hubs, and a standard interface for different Classes to indicate what the Class driver needs to do after enumeration and after disconnection. A standard hcd porting interface has also been standardised for adapting different USB IPs for IP-oriented programming. Finally, the host stack is managed using os, and provides osal to make a adaptation for different os.
CherryUSB Host Stack has the following functions:
The CherryUSB Host stack also provides the lsusb function, which allows you to view information about all mounted devices, including those on external hubs, with the help of a shell plugin.
CherryUSB Host Stack resource usage (GCC 10.2 with -O2):
file | FLASH (Byte) | No Cache RAM (Byte) | RAM (Byte) | Heap (Byte) |
---|---|---|---|---|
usbh_core.c | ~9000 | 512 + 8 * (1+x) *n | 28 | raw_config_desc |
usbh_hub.c | ~6000 | 32 + 4 * (1+x) | 12 + sizeof(struct usbh_hub) * (1+x) | 0 |
usbh_cdc_acm.c | ~900 | 7 | 4 + sizeof(struct usbh_cdc_acm) * x | 0 |
usbh_msc.c | ~2700 | 64 | 4 + sizeof(struct usbh_msc) * x | 0 |
usbh_hid.c | ~1400 | 256 | 4 + sizeof(struct usbh_hid) * x | 0 |
usbh_video.c | ~3800 | 128 | 4 + sizeof(struct usbh_video) * x | 0 |
usbh_audio.c | ~4100 | 128 | 4 + sizeof(struct usbh_audio) * x | 0 |
usbh_rndis.c | ~4200 | 512 + 2 * 2048(default) | sizeof(struct usbh_rndis) * 1 | 0 |
usbh_cdc_ecm.c | ~2200 | 2 * 1514 + 16 | sizeof(struct usbh_cdc_ecm) * 1 | 0 |
usbh_cdc_ncm.c | ~3300 | 2 * 2048(default) + 16 + 32 | sizeof(struct usbh_cdc_ncm) * 1 | 0 |
usbh_bluetooth.c | ~1000 | 2 * 2048(default) | sizeof(struct usbh_bluetooth) * 1 | 0 |
Among them, sizeof(struct usbh_hub)
and sizeof(struct usbh_hubport)
are affected by the following macros:
#define CONFIG_USBHOST_MAX_EXTHUBS 1
#define CONFIG_USBHOST_MAX_EHPORTS 4
#define CONFIG_USBHOST_MAX_INTERFACES 8
#define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 8
#define CONFIG_USBHOST_MAX_ENDPOINTS 4
x is affected by the following macros:
#define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
#define CONFIG_USBHOST_MAX_HID_CLASS 4
#define CONFIG_USBHOST_MAX_MSC_CLASS 2
#define CONFIG_USBHOST_MAX_AUDIO_CLASS 1
#define CONFIG_USBHOST_MAX_VIDEO_CLASS 1
Only standard and commercial USB IP are listed.
IP | device | host | Support status |
---|---|---|---|
OHCI(intel) | none | OHCI | √ |
EHCI(intel) | none | EHCI | √ |
XHCI(intel) | none | XHCI | √ |
UHCI(intel) | none | UHCI | × |
DWC2(synopsys) | DWC2 | DWC2 | √ |
MUSB(mentor) | MUSB | MUSB | √ |
FOTG210(faraday) | FOTG210 | EHCI | √ |
CHIPIDEA(synopsys) | CHIPIDEA | EHCI | √ |
CDNS2(cadence) | CDNS2 | CDNS2 | √ |
CDNS3(cadence) | CDNS3 | XHCI | × |
DWC3(synopsys) | DWC3 | XHCI | × |
Quickly start, USB basic concepts, API manual, Class basic concepts and examples, see CherryUSB Documentation Tutorial
USB basic concepts and how the CherryUSB Device stack is implemented, see CherryUSB Device Stack Tutorial.
chryusb_configurator is written in electron + vite2 + ts framework,currently used to automate the generation of descriptor arrays, with additional functionality to be added later.
Manufacturer | CHIP or Series | USB IP | Repo Url | Support version | Support status |
---|---|---|---|---|---|
Bouffalolab | BL702/BL616/BL808 | bouffalolab/ehci | bouffalo_sdk | <= latest | Long-term |
ST | STM32F1x | fsdev | stm32_repo | <= latest | Long-term |
ST | STM32F4/STM32H7 | dwc2 | stm32_repo | <= latest | Long-term |
HPMicro | HPM6000/HPM5000 | hpm/ehci | hpm_sdk | <= latest | Long-term |
Essemi | ES32F36xx | musb | es32f369_repo | <= latest | Long-term |
Phytium | e2000 | pusb2/xhci | phytium_repo | >=1.4.0 | Long-term |
Artinchip | d12x/d13x/d21x | aic/ehci/ohci | luban-lite | <= latest | Long-term |
Espressif | esp32s2/esp32s3/esp32p4 | dwc2 | esp32_repo | <= latest | Long-term |
NXP | mcx | kinetis/chipidea/ehci | nxp_mcx_repo | <= latest | Long-term |
Kendryte | k230 | dwc2 | k230_repo | v1.2.0 | Long-term |
Raspberry pi | rp2040/rp2350 | rp2040 | pico-examples | <= latest | Long-term |
AllwinnerTech | F1C100S/F1C200S | musb | cherryusb_rtt_f1c100s | <= latest | the same with musb |
Bekencorp | bk7256/bk7258 | musb | bk_idk | v0.7.0 | the same with musb |
Sophgo | cv18xx | dwc2 | cvi_alios_open | v0.7.0 | TBD |
WCH | CH32V307/ch58x | ch32_usbfs/ch32_usbhs/ch58x | wch_repo | <= v0.10.2 | TBD |
CherryUSB package is available as follows:
Refer to https://cherryusb.readthedocs.io/zh-cn/latest/support/index.html.
CherryUSB discord: https://discord.com/invite/wFfvrSAey8.
Thanks to the following companies for their support (in no particular order).