webusb / arduino

WebUSB demos running on Arduino (and compatible) hardware.
576 stars 152 forks source link

WebUSB not working anymore with SAMD Board Version > 1.8.10 #92

Open iKK001 opened 2 years ago

iKK001 commented 2 years ago

I discovered that your WebUSB does no longer work when installing newer SAMD-Board versions.

The default WebUSB example work for SAMD Board version 1.8.9. But it does not work anymore for version 1.8.10 and above.

Works.... CleanShot 2021-12-26 at 02 08 38

Does not work.... CleanShot 2021-12-26 at 02 14 16

I am using a MKRWiFi1010 board.

The error message is :

fatal error: USB/PluggableUSB.h: No such file or directory
 #include "USB/PluggableUSB.h"
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino MKR WiFi 1010.

Any idea what to do ?

mars-low commented 2 years ago

If downgrading SAMD core to version 1.8.9 as described in https://github.com/webusb/arduino/issues/84#issuecomment-772488739 is not an option, you could try to update library/WebUSB/WebUSB.h by including path to "api/PluggableUSB.h" and changing uint32_t to unsigned int when compiling for ARDUINO_API_VERSION and above. That ARDUINO_API_VERSION value is defined automatically when building for core 1.8.10 and above.

I've tried to do it in my fork and I've setup CI on Github Actions to verify it actually compiles on different platforms after changes. I must admit that my main purpose was to test it with Arduino Nano 33 IoT, but as I remember despite successfully compiling, still I haven't been able to run provided examples - device was not detected by browser. Unfortunately I haven't spent enough time to debug this problem. Eventually I've ended up switching to Adafruit fork of ArduinoCore-samd with TinyUSB with files for Arduino Nano 33 IoT copied from upstream repository and used Adafruit_TinyUSB_Arduino to handle WebUSB in experimental Blazor app.