Crashing into T_4.0 bootloader is an odd sign, in fact first report?
> is there a pattern/count with a pause in the RED bootloader LED blinking?
Generally the first easy thing would be to look into 'CrashReport'. Though that only works while the Teensy stays powered between restarts. Given the switch between external power and USB that won't be easy to accomplish.
Code:
void setup() {
Serial.begin(9600); // With TeensyDuino 1.54 Serial.begin() may return connected
if ( Serial && CrashReport )
{ // Make sure Serial is alive and there is a CrashReport stored.
Serial.print(CrashReport); // Once called any crash data is cleared
// In this case USB Serial is used - but any Stream capable output will work : SD Card or other UART Serial
}
Perhaps if you had a sacrificial USB cable that could be opened to cut the '5V' wire the USB cable could be left connected and then when externally powered the USB interface to the PC would still work.
That might allow seeing the problem 'go away' when normal USB communications were present.
If not, then normal code output would appear showing the activity allowing some info and debugging of the code before it fails. Adding Serial.flush() after .print()'s would have them complete transfer before proceeding.
Then, hopefully with a Button press, uploading the code would be possible and having that code to the above check for a CrashReport might offer any details if it was triggered before the code 'exited'.
Also, there may be some info on this event that Teensy Loader gets when the Loader's: menu Help / 'Verbose info' window is open.
If more help is needed seeing and understanding what CODE is involved might help, and knowing what devices are attached to the Teensy.