-
Notifications
You must be signed in to change notification settings - Fork 33
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
RFC: A Split HAL #56
Comments
How granular should the new HAL crates be? Today's RAL and HAL have a feature-flag per chip variant; Alternatively, we could do something similar to the stm32-rs project. The team has a HAL per family and Cortex-M types. Then, they require feature-flags to describe the specific chip they're using. The approach is similar to our current approach in that they require feature-flags to describe devices. But, they have smaller, more granular HAL crates for different chip lines. It might translate to Any thoughts on project organization? Regardless on how we require feature-flags, I'm partial to a single repo with a top-level workspace, rather than multiple repos. The HAL crates will probably be developed together, so having them in the one repo will help us coordinate changes. |
I like the idea of grouping things together when possible. The 1064 is seemingly a different beast than the 1061/1062, its probably the oddest duck in th the 106x set. There's also the really odd one part that has a DSP alongside it, which I don't really intend on supporting myself. The RAL script does some family segmentation already, but it could probably be changed to be more specific to the imxrt series as we know better what the splits are. I'm all for the mono-repo with workspace as well. I think it helps really keep things in sync, especially since I believe we will continue to create common drivers for all these chips, with different instances per chip. I still want to try to maximize code sharing. |
I think a first step is making the current imxrt-hal crate the imxrt106x-hal crate with feature flag gates for the mentioned components when/if they get added. The second step would be creating a imxrt101x-hal (my task) and moving various common macros/drivers/etc to a common imxrt-hal which they both would depend on. |
Seeing how the new new is to have drivers in crates ala imxrt-iomuxc, I'm thinking it makes sense to have a driver per crate, which inevitably all depend on the associated Pin types provided by iomuxc. I really like the new direction @mciantyre has pushed this! |
I started this since I finally got probe-rs working with my imxrt101x board, $10 for 500MHz is hard to beat! They have since raised the price to $40, still not too terrible considering it has a builtin debug probe |
So my first goal is to have a imxrt101x-hal and imxrt106x-hal, where the only things I care about for imxt101x-hal are iomuxc, ccm, and lpuart working. I'm experimenting with a few ideas, one of which is to stop the imxrt-ral split between chips such that...
Some interesting side notes in attempting this so far...
|
Sounds reasonable! With goals for common register blocks and optional feature flags, it sounds like we're moving away from a "split HAL," and more towards a "unified RAL." Is that the thinking? Not requiring feature-flags would be a boon for library development. Then, when users are ready to compile their binaries for their system, they can enable a chip-specific feature without too much effort.
Looks like it's missing from the 1021 SVD. I confirmed that the |
I'm still thinking the end hal is a split, but the end hal effectively needs to do only a few things, define the number and kind of peripherals into a |
Reason for the Split
TODO
Questions and AnswersQ: Should we change imxrt-ral so there's only one device family, but multiple RegisterBlock types when differing devices exist? Q: How should we shared doc comments to avoid copy/paste insanity? Q: How do we write a common crate used against a variety of hal's? |
One of the previously stated values of a spit HAL was to support documentation, so I'd like to get your thoughts on how that will work. In #89, we're changing documentation examples from
Are there other approaches we could take that don't have these trade-offs? It doesn't look like the nrf-hal has an approach for documentation examples, as the crates do not yet have documentation examples. Suppose I'm a user who wants to design a higher-level crate that works across multiple i.MX RT chips. The
Is there another way to support external users who want to create libraries for multiple chips?
Concretely, this would mean Semi-related: we may want to change our chip naming schema to more closely match the reference manuals and product identifiers. I proposed the "x" suffix back when we started discussing split HAL, and then I used it in the |
After better understanding the differences, I'm with you on ditching "x" suffix, as each chip really is different enough to warrant its own feature flag I believe. So I'm looking to the nrf-rs project and their nrf-hal repo in particular as the model to follow I've updated the Q/A section with answers I think help resolve most of the questions, if I missed something let me know |
Links back to examples works for me. We lose the benefit of documentation tests that make sure our examples are relevant. It's on us to make sure these links don't point to stale or unreleased examples; a crate release from 5 years ago will need to keep pointing to 5 year old examples.
We've cited reasons why required, narrowly-scoped feature flags aren't the best. This sounds like we're putting our current problem on users who want to do the same thing we're doing: create drivers that work across chips. If we're all trying to build drivers that work across these systems, shouldn't we help the community figure this out, without having them adopt an approach that we tried and didn't like? |
If we expose the common crate as a published crate, does that solve most of the issues? imxrt-uart-log would depend on imxrt-hal-common, and a feature flag would need to be set so the types match those in whatever chip hal your using. Is that workable? |
I think it would be workable. Sorry, I might be confused about the goals of the common HAL. When I see a reason for splitting up our crates, like
I'm interpreting that as "we only need conditional compiles when there's a drastic difference between chips." For UART and DMA HAL drivers -- the peripherals needed by
Can you clarify why I need feature flags when designing against the common HAL, particularly when consuming a UART and DMA driver API? |
Unless you are only depending on trait types that are always available from the HAL without a feature flag involved, the concrete types depend on RAL types which vary over the chips. |
It sounded like a unified RAL could solve that. I want to make sure we're on the same page with what a unified RAL, and the common HAL, might look like. I linked to my experiments below. https://github.com/mciantyre/proto-hal Could you let me know if this meets your thoughts on how this could work? The experiment seems to show that, with some restructuring to our dependencies, we should be able to create general crates that use the common HAL without required feature selection. |
A unified ral can solve most of the problem I agree, in looking at the proto-hal you have, that is indeed what I was hoping to accomplish! |
I've been mulling this over for awhile now, and really I'm starting to think...
We should have a HAL crate per chip, that depends on a common HAL (imxrt-hal) still.
My reasoning really comes back to the documentation part of the HAL, along with perhaps not wanting to rely too much on conditional compiles after all, at least at the end user supplied HAL crate.
So imagine the current HAL crate remains, but the Peripherals object that is built ends up in its own imxrt1062-hal crate which hides the need to set the feature flags up from end users.
The text was updated successfully, but these errors were encountered: