-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[AVR] Fix problems with USB CDC auto-reset #6055
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
Conversation
In the USB CDC code to invoke an auto-reset, the magic key location could be restored before it had actually been saved. The sketch would then have a corrupted value at this location. This fix prevents the value from being restored if it hasn't previously been saved.
The state of the watchdog timer is saved during a USB auto-reset and then restored if the reset is aborted, in case the sketch is using the watchdog.
Instead of checking for the NEW_LUFA_SIGNATURE once in program memory and then setting a flag which is used for further checks, a function is used that always checks program memory directly. If a flag is used, there's a slight chance that its location in RAM could fall on MAGIC_KEY_POS. In this case, an aborted USB auto-reset sequence may fail.
An auto-reset invoked using USB CDC is triggered by the port closing (when set to 1200 baud). Closing of the port is indicated by DTR going inactive. There is no need to have auto-reset invoked by a CDC_SET_LINE_CODING command. Only the CDC_SET_CONTROL_LINE_STATE command, which indicates a change in the state of DTR, should be used.
@ArduinoBot build this please |
✅ Build completed. Please test this code using one of the following: ⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-6055-BUILD-660-linux32.tar.xz ℹ️ The |
I like the Idea of having the possibility to use Watchdog with 32u4 based arduino. This patch doesn't work if you call |
Closing as merged in https://github.com/arduino/ArduinoCore-avr |
Address a problem where the bootloader magic key location could be restored before it was saved, and other issues, with a bootloader auto-reset invoked by USB CDC.
Discussed in issue #6033