Mark,
First let me give the good news. I just tried to do a build with FS USB MSD and SDCard support, using the changes you made to the code, and it works. I can see my SD Card, and I can even stream MP3's off of it, to both my PC and to my car stereo. :-)
The K66 has a new PLL dedicated to generating a 480MHz USB PHY clock, which however needs the VBUS to be connected to work.
Since I haven't used it in a real product yet I have presently accepted that the PLL will not work unless the HS USB is connected to a host. In fact, the 'final' and 'complete' solution would probable be to make USB initialisation conditional on the VBUS being present and wait if it isn't. If the cable is disconnected it also needs to be detected and abort operation because the PLL freezes and so the USB blocks if not handed completely.
Forgive my ignorance here, I've done most of my work in application development, at a much higher level, much more removed from the hardware side of things. So, the terminology you're using is very new to me. I believe I understand what you are saying here though, let me know if I'm wrong. I understand what you just said to mean, that this chip, has a separate phase locked loop, to sync the physical usb clock against, and that PLL needs power on the USB connection to operate. Correct?
If so, I don't think you would even need any code to shut down that PLL, when the usb connection was removed, for the Teensy anyways, because the Teensy itself is powered from the USB connection, and when you disconnect it, it shuts down.
you could maybe consider how the PLL's dependency on VBUS presence could be best handled
I assume some of the other boards that your software supports are powered from other sources, and would then continue running, even though the USB was disconnected. The only thing I can think to do in that scenario, would be something like what you proposed. i.e. wait until the USB connection was initiated, and then initialize the PLL, and then hook into the USB disconnect, and shutdown the PLL in response to that event. You could write the code that way, and it should still work for the Teensy I think, it's just that the shutdown code would never get executed.
The Open Source code does have the HS PHY initialisation but it WILL hang if the VBUS is not connected since the PLL will not start (forever loop).
I just checked in the latest HS driver too since there was a bug fix in it for something unrelated (only noticeable in specific situation).
If you can verify its operation (with VBUS connected) on the Teensy 3.6 it would be good
If I am understanding your request correctly, it should mean that all I need to do to test this on the Teensy, is to flip on the high speed USB define, and rebuild, and then try it on the teensy. I have just finished doing this, and I am still getting the same behavior I was getting before, when I tried the high speed test. i.e. the LED comes on, and stays solid for almost a full second, then briefly (probably like 100 ms at most) shuts off, then back on again for almost another full second. Also, the PC will not recognize the device at all. I don't even see windows trying to enumerate the device, in the message analyzer. So, it probably is the usb physical clock hung up, like you were saying.
So, I'm not sure how to proceed with the high speed thing, unfortunately, I don't have any kind of a debugger that I could hook to the teensy, to see what is going on inside. So, I'm totally dependent on the USB interface itself to communicate debug info.
I'm going to work on trying to get an emulated FAT working next, with the full speed mode, so that I can get the MSD requests into my code, and then I'll have to figure out what kind of backside transfer protocol I'm going to use, to transfer the data to the pi, and back. I'm still willing to do more testing, if I can help you with the HS side of things, so just let me know if there's something you want me to try. I've also got another idea on how to maybe help the process along, I'll shoot you a private message about it, in a bit :-)
Oh, and one more thing I noticed about your last round of changes, a few posts back, I mentioned a typo that I found in the source code for MSD
I think I found a typo in the new codebase. In the file usb_cdc_descriptors.h, at line 1112, you currently have:
(OUT_ENDPOINT | USB_MSB_OUT_ENDPOINT_NUMBER),
I believe this should be:
(OUT_ENDPOINT | USB_MSD_OUT_ENDPOINT_NUMBER),
As I did the diff to figure out exactly which files I needed to update in my dev version of the code, I saw that this typo was still there. I've fixed it in my dev codebase, but the USE_USB_CDC option won't compile with that line the way it is. Just a reminder :-)
Thanks again for all the help so far,
Chris