• Stars
    star
    1,452
  • Rank 32,405 (Top 0.7 %)
  • Language
    C
  • License
    Other
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Software-only ESP8266 USB Device

ESP8266 USB Software Driver

I wanted to have USB on the ESP8266, and a while ago I saw on the ESP32 flier, it read: "Rich Peripherals" ... "Sorry, no USB!" I thought to myself, that is ridiculous. Of course there's USB.

So, it was born. This is a software USB stack running on the ESP8266/ESP8285. It requires only one external resistor, between D- and 3.3V.

Limitations

  • You cannot use SDKs newer than 1.5.X. (As of dec-02-2016, 1.5.4 is the latest SDK that has been verified to be compatible.)
  • All ESP SDK 2.0 SDKs are incompatible.
  • By default, the chip expects D- on GPIO 4 and D+ on GPIO 5 - but any GPIO pair may be used. It is important to note that both D- and D+ MUST be adjacent.
  • This project only operates with low-speed USB (1.5 MBit/s) ideal for making peripherals, not for fake network devices and usb-serial bridges.
    That said - you can still write "control" messages that communicate with the ESP8266.
    Control messages are a great way to encapsulate your data since they handle all the framing and describing what function you wish to pass data for.

Resources

Pre-built binaries

See bottom of this thread: #40 (comment)

Examples

This project contains an example that simulates a usb keyboard and mouse. It also provides a web interface to actually remote control these virtual devices.

How to use

For a complete guide that includes information on how to install the toolchain or set up a docker container, go here: Getting started guide If you already have an environment with the toolchain, then here is what you wanna do:

Software

  • Install libusb and recursively clone this repo:

    sudo apt-get install libusb-1.0-0-dev
    git clone --recursive https://github.com/cnlohr/espusb
    cd espusb
  • user.cfg contains some settings that you might have to change to get it working.

  • Building/flashing the main binary

    make ESP_ROOT=~/esp8266/esp-open-sdk/ burn
  • Building/flashing the web interface (for the example mentioned above)

    make ESP_ROOT=~/esp8266/esp-open-sdk/ burnweb

For more advanced building/flashing methods just run make without any parameters.

Hardware

basic-schematic

Wemos D1 Mini

The Wemos D1 mini is a breadboard friendly ESP board.

You would need to flash the espusb firmware through the USB-serial connection beforehand, and then wire the GND, 5V, 3.3V, D1, D2 pins to the USB following the wiring instructions. Here is a picture of a setup with one breadboard:

EspUSB on the Wemos D1 Mini

Advanced information

Hardware

Schematic

NOTE: GPIO12/14 do not need to be connected to ground. GPIO15 may be connected via a pull-down resistor. For stability, a pull-up on GPIO2 is recommended.

Also, checkout the hardware/ folder. It has kicad designs for my tiny board. Though they are for the ESP8285, the same pin configuration may be used to run on the ESP8266.

Memory Usage

This is typical memory usage for a two-endpoint (in addition to EP0) device.

In summary:

Total SRAM: 232 bytes + Descriptors (~317 bytes)

Total Flash/IRAM (Only iram, tables and usb_init can be stuck in slow flash): 1422 bytes

More details:

SRAM:

0000007c D usb_ramtable
0000006c B usb_internal_state

IRAM:

You must write: usb_handle_custom_control - the demos here hook it up to the command engine which allows self flashing on 1MB+ parts.

C functions:

0000002a T usb_pid_handle_ack
0000014f T usb_pid_handle_data
00000022 T usb_pid_handle_out
000000e9 T usb_pid_handle_in
00000002 T usb_pid_handle_sof
00000039 T usb_pid_handle_setup

From/To (in ASM):

40100f20 t usb_asm_start
401011ef t usb_asm_end
Total length of ASM: 2cf

More Repositories

1

rawdrawandroid

Build android apps without any java, entirely in C and Make
C
3,408
star
2

mini-rv32ima

A tiny C header-only risc-v emulator.
C
1,410
star
3

channel3

ESP8266 Analog Broadcast Television Interface
C
1,277
star
4

ch32v003fun

An open source software development stack for the CH32V003, a 10Β’ 48 MHz RISC-V Microcontroller
C
674
star
5

colorchord

