Git Product home page Git Product logo

espusb's Introduction

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

espusb's People

Contributors

cnlohr avatar florolf avatar jobr99 avatar leopck avatar mateon1 avatar robbinsrush avatar zoobab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

espusb's Issues

"../ld/eagle.rom.addr.v6.ld: No such file or directory"

I was reflashing my esp using the new guide in the wiki and kept getting "../ld/eagle.rom.addr.v6.ld: No such file or directory" when trying to build. I edited the last line in the file with the wrong path (~/esp8266/esp-open-sdk/sdk/ld/eagle.app.v6.ld ). I simply changed it into "eagle.rom.addr.v6.ld", with that edit everything works. I'm not sure if I did anything wrong (like if my directory tree is messed up or what), but I thought I would mention it just in case.

How about MIC line instead of USB ?

Hi @cnlohr .
I think this is a very challenging idea . What if we can program by our headphone jack and the programmer is any device that can run Chrome ?
https://ltc.chibitronics.com/
This project use a modulated sound wave and transfer it to the MCU which has already got a firmware for this , the cable use the ID pin of the Jack which is normally left floating
https://www.adafruit.com/product/3674?utm_source=youtube&utm_medium=videodescrip&utm_campaign=newproducts

Because this is purely analog and luckily the esp has a analog port available . I think this will be a great hack :))

error: user/usb_asm_1bit.S: No such file or directory

git clone https://github.com/cnlohr/espusb.git
cd espusb
git submodule init
git submodule update

make all
# success.
make clean
make all
#error: user/usb_asm_1bit.S: No such file or directory

Basically, This problem is related to Makefile#L5 and esp82xx/main.mf#L107.

esp8266/esp-open-sdk/sdk/lib/libmain.a Not found

Hi, I can not make your project...

make ESP_ROOT=~/esp8266/esp-open-sdk burn
Makefile:10: warning: overriding recipe for target 'usbburn'
esp82xx/main.mf:113: warning: ignoring old recipe for target 'usbburn'
/home/debian/esp8266/esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc -mlongcalls -Os -I/home/debian/esp8266/esp-open-sdk/sdk/include -Iesp82xx/include -I. -Iesp82xx/fwsrc -Iuser -DICACHE_FLASH -DWEB_PORT=80 -DCOM_PORT=7777 -DBACKEND_PORT=7878  -DSLOWTICK_MS=100 -DVERSSTR='"Version: 0a60b-dev - Build Sat, 19 Sep 2020 00:37:33 +0200 with -DICACHE_FLASH -DWEB_PORT=80 -DCOM_PORT=7777 -DBACKEND_PORT=7878  -DSLOWTICK_MS=100"'  esp82xx/fwsrc/uart.c esp82xx/fwsrc/esp82xxutil.c esp82xx/fwsrc/flash_rewriter.c esp82xx/fwsrc/http.c esp82xx/fwsrc/commonservices.c esp82xx/fwsrc/http_custom.c esp82xx/fwsrc/mdns.c esp82xx/fwsrc/mfs.c user/custom_commands.c user/user_main.c user/usb_asm_1bit.S user/usb.c -flto -Wl,--relax -Wl,--gc-sections -nostdlib -L/home/debian/esp8266/esp-open-sdk/sdk/lib -L/home/debian/esp8266/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/libgcc.a /home/debian/esp8266/esp-open-sdk/sdk/lib/libmain.a /home/debian/esp8266/esp-open-sdk/sdk/lib/liblwip.a /home/debian/esp8266/esp-open-sdk/sdk/lib/libssl.a /home/debian/esp8266/esp-open-sdk/sdk/lib/libupgrade.a /home/debian/esp8266/esp-open-sdk/sdk/lib/libnet80211.a /home/debian/esp8266/esp-open-sdk/sdk/lib/libwpa.a /home/debian/esp8266/esp-open-sdk/sdk/lib/libphy.a /home/debian/esp8266/esp-open-sdk/sdk/lib/liblwip.a /home/debian/esp8266/esp-open-sdk/sdk/lib/libcrypto.a /home/debian/esp8266/esp-open-sdk/sdk/lib/libpp.a /home/debian/esp8266/esp-open-sdk/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.5/libgcc.a -T /home/debian/esp8266/esp-open-sdk/sdk/ld/eagle.app.v6.ld -B/home/debian/esp8266/esp-open-sdk/sdk/lib  -o image.elf
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/libmain.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/liblwip.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/libssl.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/libupgrade.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/libnet80211.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/libwpa.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/libphy.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/liblwip.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/libcrypto.a: No such file or directory
xtensa-lx106-elf-gcc: error: /home/debian/esp8266/esp-open-sdk/sdk/lib/libpp.a: No such file or directory

