A POSIX-compliant real-time operating system (RTOS) for embedded devices, scaling from 8-bit to 64-bit microcontrollers.
hathach/tinyusb
Open-source cross-platform USB Host and Device stack for embedded systems, designed for memory and thread safety across 50+ MCU families.
- Stars
- 7,262
- Forks
- 1,577
- Open issues
- 417
- Last commit
- yesterday
What is it?
TinyUSB is a USB stack written in C for microcontrollers, supporting both Device and Host roles. It targets embedded developers who need USB connectivity on small chips without a full operating system. The stack avoids dynamic allocation, using only static buffers, and defers all interrupt work to non-ISR task functions so that it can run safely alongside an RTOS.
On the device side, TinyUSB implements a broad set of classes including CDC serial, HID (keyboard, mouse, gamepad), mass storage with multiple LUNs, MIDI, audio (UAC1/UAC2), printer, networking (RNDIS, ECM, NCM), and WebUSB. The host side covers CDC-ACM, several USB-to-serial chip families, HID, MSC, MIDI and hubs. Developers can also write custom class drivers through callback hooks without modifying the stack.
The repository includes examples built with make and CMake, a board support layer, and a support table listing which MCU families offer device, host and high-speed capability. It works with bare metal, FreeRTOS, RT-Thread and Mynewt.
Key features
- 01Device and Host stacks in one codebase with dynamic descriptor configuration.
- 02Static memory allocation with no dynamic allocation at runtime.
- 03Interrupts deferred to task context for thread safety under an RTOS.
- 04Supports many device classes including CDC, HID, MSC, MIDI, audio and networking.
- 05Host support for CDC-ACM, HID, MSC, MIDI and multi-level hubs.
- 06Portable across 50+ MCU families and runs on bare metal, FreeRTOS or RT-Thread.
Use cases
- Adding a USB serial console or CDC port to a microcontroller product.
- Building a USB keyboard, mouse or gamepad from a small MCU.
- Exposing an SD card or flash storage to a PC as a USB mass storage drive.
- Writing a USB MIDI controller or audio device on embedded hardware.
Quick start
- 1
Get the source and read the Getting Started guide
- 2
Build the cdc_msc example from the examples directory
- 3
Add TinyUSB to your project following the Getting Started guide
Things to know
- Targets embedded MCUs, so it is not a general-purpose USB library for desktop or mobile systems.
- Support varies by MCU family; check the Supported CPUs table for host and high-speed availability.
- The Power Delivery stack is super early stage and only for testing on STM32 G4.
In collections
Topics
FAQ
- What is tinyusb?
- Open-source cross-platform USB Host and Device stack for embedded systems, designed for memory and thread safety across 50+ MCU families. TinyUSB is a USB stack written in C for microcontrollers, supporting both Device and Host roles. It targets embedded developers who need USB connectivity on small chips without a full operating system. The stack avoids dynamic allocation, using only static buffers, and defers all interrupt work to non-ISR task functions so that it can run safely alongside an RTOS.
- Is tinyusb free to use? What license does it have?
- tinyusb is open source under the MIT license. Check the license terms before using it in commercial products.
- Is tinyusb still maintained?
- Actively maintained. The last commit to tinyusb was on Nov 6, 2026.
- What can I use tinyusb for?
- Adding a USB serial console or CDC port to a microcontroller product. Building a USB keyboard, mouse or gamepad from a small MCU. Exposing an SD card or flash storage to a PC as a USB mass storage drive. Writing a USB MIDI controller or audio device on embedded hardware.
- How do I install tinyusb?
- Get the source and read the Getting Started guide Build the cdc_msc example from the examples directory Add TinyUSB to your project following the Getting Started guide
- Where can I get tinyusb?
- The source code and installation instructions are on GitHub: https://github.com/hathach/tinyusb
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A scalable real-time operating system (RTOS) for resource-constrained microcontrollers and IoT devices across many CPU architectures.
A lean Python 3 implementation that runs on microcontrollers and other resource-constrained devices, with hardware access modules.
Official development framework from Espressif for building firmware on ESP32 and other Espressif SoCs, on Windows, Linux and macOS.
Cross-platform command-line tool and build system for embedded development, covering library management, multiple boards and frameworks, debugging and unit testing.
A toolbox for building embedded applications in Zig, providing a hardware abstraction layer and board/chip support.