Git Product home page Git Product logo

esptinyusb's Introduction

New version

New version of library, compatible with esp-idf (after cleanup) can be find here:

https://github.com/chegewara/esp32-usb-v2

Description

Library allows to build USB class devices and to make it usable with minimal effort:

  • CDC, communication device class,
  • MSC, mass storage class,
  • HID, human interface device class: keyboard, mouse, gamepad, generic IN/OUT,
  • MIDI, musical instrument digital interface class,
  • DFU, device firmware update class,
  • WebUSB, its using vendor class to show webusb usage.

Hardware

To use native USB we need to connect pins 19 and 20 to usb cable or with similar connectors:

How to

Library allows to set all values in standard USB device like:

  • manufacturer
  • product name
  • serial number
  • revision
  • VID and PID
ANYusb device;  // any USB class like HID, MSC, CDC
device.manufacturer(char*);
device.product(char*); // product name
device.serial(char*);  // serial number SN
device.revision(uint16_t); // product revison
device.deviceID(uint16_t VID, uint16_t PID);
device.deviceID(uint16_t* VID, uint16_t* PID);

Default EP numbers

In case of using more than 1 USB class in 1 device please make sure there is no conflict between EP numbers and eventuallu use setBaseEP:

  • CDC - EP1 and EP2,
  • HID - keyboard - EP2, mouse - EP3,
  • MSC - EP4,
  • WebUSB - EP4,
  • MIDI - EP5
  • DFU - not required

Contributions

Issues and PRs are welcome.

USB host (WIP)

I have some basic implementation of USB host which i decided to add. This is still experimental version as i dont know what tpe of design to implement (events or callbacks).

Here is log from MSC host reading files from pendrive:

[   960][I][test.ino:86] client_event_callback(): device speed: USB_SPEED_FULL, device address: 1, max ep_ctrl size: 64, config: 1
EP num: 1/2, len: 32, address: 0x81, EP max size: 64, dir: IN
EP num: 2/2, len: 32, address: 0x02, EP max size: 64, dir: OUT
capacity_cb: block_size: 512, block_count: 60948479
inquiry_cb
[  1038][I][test.ino:221] write_test(): File written
[  1049][I][test.ino:149] read_test(): /msc/README.txt
[  1051][I][test.ino:159] read_test(): Hello World!
[  1055][I][test.ino:205] read_test(): Found file : /msc/fanet_module.pdf (735686 bytes)
[  1056][I][test.ino:205] read_test(): Found file : /msc/06639_datasheet.pdf (205240 bytes)
[  1063][I][test.ino:205] read_test(): Found file : /msc/Bluetooth_5-FINAL.pdf (2100903 bytes)
[  1072][I][test.ino:205] read_test(): Found file : /msc/USB-Basics-USB-2.0-.pdf (113669 bytes)
[  1080][I][test.ino:205] read_test(): Found file : /msc/DS_SX1280-1_V2.2.book.pdf (197260 bytes)
[  1096][I][test.ino:205] read_test(): Found file : /msc/USB-Basics-USB-2.0- (1).pdf (113669 bytes)
[  1102][I][test.ino:205] read_test(): Found file : /msc/USB---Enumeration-States.pdf (29098 bytes)
[  1110][I][test.ino:205] read_test(): Found file : /msc/USB---Protocol---bits4device.pdf (1022853 bytes)
[  1125][I][test.ino:205] read_test(): Found file : /msc/esp32-s2_technical_reference_manual_en.pdf (6769251 bytes)
[  1132][I][test.ino:205] read_test(): Found file : /msc/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf (4613315 bytes)
[  1146][I][test.ino:205] read_test(): Found file : /msc/USB Complete The Developer's Guide 4th Ed.pdf (6936935 bytes)
[  1161][I][test.ino:205] read_test(): Found file : /msc/USB Mass Storage Designing and Programming Devices and Embedded Hosts.pdf (3360734 bytes)
[  1173][I][test.ino:205] read_test(): Found file : /msc/README.txt (13 bytes)
[  1181][I][test.ino:233] write_test(): Renaming file
[  1212][I][test.ino:240] write_test(): Reading file
[  1225][I][test.ino:254] write_test(): Read from file /msc/README1.txt: 'Hello World!'
[  1233][E][test.ino:145] read_test(): Failed to open file
[  1237][I][test.ino:205] read_test(): Found file : /msc/fanet_module.pdf (735686 bytes)
[  1238][I][test.ino:205] read_test(): Found file : /msc/06639_datasheet.pdf (205240 bytes)
[  1245][I][test.ino:205] read_test(): Found file : /msc/Bluetooth_5-FINAL.pdf (2100903 bytes)
[  1253][I][test.ino:205] read_test(): Found file : /msc/USB-Basics-USB-2.0-.pdf (113669 bytes)
[  1262][I][test.ino:205] read_test(): Found file : /msc/DS_SX1280-1_V2.2.book.pdf (197260 bytes)
[  1278][I][test.ino:205] read_test(): Found file : /msc/USB-Basics-USB-2.0- (1).pdf (113669 bytes)
[  1284][I][test.ino:205] read_test(): Found file : /msc/USB---Enumeration-States.pdf (29098 bytes)
[  1292][I][test.ino:205] read_test(): Found file : /msc/USB---Protocol---bits4device.pdf (1022853 bytes)
[  1307][I][test.ino:205] read_test(): Found file : /msc/esp32-s2_technical_reference_manual_en.pdf (6769251 bytes)
[  1314][I][test.ino:205] read_test(): Found file : /msc/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf (4613315 bytes)
[  1327][I][test.ino:205] read_test(): Found file : /msc/USB Complete The Developer's Guide 4th Ed.pdf (6936935 bytes)
[  1342][I][test.ino:205] read_test(): Found file : /msc/USB Mass Storage Designing and Programming Devices and Embedded Hosts.pdf (3360734 bytes)
[  1352][I][test.ino:205] read_test(): Found file : /msc/README1.txt (13 bytes)
[  1352][I][test.ino:289] setup(): storage used: 26329088/31189319680

esptinyusb's People

Contributors

chegewara avatar cojopi avatar coolacid avatar joelsernamoreno avatar lyusupov avatar meltdown03 avatar skobkars avatar steffen-w avatar touchgadget 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

esptinyusb's Issues

Errors when compiling the new library

Hi

I have seen that you have added SD Mass Storage

I tried to test this but when I compile the example your library gives many errors.

Now I can't use the keyboard example either

I attach screenshots with the errors:

107583206-e2713c80-6bfa-11eb-9654-998b6cca21d0

107583239-edc46800-6bfa-11eb-95b9-0b7709220bd2

107583266-f4eb7600-6bfa-11eb-9d42-59782415bc1d

107583298-fb79ed80-6bfa-11eb-94cd-a2018d8417a9

107583326-03399200-6bfb-11eb-9fd5-405e0a70b25c

Thanks

Error with gamepad.ino

ESP32-S2, arduino-esp32 (branch: idf-release/v4.2), Windows 10

After successful uploading of this sketch: EspTinyUSB-master\examples\hid\gamepad\gamepad.ino
the USB-device is successfully installed and appears in Control panel.
And it looks like working properly (axes and buttons change their values).

But, in terminal program, via COM-port, it says this (with an interval of 1 sec.):

`Rebooting...
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40025f61
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x8
load:0x3ffe6108,len:0x620
load:0x4004c000,len:0xa40
load:0x40050000,len:0x284c
entry 0x4004c190
Guru Meditation Error: Core 0 panic'ed (IntegerDivideByZero). Exception was unhandled.

Core 0 register dump:
PC : 0x4008d6eb PS : 0x00060a30 A0 : 0x8008ccfc A1 : 0x3ffc82a0
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3ffc22b0 A5 : 0x00000007
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x3ffc2ae8
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x00000001 A13 : 0x3ffc2990
A14 : 0x00000001 A15 : 0x00000001 SAR : 0x00000020 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000001 LEND : 0x3ffc2990 LCOUNT : 0x40026bdd

Backtrace:0x4008d6e8:0x3ffc82a0 0x4008ccf9:0x3ffc82c0 0x4008ac3d:0x3ffc82e0 0x40081a5d:0x3ffc8300 0x4009e079:0x3ffc8320 0x4008111c:0x3ffc8340 0x40083645:0x3ffc8360

ELF file SHA256: 0000000000000000
`
The other sketches in folder "EspTinyUSB-master\examples\hid" (like keyboard.ino and mouse.ino) work properly without any errors in terminal window.

USB CDC Uploading Error on Win10

With the latest repo of Arduino ESP32 (idf/release 4.2) it gets stuck after clicking the upload button with the indication "connecting..." After a while it times out, and the process gets unsuccessful.

I'm using ESP32-S2-Saola with native USB pins, there is no UART converter.