Please help

Wifi setting to Station Mode doesn't stay

Hello,

I am using the Wemos D1 Mini. I am able to connect via AP mode from device to the Wemos. I was able to connect to Station Mode to home WIFI. It stays for some time and when reset, it reverted back into AP mode.

Edit 1: After setting DHCP permanent IP in the router, I am able to connect. However, the HID function doesn't work. Mouse or keyboard. And the bluetooth keeps getting recognized/unrecognized in windows.

Edit 2: After connect to a different USB port (i.e. reset), it defaults back to AP Mode.

I used a 1k resistor. don't know if this is causing problem?

Thank you.

Can we open a wiki?

Some people don't know howto install things. Can we open the wiki, so we can document things together?

Thanks for sharing the USP8266 :D.

Improving the web interface and API

I'm currently trying to basically rewrite the whole web interface thing because the way it is currently written it is completely unmaintainable imo.

For example big chunks of html code within the javascript code, jquery is available but not used consistently, everything is written in functions - no classes etc, lots of global variables, a unconventional request/response system is forced onto websockets, very unclear api (e.g. sending the letter "I" will respond with the current system tick of the esp etc), .........

If you ask me websockets should only be used for data that the server is either continuously sending to the client or for data that the server should send to the client as soon as it changes. (E.g. the system clock or a change on a GPIO pin).
Everything else (e.g. saving settings or uploading files) should use a traditional http api.

I would really like to do all this and I'm willing to write every piece of javascript code that needs to be written. But I really need help with the backend.

So if someone who knows c a bit better than me is willing to do this with me that would be awesome.

Consider false-ACKing for full-speed experimentation

The ESP does have the I2S bus which can read the I2S pin very quickly. I thought that would be impossible to use because of the latency incurred. @scanlime pointed out in Twitter https://twitter.com/scanlime/status/814213365715193856 that we could just send a bogus ACK and keep moving.

The example exists in the propeller example here: https://github.com/scanlime/propeller-usb-host/commits/master/usb-fs-host.spin

I am trying to think about possible schemes to watch for an SE0 flag and immediately send an ACK. I think it may need external hardware, though.

Manufacturing an EspUSB

I've been wanting to buy an EspUSB since I first heard about it in 2016. Unfortunately the design, though free and open-source, is incomprehensible to any contract manufacturers. I only have access to a large chisel soldering iron, and rarely have a stable address for shipping components to me. I need someone else to build it, and I will pay. I want to be able to type foreign languages (e.g. Chinese) directly into my laptop just by changing the virtual keys on my phone.

A year ago I tried to ask PCBWay to build it. They said they want a BOM file. I knew that this could be deduced from the schematic, but I don't trust my guesswork. I asked on the forum, without any success. I asked in the Hackaday chatroom, without success. Finally I was visiting a colleague, and they helped me reverse-engineer the BOM from the sch file. PCBWay rejected it again, wanting me to provide Digikey part numbers. A couple of hours of searching and guessing later, I hope I guessed those right. If anybody needs the BOM, I'm attaching that. It really should be included in the design folder. At this point, PCBWay took the order, and let me pay.

358_BOM.xlsx

