Anyone tried MTP library under Vscode-Platformio environment?

pjy5451

Member
Hi

I'm currently developing for integrating MTP_teensy example on my main source.
For neglecting cumbersome library collision, I just created a new project (Teensy 4.1) and tried to run MTP example (Simplied Examples>Example3-simple sd)

Since there is no MTP_teensy library on the project library, I copied and pasted the library what I got from github (MTP_Teensy-main)
https://github.com/KurtE/MTP_Teensy

But there are several errors occurred badly..

1. FS.h: No such file or directory
I could download any FS.h library from anywhere, but before that, I would like to make sure where I need to acquire FS.h library to avoid library collision.

envi.PNG

2. USB Type selection
when I tried example_3_simple_sd example code using arduino sketch, I had to change usb type as "MTP Disk (experimental)"
But I don't know what I need to change its mode in platformio environment
Through googling, I got to know that there is an option as usbtype = USB_MTPDISK so i adopted it, but please let me know it's correct or not

ini image.PNG

3. SD.h vs SDfat.h
Actually, main goal of my project is composed of two things
(1) Saving data in high rate through SDfat.h library
(2) Getting an access to SD card through external USB port

However, if I suppose that I solve the above two issues, I can't avoid worry about coming library collision issue
When I included <SD.h> and <SDfat.h> libraries simultaneously before, It gives an error
I need to sdfat library for my fast data saving, but SD.h is also mandatory required for using mtp_teensy library as i think

Sorry for many asking and thank you so much for helping me in advance
 
1. FS.h is found in cores/teensy4/FS.h

2. Correct

3. Have you even looked inside SD.h yet?

Code:
#include <Arduino.h>
#include <SdFat.h>

Teensy's implementation of SD is a very thin layer directly calling SDFat. You should look at the SdFat_Usage example to see how you can make direct SDFat calls using teensys SD but you might not need to.
 
Thank you for replying

1. FS.h is also found in cores/teensy4 but it isn't compiled and gives error. Should i add fs.h by myself when I use platformio?
fs.PNG

2. Thanks for confirming

3. Let me see through.. I understood that SD.h is required for using MTP example code since as below.. Can i perform the same function by using SDO.begin()?
sdo.PNG
 
Sorry, I am not a PlatformIO user so not much help, but:

1) Sounds like a dependency issue. Like somewhere, there should be on the command line that compiles the files, needed to add the -I for where the Teensy core is located.
For example using Arduino 2.1 the compile lines include:
"-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.2\\cores\\teensy4"

3) MTP code works using File systems as defined in FS.h so those native to sdfat can not be added to the list of file systems that are exposed by MTP. At least not directly. That is you could write your own simple FS wrapper object that forwards things to SDFat. But that is just recreating SD library.
 
Pjy5451:
Please include the entire terminal output when you try to build your code so we can see the complete system settings that your version of PIO is using. Also include your platformio.ini file as well which is very important.
If you would like I have working code using both littleFS on EXTRAM as well as the SD card system with MTP code, which works very well. I could ZIP it up and include it here if you would like to see what I did using PIO.

Regards,
Ed
 
I'd love to see that as well. I'm transitioning my project to Teensy 4.1, and am planning to bury the SD card in an enclosure... so being able to "see" the SD card via USB would be great.

I'm using PlatformIO and could try a test project if you could share what you have.

Thanks!
 
Back
Top