Bootloader for newbies

Hi chegewara,

How can I flash a bootloader that could work with Arduino Ide or Platformio?

Im stucked. Thank you.

HUB: Short device descriptor transfer failed

Hi,

I was trying your USB host example but my ESP32S2 is crashing:

ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40026870
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x498
load:0x4004c000,len:0xa88
load:0x40050000,len:0x25a8
entry 0x4004c19c
E (3251) HUB: Short device descriptor transfer failed
ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x4002c884
file: "IDF/components/usb/hub.c" line 450
func: enum_stage_cleanup_failed
expression: hcd_pipe_command(p_hub_driver_obj->single_thread.enum_dflt_pipe_hdl, HCD_PIPE_CMD_HALT)

abort() was called at PC 0x4002c887 on core 0


Backtrace:0x40026aea:0x3ffdc8e00x4002c891:0x3ffdc900 0x40031c35:0x3ffdc920 0x4002c887:0x3ffdc9a0 0x400bb44e:0x3ffdc9c0 0x400b7b8d:0x3ffdca00 0x4008350e:0x3ffdca20

I'm using the Arduino IDE with V2.0.1-RC1 boards installed with the boards manager.

I lost my OTA because of this so I can't try anything for the next couple of hours :(

Any ideas?

USB Host support?

Thanks for this excellent work!

Will it be possible to support USB Host functionality on the S2? Is this something that's being developed?

Wiring diagram to connect USB Pen/Flash drive to ESP32-S2/3

Hello.

I would like to contribute to this effort as I have a bunch of old 128 / 256 / 512MB generic USB flash sticks that I want to host files on via ESP32-S2. Ideal aim is to then load images from a USB stick onto say a massive LED Panel Display :-)

... but I don't understand how exactly to wire these up to the ESP32-S2 or S3. Can you please provide a diagram?

msc example not working?

Hi!

I'm using a lilygo esp32_s2_woor. I was able to run most of the examples provided but the msc one.
It compiles but when I connect the module to my PC nothing happens...

I also made an attempt defining this:

#define CFG_EXAMPLE_MSC_READONLY

but it didn't solve. Was anyone able to run this example?
Thanks!

keyboard2.ino missing tusb.h

Tried to compile example file keyboard2.ino for M5Stack-ATOM, file tusb.h seems to be missing?
The following is the error message from the Arduino IDE:

Arduino: 1.8.12 (Windows 10), Board: "M5Stack-ATOM, Default, 1500000, None"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\billt\AppData\Local\Arduino15\packages -hardware C:\Users\billt\OneDrive\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\billt\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\billt\OneDrive\Documents\Arduino\libraries -fqbn=esp32:esp32:m5stack-atom:PartitionScheme=default,UploadSpeed=1500000,DebugLevel=none -vid-pid=0403_6001 -ide-version=10812 -build-path C:\Users\billt\AppData\Local\Temp\arduino_build_413970 -warnings=all -build-cache C:\Users\billt\AppData\Local\Temp\arduino_cache_797377 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-1.22.0-97-gc752ad5-5.2.0.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0 -prefs=runtime.tools.mkspiffs.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.esptool_py.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.0.0 -prefs=runtime.tools.esptool_py-3.0.0.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.0.0 -verbose C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\examples\hid\keyboard2\keyboard2.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\billt\AppData\Local\Arduino15\packages -hardware C:\Users\billt\OneDrive\Documents\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\billt\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\billt\OneDrive\Documents\Arduino\libraries -fqbn=esp32:esp32:m5stack-atom:PartitionScheme=default,UploadSpeed=1500000,DebugLevel=none -vid-pid=0403_6001 -ide-version=10812 -build-path C:\Users\billt\AppData\Local\Temp\arduino_build_413970 -warnings=all -build-cache C:\Users\billt\AppData\Local\Temp\arduino_cache_797377 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0 -prefs=runtime.tools.xtensa-esp32-elf-gcc-1.22.0-97-gc752ad5-5.2.0.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0 -prefs=runtime.tools.mkspiffs.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.esptool_py.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.0.0 -prefs=runtime.tools.esptool_py-3.0.0.path=C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.0.0 -verbose C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\examples\hid\keyboard2\keyboard2.ino
Using board 'm5stack-atom' from platform in folder: C:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5
Using core 'esp32' from platform in folder: C:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5
cmd /c if exist "C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\examples\hid\keyboard2\partitions.csv" copy /y "C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\examples\hid\keyboard2\partitions.csv" "C:\Users\billt\AppData\Local\Temp\arduino_build_413970\partitions.csv"
cmd /c if not exist "C:\Users\billt\AppData\Local\Temp\arduino_build_413970\partitions.csv" copy "C:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\tools\partitions\default.csv" "C:\Users\billt\AppData\Local\Temp\arduino_build_413970\partitions.csv"
Detecting libraries used...
"C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM "-DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h"" -DHAVE_CONFIG_H -DGCC_NOT_5_2_0=0 -DWITH_POSIX "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/config" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/app_trace" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/app_update" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/asio" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/bootloader_support" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/bt" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/coap" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/console" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/driver" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/efuse" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp-tls" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp32" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_adc_cal" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_event" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_http_client" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_http_server" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_https_ota" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_https_server" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_ringbuf" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_websocket_client" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/espcoredump" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/ethernet" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/expat" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/fatfs" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/freemodbus" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/freertos" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/heap" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/idf_test" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/jsmn" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/json" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/libsodium" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/log" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/lwip" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/mbedtls" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/mdns" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/micro-ecc" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/mqtt" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/newlib" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/nghttp" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/nimble" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/nvs_flash" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/openssl" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/protobuf-c" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/protocomm" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/pthread" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/sdmmc" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/smartconfig_ack" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/soc" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/spi_flash" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/spiffs" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/tcp_transport" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/tcpip_adapter" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/ulp" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/unity" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/vfs" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/wear_levelling" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/wifi_provisioning" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/wpa_supplicant" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/xtensa-debug-module" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp-face" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp32-camera" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp-face" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/fb_gfx" -std=gnu++11 -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -w -Wno-error=maybe-uninitialized -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-missing-field-initializers -Wno-sign-compare -fno-rtti -c -w -x c++ -E -CC -DF_CPU=240000000L -DARDUINO=10812 -DARDUINO_M5Stack_ATOM -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD="M5Stack_ATOM"" "-DARDUINO_VARIANT="m5stack_atom"" -DESP32 -DCORE_DEBUG_LEVEL=0 "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\variants\m5stack_atom" "C:\Users\billt\AppData\Local\Temp\arduino_build_413970\sketch\keyboard2.ino.cpp" -o nul
Alternatives for hidkeyboard.h: [[email protected]]
ResolveLibrary(hidkeyboard.h)
-> candidates: [[email protected]]
"C:\Users\billt\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM "-DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h"" -DHAVE_CONFIG_H -DGCC_NOT_5_2_0=0 -DWITH_POSIX "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/config" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/app_trace" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/app_update" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/asio" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/bootloader_support" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/bt" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/coap" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/console" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/driver" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/efuse" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp-tls" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp32" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_adc_cal" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_event" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_http_client" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_http_server" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_https_ota" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_https_server" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_ringbuf" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp_websocket_client" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/espcoredump" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/ethernet" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/expat" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/fatfs" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/freemodbus" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/freertos" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/heap" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/idf_test" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/jsmn" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/json" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/libsodium" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/log" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/lwip" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/mbedtls" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/mdns" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/micro-ecc" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/mqtt" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/newlib" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/nghttp" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/nimble" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/nvs_flash" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/openssl" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/protobuf-c" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/protocomm" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/pthread" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/sdmmc" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/smartconfig_ack" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/soc" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/spi_flash" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/spiffs" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/tcp_transport" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/tcpip_adapter" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/ulp" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/unity" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/vfs" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/wear_levelling" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/wifi_provisioning" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/wpa_supplicant" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/xtensa-debug-module" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp-face" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp32-camera" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/esp-face" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5/tools/sdk/include/fb_gfx" -std=gnu++11 -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -w -Wno-error=maybe-uninitialized -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-missing-field-initializers -Wno-sign-compare -fno-rtti -c -w -x c++ -E -CC -DF_CPU=240000000L -DARDUINO=10812 -DARDUINO_M5Stack_ATOM -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD="M5Stack_ATOM"" "-DARDUINO_VARIANT="m5stack_atom"" -DESP32 -DCORE_DEBUG_LEVEL=0 "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32" "-IC:\Users\billt\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\variants\m5stack_atom" "-IC:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\src" "C:\Users\billt\AppData\Local\Temp\arduino_build_413970\sketch\keyboard2.ino.cpp" -o nul
Alternatives for tusb.h: []
ResolveLibrary(tusb.h)In file included from C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:3:0,

-> candidates: []
from C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,

             from C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\src/hidkeyboard.h:2,

             from C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\examples\hid\keyboard2\keyboard2.ino:6:

C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB\src/usb_descriptors.h:17:18: fatal error: tusb.h: No such file or directory

compilation terminated.

Using library ESP32TinyUSB at version 1.2.0 in folder: C:\Users\billt\OneDrive\Documents\Arduino\libraries\ESP32TinyUSB
exit status 1
Error compiling for board M5Stack-ATOM.

Error compiling & unable to get webusb to run

For context, this is my platformio file:

[env:esp32s2doit-devkit-v1]
platform = espressif32
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#idf-release/v4.2
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
  https://github.com/chegewara/EspTinyUSB
  ...
monitor_speed = 115200
board_build.mcu = esp32s2
build_flags = 
  -D ESP32S2

The project does however not compile as I get this error:

Compiling .pio/build/esp32s2doit-devkit-v1/liba3b/ESP32TinyUSB/classes/msc/sdcard.cpp.o
In file included from .pio/libdeps/esp32s2doit-devkit-v1/ESP32TinyUSB/src/classes/msc/sdcard.cpp:1:
.pio/libdeps/esp32s2doit-devkit-v1/ESP32TinyUSB/src/sdusb.h:3:10: fatal error: FS.h: No such file or directory

Do I need to include something else to get it to compile out of the box?
After removing sdusb.h and sdcard.cpp, the project compiles.

Next problem that I have is the inability to get webusb to work.
This is my sketch:


#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>
#include <webusb.h>
#include <cdcusb.h>

WebUSB WebUSBSerial;
CDCusb USBSerial;

class MyWebUSBCallbacks : public WebUSBCallbacks{
    void onConnect(bool state) {
      USBSerial.printf("webusb is %s\n", state ? "connected":"disconnected");
    }
};

void setup() {  
  while (!Serial);

  WebUSBSerial.landingPageURI("localhost:3001", false); // even if set to default URL, does not show up
  WebUSBSerial.deviceID(0xcafe, 0x0002);
  WebUSBSerial.setCallbacks(new MyWebUSBCallbacks());

  if(!WebUSBSerial.begin()) {
    USBSerial.println("Failed to start webUSB stack"); // does not fail - checked
  }

  if(!USBSerial.begin()) {
    USBSerial.println("Failed to start USB stack"); // does not fail - checked
  }
}

void echo_all(char c)
{
    Serial.write(c);
    WebUSBSerial.write(c);
    USBSerial.write(c);
}

void loop() {
  
  while (WebUSBSerial.available()) {
      echo_all(WebUSBSerial.read());
  }

  while (Serial.available()) {
      echo_all(Serial.read());
  }

  while (USBSerial.available()) {
      echo_all(USBSerial.read());
  }
}

The CDC class device works and the messages are echoed to my serial monitor console successfully via my computer terminal with
xtrinch@elizabeta:~$ echo -e "test" > /dev/ttyACM0.
I can even flash the device via this tty and do not have to enter bootloader mode.

The problem however is the web usb, as the device does not show up in chrome under available devices. Note that I've tried without any vendor filters and the device is just not here. Neither does it have a designator in /dev/tty* (Not sure if the web usb devices should have that though?). If I boot the board in bootloader mode, it shows up in chrome as an espressif device, so it's definitely a software thing.

I've tried also with the default www.tinyusb.org/examples/webusb-serial by omitting the custom URL specifications but it does not show up there either.

I am using latest chrome on ubuntu 20.04.

Please help.

Cannot flash without going into bootloader mode

While it's perfectly doable to put the board in bootloader mode and then flash, it would be really great to be able to flash it without that, like any other esp32 boards. The board isn't in sleep mode or anything, and I can even talk to it via webusb, but I can't flash it.

I'm getting this error:

CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/ttyACM0
Uploading .pio/build/esp32s2doit-devkit-v1/firmware.bin
esptool.py v3.1
Serial port /dev/ttyACM0
Connecting...
Traceback (most recent call last):
  File "/home/xtrinch/.platformio/packages/tool-esptoolpy/esptool.py", line 4582, in <module>
    _main()
  File "/home/xtrinch/.platformio/packages/tool-esptoolpy/esptool.py", line 4575, in _main
    main()
  File "/home/xtrinch/.platformio/packages/tool-esptoolpy/esptool.py", line 4074, in main
    esp = esp or get_default_connected_device(ser_list, port=args.port, connect_attempts=args.connect_attempts,
  File "/home/xtrinch/.platformio/packages/tool-esptoolpy/esptool.py", line 121, in get_default_connected_device
    _esp.connect(before, connect_attempts)
  File "/home/xtrinch/.platformio/packages/tool-esptoolpy/esptool.py", line 629, in connect
    last_error = self._connect_attempt(mode=mode, esp32r0_delay=False, usb_jtag_serial=usb_jtag_serial)
  File "/home/xtrinch/.platformio/packages/tool-esptoolpy/esptool.py", line 590, in _connect_attempt
    self.bootloader_reset(esp32r0_delay, usb_jtag_serial)
  File "/home/xtrinch/.platformio/packages/tool-esptoolpy/esptool.py", line 553, in bootloader_reset
    self._setDTR(False)  # IO0=HIGH
  File "/home/xtrinch/.platformio/packages/tool-esptoolpy/esptool.py", line 499, in _setDTR
    self._port.setDTR(state)
  File "/home/xtrinch/.platformio/penv/lib/python3.8/site-packages/serial/serialutil.py", line 603, in setDTR
    self.dtr = value
  File "/home/xtrinch/.platformio/penv/lib/python3.8/site-packages/serial/serialutil.py", line 473, in dtr
    self._update_dtr_state()
  File "/home/xtrinch/.platformio/penv/lib/python3.8/site-packages/serial/serialposix.py", line 715, in _update_dtr_state
    fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_DTR_str)
OSError: [Errno 71] Protocol error
*** [upload] Error 1

Any ideas? Any help would be greatly appreciated, even if only to point me in the direction of what this error is and where do I start looking.

Compiling throws a bunch of redefinition warnings

In VSCode Platforio, and also in Arduino IDE, the compile throws countless of lines of warnings. The are all about redefinition. I know warning is not an error, it works, but maybe it worth noting them. Because warnings usually help avoiding future errors. Some examples while compiling gamepad.ino:

In file included from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:76: warning: "CFG_TUSB_RHPORT0_MODE" redefined
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE

In file included from C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:28,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h:171: note: this is the location of the previous definition
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE

In file included from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:77: warning: "CFG_TUSB_OS" redefined
#define CFG_TUSB_OS OPT_OS_FREERTOS

In file included from C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:28,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h:220: note: this is the location of the previous definition
#define CFG_TUSB_OS OPT_OS_NONE

In file included from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:102: warning: "CFG_TUD_CDC" redefined
#define CFG_TUD_CDC CONFIG_TINYUSB_CDC_ENABLED

In file included from C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:28,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h:236: note: this is the location of the previous definition
#define CFG_TUD_CDC 0

In file included from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:103: warning: "CFG_TUD_MSC" redefined
#define CFG_TUD_MSC CONFIG_TINYUSB_MSC_ENABLED

In file included from C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:28,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h:240: note: this is the location of the previous definition
#define CFG_TUD_MSC 0

In file included from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/esptinyusb.h:7,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:2,
from C:\Users\DeXTeR\Documents\Arduino\libraries\ESP32TinyUSB\src/hidgamepad.h:1,
from D:\Arduino\GamepadTest\GamepadTest.ino:7:
C:\Users\DeXTeR\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.1/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:104: warning: "CFG_TUD_HID" redefined
#define CFG_TUD_HID CONFIG_TINYUSB_HID_ENABLED

HID_KEY_A definition

Hi,

where are defined the costants like HID_KEY_A used in example keyboard.ino?

class fs::SDFS has no member named 'readRAW'

Whenever I try to run any of the examples I get the following errors:

EspTinyUSB-master/src/classes/msc/sdcard.cpp:66:12: error: 'class fs::SDFS' has no member named 'readRAW'
SD.readRAW((uint8_t*)buffer, lba);

And then a similar one but for 'writeRAW'

Gamepad not working

Dear all,

With all the recommended fixes, I can get the samples to work, except the gamepad. It shows up, but the sample code does not work.

I am using 2.0.0-rc1 and the master.

Best,
X

Persist reset issue

We have now added persist reset in CDC, which allows arduino IDE to enter bootload mode without need to press buttons, just like with UART.
There is one small issue, which i probably not fix, but worth to mention. It is required to press upload button twice, first time to enter bootloader mode and again to start flashing. The issue is caused by 2 probably things:

  • my lack of knowledge about this mechanism,
  • library design, which i prefer to stay this way.