Now they're asking for a "pick & place file". My colleague said to just send PCBWay a photo, but they won't accept it, they want a "centroid file". I don't know how to make one of those. I've already guessed a lot, and I think there's only a 50% chance that the finished product will work, because I've had to make up random numbers for half the design process. I guess I'll lose the money I've already paid to PCBWay.

Please can someone tell me how to get the EspUSB Tiny manufactured?

Use from esp8266/Arduino

Can Arduino sketches use espusb? If so, how? (I would like to avoid having to compile a toolchain and SDK, and use the ones that come with esp8266/Arduino instead.

Whereas #1 is about the bootloader (i.e., being able to flash the ESP from the Arduino IDE without a USB-to-Serial adapter), this ticket is about compiling e.g., a USB HID device using the Arduino IDE, similar to vusb-for-arduino.

Multimedia keys

Hi. In Windows 10 none of volume keys, play/pause work. Only in Linux (Mint) volume keys works. Any idea why media keys are not working?

Pre-Compiled?

I cant seem to compile it! Is it possible to get a pre-compiled copy for esp8266 12E?

GPIO pair for D- and D+

Can you explain a bit on 'any GPIO pair may be used. It is important to note that both D- and D+ MUST be adjacent.' ?

Is it means GPIO12 and GPIO13 (D-, D+) will work, but GPIO12 and GPIO14 (D-, D+) won't ?

Why is that?

Thanks a lot! This is great project!

The default example includes a remote control web page?

Is all this: https://github.com/cnlohr/espusb/tree/master/web/page
part of the default example that gets flashed to the ESP when using the default makefile?

If so, how can I access the site then? I tried http://192.168.4.1 but all I get is an empty page with the words "File not found" in to top-left corner.

I think it would make more sense to let espusb simply be a library and create a new repository for the example.
Or at least mention in the readme that there even is an example and also what it does. ;)

How can I add more files to the web interface?

I tried to add a new css and js file to the web/page folder, but they don't seem to get flashed properly. Changing to the existing files works just fine btw. I thought that burnweb should be enough, but it appears that I must be missing something.
In my desperation I even tried to run all, clean, purge and burn ... but it didn't change anything the new files were not available on the esp.

Any idea what I could be missing?

edit:
It seems like one file actually made it. But two other files didn't. Weird.

Joystick over ESPUSB

I've been trying to enable joystick over espusb, I've managed to add the joystick hid descriptor based off a joystick I have (Microsoft Force Feedback Joystick 2). I am trying to attempt to create a composite device with mouse + keyboard + joystick... is this possible?

Anyway, I managed to get some readings from the 'dmesg' by adding the hid descriptor into the usb_config.h but I'm receiving lots of errors as well :( I think I'm missing something or doing something wrong. Any advice? I've placed the usb_config.h together with this post.

[   28.127483] hid-generic 0003:ABCD:8266.0008: input,hidraw7: USB HID v1.10 Joystick [CNLohr ESPUSB2] on usb-0000:00:1d.0-1.2/input2

image

joystick_hid_desc

//From Microsoft Force Feedback Joystick 2 Reverse Engineered
static const uint8_t joystick_hid_desc[61] = {   /* USB report descriptor */
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x04,                    // USAGE (Joystick)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x85, 0x01,                    //   REPORT_ID (1)
    0xa1, 0x02,                    //   COLLECTION (Logical)
    0x09, 0x32,                    //     USAGE (Z)
    0x09, 0x31,                    //     USAGE (Y)
    0x09, 0x30,                    //     USAGE (X)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //     LOGICAL_MAXIMUM (255)
    0x35, 0x00,                    //     PHYSICAL_MINIMUM (0)
    0x46, 0xff, 0x00,              //     PHYSICAL_MAXIMUM (255)
    0x75, 0x08,                    //     REPORT_SIZE (8)
    0x95, 0x03,                    //     REPORT_COUNT (3)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0xc0,                          //   END_COLLECTION

    0x85, 0x02,                    // REPORT_ID (2)

    0xa1, 0x02,                    //   COLLECTION (Logical)
    0x05, 0x09,                    //     USAGE_PAGE (Button)
    0x29, 0x02,                    //     USAGE_MAXIMUM (Button 2)
    0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
    0x95, 0x02,                    //     REPORT_COUNT (2)
    0x75, 0x01,                    //     REPORT_SIZE (1)
    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x81, 0x02,                    //     Input (Data, Variable, Absolute)
    0x95, 0x01,                    //     Report Count (1)
    0x75, 0x06,                    //     Report Size (6)
    0x81, 0x01,                    //     Input (Constant) for padding    
    0xc0,                          //   END_COLLECTION
0xc0 // END_COLLECTION
};

