Adafruit's TinyUSB with Teensy 4.0

Status
Not open for further replies.

isaacjacobson

Well-known member
Hello,

Adafruit has a library which allows your computer to read an arduino like a mass storage device and realtime interact with it. This has been something I've been trying to accomplish for quite some time. There are not seeming to be many options specifically for the apple/mac world.

Here's the demo of the library in action: https://www.youtube.com/watch?v=0bWba0PU4-g
Here's their GitHub for it: https://github.com/adafruit/Adafruit_TinyUSB_Arduino

This is EXACTLY what I need for my next project.

It's not seeming to work on Teensy 4.0. Specifically, none of their Mass Storage Device examples will compile.

When I go to compile the "msc_external_flish_sdcard" example, I get this error:


Code:
In file included from /Users/*************/Documents/Arduino/libraries/Adafruit_TinyUSB_Library/src/Adafruit_TinyUSB.h:28:0,
                 from /Users/*************/Documents/Arduino/libraries/Adafruit_TinyUSB_Library/examples/MassStorage/msc_external_flash_sdcard/msc_external_flash_sdcard.ino:25:
/Users/*************/Documents/Arduino/libraries/Adafruit_TinyUSB_Library/src/Adafruit_USBD_HID.h:28:35: [B]fatal error: Adafruit_TinyUSB_Core.h:[/B] No such file or directory
compilation terminated.
Error compiling for board Teensy 4.0.

The reference to the "Adafruit_TinyUSB_Core.h" is confusing, because it apparently does not exist?

I would GREATLY appreciate any assistance in getting this library to work with Teensy 4!
(Or an alternative method to accomplish the same thing).
 