To make it work with 1 time button press it is required the CDC descriptor to be exactly the same as in ESP32 S2 bootroom, which is using EP addressing i dont really like (3, 84, 85). We have not too many EP available on S2 and i prefer to have EP addresses with consecutive numbers, which makes it easier to handle and to use few classes at the same time.

Help request - adding specific USB descriptors

Hi,

Thank you for the library!

I've got it up and running well and have run some of the examples. I'd like to use it as the basis for an adaptor to use other controllers on an original Xbox but can't work out how to apply a specific set of descriptors to the format/structure used by the library.

The descriptors can be found here but there don't seem to be completely analogous sets of descriptors across the projects.

Can you offer any guidance? I was wondering if the right approach is to subclass HIDgamepad or HIDusb to return these fixed descriptors, rather than generating them as seems (I think?) to take place in ESPTinyUSB::begin(...)?

Any help would be much appreciated! As is probably obvious, I'm still relatively new to C++.

Thanks.

ESP32S2 host crash when removing device

I'm trying the example from examples/host/msc/msc.ino. Read & write function is working normally, but it crashed when removing the flash drive. The ESP print this error:

E (30181) USBH: Device 1 gone

assert failed: usbh_hal_chan_request_halt IDF/components/hal/usbh_hal.c:294 (chan_obj->flags.active && !chan_obj->flags.error_pending)


Backtrace:0x4002649e:0x3ffc36700x400289e9:0x3ffc3690 0x4002d9ed:0x3ffc36b0 0x40093775:0x3ffc37e0 0x40092095:0x3ffc3800 0x4008fe5e:0x3ffc3820 0x4008f236:0x3ffc3850 0x40081dad:0x3ffc3870 




ELF file SHA256: 0000000000000000

Rebooting...

I'm using AI-Thinker dev module ESP-12K with 8MB PSRAM.
Any idea why this happen? Do I need to do something before removing the device? Or maybe I need extra component? I'm connecting female USB port directly to pin 19, 20, VCC and GND.

WebUSB on windows

Hi,

I have a rather strange problem with my webusb + CDC setup. Below are the usb descriptors generated with this library.

The web usb part is working without issues on Linux (Ubuntu 20.04), I can connect to it, send it characters, receive characters, the whole thing. On windows however, I can see it in chrome and can connect to it, but cannot claim the webusb interface. (Note that I am testing with the same website on linux/windows). Below is the code I am using. I'd be inclined to think I'm doing something wrong in javascript, if the exact same code wasn't working fine on Linux. I even tested with the nightly build of chrome to see if it is some random chrome bug. The code just stalls at claimInterface and never returns. No errors, just never returns.

What could possibly be the cause of this?

Javascript code:

public async connect() {
    await this.device_.open();
    if (this.device_.configuration === null) {
      this.device_.selectConfiguration(1);
    }

    // find the interface which has 0xff interface class as its alternate and its interface number is 2
    this.interface = (this.device_.configuration.interfaces || []).find(
      (c) =>
        !!c.alternates.find((a) => a.interfaceClass === 0xff) &&
        c.interfaceNumber === 2
    );
    if (!this.interface) {
      throw new Error("Interface not found");
    }
    const alternate = this.interface.alternates[0];

    this.endpointIn = alternate.endpoints.find((e) => e.direction === "in");
    this.endpointOut = alternate.endpoints.find((e) => e.direction === "out");

    if (!this.endpointIn || !this.endpointOut) {
      throw new Error("Endpoints not found");
    }

    **------------> THIS IS THE LINE THAT NEVER RETURNS**
    await this.device_.claimInterface(this.interface.interfaceNumber);

    await this.device_.selectAlternateInterface(
      this.interface.interfaceNumber,
      0
    );

    await this.device_.controlTransferOut({
      requestType: "class",
      recipient: "interface",
      request: 0x22,
      value: 0x01,
      index: this.interface.interfaceNumber,
    });
  }

USB descriptors:

Bus 001 Device 010: ID 2341:0002 Arduino SA ESP32S2 arduino device
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.10
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x2341 Arduino SA
  idProduct          0x0002 
  bcdDevice            1.00
  iManufacturer           1 Espressif
  iProduct                2 ESP32S2 arduino device
  iSerial                 3 1234-5678
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0062
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass       2 Abstract (modem)
      bFunctionProtocol       0 
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass      2 Abstract (modem)
      bInterfaceProtocol      0 
      iInterface              4 CDC class
      CDC Header:
        bcdCDC               1.20
      CDC Call Management:
        bmCapabilities       0x00
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              16
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              7 Vendor class (webUSB)
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength       0x0039
  bNumDeviceCaps          2
  Platform Device Capability:
    bLength                24
    bDescriptorType        16
    bDevCapabilityType      5
    bReserved               0
    PlatformCapabilityUUID    {3408b638-09a9-47a0-8bfd-a0768815b665}
      WebUSB:
        bcdVersion    1.00
        bVendorCode      1
        iLandingPage     1 http://iotfreezer.com
  Platform Device Capability:
    bLength                28
    bDescriptorType        16
    bDevCapabilityType      5
    bReserved               0
    PlatformCapabilityUUID    {d8dd60df-4589-4cc7-9cd2-659d9e648a9f}
    CapabilityData[0]    0x00
    CapabilityData[1]    0x00
    CapabilityData[2]    0x03
    CapabilityData[3]    0x06
    CapabilityData[4]    0xb2
    CapabilityData[5]    0x00
    CapabilityData[6]    0x02
    CapabilityData[7]    0x00
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

USB Won't Initialise - "This device cannot start. (Code 10)"

I'm sure I'm doing something wrong here, but now I've got everything building successfully (thanks for the pointer chegewara), I now cant get the ESP to initialise as a USB device properly.

