June 29, 2022

CherryUSB – A Lightweight USB/Host Stack for Embedded Systems

CherryUSB is a lightweight, open-source USB host/device stack for embedded systems with one or more USB interfaces. The stack implements various class drivers such as CDC, HID, MSC, audio, video, etc.

It is apparently part of the Boufallo Lab SDK (e.g. for the BL702 microcontroller), and has been ported and tested with the WCH CH32V307 RISC-V, STMicro STM32F4 and Nuvoton NUC442 Cortex-M4 microcontroller, as well as a Cortex-M3 microcontroller at two arms I’ve never heard of: EastSoft ES32F3 and MindMotion MM32L3xx.

CherryUSB Device Stack Highlights:

  • Support full and high speed USB2.0
  • Endpoint irq callback
  • USB course support
    • Composite device
    • Communications Device Class (CDC)
    • Human Interface Device (HID) including “Custom HID”
    • Mass storage class (MSC)
    • USB video class (UVC1.0, UVC1.5)
    • USB AUDIO class (UAC1.0, UAC2.0)
    • Device Firmware Upgrade (DFU) CLASS
    • MIDI CLASS (MIDI)
    • CLASS Test and Measurement (TMC)
    • Vendor class
  • NDIS Remote Support (RNDIS)
  • Supports WINUSB 1.0, WINUSB 2.0 with BOS (Binary Device Object Store)

The core of the USB device stack uses 3045 bytes of flash memory and 373 of RAM, and the HID class takes an additional 784 bytes of storage and 201 bytes of RAM. We are not told on which target, but it gives an idea.

CherryUSB Host Stack Features:

  • Automatic loading of supported class drivers
    • Composite device
    • Communications Device Class (CDC)
    • Human Interface Device (HID)
    • Mass storage class (MSC)
    • Vendor class
  • Synchronous and asynchronous transfers
  • Multi-level HUB support, expandable up to 7 levels
  • Remote NDIS (RNDIS) support

We don’t receive any footprint estimates for the host stack.

The source code can be found on Github, released under an Apache 2.0 license. There is also a graphical configuration tool used to generate USB descriptors. Documentation is available but only in Chinese, and I also notice some instructions for RT-Thread RTOS, so that more microcontrollers can be supported beyond the list provided in the introduction.

Support CNX software! Make a donation through PayPal or cryptocurrencies, become a patron on Patreon, or buy exam samples

ROCK Pi 4C Plus