Home

Awesome

CherryUSB

中文版

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

CherryUSB

Why choose

Easy to study USB

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:

Easy to use USB

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:

Easy to bring out USB performance

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 Structure

DirectoryDescription
classusb class driver
commonusb spec macros and utils
coreusb core implementation
demousb device and host demo
osalos wrapper
platformclass support for other os
docsdoc for guiding
portusb dcd and hcd porting
toolstool url

Device Stack Overview

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):

fileFLASH (Byte)No Cache RAM (Byte)RAM (Byte)Heap (Byte)
usbd_core.c~4400512(default) + 32000
usbd_cdc_acm.c~400000
usbd_msc.c~3800128 + 512(default)160
usbd_hid.c~360000
usbd_audio.c~1500000
usbd_video.c~26000840
usbd_rndis.c~21002 * 1580(default)+156+8760

Host Stack Overview

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):

fileFLASH (Byte)No Cache RAM (Byte)RAM (Byte)Heap (Byte)
usbh_core.c~9000512 + 8 * (1+x) *n28raw_config_desc
usbh_hub.c~600032 + 4 * (1+x)12 + sizeof(struct usbh_hub) * (1+x)0
usbh_cdc_acm.c~90074 + sizeof(struct usbh_cdc_acm) * x0
usbh_msc.c~2700644 + sizeof(struct usbh_msc) * x0
usbh_hid.c~14002564 + sizeof(struct usbh_hid) * x0
usbh_video.c~38001284 + sizeof(struct usbh_video) * x0
usbh_audio.c~41001284 + sizeof(struct usbh_audio) * x0
usbh_rndis.c~4200512 + 2 * 2048(default)sizeof(struct usbh_rndis) * 10
usbh_cdc_ecm.c~22002 * 1514 + 16sizeof(struct usbh_cdc_ecm) * 10
usbh_cdc_ncm.c~33002 * 2048(default) + 16 + 32sizeof(struct usbh_cdc_ncm) * 10
usbh_bluetooth.c~10002 * 2048(default)sizeof(struct usbh_bluetooth) * 10

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

USB IP Support

Only standard and commercial USB IP are listed.

IPdevicehostSupport status
OHCI(intel)noneOHCI×
EHCI(intel)noneEHCI
XHCI(intel)noneXHCI
UHCI(intel)noneUHCI×
DWC2(synopsys)DWC2DWC2
MUSB(mentor)MUSBMUSB
FOTG210(faraday)FOTG210EHCI
CHIPIDEA(synopsys)CHIPIDEAEHCI
CDNS2(cadence)CDNS2CDNS2
CDNS3(cadence)CDNS3XHCI×
DWC3(synopsys)DWC3XHCI×

Documentation Tutorial

Quickly start, USB basic concepts, API manual, Class basic concepts and examples, see CherryUSB Documentation Tutorial

Video Tutorial

USB basic concepts and how the CherryUSB Device stack is implemented, see CherryUSB Device Stack Tutorial.

Graphical Config Tool

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.

Demo Repo

ManufacturerCHIP or SeriesUSB IPRepo UrlSupport versionSupport status
BouffalolabBL702/BL616/BL808bouffalolab/ehcibouffalo_sdk<= latestLong-term
STSTM32F1xfsdevstm32_repo<= latestLong-term
STSTM32F4/STM32H7dwc2stm32_repo<= latestLong-term
HPMicroHPM6000/HPM5000hpm/ehcihpm_sdk<= latestLong-term
EssemiES32F36xxmusbes32f369_repo<= latestLong-term
Phytiume2000pusb2/xhciphytium_repo>=1.4.0Long-term
Artinchipd12x/d13x/d21xaic/ehci/ohciluban-lite<= latestLong-term
Espressifesp32s2/esp32s3/esp32p4dwc2esp32_repo<= latestLong-term
NXPmcxkinetis/chipidea/ehcinxp_mcx_repo<= latestLong-term
AllwinnerTechF1C100S/F1C200Smusbcherryusb_rtt_f1c100s<= latestthe same with musb
Bekencorpbk7256/bk7258musbbk_idkv0.7.0the same with musb
Sophgocv18xxdwc2cvi_alios_openv0.7.0TBD
WCHCH32V307/ch58xch32_usbfs/ch32_usbhs/ch58xwch_repo<= v0.10.2TBD
Raspberry pirp2040rp2040pico-examples<= v0.10.2No more updated

Package Support

CherryUSB package is available as follows:

Commercial Support

Refer to https://cherryusb.readthedocs.io/zh-cn/latest/support/index.html.

Contact

CherryUSB discord: https://discord.com/invite/wFfvrSAey8.

Company Support

Thanks to the following companies for their support (in no particular order).

<img src="docs/assets/bouffalolab.jpg" width="100" height="80"/> <img src="docs/assets/hpmicro.jpg" width="100" height="80" /> <img src="docs/assets/eastsoft.jpg" width="100" height="80" /> <img src="docs/assets/rtthread.jpg" width="100" height="80" /> <img src="docs/assets/sophgo.jpg" width="100" height="80" /> <img src="docs/assets/phytium.jpg" width="100" height="80" /> <img src="docs/assets/thead.jpg" width="100" height="80" /> <img src="docs/assets/nuvoton.jpg" width="100" height="80" /> <img src="docs/assets/artinchip.jpg" width="100" height="80" /> <img src="docs/assets/bekencorp.jpg" width="100" height="80" /> <img src="docs/assets/nxp.png" width="100" height="80" /> <img src="docs/assets/espressif.png" width="100" height="80" />