MTP_t4 working well on t3.6
I'm using MTP_t4
https://github.com/WMXZ-EU/MTP_t4 installed following the (brief) instructions given in the ReadMe and have encountered no problems in my T3.6 project.
I am using SdFat v2.0 beta8 rather than the older SdFat, because I need the ExFat support and the direct support for large pre-allocated files to prevent blocking writes that sometimes have unacceptably long latency.
Since I'm using two SD cards in my project (the T3.6 built-in SD adaptor and the AudioBoard SD adaptor) and might want to expose either one of them, I've hacked away at the Mtp_t4 storage library to stop it from defining or initializing a drive, forcing it instead to use an already-defined instance of SdFs that I instantiate in a "drives" class that wraps and extends my drives. I modified storage.h to #include my "drives.h", then call chvol() to set the active drive volume before starting the mtp daemon loop.
This works well for connecting to Windows 10 from my teensy with code compiled under Visual Studio/Visual Micro in Serial+MTP mode.
I've encountered only three issues thus far:
1. The reported drive size is not correct. I recall seeing a patch somewhere that may help with this, but haven't been able to track it down.
2. Once the mtp daemon has run, it's not possible to shut down MTP without power-cycling the teensy. If the daemon does not loop, PC programs that enumerate drives on "ThisPC" will hang "forever" until the USB cable is disconnected or the teensy is powered off. There probably is some way to send a disconnect or teardown request to the PC, but I haven't been able to find it as yet.
3. The USB0 port on the t3.6 is limited by hardware to a maximum speed of 12 Mbps. Copying a gigabyte logging data file from the teensy to the PC thus takes about 15 minutes, so for those larger files it's easier to open the case and pull the card in and out. For updating resource files, however, the MTP connection is a game-changer.
It would be even better if I could use the teensy's USB1 port, which can run at 480 Mbps, but the only person I've found who is using it in device mode had to move everything to the uTasker operating system to get that working. I might go there, but not right now. If anybody knows of any work being done towards device mode support for USB1 on the t3.6, I would love to be pointed in the right direction.
In the meantime, I'm thrilled to have high-speed, low-latency logging on the teensy 3.6 working with MTP drive access from the PC!!