Chromatic Sound to Light Conversion System
C
663
star
6

noeuclid

Non-euclidean GPU Raytraced Game
C
647
star
7

esp8266ws2812i2s

ESP8266-based I2S-output WS2812(B) Driver
C
536
star
8

avrcraft

Minecraft server optimized for 8-bit devices.
C
435
star
9

rv003usb

CH32V003 RISC-V Pure Software USB Controller
C
328
star
10

ws2812esp8266

DEPRECATED. Please use esp8266ws2812i2s. No really, stop forking and starring this.
C
298
star
11

esp82xx

Useful ESP8266 C Environment
C
289
star
12

espthernet

ESP8266 10-Base-T Ethernet Driver
C
246
star
13

nosdk8266

Trying to make ESP8266 projects without a big SDK.
C
235
star
14

esp8266rawpackets

Raw Packet Experiments on the ESP8266
JavaScript
148
star
15

fx3fun

Treat your Cypress FX3 a little like a logic analyzer or software defined bus.
C
147
star
16

epaper_projects

C
145
star
17

voxeltastic

View 3D Volume with Translucency in WebGL
JavaScript
143
star
18

shadertrixx

CNLohr's repo for his Unity assets and other shader notes.
ShaderLab
137
star
19

cnovr

CNLohr's OpenVR Misadventures
C
128
star
20

ethertiny

A firmware-only half-duplex 10Base-T implementation for AVRs
PostScript
121
star
21

cnixxi

My experiment with nixie tubes.
C
112
star
22

wiflier

ESP8266-based Quadcopter Brain
KiCad Layout
93
star
23

embeddedDOOM

"emdoom" - a port of DOOM targeted for memory-strapped systems.
C
90
star
24

espwebc3

An in-browser integrated development platform for the ESP32-C3
HTML
84
star
25

esplocalizer

ESP8266 with IMU, Barometer and Battery
C++
83
star
26

esp8266oddclock

What happens when you rip the ESP8266's stable clock source out from under it's feet?
C
81
star
27

esptracker

Lighthouse-based tracker using the TS4231
C
60
star
28

rawdrawandroidexample

Example app using rawdrawandroid as a submodule.
C
59
star
29

wifirxpower

Linux-based WiFi RX Power Grapher
C
59
star
30

pylotron

Embedded VNC-based FPS.
C
58
star
31

esp32s2-cookbook

Low-level tests with the ESP32-S2
C
48
star
32

androidusbtest

Access external devices from Android apps directly in C.
C
46
star
33

superlongexposure

FFMPEG-based tool for non-linear compositing video into long exposures.
C
41
star
34

tplink-raw-wifi

Test using tp-links to do raw wifi.
C
41
star
35

pi_tpi

Using a Raspberry Pi to program an ATTiny10 9 5 or 4
C
39
star
36

what_im_up_to

Just my dumping ground for ideas.
37
star
37

tsopenxr

Single-file header for simple OpenXR Framework use with C
C
36
star
38

t85loudspeaker

ATTiny85 Sound Output
C
35
star
39

avr_vhf

Channel 3 VHF Broadcasting with an AVR
C++
34
star
40

esp8266_dmx_explorer

C
32
star
41

esp8266duplexi2s

Generic duplex communication on the I2S bus in the ESP8266.
C
31
star
42

lamenet

A way of making a really awful network connection.
C
31
star
43

dumbcraft8266

My first stab at a Minecraft-enabled firmware for the ESP8266
C
30
star
44

swadges2017

MAGFest Swag Badges 2017 Firmware
C
29
star
45

cnballpit-vrc

C#
28
star
46

cnhardware

C
28
star
47

esp8266_link_test

Test link between an ESP8266 and a base station or another ESP8266 easily.
KiCad Layout
26
star
48

brokeredupdateandsync

CN's VRC Tools and Prefabs
C#
26
star
49

tinycc-win64-installer

A quick way to use tinyCC on Windows.
NSIS
25
star
50

wificompositer

Various tools I used to collect and composite data from a wifi device into an image.
C
24
star
51

miniosc

Single-file-header OSC library for C (includes platform-independent sockets)
C
21
star
52

esp32-cnlohr-demo

My always-incomplete ESP32 fun zone
C
20
star
53

