THANK YOU.. Maybe its not working on Teensy 3.5 I guess![]()
That's normal. Only the Teensy 3.6 has the second USB port which can be configured as a USB host. That's clearly visible in the comparison table here : https://www.pjrc.com/teensy/techspecs.html.
just in case,
it may need a micro SD card in the built-in slot to show the device?
Hi, just inquiring if it is possible to use the second USB port on the Teensy 3.6 with MTP? If so, can you advise how to make it work?
Thanks in advance.
So with the MTP_Blinky.ino code running on a Teensy 3.6 is it supposed to show up on a Windows PC as a USB Drive or is there more to be done to make this happen?
Hi,
Just discovered the MTP library and seems to be exactly what I need. But where can I change the settings in order to work with the SD slot of the Audio Adapter?
I saw a lot of flags in 'SdFatConfig.h' to change set custom SPI configuration (only for STM32 and AVR boards).
Since I use a Teensy 3.6, the same file enables SDIO and SDIOEX classes... where I have no clue, how to make it work on the audio adapter slot.
Can someone help me? Thanks, Sebastien
P.S. And if you ask why I don't simply use the built-in slot, it's for historical reasons: I started using the "upper" one, that was easier to handle. And now I mounted the Teensy+Adapter on a PCB and can't access the built-in slot anymore![]()
@sschiesser
I think something key was written in the MTP library, but the library is relative simple to edit
guess you can probably modify somewhere in "https://github.com/yoonghm/MTP/blob/master/MTP.h"
like changing line 37 :
SdFatSdioEX SD;
to
SdFat SD;
Also I didn't find call of SD.begin(); in the library,
you probably will need to do SD.begin(yourCSpin); before calling MTP.loop();
not sure would it work
Yes it did! I thought I first need to set new #define to enable changes, but finally I just needed
in setup() andCode:SPI.setMOSI(myMOSIpin); SPI.setSCK(mySCKpin);
in loop().Code:SD.begin(myCSpin);
Thanks, s
Good evening (@CET)
After successful test with the MTP_blinky, I tried to implement the library into my code and get an error I can't explain: when just adding
anywhere in my code (in main.ino, main.h or any other file), I always get the error " 'SdFat' does not name a type".Code:#include <MTP.h>
This error also happens when I remove <MTP.h> and write
The libraries are correctly installed and the examples codes work... some idea?Code:#include <SdFat.h> SdFat SD;
Best,
Sébastien
For anyone having troubles getting the MTP code from yoonghm's repository to work, I've figured out what's going wrong with it.
The "MTP Disk (Experimental)" USB type choice creates three interfaces: CDC control, CDC data, and MTP. However, the configuration descriptor that is generated claims only two interfaces to exist, and the interface descriptors themselves have numbers 0, 1, and 0 respectively. Either the incorrect count, or the duplicate interface number, is enough to get Windows (7, at least) to completely reject the device - of course without giving any indication anywhere of exactly why the device is being rejected.
To fix, you need to edit the usb_desc.h file - the one you copied from the MTP library into your Teensyduino installation. Find the section that starts with:
Just under that, find:Code:#elif defined(USB_MTPDISK)
and change the number to 3, then a few lines further down find:Code:#define NUM_INTERFACE 2
and change the number to 2.Code:#define MTP_INTERFACE 0 // MTP Disk
Ok, I spoke a bit too soon about that making the code work - it at least gets the device to appear, but pretty much nothing other than creating empty folders would actually work. There was a warning during compilation that I should have paid closer attention to:
FILE_WRITE had a value of 0x4202, but that parameter (and everything else within the SDFat library that deals with file flags) is only a byte. Somehow the compiler was picking up a traditional Unix definition of the file opening flags (O_CREAT and all that) that has the bits scattered throughout an int, instead of the Arduino definition that squeezes them all into a byte. I traced this down to the file Arduino\libraries\SdFat\src\SdFatConfig.h:Code:C:\Program Files\Arduino\libraries\MTP/MTP.h: In member function 'virtual uint32_t MTPStorage_SD::Create(uint32_t, bool, const char*)': C:\Program Files\Arduino\libraries\MTP/MTP.h:375:38: warning: large integer implicitly truncated to unsigned type [-Woverflow] OpenFileByIndex(ret, FILE_WRITE); ^
I have absolutely no idea what the right solution is here, so I just added a couple of lines right after that to force the Arduino definitions:Code:/** If the symbol USE_FCNTL_H is nonzero, open flags for access modes O_RDONLY, * O_WRONLY, O_RDWR and the open modifiers O_APPEND, O_CREAT, O_EXCL, O_SYNC * will be defined by including the system file fcntl.h. */ #if defined(__AVR__) // AVR fcntl.h does not define open flags. #define USE_FCNTL_H 0 #elif defined(PLATFORM_ID) // Particle boards - use fcntl.h. #define USE_FCNTL_H 1 #elif defined(__arm__) // ARM gcc defines open flags. #define USE_FCNTL_H 1 #else // defined(__AVR__) #define USE_FCNTL_H 0 #endif // defined(__AVR__)
I haven't tested this very thoroughly yet, but at least I can copy a text file to the Teensy and read it back now.Code:#undef USE_FCNTL_H #define USE_FCNTL_H 0