-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Made USP-API included flexible #3679
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
d0a0b06
to
35abe4f
Compare
35abe4f
to
7e3b59a
Compare
7e3b59a
to
043f3de
Compare
To enable this function you could use arduino/arduino-builder#15
May anyone review this PR?
With arduino/arduino-builder#15 one could dynamically disable the USB-Core if needed. This keeps the USB-Core for beginners but can be still disabled also for leonardo boards. (The problem with the unfixed USB Clock bootloader is still there, but professional users should be aware of that)
CLAassistant
commented
Apr 9, 2021
CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
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