spreadgine

An OpenGL ES engine with WebGL Output.
C
19
star
54

slapsplat

GLSL
19
star
55

oledscope

Playing around with a 128x128 OLED module
C
19
star
56

cnlohr_social_media_tools

Various social media interface tools.
C
18
star
57

assembly-notes

My repo for a guide to and notes on assembly lagnuage, inling, etc.
18
star
58

usb2812

ATMega32u2 USB driver for WS2812 LEDs.
C
18
star
59

x11framegrab

Small static program for taking screenshots of x11 screens and saving/streaming as a variety of formats.
C
18
star
60

esp8266lighthouse

DO NOT USE THIS PROJECT - WILL BE SUPERCEDED
C
17
star
61

wasm_integrated

An example of how you can fully integrate wasm into a webpage. No need for fetching or any of that jazz.
HTML
17
star
62

swadge-vrchat-bridge

C
16
star
63

magfestbadges

The codebase, schematics, etc. of the MAGFest Badges.
C
16
star
64

cntools

Incomplete-ish C "libraries"
C
16
star
65

wi07clight

Using the wi07c's ESP8266 to control a desk light.
C
16
star
66

avrjslinux

JSLinux Running on an AVR with I/O Port Remapping
JavaScript
14
star
67

tinyispterm

An SPI terminal for USB Tiny ISP compatible AVR prorgammers.
Python
14
star
68

esp32-c3-cntest

C
13
star
69

h264fun

Fun with h264 (mostly encoding)
C
13
star
70

tensigral_lamp

My PCB Tensegrity structure lamp.
C
12
star
71

addressable_leds

Charles's list of addressable LEDs
12
star
72

kelvindmmwifi

Adding some sweet wifis to a kelvin multimeter.
KiCad Layout
11
star
73

attiny85_tb

ATTiny85 Test Bench Tool with Screw Terminals
Eagle
10
star
74

voxeltastic-vrc

Voxel Tracing Shader for VRChat
ShaderLab
10
star
75

esp32s2_dmx512_usb

C
10
star
76

rawdrawwasm

My stab at rawdraw on wasm.
HTML
10
star
77

swadgeguide

My guide for making swadges.
HTML
9
star
78

terriblewordsearch

A C tool for making terrible word searches.
C
9
star
79

cndvr

Assembly
9
star
80

flexcrt

A header for CRTs to allow for scattered writes.
HLSL
8
star
81

swadge2019

the repo for the 2019 swadge
C
8
star
82

espbadapple

Bad Apple in 62kB or bust.
C
8
star
83

donut

MAGFest /is/ a donut.
C
8
star
84

minimal_stm32f407

STM32F407 Minimal self-contained Makefile-based build environment (Plus printf!)
C
8
star
85

esp8266irxmit

ESP8266 IR Transmistter
C
7
star
86

minimal_stm32f303

STM32F303 Minimal self-contained Makefile-based build environment (Plus printf!)
C
7
star
87

netlink_without_libnl

Testing using the kernel's netlink, more specifically nl80211 without libnl or genl
C
7
star
88

wxrchat

Distributed WebXR Chat Application
C
6
star
89

esp32_ethernet_test

My Ethernet on the ESP32 Test (incomplete!)
C
6
star
90

tinyisp-micro

My USBTinyISP (with an ATTiny44)
KiCad Layout
6
star
91

esp_network_rgb

JavaScript
6
star
92

charlesvideotools

Linux Video Creation Notes and Tools
C
5
star
93

esp_nonos_sdk

Patchwork of various esp_nonos_sdk subsystems.
C
5
star
94

in99

Gain a superficial of topics in 99 seconds.
5
star
95

shader_perf_grass_comparison

Fake test for checking perf of different shader types.
ShaderLab
5
star
96

stm32f042_fun

My fun repo for the STM32f042
C
4
star
97

bridgesim

Project abandoned. Library code probably has problems.
C
4
star
98

avr_ledprojector

Using an AVR with an mlx90614 to project temperatures!
KiCad Layout
4
star
99

esp8266_32x32panel

An attempt at driving 32x32 panels with an ESP8266.
KiCad Layout
4
star
100

sk6812rgbyspectraldata

Just an email I got from Andrew Sowa
4
star