-
Notifications
You must be signed in to change notification settings - Fork 68
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
Enable and fix additional warnings, switch to -O3 and LTO. #363
Enable and fix additional warnings, switch to -O3 and LTO. #363
Conversation
…limits warnings as they are usually just noise.
Thank you for your contribution! |
Thanks for your contribution! Unfortunately, after flashing your branch, my UHK doesn't enumerate anymore over USB. Any ideas why? I'm running gcc 9.3.0 |
Interesting. That's almost certainly the LTO -- it works for me on GCC 10 and in my experience has been OK for embedded ARM since GCC 8 or so, but it does depend on well defined behaviors of the code. It's possible that there's some latent undefined behaviour in the Kinetis SDK or just a bad interaction on the version you have installed. In that case, given the large amount of flash available, it's not worth trying to troubleshoot and can be re-disabled. The other changes in this branch should still be valid. |
LTO has indeed caused the issue and removing it made the firmware work with gcc 9.3.0. We can enable LTO later when newer GCC versions are more widely available. |
…tings_reloads Fix address settings reloading, and consequently dongle leds updates.
This is more of a RFC than an actual request to pull as-is. I'm just getting acquainted with the project and code.
This is a roll-up of several minor changes:
Switching from -O3 to -Os. Most ARM embedded platforms don't really gain a whole lot from -O3 other than code bloat, and generally any hot loops can be marked as such with attributes, or compiled with alternative settings.
Enabling Link Time Optimization. As long as we're OK targeting modern GCC installations, i.e. GCC 8+, LTO is quite stable for ARM Cortex M. This greatly reduces the code size and helps inlining across translation units, leading to smaller and faster code.
Right V2 firmware with -O3:
Right V2 firmware with LTO and -Os:
Enabling additional warnings. Fairly self-explanatory. I've disabled some of the nosier ones that are enabled with
-Wextra
and patched the code to fix the new warnings that were generated.Add missing
const
to pointer params. Just a few instances I noticed where functions that were not expected to alter their pointer arguments pass into them, which I've now altered to be passed as
const T`.I've built and tested the repo on my local Drone CI, and built/flashed my new V2 unit with it without any apparent issues.