config_descriptor

    //Interface Descriptor:: Joystick
    0x09,// bLength
    0x04,// bDescriptorType

    //Need to adjust this accordingly if we add more devices :: bInterfaceNumber is like an ID so must be unique
    0x02,// bInterfaceNumber
    0x00,// bAlternateSetting
    0x02,// bNumEndPoints
    0x03,// bInterfaceClass   (Human Interface Device Class)
    0x00,// bInterfaceSubClass   
    0x00,// bInterfaceProtocol   
    0x00,// iInterface


    //HID Descriptor
    0x09,// bLength
    0x21,// bDescriptorType
    0x10,0x01,//    bcdHID
    0x00,// bCountryCode
    0x01,// bNumDescriptors
    0x22,// bDescriptorType   (Report descriptor)
//  0x3F,0x05,//    bDescriptorLength
    61, 0x00,// bDescriptorLength

    //Endpoint Descriptor IN
    0x07,// bLength
    0x05,// bDescriptorType
    0x81,// bEndpointAddress   (IN Endpoint)
    0x03,// bmAttributes    (Transfer: Interrupt / Synch: None / Usage: Data)
    0x40,0x00,//    wMaxPacketSize   (64 Bytes) 
    0x01,// bInterval


    //Endpoint Descriptor OUT   
    0x07,// bLength
    0x05,// bDescriptorType
    0x02,// bEndpointAddress   (OUT Endpoint)
    0x03,// bmAttributes    (Transfer: Interrupt / Synch: None / Usage: Data)
    0x10,0x00,//    wMaxPacketSize   (16 Bytes) 
    0x04,// bInterval

descriptor_list[](honestly, I don't have a clue on the 0x2200 thing, so i just added and increased the number sequentially :D)

descriptor_list[] = {
    {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)},
    {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)},
    {0x2200, 0x0000, mouse_hid_desc, sizeof(mouse_hid_desc)},
    {0x2200, 0x0001, keyboard_hid_desc, sizeof(keyboard_hid_desc)},
    {0x2200, 0x0002, joystick_hid_desc, sizeof(joystick_hid_desc)}, <---- added
    {0x0300, 0x0000, (const uint8_t *)&string0, 4},
    {0x0301, 0x0409, (const uint8_t *)&string1, sizeof(STR_MANUFACTURER)},
    {0x0302, 0x0409, (const uint8_t *)&string2, sizeof(STR_PRODUCT)},   
    {0x0303, 0x0409, (const uint8_t *)&string3, sizeof(STR_SERIAL)}
};

EDIT: Added the usb_config.h on gist: https://gist.github.com/leopck/aadf4d8c7362d8f4b353740e41a54fa7

Set static wifi station to connect

Hi, i dont now if this issue is correct submited but i will try :)

How can i change the wifi settings hard coded in the source code?

  1. how can i set a permanent wifi station like my router and hard code the ssid and password in it?

  2. how can i rename the accespoint the esp8266 is opening but also hardcoded, where are these lines in the code. i searched everything but did not find it.

i am comming from arduino and want to learn c programming its not that easy but defenetly better :D

Profiling for esp8266 based code

Basic Infos
Hardware

Hardware: ESP8266
Core Version:
Description

Hi guys! I have developed a project based on NodeMCU, Now I am trying to debugging and profiling it.
Can any could please help how to profile the code?
I am able to debug it using gdb over eclipse and now I am trying to compile it using -pg Flag so that it gnenerate some info using mcount() and then I could use Gprof for further profiling.
Share some ideas would be appreciated.
Settings in IDE

