whatisgithub

What is tinyusb?

hathach/tinyusb — explained in plain English

Analysis updated 2026-06-24

6,796CAudience · developerComplexity · 3/5LicenseSetup · moderate

In one sentence

Open-source C library that lets microcontrollers act as USB devices (keyboard, storage, audio) or USB hosts (reading connected keyboards, drives, MIDI gear), designed for small embedded chips with tight memory budgets.

Mindmap

mindmap
  root((TinyUSB))
    What it does
      USB device stack
      USB host stack
      No dynamic memory
    Tech Stack
      C language
      FreeRTOS support
      50 plus MCU families
    Use Cases
      Keyboard emulation
      USB drive emulation
      MIDI over USB
    Audience
      Embedded developers
      Hardware hobbyists
    License
      MIT open source
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Make a microcontroller appear to a computer as a USB keyboard, mouse, or storage drive

USE CASE 2

Build a USB host that reads input from keyboards, mice, or MIDI instruments plugged into your board

USE CASE 3

Add USB audio or MIDI output to an embedded hardware project

USE CASE 4

Write a custom USB device class driver without modifying the library core

What is it built with?

CFreeRTOSRT-ThreadMynewt

How does it compare?

hathach/tinyusbyanfeizhang/coder-kung-fumackron/miniaudio
Stars6,7966,7856,761
LanguageCCC
Setup difficultymoderatemoderateeasy
Complexity3/51/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires a supported MCU toolchain and a compatible hardware development board.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

TinyUSB is an open-source library written in C that lets microcontrollers communicate over USB. It handles both the device side (making your board appear to a computer as a keyboard, storage drive, audio interface, or serial port) and the host side (letting your board read from a USB keyboard, drive, or MIDI instrument plugged into it). It is designed to run on small embedded chips where memory is tight and real-time response matters. Two design goals shape everything about the library. First, it never allocates memory dynamically at runtime, so there are no surprise crashes from running out of memory on a small chip. All buffers are declared upfront. Second, USB interrupt events are never processed directly inside the interrupt handler, instead they are pushed into a queue and handled in ordinary task code. This makes the library safe to use in multitasking environments where multiple pieces of code might try to access the USB hardware at the same time. The device stack supports a wide range of USB device types: serial port emulation (CDC), human interface devices like keyboards and mice (HID), mass storage (MSC, which makes the board show up as a USB drive), audio (UAC1 and UAC2), MIDI, networking, Bluetooth, device firmware update, and more. The host stack lets a board act as the USB controller that reads input from keyboards, mice, storage drives, MIDI devices, and USB serial adapters from common chip makers. You can also write your own device class driver without modifying the library itself. The library supports over 50 different microcontroller families from manufacturers including Raspberry Pi, Nordic Semiconductor, STMicroelectronics, NXP, Espressif, Renesas, and many others. It works with no operating system at all, or alongside FreeRTOS, RT-Thread, or Mynewt. Examples are provided for a range of supported development boards, and the recommended starting point for new users is the combined CDC and mass storage example. The project is funded by Adafruit and is licensed under the MIT license. Documentation lives online, and the community uses GitHub Discussions for questions. The README includes a large compatibility table listing exactly which USB features (device mode, host mode, high-speed) are supported on each chip family.

Copy-paste prompts

Prompt 1
Using TinyUSB on a Raspberry Pi Pico, show me how to make the board appear as a USB keyboard and send keystrokes to a connected computer.
Prompt 2
Walk me through setting up TinyUSB in host mode to read input from a USB keyboard attached to an STM32 microcontroller.
Prompt 3
How do I configure TinyUSB to expose a mass storage device from an Espressif chip so it shows up as a USB drive on my PC?
Prompt 4
Show me how to combine CDC serial port and HID keyboard in a single TinyUSB device configuration on a bare-metal project.
Prompt 5
What does the TinyUSB main task loop look like for a FreeRTOS project on an NXP microcontroller?

Frequently asked questions

What is tinyusb?

Open-source C library that lets microcontrollers act as USB devices (keyboard, storage, audio) or USB hosts (reading connected keyboards, drives, MIDI gear), designed for small embedded chips with tight memory budgets.

What language is tinyusb written in?

Mainly C. The stack also includes C, FreeRTOS, RT-Thread.

What license does tinyusb use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is tinyusb to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is tinyusb for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.