-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[v4.2 branch] Auto-reset ESP32-S2 USB UART to bootloader times out on packet header or on changing mode #4528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
yes I am aware, work on USB has not completed yet :) System timer is resetting after some time needs to be prepared properly before rebooting into Download. I'm thinking of turning off persistence in the branch for now. Will fix the issue, but the device will reenumerate. If default config is used, it will come up on the same port. You can try by commenting out the following lines: https://github.com/espressif/arduino-esp32/blob/idf-release/v4.2/cores/esp32/esp32-hal-tinyusb.c#L534-L537 |
hmm i commented those out and it makes windows 10 upset, will manually reset for now
|
could you please try with the latest branch code? |
the 4.2 branch or master? |
ok on the latest 4.2 commit i can reset into bootloader mode but it does not seem to be able to get out of bootloader mode. i have to press the reset button to launch the new code |
about half the time it isnt able to get into bootloader mode, hangs at the Connecting... stage until i press reset then fails
|
I'll look into it further. I hope that one of my boards will fail. TinyUSB is not yet done deal. AMF what is in Arduino is different from what is currently in IDF :) Did it stop resetting the download mid way though? When you enter download mode manually, bootloader can not reset into the app by itself (USB only). You should get a message about it:
|
The other issue is that esptool expects the port to be available when it resets the device, which is not the case once persistence is disabled and that caused the earlier error you were getting. If you want a few seconds and rerun esptool it would go. |
Commenting this line disables any tweaks about persistence, with the exception of the ability to reboot into download from software. |
im no longer getting intermittant errors - once it starts the auto-reset and download it completes (altho it does not auto-reset into the loaded firmware until i press reset) |
esptool will autoreset if you do not enter download manually. You do not need to press the buttons once you flash the latest 4.2. It should reboot fine on it's own |
here is my test code: USBCDC USBSerial;
static void usbEventCallback(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data){
if(event_base == ARDUINO_USB_EVENTS){
arduino_usb_event_data_t * data = (arduino_usb_event_data_t*)event_data;
switch (event_id){
case ARDUINO_USB_STARTED_EVENT:
Serial.println("USB PLUGGED");
break;
case ARDUINO_USB_STOPPED_EVENT:
Serial.println("USB UNPLUGGED");
break;
case ARDUINO_USB_SUSPEND_EVENT:
Serial.printf("USB SUSPENDED: remote_wakeup_en: %u\n", data->suspend.remote_wakeup_en);
break;
case ARDUINO_USB_RESUME_EVENT:
Serial.println("USB RESUMED");
break;
default:
break;
}
} else if(event_base == ARDUINO_USB_CDC_EVENTS){
arduino_usb_cdc_event_data_t * data = (arduino_usb_cdc_event_data_t*)event_data;
switch (event_id){
case ARDUINO_USB_CDC_CONNECTED_EVENT:
Serial.println("CDC CONNECTED");
break;
case ARDUINO_USB_CDC_DISCONNECTED_EVENT:
Serial.println("CDC DISCONNECTED");
break;
case ARDUINO_USB_CDC_LINE_STATE_EVENT:
Serial.printf("CDC LINE STATE: dtr: %u, rts: %u\n", data->line_state.dtr, data->line_state.rts);
break;
case ARDUINO_USB_CDC_LINE_CODING_EVENT:
Serial.printf("CDC LINE CODING: bit_rate: %u, data_bits: %u, stop_bits: %u, parity: %u\n", data->line_coding.bit_rate, data->line_coding.data_bits, data->line_coding.stop_bits, data->line_coding.parity);
break;
case ARDUINO_USB_CDC_RX_EVENT:
Serial.printf("CDC RX: %u\n", data->rx.len);
{
uint8_t buf[data->rx.len];
size_t len = USBSerial.read(buf, data->rx.len);
Serial.write(buf, len);
}
break;
default:
break;
}
}
}
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
USB.onEvent(usbEventCallback);
USBSerial.onEvent(usbEventCallback);
USBSerial.begin();
USB.begin();
}
void loop() {
while(Serial.available()){
size_t l = Serial.available();
uint8_t b[l];
l = Serial.read(b, l);
USBSerial.write(b, l);
}
} |
I'm just trying to upload simple blink sketch:
|
but you do want to upload over USB, which is not the default. USB does require specifically to be turned on (or Serial selected to go to USB CDC). Else USB is not on and you can't just upload to the board over it. |
yeah i have USB CDC selected by default for my variants. it works...most of the time. just not always :) |
I have a couple S2 boards here, one is Saola and the other has only native USB. Both boards work fine, I have them connected and trying upload from time to time hoping for fail :) so far no fail :( I tried random pick of not-so-great cables, those made no difference... still flashing fine. I am on a Mac though... |
do you have access to windows 10 computer? |
I have VM that I can try, though it's so bogged down that I doubt it has anything to do with reality :) I'll think of something |
ok - a windows computer/laptop can be pretty inexpensive - a VM will not work well i think, USB never quite passes through the same way |
Yeah I'm worried about the same thing. Will probably get some Intel Nuk type of small PC. It's good to have anyway :) |
Bought an i3 windows thing. Can replicate the problem :) Will let you know when we solve it and I'll look for a workaround/non-persistent mode |
yay thank you so much! a lot of people use windows and this will be really helpful |
Hi there. Any luck on getting the auto reset fixed. It's pretty painful having to put the board in upload mode and then reset it every time. Thank you, |
Hi All, Is there any update related to this issue, the idf version is working properly with a simple "USB Console" configuration in menuconfig. However, on Ardunio side there is a problem even which crashes the configuration made by esp-idf. |
The TinyUSB library is not working, there is a problem in Windows. As an alternative solution, is it possible to implement "USB Console" feature of ESP-IDF to Arduino ESP32 Core? @me-no-dev |
Any progress or any estimated finish time? |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
bumping stalebot |
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. |
Can you please retry with this sketch and current master? |
on windows 10, it can kick into the bootloader, but it doesnt recognize that the COM port changes. its COM3 using arduino runtime, and COM66 in the bootloader mode
|
hi @ladyada which board did you select? Can you try with the generic S2 module, select Upload through USB CDC and try again? The upload should have probed for the changed port and I do not see it in the log above |
i retried this today while testing #4729 and on the metro esp32-s2, at least, auto-reset is much more stable so this seems to be ok! |
@ladyada How did you achive that? |
you should not need to press the reset to enter the bootloader, but if you do, you always need to press reset to exit it after flashing. This is not Arduino related, but how the USB download mode works on ESP32-S2 |
@me-no-dev seems this issue could be closed? Or do more testing is needed? |
It should be OK to close. No more issues have been reported |
Using windows 10 and Arduino 1.8.13 with ESP32-S2 WROVER, uploading 'blink sketch'
Uploading from ROM bootloader works great. Uploading from "user USB-serial" mode gets close to working!
Sometimes can switch mode and get into the bootloader and then times out later in the process
The text was updated successfully, but these errors were encountered: