TinyUSB, sometimes project do not work

I’ve been using platformio, great work by the way, with Seeed Xiao modules and generally, everything goes smoothly, sometimes when I add USB the project that was working just bricks the Xiao and I have to do the double-tap reset to get the boot loader back.

I have two projects now, one works, one does not, been through in files and all seems to match, code for USB was copied over from the working project, done clean and build, delete all lib_deps and build and nothing seems to make it go.,

In the past I have had to create a new project, add USB and then add all code back, keen to understand what I’m doing wrong here,

any suggestions?


more investigation suggests the code is running to some extent but that the USB enumeration is failing, thus the USB serial does not come up and we cannot see any diagnostics, windows reports

Windows has stopped this device because it has reported problems. (Code 43)

A request for the USB device descriptor failed.

My guess is that the USB descriptors are in some way screwed up, could this be due to link order or p[position in memory?

if #ifdef out all usb code then I get the main loop to execute which I can see by virtue of less flashing that are controlled by mcp23008 on i2c bus.

but USB still fails to enumerate with same error

to resolve I have to remove the following

; build_flags = -DUSE_TINYUSB

lib_deps =

; adafruit/Adafruit TinyUSB Library @ ^0.10.5

and delete the tinyusb folder in libdeps\seeed xiao

then USB serial is back and all runs but cannot attach to the USB hid device

any ideas?

other projects work…

Do you have a exact platformio.ini and code which works in the Arduino IDE but not in PlatformIO?

I have projects that work in platformIO and another that does not, have made the .ini the same for both.

I try to avoid the Arduino UI at all costs!

Planning to recreate from scratch and see what changes


One caveat with PlatformIO + TinyUSB is always that lib_archive = no must be set in the platformio.ini. Maybe that changes things?

ok, i have no setting at all for lib_archive, I’ll try it tonight

not tried the archive flag yet but seems you have to the USB init very early in setup() to ensure that your device is enumerated okay with windows, may not be a surprised as I guess host expects to enumerate as soon s connected, if you delay the setup then your device will work as its own thing b ut doe snot enumerate and show up.

been recreating from a copy of working project, just added

#include <DallasTemperature.h>

this has bricked the xiao so it will need a double tap reset to get boot loader back. adding libdep for

milesburton/DallasTemperature @ ^3.9.1

is okay until you use the include file, will dig further into that tonight