Module: NodeMCU
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: dio
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: nodemcu

USBBURN how to? Error: make: web/execute_reflash: Command not found

make: web/execute_reflash: Command not found

Hello! I just got the espusb to work on my WSL (was a funny ride...)

I want to also use the usbburn. What can I do to fix this error?
make: web/execute_reflash: Command not found

Also, don't I have to also flash a bootloader? Can someone please give me some instructions on how to do all of this?
Thank you very much!

Android app to control the espusb

Hi,
Recently, i have a need to buy a working USB keyboard to unlock my laptop during boot time. Bluetooth keyboard,which i have,dont work during unlocking the encrypted disk of my Laptop during boot.

Before I buying the keyboard,I found this amazing project to use esp8266 as USB HID device. So without hasitating,i make one for me.
But,the WebUI is not user freindly. And i could not acheive my speed of doing stuff with the mobile keyboard.

So i modified an opensource Remote Pc control app [for android] to work with espusb.

https://github.com/DroidForked/Remote-Control-PC

prebuild apk: app-debug.apk

have a look if you are interested.

I also include a python script to control espusb,if you want to use with python to control espusb: main.py

Wiki - Getting Started Guide

I'm new to this, not sure if this is the place to post it, feel free to move it somewhere else.

On the Getting Started Guide, under "Building/flashing under a Docker container", to build the docker image, the final step should be sudo docker build -t tavk/esp-sdk:0.1.0 . with a space followed by a full stop at the end.

Numpad Keycodes and Android Keycodes collides / Optimize generation of scancodes

I've just found that my numpad is typeing chars in the english layout.
For example Numpad 7 has JavaScript KeyCode 103 (0x67), which is also the KeyCode of 'g' on my android phone.

Android is sending always 229 as KeyCode to get around this I've seen that you are mapping the unicode position of the char to the scancode. Maybe we should always use the unicode way, except for the arrow keys and similar keys.

Open for good ideas to handle that problem...

USB HID MIDI Device?

Is it possible to make the ESP8266 appear as a HID MIDI device over USB with this library?
If so, what are the necessary steps?

A little how to use section in the readme would be nice

I have a very hard time understanding how to use your project.
I just want to make my ESP8266 act as a USB keyboard.
And the file user/usb_config.h makes me think that the implementation for this does exist.

It would be really nice if you could add a little section to the readme explaining what user.cfg is all about and what to do in order to get the ESP8266 to act as the desired device.

At the moment I'm just very confused. I mean what do the variables in user.cfg even do? If the IP for example doesn't set the IP address for the ESP8266, then what does it do?

Best regards
tvk

PS: I love your work!

wemos d1 issues

Hi I am having trouble with getting espusb to work. I have managed to get the software to work. (I think) The website is working an "Messages: is increasing when I reload the side. But when I am unable to send key strokes to the computer

When I connect it to a ubuntu machine I am seeing this in the dmesg

[ 8670.728659] usb 2-2: device descriptor read/64, error -71 [ 8670.836665] usb usb2-port2: attempt power cycle [ 8671.488592] usb 2-2: new full-speed USB device number 73 using xhci_hcd [ 8671.488807] usb 2-2: Device not responding to setup address. [ 8671.696671] usb 2-2: Device not responding to setup address. [ 8671.904508] usb 2-2: device not accepting address 73, error -71 [ 8672.032503] usb 2-2: new full-speed USB device number 74 using xhci_hcd [ 8672.032658] usb 2-2: Device not responding to setup address. [ 8672.240634] usb 2-2: Device not responding to setup address. [ 8672.448482] usb 2-2: device not accepting address 74, error -71 [ 8672.448550] usb usb2-port2: unable to enumerate USB device

When I plug it in a windows machine it is recognized as a unknown device

Hardware is not my strongest side, but I really need this to work

