Tinyusb on seeedstudio femto

Trying to get Tinyusb package working on a seeded femtin platform.io/vs code

Works fine on arduino ide, but cannot compile package in vscode, loads of errors but first is

	"resource": "/c:/icotest/Adaptors/SeedFemto/usb intterface seeed femto/.pio/libdeps/seeed_femto/Adafruit TinyUSB Library/src/Adafruit_USBD_HID.cpp",
	"owner": "cpp",
	"severity": 8,
	"message": "'HID_PROTOCOL_NONE' was not declared in this scope",
	"startLineNumber": 37,
	"startColumn": 15,
	"endLineNumber": 37,
	"endColumn": 15

bit stuck on this, no sign of this in package files, googling finds it but these files are not pulled down


any ideas?


I assume you mean a Seeed Femto here.

You’re linking to the Adafruit TinyUSB library here. The Arduino core that that board is using is defined as…

which maps to

which maps to GitHub - Seeed-Studio/ArduinoCore-samd.

It already includes the TinyUSB library, see ArduinoCore-samd/cores/arduino/TinyUSB at master · Seeed-Studio/ArduinoCore-samd · GitHub.

The builder code automatically builds it, too.

So, there’s no need to externally add it. Adding it via lib_deps is wrong, and I can see you did it that because

contains .pio/libdeps in the path.

I can do a minimal project with a library on top of TinyUSB like

#include <Arduino.h>
#include <KeyboardController.h>
USBHost usb;
KeyboardController keyboard(usb);

void setup() {
  if (usb.Init() == -1)
	  Serial.println("USB Host did not start.");

void loop() {
platform = atmelsam
board = seeed_femto
framework = arduino

and it compiles.

Checking size .pio\build\seeed_femto\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.5% (used 3120 bytes from 32768 bytes)
Flash: [=         ]   6.5% (used 17120 bytes from 262144 bytes)
============================= [SUCCESS] Took 5.43 seconds =============================

So with what exact code + platformio.ini are you running in what exact problem? :sweat_smile:

1 Like

Correction: There seem to be two USB stacks in the core, one is TinyUSB and the other folder is just called USB. The TinyUSB source code files are all surrounded by #ifdef USE_TINYUSB.

So in order to use that, you need to add build_flags = -DUSE_TINYUSB in the platformio.ini. But then you can’t directly use the e.g. USBHost library because it errors out since it seems to be written for the other USB core. So, it really depends on just what USB functionality you want to implement.

E.g. it also has a HID library and object that you can use to send HID reports, etc.



Thanks for your detailed response, helps me see how these work!

build_flags = -DUSE_TINYUSB

Was the trick, compiled first time, I have taken the lib deps out as well.

Now I need to make my code work!


1 Like

And yes meant Seeed Femto, not sure what happened there, my typing is probably the cause…