If the running application could catch an interrupt from incoming serial USB data, I could force a quick reset back into the same app and speed things up.
If you are willing to hack the core you can trigger a reset (or something else) by adding code to the location where TD detects the reboot request via baud rate 134 (https://github.com/luni64/cores/blob...sy4/usb.c#L688)
E.g this:
Code:
#ifdef CDC_STATUS_INTERFACE
// 0x2021 is CDC_SET_LINE_CODING
if (setup.wRequestAndType == 0x2021 && setup.wIndex == CDC_STATUS_INTERFACE) {
memcpy(usb_cdc_line_coding, endpoint0_buffer, 7);
printf("usb_cdc_line_coding, baud=%u\n", usb_cdc_line_coding[0]);
if (usb_cdc_line_coding[0] == 134) {
usb_start_sof_interrupts(NUM_INTERFACE);
usb_reboot_timer = 80; // TODO: 10 if only 12 Mbit/sec
}
else if (usb_cdc_line_coding[0] == 135) {
SCB_AIRCR = 0x05FA0004;
}
}
#endif
It will reset the board if the baud rate is switched to 135. I tested this with PUTTY and it works. However, for a real life application you probably want some more elaborate code to prevent multiple resets until the PC app/script sets the baud rate back to != 135;
---
However, resetting the board with python is really simple and, if I understand correctly, you'd need some script to upload your hex file anyway. Here proove of concept code without any error checking, hardcoded com-port (windows) and assuming only one teensy on the bus:
Code:
import hid
import serial
import time
ser = serial.Serial('COM10',baudrate=134) # start bootloader
time.sleep(1) # give it some time to boot up HalfKay (better spin until the bootloader device appears on the bus)
device = hid.Device(0x16c0,0x478) # connect to the bootloader
device.write(bytes([0x00, 0xFF, 0xFF, 0xFF])) # send reset report
time.sleep(1) # give it some time to boot up the bios (better spin...)
ser = serial.Serial('COM10') # connect to the bios via serial
#upload code to ram and start....