Her is some pictures of how I have connected the HW
https://photos.app.goo.gl/QQ4c7XgAZnopFRRw5

Can someone point me in the right directions.

WiFi Password

Hi there does anyone know if it would be possible to set a WiFi password for the hosted ap I haven't been able to find it anywhere or even just hide the ssid would do?
Thanks

Nodemcu with espusb

I have a nodemcu
I can flash espusb inside
I can connect my smartphone to 192.168.4.1
But i lost connection if push web buttons...

What schematic need for connect a nodemcu and work with espusb in mode hid?

Thank!!!

Document how to build this

Would be good to have some instructions about the required build environment, e.g., which compilers, which SDKs, etc.

Need reset wifi for ap mode

After wifi configured, and reset wifi router, esp8266 don't connect more.
Serial monitor:
12:11:44.098 -> Connection failed with code 3... Retrying, try:
12:11:50.697 -> Connection failed with code 3... Retrying, try:
12:11:57.329 -> Connection failed with code 3... Retrying, try:
[...]
Need a method for reset wifi settings, for AP mode.

Serial over ESPUSB

Hi sorry for creating double issue (Joystick over ESPUSB) but I didn't want to mix these two projects together.

I thought of sharing these with others, just in case someone here is interested.
I've been attempting serial over espusb as how I've seen DigiSpark did it using Low-Speed CDC. So I tried replicating their method as well. I have only did the change to the usb_config.h for the moment.