You might want to checkout CircuitPython for Teensy 4.0 (https://circuitpython.org/board/teensy40/). They may have a way to build TinyUSB for Teensy 4. I've not used it, but most of the other CircuitPython boards seem to support TinyUSB.

<edit>
FWIW, I just loaded the 5.3.0-rc.0 hex image into a Teensy 4.0, and it uses flash memory as a disk drive that is automatically exported. On my Teensy 4.0, the exported filesystem was roughly 1 megabyte.
 
Last edited:
I'd recommend filing an issue on the arduino TinyUSB library repo. I bet Thach would be happy to help get it working on Teensy.
 
Thanks for the help so far!

Adafruit's TinyUSB Library is an awesome Library, and the Teensy is an awesome board. Would love it if I or someone could find a way to bring those worlds together.

You might want to checkout CircuitPython for Teensy 4.0 (https://circuitpython.org/board/teensy40/).

I was looking into this. It looks very cool! However, I'm already so deep into using the Audio System Design Tool for the Teensy Audio Library. I'm sure it would be pretty crazy trying to bring that all over to CircuitPython.

I'd recommend filing an issue on the arduino TinyUSB library repo.

That's a good idea. I went ahead and did that. We'll see what happens!


I noticed that hathach's original TinyUSB library seems to support Teensy 4.0 (https://github.com/hathach/tinyusb/blob/master/docs/boards.md) But Adafruit's TinyUSB library does not support it – and Adafruit's library is what brought the ability to read the SD Card as a Mass Storage device via the native USB port.

Thanks for the help all – I'll keep working on it and post any updates!
 
I noticed that hathach's original TinyUSB library seems to support Teensy 4.0 (https://github.com/hathach/tinyusb/blob/master/docs/boards.md) But Adafruit's TinyUSB library does not support it – and Adafruit's library is what brought the ability to read the SD Card as a Mass Storage device via the native USB port.

TinyUSB itself definitely works on Teensy 4.0 and 4.1 because we use it in CircuitPython. It's the Arduino integration that I don't know about. Thach should be able to help with it though.
 
TinyUSB itself definitely works on Teensy 4.0 and 4.1 because we use it in CircuitPython. It's the Arduino integration that I don't know about. Thach should be able to help with it though.

You're awesome thanks! Also I've been checking out CircuitPython – really cool stuff. Thanks for your work on that and bringing info to the forum.
 
I filed an issue on Adafruit's TinyUSB library repo (https://github.com/adafruit/Adafruit_TinyUSB_Arduino/issues/63)

I pretty quickly received a response from Thatch:

"unfortunately TinyUSB requires the core BSP to support (port) it. It is not as simple as other peripherals such as I2C. Since most the core will use and setup its own USB stack for CDC when starting up the sketch.
For BSP core to support TinyUSB https://github.com/adafruit/Adafruit_TinyUSB_ArduinoCore must be added and ported to the platform. You will need to ask Teensy BSP maintaining team to port it first.
In the future, I will try to see if we could make it easier to support on new platform by moving most parts of the Core to the Lib, more or less it still needs BSP changes to adopt the library."

Would anyone know how to get in touch with the Teensy BSP maintaining team? Would someone on that team happen to have time to look into this?

I think a lot of people and projects could really benefit from this. Adding support of this Library would give the ability to read/write files to the SD Card/flash memory of the Teensy via a USB cable as a Mass Storage Device Class is (MSC). This is a lot more universally usable than MTP (Mac doesn't like MTP – classic Apple..)

This would be an incredible feature to pair with Teeny's powerful audio library or other projects which utilize the microSD card. Frequently moving the microSD card from the Teensy to a card reader can be tedious for some projects.

Thanks ahead of time!
 
Would anyone know how to get in touch with the Teensy BSP maintaining team? Would someone on that team happen to have time to look into this?

AFAIK, there is nothing like a "Teensy BSP maintaining team".
IOW, you may create a BSP yourself.
That's why I stopped looking into TinyUSB
 
I filed an issue on Adafruit's TinyUSB library repo (https://github.com/adafruit/Adafruit_TinyUSB_Arduino/issues/63)

I pretty quickly received a response from Thatch:

Would anyone know how to get in touch with the Teensy BSP maintaining team? Would someone on that team happen to have time to look into this?

I think a lot of people and projects could really benefit from this. Adding support of this Library would give the ability to read/write files to the SD Card/flash memory of the Teensy via a USB cable as a Mass Storage Device Class is (MSC). This is a lot more universally usable than MTP (Mac doesn't like MTP – classic Apple..)

This would be an incredible feature to pair with Teeny's powerful audio library or other projects which utilize the microSD card. Frequently moving the microSD card from the Teensy to a card reader can be tedious for some projects.

Thanks ahead of time!

I think Thach did the BSPs as well. There isn't a team of people. He was pointing out why it didn't work and what would need to be added.
 
I think Thach did the BSPs as well. There isn't a team of people. He was pointing out why it didn't work and what would need to be added.

Admittedly, I'm pretty new to this stuff.

BSPs is something I don't know too much about. Would it be pretty complex and difficult to port it myself? (or do whatever needs to be done to get Adafruit's TinyUSB working on Teensy)?

Thanks for the time you've all already put into helping with this.
 
I don't know the details myself. I'd suggest looking at the other similar boards that are supported in the folder Thach pointed to.
 
Know a little late here but the Teensy 4.0 bsp support is in the bsp directory of TinyUSB. Do a search on teensy in the tinyUSB repository and you will find it. For the T4.1 would probably have to be modified since there is more flash
 
Know a little late here but the Teensy 4.0 bsp support is in the bsp directory of TinyUSB. Do a search on teensy in the tinyUSB repository and you will find it. For the T4.1 would probably have to be modified since there is more flash

Also I imagine it would be very useful to use the flash memory (if soldered in) and/or the micro SD cards on the Teensy 4.1.
 
Also I imagine it would be very useful to use the flash memory (if soldered in) and/or the micro SD cards on the Teensy 4.1.

I agree. Want to give it a try but have a couple of other things in process I need to finish before I get wrapped up in tinyUSB. Was looking out of curiosity so on list :) And yes it would be very useful that was why I was looking at, and I am pretty sure it can be done with SPIFFS instead of FS.
 
Know a little late here but the Teensy 4.0 bsp support is in the bsp directory of TinyUSB. Do a search on teensy in the tinyUSB repository and you will find it. For the T4.1 would probably have to be modified since there is more flash

Does that mean that theoretically Adafruit’s TinyUSB library should already be able to compile on a Teensy 4.0 through Teensyduino? Or what would need to happen to make that work?
 
Unfortunately no. Was playing with it for the last couple of days. The Adafruit lib is configured for samd boards. Also a different usb desc has to be created from what I see. So it’s not out of the box compatible
 
Unfortunately no. Was playing with it for the last couple of days. The Adafruit lib is configured for samd boards. Also a different usb desc has to be created from what I see. So it’s not out of the box compatible

I thought that was the case. Thanks for looking at it. I've been messing with it a fair amount, but it's a bit out of my expertise to make it happen.
 
Status
Not open for further replies.
Back
Top