-
Notifications
You must be signed in to change notification settings - Fork 108
transfer all current feature gating to device specific features #266
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
transfer all current feature gating to device specific features #266
Conversation
Hmm, I'm still at a loss on how to handle all these features... |
I can't see a way to avoid per-MCU features. There's just too many "on this device / group of devices, needs to be done this way".
A quick skim of the other stm32 hal crates
As a side note, the F3 use of the build script made me a bit curious. The build script can be used to enable crate local features, but no dependencies (since dependencies are built prior to the build script running, this does make a lot of sense...). Pretty sure this is not a good idea as it's just a bit outside the box
|
I do have a slightly different idea that, while it may not necessarily reduce the total complexity involved here, could help localise it (+ side benefits). Multiple crates Each module has a relatively limited number of points where differences are encountered (and therefore features required if it was a crate). This crate acting as the umbrella connecting them all together needs only the device features (which then enable the relevant features in the sub-crates) and it would be quite easy to make the API of this crate look unchanged (i.e. modules or crates doesn't matter to a consumer). The number of features at a single crate is reduced to a manageable level (no combinatorial explosion -> testable). Cargo workspaces work extremely well (including being able to use paths for development and versions for published releases so it can all be developed in a single repo without issue) so the downsides that I can see are mostly to do with publishing multiple crates rather than just a single crate and I have not a clue what is involved there. The side benefit I mentioned would be that fracturing the crate will most likely generate some pretty good compile time improvements. For the project I have been working on (a moderate sized firmware), it takes about 100 seconds to build (minimal effort to optimise that). 40 of those seconds are spent waiting for the PAC and HAL crates to chug through as the last two crates, completely single threaded (note that this is just as pronounced when making changes to the HAL. One small change == 20 seconds compiling, and it hampers IDE responsiveness too) Note: I refer to the module as being the crate boundaries here mostly because that's the smallest that could be sensible. groupings of several modules that reuse a common set of features would work as well |
I like this approach here more than the one shown in #261 because it leaves us with a cleaner And I would also like to remind that feature-gating devices also requires setting up alternate function pin mappings. I still think that the approach I have sketched in #253 could be a viable option there because it lists out the mappings per-device instead of per-peripheral. Currently, this is done in the peripheral implementations itself but I already find those hard to read, i.e. hard to verify. |
I would agree that doing GPIO / AFx probably needs to be rethought and probably in a single location. The approach in gpio.rs does not make it easy to identify which device has which pins quickly. Second stage / #253 / changes here? I would agree that this is the better starting point for per device features. It is more flexible inside the code (at the cost of verbosity) and can easily be extended later if reduced verbosity is required. #261 has probably served its purpose so I will close it As far as overwhelming feature sets goes, Documenting it well in the readme, compile error message, and a large comment block / clear naming and separation in the cargo.toml (i.e. device features first, big comment block before internal features, internal features with clear naming convention e.g. prv_GPIOE, prv_GPIOF). Something like https://github.com/rust-lang/rfcs/blob/master/text/1977-public-private-dependencies.md would be really handy for this stuff |
MCU with missing PAC support is marked like `// feature = "stm32l471", // missing PAC support`
e9e1caf
to
2886de1
Compare
@korken89 rebased on master. What needs to happen to close this?
|
Overall LGTM. Lets add all feature gates to the CI though, so we at least test that them all can build the HAL. After that I'll merge this! |
"support" is extremely minimal
d5538cf
to
085f69b
Compare
All of the standard L4 parts added. L4R/S (L4+) are not because support is pretty light and it makes examples quite difficult |
MCU with missing PAC support is marked like
// feature = "stm32l471", // missing PAC support
when PAC support is resolved, feature gate can just be uncommented
This is pretty much the exact opposite style to #261 with no derived / internal features at all. There's enough inconsistencies that I can see this being beneficial, although some of the longer conditions are quite knarly
Missing PAC support is notably problematic, particularly for L451/L471, but several other locations as well. I've tried to leave these in place but commented where I find them