usb_config.h (https://gist.github.com/leopck/0d3d1e38a11f3742f0a86bdcb3d88740)

So after multiple trial and errors I somehow got something on my 'dmesg'

[ 1331.813737] usb 2-1.2: Product: ESPUSB2
[ 1331.813741] usb 2-1.2: Manufacturer: CNLohr
[ 1331.838176] cdc_acm 2-1.2:1.0: ttyACM0: USB ACM device
[ 1331.838974] usbcore: registered new interface driver cdc_acm
[ 1331.838981] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Which looks like good news! Until I see more messages below:

[ 1331.845052] ------------[ cut here ]------------
[ 1331.845068] WARNING: CPU: 7 PID: 862 at /build/linux-a2WvEb/linux-4.4.0/drivers/usb/core/urb.c:449 usb_submit_urb.part.6+0x142/0x560()
[ 1331.845072] usb 2-1.2: BOGUS urb xfer, pipe 3 != type 1
[ 1331.845075] Modules linked in: cdc_acm cp210x usbserial rfcomm drbg ansi_cprng ctr ccm bbswitch(OE) bnep nvidia_uvm(POE) nvidia_modeset(POE) nvidia(POE) arc4 snd_hda_codec_hdmi snd_hda_codec_realtek ath9k snd_hda_codec_generic intel_rapl ath9k_common x86_pkg_temp_thermal uvcvideo ath9k_hw snd_hda_intel snd_usb_audio intel_powerclamp videobuf2_vmalloc coretemp videobuf2_memops snd_usbmidi_lib kvm_intel snd_hda_codec ath videobuf2_v4l2 snd_hda_core mac80211 videobuf2_core snd_hwdep btusb kvm v4l2_common snd_pcm btrtl snd_seq_midi videodev btbcm snd_seq_midi_event btintel snd_rawmidi media bluetooth cfg80211 snd_seq irqbypass crct10dif_pclmul snd_seq_device crc32_pclmul snd_timer jmb38x_ms memstick mei_me snd joydev input_leds mei soundcore shpchp lpc_ich serio_raw cryptd binfmt_misc ideapad_laptop
[ 1331.845172]  sparse_keymap mxm_wmi wmi mac_hid parport_pc ppdev lp parport autofs4 hid_generic usbhid hid i915 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops psmouse sdhci_pci ahci drm sdhci tg3 libahci ptp pps_core video fjes
[ 1331.845215] CPU: 7 PID: 862 Comm: ModemManager Tainted: P           OE   4.4.0-36-generic #55-Ubuntu
[ 1331.845220] Hardware name: LENOVO 20090                           /Base Board Product Name, BIOS 47CN28WW(V2.06) 06/14/2011
[ 1331.845224]  0000000000000286 00000000aa160979 ffff8802097fba08 ffffffff813f13b3
[ 1331.845231]  ffff8802097fba50 ffffffff81d486b8 ffff8802097fba40 ffffffff810810f2
[ 1331.845236]  ffff88010c30c0c0 0000000000000003 ffff88017a991800 0000000000000000
[ 1331.845242] Call Trace:
[ 1331.845255]  [<ffffffff813f13b3>] dump_stack+0x63/0x90
[ 1331.845263]  [<ffffffff810810f2>] warn_slowpath_common+0x82/0xc0
[ 1331.845269]  [<ffffffff8108118c>] warn_slowpath_fmt+0x5c/0x80
[ 1331.845284]  [<ffffffff81618802>] usb_submit_urb.part.6+0x142/0x560
[ 1331.845289]  [<ffffffff81618c82>] usb_submit_urb+0x62/0x70
[ 1331.845297]  [<ffffffffc073020b>] acm_submit_read_urb+0x3b/0x80 [cdc_acm]
[ 1331.845304]  [<ffffffffc07330b6>] acm_port_activate+0x186/0x1e8 [cdc_acm]
[ 1331.845310]  [<ffffffff814f3a7e>] tty_port_open+0x8e/0xe0
[ 1331.845317]  [<ffffffffc0730d03>] acm_tty_open+0x33/0x60 [cdc_acm]
[ 1331.845324]  [<ffffffff814ebfff>] tty_open+0x11f/0x6b0
[ 1331.845331]  [<ffffffff81211b8f>] chrdev_open+0xbf/0x1b0
[ 1331.845337]  [<ffffffff8120acef>] do_dentry_open+0x1ff/0x310
[ 1331.845341]  [<ffffffff81211ad0>] ? cdev_put+0x30/0x30
[ 1331.845346]  [<ffffffff8120be84>] vfs_open+0x54/0x80
[ 1331.845352]  [<ffffffff81217aeb>] ? may_open+0x5b/0xf0
[ 1331.845358]  [<ffffffff8121b667>] path_openat+0x1b7/0x1330
[ 1331.845365]  [<ffffffff8121d9d1>] do_filp_open+0x91/0x100
[ 1331.845371]  [<ffffffff8122b266>] ? __alloc_fd+0x46/0x190
[ 1331.845377]  [<ffffffff8120c258>] do_sys_open+0x138/0x2a0
[ 1331.845383]  [<ffffffff8106b544>] ? __do_page_fault+0x1b4/0x400
[ 1331.845389]  [<ffffffff8120c3de>] SyS_open+0x1e/0x20
[ 1331.845395]  [<ffffffff8182dfb2>] entry_SYSCALL_64_fastpath+0x16/0x71
[ 1331.845400] ---[ end trace 53721cd36948f595 ]---

This issue is similar to an issue from DigiSpark (digistump/DigistumpArduino#16) but it wasn't resolved at the end. Any ideas?

Also, there's another option which is to use v-USB HID Serial as shown here (http://rayshobby.net/hid-class-usb-serial-communication-for-avrs-using-v-usb/) but I haven't attempted this.

@cnlohr I was reading thru how you sent data over the espUSB and from the file 'execute_reflash.c' I saw that you used libusb_control_transfer to transfer pieces of the software over. Is it possible to reuse this for serial?

Question

Sorry for my posible stupid question....(I have 0 USB stack knowledge)
I see in the picture the HW prototype with D1 mini, is it possible to use the D1 mini usb for the exact purpose? (the d1 mini as I understand has its own ch340 usb to serial converter ).
If I understand correctly the D1 already handles full speed usb communication (when flashing for example) to the esp uart...

Is espusb compatible with FreeRTOS version?

I'm curious is the espusb project compatible with the FreeRTOS version of the espressif SDK? I was curious because I heard that the ESP32 is based on the FreeRTOS version. I took a very very short glance at the ESP32 codes and it looks pretty much the same on the C side at the least to ESP8266.

It'll be great if this works on ESP32 as well :D

ESP32 as software defined USB host?

Hi, great work you did (not only here)!

Is there a plan to not only make the ESP32 available as an USB device,
but also connect USB devices (I am mostly interested in keyboards) to the ESP32?

Best regards from Germany

Peter

Error on esptool.py: A fatal error occurred: Invalid head of packet ('\xe0')

I just pulled your latest commit and make the application, it seems that I'm having this issue on my Ubuntu 16.04 machine to burn into my NodeMCU

esptool.py v1.2-dev
Connecting...
Running Cesanta flasher stub...

A fatal error occurred: Invalid head of packet ('\xe0')

I checked the user.cfg and found the issue (for me at least) to be FWBURNFLAGS = -b 1000000 after changing this to FWBURNFLAGS = -b 115200 or ``FWBURNFLAGS = -b 1500000` I can burn into my NodeMCU nicely.

Does FWBURNFLAGS = -b 1000000 work for you?

and saw the esp82xx really great job there!

Hardware design has outdated and missing libraries

I don't know if you noticed, but the hardware design doesn't work with recent versions of KiCad. This has two reasons:

  • Custom libraries, you used were not exported with the project.
  • KiCad broke compatibility of standard footprints about a year ago. Resistors and such are now much smaller in EESchema, leading to broken connections in the schematic, because KiCad doesn't automatically restore connections. It's stupid, but that's the way it is. Doesn't seem to be a problem with the current daily build, though. That has learned to handle it more gracefully with a dialog.

kicad library fail

How to Send key press to host?

Can you explain a bit on how to send key press to host? (Initial from ESP8266. )

I am looking at source code of myTimer in user_main.c , seems to me that you were testing key press.
But the code only show build the data structure and fill the buffer, where is the action function to send?
What does CSTick( 1 ); do ?

I thought usb_send_data is used to send data, but only usb_pid_handle_in and usb_pid_handle_data use it, both looks like to receive the data from host.

Is the USB 8285 Tiny board still untested?

Interested in putting a couple of the tiny boards together. It's been a couple years so figured I'd check and see if anyone else has come along and used the tiny board design? If so were there any changes needed?

Error: unable to enumerate USB device

Hi, I'm having slight trouble getting the espusb working on my NodeMCU ESP-12E. I think I have done something wrong but after troubleshooting this whole time, I think it's better for me to ask here.

I git pull your repo and change the SDK path then perform the usual "make" and "make burn" as shown in your video which compiles and flashes with ease and no error.

However, after wiring up my NodeMCU with USB Type B then connect to my Linux machines, these are the output I got from dmesg:

Wiring the ESP8266 to my Ubuntu 16.04 machine I get this messages:
[593134.728040] usb 3-1: new low-speed USB device number 5 using uhci_hcd
[593135.144039] usb 3-1: device not accepting address 5, error -71
[593135.144217] usb usb3-port1: unable to enumerate USB device

Wiring to Raspberry pi 3 (Raspbian Jessie):
[ 7814.928437] usb 1-1.4: new low-speed USB device number 72 using dwc_otg
[ 7815.348436] usb 1-1.4: device not accepting address 72, error -32
[ 7815.348535] usb 1-1-port4: unable to enumerate USB device

Wiring to OpenWRT 15.04:
[25945.270000] usb 1-1: new low-speed USB device number 6 using ehci-platform
[25945.750000] usb 1-1: device not accepting address 6, error -71
[25945.750000] usb usb1-port1: unable to enumerate USB device

My first schematics I added a 100ohm pull up resistor to D- (GPIO12) to 3.3v.

v1 (EDIT BY CNLOHR: NOW GPIO4/5)

Then later I added a pull down resistor to D- and D+ but still no luck.

v2 (EDIT BY CNLOHR: NOW GPIO4/5)

Did I do a mistake somewhere or missed out a step? Thanks again for this great project ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.