Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves https://github.com/arduino/Arduino/issues/3675
This also saves us tons of flash and ram for the Leonardo if the CDC Serial/HID is not used.
Example: 3724 flash, 135 ram (with Serial.begin(0)) vs 578 flash, 9 ram without
The "downside" is that you need to reset the Leonardo if no USB-Core was compiled. But with the new Serial touch waiting this is not a problem. Maybe an additional note like "If your Leonardo board does not show up, reset it NOW." could easily solve this.
This PR would save us a lot of flash + ram AND USB caused problems (like unneded time consuming USB ISR Interrupts).
Edit: I updated the PR this way:
The positive thing is that newer bootloaders are more save (Bootkey position, all registers cleared) and compile smaller (with this PR). And if the old bootloader is used nothing changes.
Only for newer bootloader
There is also a problem that if no USB-Core is used, the Led blink example wont work correctly with the current bootloader. This is caused by a bad coded bootloader which does not fully reset the MCU via watchdog and leaves the USB-Clock configured. You need a workaround to fix this (not included in this PR yet). HoodLoader2 already includes this (if you want to see it in action, v2.0.5 available for 32u4 as well!).
The Workaround is not so easy to add in this flexible setup. In my case I let the user choose with/without USB-Core. Thatswhy I only enabled it for fixed bootloaders to avoid flash consuming workarounds. So old bootloaders still work, but newer can use this feature.
Updating the bootloader can fix:
So a new bootloader would really solve some issues and makes sense to me. Especially clearing all registers via watchdog and using a proper BOOTKEY position can solve unexpected problems. (if you code a new bootloader make sure to use the lufa master, since it contains an important USB-HUB fix.)
You then could provide a simple bootloader burning sketch to flash the new bootloader with a 2nd arduino (to avoid confusing about ISP, capacitor etc).
Questions
cc @facchinm