Files
CherryUSB/README.md

141 lines
7.6 KiB
Markdown
Raw Normal View History

2022-02-01 23:07:38 +08:00
# CherryUSB
2021-11-30 21:43:33 +08:00
2021-12-12 15:21:56 +08:00
[中文版](./README_zh.md)
2021-11-30 21:43:33 +08:00
2022-05-25 11:00:17 +08:00
CherryUSB is a tiny, beautiful and portable USB host and device stack for embedded system with USB ip.
2021-11-30 21:43:33 +08:00
2022-09-09 21:37:12 +08:00
![CherryUSB](./docs/assets/usb_outline.png)
2022-05-21 16:50:01 +08:00
2022-05-25 11:00:17 +08:00
## Why choose
2022-07-03 22:14:23 +08:00
- More comprehensive class drivers, and class drivers are all templated, easy to learn and add independently
- Tree programming, easy to understand the relationship between class driver and interface, endpoint, the relationship between hub, port, class; code layer by layer, call relationship at a glance, easy to understand the usb enumeration process and class driver loading
- The use of device protocol stacks is equivalent to uart tx/rx dma, and the use of the host stack is equivalent to file opertion.
2022-07-03 22:14:23 +08:00
- Standardized porting interface, as well as ip-oriented programming, eliminating the need to rewrite drivers for the same ip
- Api less, clear classification: dcd/hcd api, registration api, command callback api
- Streamlined code, minimal memory footprint, and the ip driver code is also streamlined to achieve the theoretical bandwidth of the usb hardware
2022-05-25 11:00:17 +08:00
## Directoy Structure
2021-12-04 14:41:09 +08:00
```
.
├── class
├── common
├── core
├── demo
├── docs
2022-01-15 17:14:26 +08:00
├── osal
2021-12-04 14:41:09 +08:00
├── packet capture
└── port
2022-05-25 11:00:17 +08:00
└── tools
2021-12-04 14:41:09 +08:00
```
2021-12-12 15:21:56 +08:00
| Directory | Description |
|:-------------:|:---------------------------:|
|class | usb class driver |
|common | usb spec macros and utils |
|core | usb core implementation |
2022-04-04 15:54:53 +08:00
|demo | different chips demo |
2022-01-15 17:14:26 +08:00
|osal | os wrapper |
2021-12-12 15:21:56 +08:00
|docs | doc for guiding |
2021-12-12 21:49:21 +08:00
|packet capture | packet capture file |
2021-12-12 15:21:56 +08:00
|port | usb dcd and hcd porting |
2022-04-13 10:29:33 +08:00
|tools | tool used url |
2021-12-12 15:21:56 +08:00
2022-05-25 11:00:17 +08:00
## Device Stack Overview
2021-12-12 15:21:56 +08:00
2022-02-01 23:07:38 +08:00
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.
2021-12-12 15:21:56 +08:00
2022-02-01 23:07:38 +08:00
CherryUSB Device Stack has the following functions
2021-12-12 15:21:56 +08:00
- Support USB2.0 full and high speed
- Support endpoint irq callback register by users, let users do whatever they wants in endpoint irq callback.
2022-04-04 15:54:53 +08:00
- Support Composite Device
2022-01-29 23:36:16 +08:00
- Support Communication Device Class (CDC)
2021-12-12 15:21:56 +08:00
- Support Human Interface Device (HID)
- Support Mass Storage Class (MSC)
2022-04-04 15:54:53 +08:00
- Support USB VIDEO CLASS (UVC1.0、UVC1.5)
- Support USB AUDIO CLASS (UAC1.0、UAC2.0)
2021-12-12 15:21:56 +08:00
- Support Device Firmware Upgrade CLASS (DFU)
- Support USB MIDI CLASS (MIDI)
- Support Test and Measurement CLASS (TMC)
2022-04-04 15:54:53 +08:00
- Support Remote NDIS (RNDIS)
- Support WINUSB1.0、WINUSB2.0(with BOS)
2021-12-12 21:49:21 +08:00
- Support Vendor class
2021-12-12 15:21:56 +08:00
2022-06-23 21:30:32 +08:00
CherryUSB Device Stack resource usage (GCC 10.2 with -O2):
2021-11-30 21:43:33 +08:00
| file | FLASH (Byte) | RAM (Byte) |
|:-----------:|:--------------:|:------------:|
|usbd_core.c | 3045 | 373 |
|usbd_cdc.c | 302 | 20 |
|usbd_msc.c | 2452 | 132 |
|usbd_hid.c | 784 | 201 |
|usbd_audio.c | 438 | 14 |
|usbd_video.c | 402 | 4 |
2022-05-25 11:00:17 +08:00
## Host Stack Overview
2021-11-30 21:43:33 +08:00
2022-06-05 16:45:39 +08:00
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.
2022-01-29 23:36:16 +08:00
2022-02-01 23:07:38 +08:00
CherryUSB Host Stack has the following functions
2022-01-29 23:36:16 +08:00
- Automatic loading of supported Class drivers
- Support blocking transfers and asynchronous transfers
2022-04-04 15:54:53 +08:00
- Support Composite Device
2022-01-29 23:36:16 +08:00
- Multi-level HUB support, expandable up to 7 levels
- Support Communication Device Class (CDC)
- Support Human Interface Device (HID)
- Support Mass Storage Class (MSC)
2022-04-04 15:54:53 +08:00
- Support Remote NDIS (RNDIS)
2022-01-29 23:36:16 +08:00
- Support Vendor class
2022-02-01 23:07:38 +08:00
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.
2022-01-29 23:36:16 +08:00
2022-06-23 21:30:32 +08:00
CherryUSB Host Stack resource usage (GCC 10.2 with -O2):
| file | FLASH (Byte) | RAM (Byte) |
|:-------------:|:--------------:|:------------:|
|usbh_core.c | 7992 | 472 |
|usbh_cdc_acm.c | 1208 | 4 |
|usbh_msc.c | 2239 | 4 |
|usbh_hid.c | 930 | 4 |
|usbh_hub.c | 3878 | 14 |
2022-05-25 11:00:17 +08:00
## Documentation Tutorial
2021-11-30 21:43:33 +08:00
Quickly start, USB basic concepts, API manual, Class basic concepts and examples, see [CherryUSB Documentation Tutorial](https://cherryusb.readthedocs.io/)
2021-11-30 21:43:33 +08:00
2022-05-25 11:00:17 +08:00
## Video Tutorial
2021-11-30 21:43:33 +08:00
2022-02-15 21:06:51 +08:00
USB basic concepts and how the CherryUSB Device stack is implemented, see [CherryUSB Device Stack Tutorial](https://www.bilibili.com/video/BV1Ef4y1t73d).
2022-04-13 10:29:33 +08:00
2022-05-25 11:00:17 +08:00
## Graphical Config Tool
2022-04-13 10:29:33 +08:00
2022-05-27 22:52:37 +08:00
[chryusb_configurator](https://github.com/Egahp/chryusb_configurator) is written in **electron + vite2 + ts** frameworkcurrently used to automate the generation of descriptor arrays, with additional functionality to be added later.
## Demo Repo
Note: After version 0.4.1, the dcd drivers have been refactored and some repositories are not maintained for a long time, so if you use a higher version, you need to update it yourself.
| Manufacturer | CHIP or Series | USB IP| Repo Url |Corresponds to master version|
|:--------------------:|:------------------:|:-----:|:--------:|:---------------------------:|
|Bouffalolab | BL702 | bouffalolab|[bl_mcu_sdk](https://github.com/bouffalolab/bl_mcu_sdk/tree/master/examples/usb)| latest |
|Essemi | ES32F36xx | musb |[es32f369_repo](https://github.com/sakumisu/CherryUSB/tree/master/demo/es32)|latest |
|AllwinnerTech | F1C100S | musb |[cherryusb_rtt_f1c100s](https://github.com/CherryUSB/cherryusb_rtt_f1c100s)|latest |
|ST | STM32F103C8T6 | fsdev |[stm32f103_repo](https://github.com/sakumisu/CherryUSB/tree/master/demo/stm32/usb_device/stm32f103c8t6)|latest |
|ST | STM32F4 | dwc2 |[stm32f429_device_repo](https://github.com/sakumisu/CherryUSB/tree/master/demo/stm32/usb_device/stm32f429igt6) [stm32f429_host_repo](https://github.com/sakumisu/CherryUSB/tree/master/demo/stm32/usb_host/stm32f429igt6)|latest |
|ST | STM32H7 | dwc2 |[stm32h743_device_repo](https://github.com/sakumisu/CherryUSB/tree/master/demo/stm32/usb_device/stm32h743vbt6) [stm32h743_host_repo](https://github.com/sakumisu/CherryUSB/tree/master/demo/stm32/usb_host/stm32h743xih6)|latest |
2022-09-12 11:42:35 +08:00
|HPMicro | HPM6750 | hpm/ehci |[hpm_repo](https://github.com/CherryUSB/cherryusb_hpmicro)|latest |
|WCH | CH32V307 | ch32_usbfs/ch32_usbhs|[ch32v307_repo](https://github.com/CherryUSB/cherryusb_ch32v307)|latest |
|WCH | CH57x | ch58x |[ch57x_repo](https://github.com/CherryUSB/cherryusb_ch57x)|v0.4.1 |
|Nuvoton | Nuc442 | nuvoton |[nuc442_repo](https://github.com/CherryUSB/cherryusb_nuc442)|v0.4.1 |
|Geehy | APM32E10x APM32F0xx| fsdev |[apm32_repo](https://github.com/CherryUSB/cherryusb_apm32)|v0.4.1 |
|Nordicsemi | Nrf52840 | nrf5x |[nrf5x_repo](https://github.com/CherryUSB/cherryusb_nrf5x)|v0.4.1 |
|Espressif | esp32 | dwc2 |[esp32_repo](https://github.com/CherryUSB/cherryusb_esp32)|v0.4.1 |
|Mindmotion | MM32L3xx | mm32 |[mm32_repo](https://github.com/CherryUSB/cherryusb_mm32)|v0.4.1 |
2022-06-05 16:45:39 +08:00
## Contact
QQ group: 642693751