For example, using the keyboard2.ino example (or any other example from this library I've tried), Windows shows this error in device manager:
image

And with Core Debug=Verbose on the ESP, I get the following lines logged from via UART0:

13:55:02.704 -> [  1248][D][hidkeyboard.cpp:23] begin(): begin len: 25
13:55:02.737 -> [  1248][D][usb_descriptors.cpp:45] getConfigurationDescriptor(): descriptor length: 34
13:55:02.737 -> 
13:55:02.737 -> [  1250][W][esptinyusb.cpp:185] begin(): failed to init, (return fixed in tinyusb 0.8.0)
13:55:02.737 -> [  1258][D][esptinyusb.cpp:47] esptinyusbtask(): USB tud_task created
13:55:04.746 -> FAIL
13:55:05.720 -> FAIL
13:55:07.726 -> FAIL

So it looks like the usb begin() is failing, but I cannot see why.

I've tried the same setup using PlatformIO and Arduino IDE and have the same results.

I'm able to successfully compile and run the USBSerial example from ESP32 Arduino, which gives the expected results on the USB interface. I believe this rules out possibilities that I have some kind of hardware problems...maybe? I can also upload sketches to the board using CDC so that also gives me confidence in the hardware.

A few other points about my environment, in case it is of relevance:

Please can anyone help? Any pointers would be very greatly appreciated.

Library compatibility and future

I am trying to fix now all breaking changes introduced in upstream tinyusb library and i found there is some issue which i cant fix.
As you all know the core repository for all espressif boards is https://github.com/espressif/arduino-esp32. Maintainers of that repository also are making tinyusb library built-in as a core library and with most recent they did i think i am not able to "fix" my library to let it run alongside core-tinyusb. Here is error log i am having now:

hardware/espressif/esp32/tools/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: arduino_cache_480191\core\core_dffc23aa76a67c47fb55ef1b712972c1.a(esp32-hal-tinyusb.c.o): in function `tud_descriptor_configuration_cb':
hardware\espressif\esp32\cores\esp32/esp32-hal-tinyusb.c:267: multiple definition of `tud_descriptor_configuration_cb'; libraries\esptinyusb\usb_descriptors.cpp.o:C:\Users\darek\Documents\Arduino\libraries\esptinyusb\src/usb_descriptors.cpp:132: first defined here
hardware/espressif/esp32/tools/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: arduino_cache_480191\core\core_dffc23aa76a67c47fb55ef1b712972c1.a(esp32-hal-tinyusb.c.o): in function `tud_descriptor_device_cb':
hardware\espressif\esp32\cores\esp32/esp32-hal-tinyusb.c:276: multiple definition of `tud_descriptor_device_cb'; libraries\esptinyusb\usb_descriptors.cpp.o:C:\Users\darek\Documents\Arduino\libraries\esptinyusb\src/usb_descriptors.cpp:120: first defined here
hardware/espressif/esp32/tools/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: arduino_cache_480191\core\core_dffc23aa76a67c47fb55ef1b712972c1.a(esp32-hal-tinyusb.c.o): in function `tud_descriptor_string_cb':
hardware\espressif\esp32\cores\esp32/esp32-hal-tinyusb.c:285: multiple definition of `tud_descriptor_string_cb'; libraries\esptinyusb\usb_descriptors.cpp.o:C:\Users\darek\Documents\Arduino\libraries\esptinyusb\src/usb_descriptors.cpp:148: first defined here

The problem is any of those upstream callbacks cant be overridden.
Maybe there is some way to fix it all, but i spent few hours and endup in deep hole and without changes in arduino-esp32 i dont see option to continue developing this library.

Refactor classes to use callbacks

Each class should have its own set of callbacks. It will be easier to handle callbacks from object level if eventually will be possible to have 2 or more instances of the same class like 2x CDC or HID.

Both Mouse and keyboard is not working in one sketch

I need to have both mouse and keyboard working from one esp32-s2. So i tried this code but in device manager of windows does not recognize the device.
NT: i tried both seperately and they work fine.

/**
 * Simple HID keyboard
 * author: chegewara
 */

#include "hidkeyboard.h"

#include "Arduino.h"
#include "hidmouse.h"

HIDmouse mouse;

HIDkeyboard dev;

void setup()
{
    Serial.begin(115200);
    dev.begin();
    mouse.begin();
}

void loop()
{
    delay(10);

    uint8_t key_val = 'k';  
    dev.sendChar(key_val); // send ASCII char
     
    delay(1000);
    mouse.doublePressLeft();
    delay(1000);
    mouse.pressRight();
    delay(1000);
    mouse.move(-105, -105);
    delay(1000);
    mouse.pressLeft();
    delay(1000);
    mouse.scrollUp(1);
    delay(1000);
    mouse.scrollDown(1);
    delay(1000);
}

Unable to Compile Example code.

Hello,
Thanks for the awesome job that you have done.

I am unable to compile the mouse example code. I got this error

Arduino: 1.8.13 (Linux), Board: "ESP32S2 Dev Module, UART0, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi), QIO, 80MHz, 4MB (32Mb), 921600, None"

/home/hassan/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2020r3/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: /tmp/arduino_cache_878962/core/core_be6f73b75f18c4c900d60d2623283068.a(main.cpp.o):(.literal._Z8loopTaskPv+0x8): undefined reference to `setup()'
/home/hassan/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2020r3/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: /tmp/arduino_cache_878962/core/core_be6f73b75f18c4c900d60d2623283068.a(main.cpp.o):(.literal._Z8loopTaskPv+0xc): undefined reference to `loop()'
/home/hassan/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2020r3/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: /tmp/arduino_cache_878962/core/core_be6f73b75f18c4c900d60d2623283068.a(main.cpp.o): in function `loopTask(void*)':
/home/hassan/.arduino15/packages/esp32/hardware/esp32/2.0.0-alpha1/cores/esp32/main.cpp:31: undefined reference to `setup()'
/home/hassan/.arduino15/packages/esp32/tools/xtensa-esp32s2-elf-gcc/gcc8_4_0-esp-2020r3/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld: /home/hassan/.arduino15/packages/esp32/hardware/esp32/2.0.0-alpha1/cores/esp32/main.cpp:39: undefined reference to `loop()'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board ESP32S2 Dev Module.


What am I doing wrong?

My version of arduino-esp32 is 2.00-alpha. I hope that isnt the cause of the problem?
Thank You.

Best Regards,
Taiwo

HID_KEY_RETURN does not work

using arduino-esp32-2-rc1 and lib-1.3.2

/**
 * Simple HID mouse and keyboard composite
 * author: chegewara
 */


#include "hidcomposite.h"
#if CFG_TUD_HID
HIDcomposite device;

void setup()
{
    Serial.begin(115200);
    device.begin();
}

void loop()
{
    delay(1000);
    device.doublePressLeft();
    delay(1000);
    device.pressRight();
    delay(1000);
    device.move(-150, -150);
    delay(1000);
    device.move(150, 150);
    delay(1000);
    device.pressLeft();
    delay(1000);
    device.scrollUp(1);
    delay(1000);
    device.scrollDown(1);
    delay(1000);
    device.sendKey(HID_KEY_A);
    delay(1000);
    device.sendKey(HID_KEY_RETURN);
    delay(1000);
    device.sendKey(HID_KEY_T);
    delay(1000);
    Serial.println(device.sendString(String("123456789\n"))?"OK":"FAIL");
    delay(1000);
    Serial.println(device.sendString(String("abcdefghijklmnopqrst Uvwxyz\n"))?"OK":"FAIL");    
}

#endif
```

How can I use it in Arduino IDE?

Hi,

Thanks a lot for you project. And I want to try it under Arduino environment.

First I install your library then copy the source code of tinyusb to the source directory.

But I still get below error message:

Documents\Arduino\libraries\EspTinyUSB-master\src/osal/osal_freertos.h:32:20: fatal error: semphr.h: No such file or directory

Could you please with a simple guide of how to use your library?

Z.t

HELP: key combination

tinyUSB don't have some symbols accessible directly. In order to get $%^&?" and other symbols i used this method but can get it working. if i press the keys i get only numbers.
What the issue might be?


//#define KEYS_TILDE      HID_KEY_TILDE|KEYBOARD_MODIFIER_LEFTSHIFT       /* ~ */
#define KEYS_EXCL       HID_KEY_1|KEYBOARD_MODIFIER_LEFTSHIFT           /* ! */
#define KEYS_AT         HID_KEY_2|KEYBOARD_MODIFIER_LEFTSHIFT           /* @ */
#define KEYS_HASH       HID_KEY_3|KEYBOARD_MODIFIER_LEFTSHIFT           /* # */
#define KEYS_DOLLAR     HID_KEY_4|KEYBOARD_MODIFIER_LEFTSHIFT           /* $ */
#define KEYS_PERCENT    HID_KEY_5|KEYBOARD_MODIFIER_LEFTSHIFT           /* % */
#define KEYS_CARET      HID_KEY_6|KEYBOARD_MODIFIER_LEFTSHIFT           /* ^ */
#define KEYS_AMP        HID_KEY_7|KEYBOARD_MODIFIER_LEFTSHIFT           /* & */
#define KEYS_ASTERISK   HID_KEY_8|KEYBOARD_MODIFIER_LEFTSHIFT           /* * */
#define KEYS_LRBRACKET  HID_KEY_9|KEYBOARD_MODIFIER_LEFTSHIFT           /*( */
#define KEYS_RRBRACKET  HID_KEY_0|KEYBOARD_MODIFIER_LEFTSHIFT           /* ) */

#define KEYS_LCBRACKET  HID_KEY_LEFT_BRACE|KEYBOARD_MODIFIER_LEFTSHIFT  /* { */
#define KEYS_RCBRACKET  HID_KEY_RIGHT_BRACE|KEYBOARD_MODIFIER_LEFTSHIFT /* } */
#define KEYS_COLON      HID_KEY_SEMICOLON|KEYBOARD_MODIFIER_LEFTSHIFT   /* : */
#define KEYS_DQUOTE     HID_KEY_QUOTE|KEYBOARD_MODIFIER_LEFTSHIFT       /* " */
#define KEYS_LABRACKET  HID_KEY_COMMA|KEYBOARD_MODIFIER_LEFTSHIFT       /* < */
#define KEYS_RABRACKET  HID_KEY_PERIOD|KEYBOARD_MODIFIER_LEFTSHIFT      /* > */
#define KEYS_QMARK      HID_KEY_SLASH|KEYBOARD_MODIFIER_LEFTSHIFT       /* ? */

static uint8_t keymapSymbols[] =
{
  HID_KEY_GUI_LEFT,     HID_KEY_CAPS_LOCK,      HID_KEY_TAB,          HID_KEY_ESCAPE,           EXPANSION_SWITCH,         'E',                    'E',                  EXPANSION_SWITCH,       HARDWARE_TEST,       KMAP_SWITCH,      LCD_SWITCH,
  HID_KEY_ARROW_LEFT,   KEYS_EXCL,              KEYS_AT,              KEYS_HASH,                KEYS_DOLLAR,              KEYS_PERCENT,           KEYS_CARET,           KEYS_AMP,               KEYS_ASTERISK,       KEYS_LRBRACKET,   KEYS_RRBRACKET,
  HID_KEY_ARROW_RIGHT,  'E',                    HID_KEY_ARROW_UP,     HID_KEY_PAGE_UP,          KEYS_DQUOTE,              HID_KEY_EUROPE_1,       HID_KEY_BRACKET_LEFT, HID_KEY_BRACKET_RIGHT,  HID_KEY_SLASH,       HID_KEY_GRAVE,    KEYS_COLON,
  KMOUSE_LEFT,          'E',                    HID_KEY_ARROW_DOWN,   HID_KEY_PAGE_DOWN,        KEYS_DOLLAR,              HID_KEY_APOSTROPHE,     HID_KEY_EXSEL,        KEYS_QMARK,             HID_KEY_SEMICOLON,   HID_KEY_EUROPE_2, HID_KEY_BACKSPACE,
  KMOUSE_RIGHT,         HID_KEY_CONTROL_LEFT,   HID_KEY_KEYPAD_ADD,   HID_KEY_KEYPAD_SUBTRACT,  HID_KEY_KEYPAD_MULTIPLY,  HID_KEY_KEYPAD_DIVIDE,  HID_KEY_KEYPAD_EQUAL, HID_KEY_COMMA,          HID_KEY_PERIOD,      HID_KEY_SPACE,    HID_KEY_ENTER
};

static uint8_t modifierKey = 0;

static void processKeys( void )
{
  if( !Keyboard.getKeys() ) return;

  // disable the keyboard when display is off
  if( !digitalRead( POWER_LCD ) ) return;
   
  int i;

  for( i = 0; i < LIST_MAX; i++ )
  {
    if( !Keyboard.key[i].stateChanged ) continue;

    uint8_t key = mapKey( Keyboard.key[i].kchar );

    if( key == KMAP_SWITCH || key == HARDWARE_TEST || key == KMOUSE_LEFT || 
        key == KMOUSE_RIGHT || key == EXPANSION_SWITCH ||  key == LCD_SWITCH  ) continue;

    switch( Keyboard.key[i].kstate )
    {
      case PRESSED:
        if( key == HID_KEY_CONTROL_LEFT )
        {
          HIDdevice.sendPress( 0, KEYBOARD_MODIFIER_LEFTCTRL );
          modifierKey = KEYBOARD_MODIFIER_LEFTCTRL;
        } 
        else if( key == HID_KEY_GUI_LEFT )
        {
          HIDdevice.sendPress( 0, KEYBOARD_MODIFIER_LEFTGUI );
          modifierKey = KEYBOARD_MODIFIER_LEFTCTRL;
        } 
        else
        {
          HIDdevice.sendPress( key, modifierKey );
          modifierKey = 0;
        }
        break;
        
      case RELEASED:
        HIDdevice.sendRelease();
        modifierKey = 0;
        break;
    }
  }
}

MODIFIER key doese not work

I am trying to use the MODIFIER keys from this list, but it does not work. I get no output. see the processKeys function, i tried both commented and un-commented one. Commented one also does not work also it only gives output from some keys fromthe array. but un-commented one, every key works except the HID_KEY_CONTROL_LEFT.
https://github.com/hathach/tinyusb/blob/master/src/class/hid/hid.h#L282

// firmware V4.1
// mutantC v4

#include "Arduino.h"
#include "hidcomposite.h"
#include <Keypad.h>

HIDcomposite device;

const int LED_1 = 17; 
const int LED_2 = 5; 
const int POWER_MAIN =37;
const int POWER_OFF =26;
const int POWER_EX =39;
const int POWER_LCD =38;
const int BUZZER =40;
const int PI_STATE =42;
const int BATTERY_MESUREMENT =18;

// Thumbstick, set pin numbers for the five buttons:
const int rightButton = 9;
const int upButton= 8;
const int leftButton = 4;
const int downButton= 10;
const int mouseButton = 3;

// For Thumbstick
int range = 10;              // output range of X or Y movement; affects movement speed
int responseDelay = 10;     // response delay of the mouse, in ms

// Switch Stats
static bool keymapState = 0;
static bool expansionState = 0;
static bool lcdState = 0;
bool powerstate = 0;

// For Keypad
const byte ROWS = 5;
const byte COLS = 11;

// For Battery Voltage
int value = 0;
float voltage;

#define POWEROFF              0x91
#define KMAP_SWITCH           0x92
#define EXPANSION_SWITCH      0x93
#define LCD_SWITCH            0x94
#define NOTIFICATION_LED      0x95
#define KMOUSE_LEFT           0x96
#define KMOUSE_RIGHT          0x97
#define KBATTERY_SWITCH       0x98
#define NOTIFICATION_BUZZER   0x99

static uint8_t keymapAlpha [] = {
  KMOUSE_RIGHT, LCD_SWITCH, EXPANSION_SWITCH, KBATTERY_SWITCH, NOTIFICATION_BUZZER, POWEROFF, NOTIFICATION_LED,  'E',  'E',  KMAP_SWITCH,  KMOUSE_LEFT,
  HID_KEY_1,           HID_KEY_2,  HID_KEY_3, HID_KEY_4,  HID_KEY_5,  HID_KEY_6, HID_KEY_7, HID_KEY_8, HID_KEY_9,  HID_KEY_0,   HID_KEY_ARROW_LEFT ,
  HID_KEY_Q,           HID_KEY_W,  HID_KEY_E, HID_KEY_R,  HID_KEY_T,  HID_KEY_Y, HID_KEY_U, HID_KEY_I, HID_KEY_O,  HID_KEY_P,   HID_KEY_ARROW_RIGHT        ,
  HID_KEY_CAPS_LOCK  , HID_KEY_A,  HID_KEY_S, HID_KEY_D,  HID_KEY_F,  HID_KEY_G, HID_KEY_H, HID_KEY_J, HID_KEY_K,  HID_KEY_L,   HID_KEY_BACKSPACE,
  HID_KEY_CONTROL_LEFT, HID_KEY_GUI_LEFT, HID_KEY_Z,  HID_KEY_X, HID_KEY_C, HID_KEY_V, HID_KEY_B,  HID_KEY_N,   HID_KEY_M,   HID_KEY_SPACE,  HID_KEY_RETURN             
};

static uint8_t keymapSymbols[] = {
  KMOUSE_RIGHT, LCD_SWITCH, EXPANSION_SWITCH, KBATTERY_SWITCH, NOTIFICATION_BUZZER, POWEROFF, NOTIFICATION_LED,  'E',  'E',  KMAP_SWITCH,  KMOUSE_LEFT,
  HID_KEY_ESCAPE,       HID_KEY_APOSTROPHE, HID_KEY_BACKSLASH,  HID_KEY_SLASH,  HID_KEY_SLASH,  HID_KEY_SLASH, HID_KEY_SLASH, HID_KEY_SEMICOLON,  HID_KEY_APOSTROPHE,  HID_KEY_BRACKET_RIGHT,  HID_KEY_ARROW_LEFT,
  HID_KEY_TAB,          HID_KEY_BRACKET_RIGHT,  HID_KEY_ARROW_UP, HID_KEY_BRACKET_RIGHT, HID_KEY_BRACKET_RIGHT,      HID_KEY_BRACKET_RIGHT,  HID_KEY_BRACKET_RIGHT,    HID_KEY_BRACKET_RIGHT,      HID_KEY_BRACKET_RIGHT,  HID_KEY_BRACKET_RIGHT, HID_KEY_ARROW_RIGHT,
  HID_KEY_CAPS_LOCK,    'E',  HID_KEY_ARROW_DOWN, 'E',   HID_KEY_BRACKET_RIGHT, HID_KEY_BRACKET_RIGHT , HID_KEY_BRACKET_LEFT      , HID_KEY_BRACKET_RIGHT, HID_KEY_BRACKET_RIGHT, HID_KEY_BRACKET_RIGHT, HID_KEY_BACKSPACE,
  HID_KEY_CONTROL_LEFT , HID_KEY_GUI_LEFT,  HID_KEY_EQUAL, HID_KEY_MINUS,   HID_KEY_SLASH,   HID_KEY_BRACKET_RIGHT,      HID_KEY_KEYPAD_EQUAL,      HID_KEY_COMMA,     HID_KEY_PERIOD,     HID_KEY_BRACKET_RIGHT,  HID_KEY_RETURN
};

static char dummyKeypad[ROWS][COLS] = {
  { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10},
  {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21},
  {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
  {33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43},
  {44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54}
};

byte rowPins[ROWS] = {2, 41, 11, 12, 13};                     //connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 21, 33, 36, 34, 35, 16, 1, 14, 15, 7}; //connect to the column pinouts of the 

//initialize an instance of class NewKeypad
Keypad Dummy  = Keypad(makeKeymap(dummyKeypad), rowPins, colPins, ROWS, COLS);

void setup(void){
  
  // Set PIN Stater
  pinMode(LED_1, OUTPUT);
  pinMode(LED_2, OUTPUT);
  pinMode(POWER_MAIN, OUTPUT);
  pinMode(POWER_OFF, INPUT_PULLUP);
  pinMode(POWER_EX, OUTPUT);
  pinMode(POWER_LCD, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  pinMode(BATTERY_MESUREMENT, INPUT_PULLUP);
  pinMode(PI_STATE, INPUT_PULLUP);

  // Set thumbstick PIN Stater
  pinMode(upButton, INPUT_PULLUP);
  pinMode(downButton, INPUT_PULLUP);
  pinMode(leftButton, INPUT_PULLUP);
  pinMode(rightButton, INPUT_PULLUP);
  pinMode(mouseButton, INPUT_PULLUP);


  // Set Switch State
  digitalWrite(POWER_MAIN, HIGH);
//  digitalWrite(POWER_EX, LOW);
  digitalWrite(POWER_LCD, LOW);
  digitalWrite(BUZZER, LOW);
  powerstate = digitalRead(POWER_OFF);

  // Serial setup
  Serial.begin(115200);

  // Set up Keyboard and Mouse HID
  device.begin();
  
  // Set up keypad matrix
  Dummy.setHoldTime(1);
  Dummy.setDebounceTime(0);
  Dummy.addEventListener(keypadEvent);
  delay(1000);
}


void loop(void){

//  digitalWrite(LED_1, HIGH);
//  digitalWrite(LED_2, HIGH);
//  delay(1000);                   
//  digitalWrite(LED_1, LOW);    
//  digitalWrite(LED_2, LOW);

//  Serial.println(powerstate);
//  Serial.println(digitalRead(POWER_OFF));
  


  // Check Mouse state
  thumbstick ();
  
  // Check Keyboard state
  processKeys();
}

static void selectAlphabet(void)
{
  digitalWrite(LED_1, LOW);
  keymapState = 0;
}

static void selectSymbols(void)
{
  digitalWrite(LED_1, HIGH);
  keymapState = 1;
}

static void switchKeymap(void)
{
  if (keymapState)
    selectAlphabet();
  else
    selectSymbols();
}

static uint8_t mapKey(char key)
{
  if (keymapState)
    return keymapSymbols[key];

  return keymapAlpha[key];
}

static void keypadEvent(KeypadEvent key)
{
  if (Dummy.getState() != PRESSED)
    return;

  uint8_t kcode = mapKey(key);
  
  switch (kcode) {
  case KMAP_SWITCH:
    switchKeymap();
  break;
  case KBATTERY_SWITCH:
    battery_state();
  break;
  case KMOUSE_LEFT:
    mouse_left();
  break;
  case KMOUSE_RIGHT:
    mouse_rgiht();
  break;
  case NOTIFICATION_BUZZER:
    notificationBuzzer();
  break;
  case EXPANSION_SWITCH:
    power_expansion();
  break;
  case NOTIFICATION_LED:
    notificationLED();
  break;
  case LCD_SWITCH:
    power_lcd();
  break;
  case POWEROFF:
    poweroff();
  break;
  }
}

//static uint8_t modifierKey = 0x00;
//
//static void processKeys(void)
//{
// if (!Dummy.getKeys())
//   return;
//
// int i;
//
// for (i = 0; i < LIST_MAX; i++) {
//   if (!Dummy.key[i].stateChanged)
//     continue;
//
//   uint8_t key = mapKey(Dummy.key[i].kchar);
//
//   if (key == KMAP_SWITCH || key == KBATTERY_SWITCH || key == NOTIFICATION_BUZZER || key == KMOUSE_LEFT || key == KMOUSE_RIGHT || key == EXPANSION_SWITCH || key == NOTIFICATION_LED || key == LCD_SWITCH || key == POWEROFF)
//     continue;
//
//   switch (Dummy.key[i].kstate) {
//   case PRESSED: {
//       if (key & HID_KEY_SHIFT_LEFT) {
//           modifierKey = key;
//       } else if (key & HID_KEY_CONTROL_LEFT) {
//           modifierKey = key;
//       } else if (key & HID_KEY_ALT_LEFT) {
//           modifierKey = key;
//       } else if (key & HID_KEY_GUI_LEFT) {
//           modifierKey = key;
//       } else {
//           if (modifierKey & 0x00) { // if empty modifier
//                device.sendKey(key);
//                modifierKey = 0x00;
//           } else {
//                device.sendKey(key, modifierKey);
//                modifierKey = 0x00;
//           }
//       }
//   }
//   break;
//   case RELEASED: {
//     device.sendRelease();
//     modifierKey = 0x00;
//   }
//   break;
//   }
// }
//}

static void processKeys(void)
{
  if (!Dummy.getKeys())
    return;

  int i;

  for (i = 0; i < LIST_MAX; i++) {
    if (!Dummy.key[i].stateChanged)
      continue;

    uint8_t key = mapKey(Dummy.key[i].kchar);

    if (key == KMAP_SWITCH || key == KBATTERY_SWITCH || key == NOTIFICATION_BUZZER || key == KMOUSE_LEFT || key == KMOUSE_RIGHT || key == EXPANSION_SWITCH || key == NOTIFICATION_LED || key == LCD_SWITCH || key == POWEROFF)
      continue;

    switch (Dummy.key[i].kstate) {
    case PRESSED: {
//      uint8_t modifierKey = HID_KEY_NONE;
//      if (key & HID_KEY_SHIFT_LEFT) {yg
//        modifierKey = HID_KEY_SHIFT_LEFT;
//      }
//      device.sendPress(key, modifierKey);
      device.sendKey(key);
    }
    break;
    case RELEASED:
      device.sendRelease();
    break;
    }
  }
}


void thumbstick (void){
  
  // read the thumbstick buttons:
  int upState = digitalRead(upButton);
  int downState = digitalRead(downButton);
  int rightState = digitalRead(rightButton);
  int leftState = digitalRead(leftButton);

  // calculate the movement distance based on the button states:
  int  xDistance = (leftState - rightState) * range;
  int  yDistance = (upState - downState) * range;

  // if X or Y is non-zero, move:
  if ((xDistance != 0) || (yDistance != 0)) {
    device.move(xDistance, yDistance);
  }

  // a delay so the mouse doesn't move too fast:
  delay(responseDelay);
}


void mouse_left (void){
  device.pressLeft();
  delay(responseDelay); 
}

void mouse_rgiht (void){
  device.pressRight();
  delay(responseDelay);
}


static void power_lcd(void)
{
  if(lcdState){
    digitalWrite(POWER_LCD, LOW);
    Serial.println("POWER_LCD=LOW");
    lcdState = 0;
  } else {
    digitalWrite(POWER_LCD, HIGH);
    Serial.println("POWER_LCD=HIGH");
    lcdState = 1;
  }
}

static void power_expansion(void)
{
  if(expansionState){
    digitalWrite(POWER_EX, LOW);
    Serial.println("POWER_EX=LOW");
    expansionState = 0;
  } else {
    digitalWrite(POWER_EX, HIGH);
    Serial.println("POWER_EX=HIGH");
    expansionState = 1;
  }
}

static void notificationLED(void)
{
  Serial.println("notificationLED");
  digitalWrite(LED_2, HIGH);
  delay(25);
  digitalWrite(LED_2, LOW);
  delay(25);
  digitalWrite(LED_2, HIGH);
  delay(25);
  digitalWrite(LED_2, LOW);
  delay(25);
  digitalWrite(LED_1, HIGH);
  delay(25);
  digitalWrite(LED_1, LOW);
  delay(25);
  digitalWrite(LED_1, HIGH);
  delay(25);
  digitalWrite(LED_1, LOW);
  delay(25);
}

static void notificationBuzzer(void)
{
  Serial.println("notificationBuzzer");
  digitalWrite(BUZZER, HIGH);
  delay(50);
  digitalWrite(BUZZER, LOW);
  delay(50);
  digitalWrite(BUZZER, HIGH);
  delay(50);
  digitalWrite(BUZZER, LOW);
}

static void poweroff(void)
{
//  uint8_t i;

  /* Ask RPi to powerdown */
//  Keyboard.write(CONSUMER_POWER);

//  /* Wait for about 16 seconds */
//  for (i = 0; i < 20; i++) {
//    notification();
//  }
 // delay(16000);
  /* And finally turn off the power */
  Serial.println("poweroffOFF");
  digitalWrite(POWER_MAIN, LOW);
}

static void battery_state(void)
{
  Serial.println("battery_state");
  Serial.println(read_voltage());
}

static float read_voltage(void)
{
  // Get Battery voltage
  value = analogRead(BATTERY_MESUREMENT);
  voltage = value * 5.0/1023;
//  Serial.print("Voltage= ");
//  Serial.println(voltage);
  delay(200);
  return voltage;
}

On-board external Flash as USB Mass Storage

Hi, I know this question already got raised but just pointing out that the flash that ESP32 modules are equipped with would be great to access through this library.
The Ramdisk option - just too little space for practical value.
The SD card option - great but requires additional hardware.

If anyone have time, a "flash_msc" would be just great. Perhaps using the LittleFS filesystem :). What do you think.

HID disconnects unless large delay() used

For some reason, Windows is not seeing a HIDGeneric device unless I put a large (50-100ms) delay() in my loop. Occasionally it will enumerate and immediately disconnect, or simply not be visible at all. This is with an ESP32-S2 feather,

Obviously one of the advantages of HID is the data rate, so this does seem counterproductive.

sendPress(HID_KEY_A, 0) crash

Hi, I have a question about hidkeyboard lib

When I wrote the demo code for my keyboard. I got the crash message and my esp32-s2 always reboot.

This is my code:

#include "hidkeyboard.h"

HIDkeyboard dev;

void setup()
{
    Serial.begin(115200);
    dev.begin();
    dev.sendPress(HID_KEY_A, 0);
    //delay(1000);
    //dev.sendRelease();
    
}

void loop()
{
    delay(1000);
    Serial.println("loop...");
}

And the this is the esp32 log:

Rebooting...
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40026258
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x498
load:0x4004c000,len:0xa88
load:0x40050000,len:0x25a8
entry 0x4004c19c
Guru Meditation Error: Core  0 panic'ed (IntegerDivideByZero). Exception was unhandled.

Core  0 register dump:
PC      : 0x4008eca7  PS      : 0x00060a30  A0      : 0x8008e294  A1      : 0x3ffc8190  
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x3ffc1c28  A5      : 0x00000009  
A6      : 0x00000000  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x3ffc2274  
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x00000001  A13     : 0x3ffc2128  
A14     : 0x00000001  A15     : 0x00000000  SAR     : 0x00000018  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x00000001  LEND    : 0x3ffc2128  LCOUNT  : 0x400270c1  


Backtrace:0x4008eca4:0x3ffc81900x4008e291:0x3ffc81b0 0x4008bea5:0x3ffc81d0 0x4008bee1:0x3ffc81f0 0x40081ce6:0x3ffc8220 0x400813aa:0x3ffc8250 0x40083b0e:0x3ffc8280 




ELF file SHA256: 0000000000000000

Rebooting...

The sendChar work for me. I do not know how to debug.
Did I use it wrong?

Thanks a lot.

USB MIDI Host [feature request]

What would need to be done to add MIDI USB Host support ...I have MIDI kit, time, patience, reasonable programming skillz, and very little knowledge about low-level USB.

hidusb.h:10:44: error: 'hid_report_type_t' has not been declared

When I'm trying to compile the keyboard example I get:

In file included from C:\Users\Defozo\Documents\Arduino\libraries\ESP32TinyUSB\src/hidkeyboard.h:2,
                 from C:\Users\Defozo\Documents\Arduino\sketch_apr17a\sketch_apr17a.ino:6:
C:\Users\Defozo\Documents\Arduino\libraries\ESP32TinyUSB\src/hidusb.h:10:44: error: 'hid_report_type_t' has not been declared
     virtual void onData(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) { }
                                            ^~~~~~~~~~~~~~~~~
Multiple libraries were found for "SD.h"
 Used: C:\Users\Defozo\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.0-alpha1\libraries\SD
 Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\SD
exit status 1
Error compiling for board ESP32S2 Dev Module.

I'm using version 1.2.0 of the library.

usb/usb_host.h: No such file or directory

Hi!
I have try to test usb host function on new esp32-s2 but the compile failed pointed toward "usb/usb_host.h: No such file or directory"
Where I could find that file?

Thanks

USB Writeblocker

I want to make a USB Stick Writeblocker.

Is it possible to plug a USB-Stick to ESP32-S2 and emulate a USB device with the content of the actual USB-Stick to make it read only?

ESP32-S2 USB SD MSC not working well

Hi, @chegewara, I'm trying to use an ESP32S2 USB stick(https://www.hackster.io/news/create-custom-usb-devices-with-the-esp32s2stick-458bf370a522) to make an SD to USB adapter, however it seems to be taking too long to read the whole 8GB SD card for the USB, when I enable verbose core debug level, it just shows "[V][sdcard.cpp:65] onRead(): default onread". I saw on this post: https://www.esp32.com/viewtopic.php?t=15908 that you used a 16GB SD card and got it working. The comunication with the SD card is working, because the test code created the directory /mydir, wrote and read the hello.txt file, so to me it seems like something on the USB side.

My code is this:
USB_stick.zip

Obs.: I tried putting the code in the post, but I couldn't get right, this is my first post on github.

I'm using ESP32 2.0.1 RC1 and windows 10.

Edit: I tested it on linux and it worked, but on any windows machine it seems to not work.

Feature Request: SDMMC/SDIO support for MSC_SD example?

This is actually a feature request, but i couldn't figure out how to tag it as such.

Many SD BO and connectors support a much faster SDIO compared to the legacy SPI. This would significantly alleviate the speed bottleneck which is at least partially caused by the SPI interface in the example. This might even be relatively simple to implement, as esp32 s2 supports SDIO, and the arduino-esp32 library has provided SD_MMC API in their examples, The API format is relatively similar to the SPI API, the only seemingly significant difference being the amount of pin connections needed.

MSC moun/unmout issue

There is issue with unmout msc device. When device is unmounted from system, but onReady will return true, then tinyusb stack will call onunmout all the time:
https://github.com/chegewara/EspTinyUSB/blob/master/src/classes/msc/ramdisk.cpp#L32

We need to think how to implement this:

  • add class USBCallbacks in each MSC class (ramdisk, sdcard etc), or
  • let the user to implement it in own code.
  • implement it in each class and allow user to add its own USBCallbacks, to allow actions in mount/unmount

Pros/cons:

  • 1st option - simplify library use, dont bother user with low level actions, but wont let him to add led blinking depending on device state,
  • 2nd option - more flexibility, but also more complexity for user,
  • 3rd option is best, because will handle onready for user, and allow to add led blinking or similar things depending if device is mounted

MIDI Not working

When I try the MIDI example, it builds and runs ok, but I dont see the MIDI device on my system. Running lsusb -v shows that the Espressif Device is there and has some MIDI properties, but no program that uses MIDI cannot see or use it. I tried it in Windows and Linux.

Missing usbd.h file

I had this working great in July or so.
I went back to revisit it and won't compile (Webusb example) due to usbd.h file missing.
Also errors related to usb endpoints.
Any help is appreciated.
Thanks!

Media Key Support?

Is there also Media Key support (planned)?

e.g., KEY_MEDIA_NEXT_TRACK , KEY_MEDIA_PLAY_PAUSE, KEY_MEDIA_VOLUME_UP ...

Best regards

all_in_one example in crash loop immediately after download

This issue is in reference to the "all_in_one" example - I have not tried any of the others.

The code is compiling, I have the ESP32S2 branch installed (manually) in the Arduino IDE, I can build and download the code, but all it does is what is shown in the log below.

Is there any particular setup option and / or partition scheme I have to use to make this work?

01:00:56.909 -> ELF file SHA256: 0000000000000000
01:00:56.909 ->
01:00:56.909 -> Rebooting...
01:00:56.909 -> ESP-ROM:esp32s2-rc4-20191025
01:00:56.943 -> Build:Oct 25 2019
01:00:56.943 -> rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
01:00:56.943 -> Saved PC:0x40025c41
01:00:56.943 -> SPIWP:0xee
01:00:56.943 -> mode:DIO, clock div:1
01:00:56.943 -> load:0x3ffe8100,len:0x4
01:00:56.943 -> load:0x3ffe8104,len:0x570
01:00:56.943 -> load:0x40050000,len:0x1620
01:00:56.943 -> load:0x40054000,len:0x1a04
01:00:56.943 -> entry 0x40050280
01:00:57.078 -> Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
01:00:57.078 ->
01:00:57.078 -> Core 0 register dump:
01:00:57.078 -> PC : 0x4001abc8 PS : 0x00060030 A0 : 0x80080ee1 A1 : 0x3ffc8b50
01:00:57.112 -> A2 : 0x00000000 A3 : 0x3ffbda30 A4 : 0x00001400 A5 : 0x00000000
01:00:57.112 -> A6 : 0x4d903ceb A7 : 0x534f4453 A8 : 0x3ffbee30 A9 : 0x3ffc8b20
01:00:57.112 -> A10 : 0x00000000 A11 : 0x00000400 A12 : 0x00000000 A13 : 0x00000003
01:00:57.112 -> A14 : 0x3ffc2790 A15 : 0x3ffc8c00 SAR : 0x00000000 EXCCAUSE: 0x0000001d
01:00:57.112 -> EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000003 LCOUNT : 0x40026961
01:00:57.146 ->
01:00:57.146 -> Backtrace:0x4001abc5:0x3ffc8b50 |<-CORRUPTED

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.