You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should switch to Google's safe-mmio, which fixes both of the above.
The alternative would be sending AArch64 MMIO fixes to Knurling's derive-mmio crate and using that instead (it is used heavily by aarch32 and aarch32-rt already).
Edit: This crate actually doesn't do any MMIO, so the unsoundness and the MMIO load issues are irrelevant.
Switching to safe-mmio would imply a substantial change in the API for the provided registers I presume? Or do you see a way to wrap around this?
If not, I guess the argument can be made that it makes more sense for users to directly switch to arm-sysregs (from the same authors as safe-mmio) than to refactor for a big breaking-change aarch64-cpu release?
The Rusted Firmware team have a specific goal - implementing Trusted Firmware services for Armv8-A and Armv9-A. I see support for AArch64 as being somewhat wider than that so I'm not sure I'd propose that EDWG abandon AArch64 entirely. For example, this crate is important for all the Raspberry Pi 64-bit bare-metal projects (like the one we host). Also for upcoming safety-island use-cases.
However I concede that switching to safe-mmio is a big breaking change. I don't know how to remedy that, and it's also one that svd2rust PACs do not have a good answer for. They just do the breakage and hope people are ok with it.
If you're going to break it, sooner is probably better than later.
When I started aarch64-cpu back then, the choice of tock-registers was a very deliberate one.
I found their API and readability much cleaner and more elegant than all the alternatives at the time, and it therefore was the perfect fit for the Pi OS tutorials.
One alternative would be to hold out some more in hope that the tock folks get the issues fixed sometime soon.
I saw the GitHub issue you opened in their repo where they say they just restarted their efforts on this.
Actually writing code though, yeah, it has its charms compared to the very closure based svd2rust code (and actually that API is also not very discoverable through the docs either).
@jonathanpallant suggestion for or explanation of the "ideal" documentation in an issue somewhere would (hopefully) help put that on the todo list at least (perhaps post a version that fixes the core issues)
So I have a blog post (a big blog post) digging into safe-mmio vs derive-mmio vs tock-registers vs svd2rust. But to start, I've made a very simple UART driver and built it four ways.
I don't know where I'm going to host the docs (pushing to crates.io seems wrong?) but perhaps you could do two things:
Check out that repo and see if my tock-registers example is idiomatic.
Run cargo doc and and try and use it (and only it) to answer the question "How do I make a UART object and configure my UART with it". I actually found it really quite tricky to even write the example, and auto-complete wasn't really helping thanks to having both modules and types with the same name.
@jonathanpallant OK, this is very helpful. First, yes, I would say this is pretty canonical use of tock-registers. No notes.
Second, yes, it's pretty clear from looking at these docs what you mean.
Basically, two things: your documentation of the specific fields in the control register are not present at all anywhere in the generated documentation. For a UART that looks very similar to any other UART, it's pretty self explanatory, but for anything more complicated or any deviation from typical/expected meanings of fields (e.g. I've seen baud rate being derived by dividing or multiplying the value in the field) you would basically have to have have the datasheet sitting next to you to write driver code on top of this, even though your comments basically have (or certainly could have) all of that information.
Next, the general interface for using tock-registers is neither typical, canonical Rust-isms, so things like tab-completion aren't going to help much, nor is it documented for the generated structs themselves. So you basically need to know (and remember) how to use tock-registers when you're using them. You don't get to re-learn it from the docs, or from tab-completing methods.
derive_mmio seems to do much better especially on the latter (documentation itself is a bit thin in general, but how much is there to say, really about "this field is a baud rate").
The discussion from 2026-03-10 WG meeting - the crate does NOT use tock-registers' mmio so it should be safe to keep, although bitbybit and #71 could be interesting follow ups.
Activity
andre-richter commentedon Feb 23, 2026
Switching to
safe-mmiowould imply a substantial change in the API for the provided registers I presume? Or do you see a way to wrap around this?If not, I guess the argument can be made that it makes more sense for users to directly switch to arm-sysregs (from the same authors as safe-mmio) than to refactor for a big breaking-change aarch64-cpu release?
jonathanpallant commentedon Feb 23, 2026
The Rusted Firmware team have a specific goal - implementing Trusted Firmware services for Armv8-A and Armv9-A. I see support for AArch64 as being somewhat wider than that so I'm not sure I'd propose that EDWG abandon AArch64 entirely. For example, this crate is important for all the Raspberry Pi 64-bit bare-metal projects (like the one we host). Also for upcoming safety-island use-cases.
However I concede that switching to safe-mmio is a big breaking change. I don't know how to remedy that, and it's also one that svd2rust PACs do not have a good answer for. They just do the breakage and hope people are ok with it.
If you're going to break it, sooner is probably better than later.
andre-richter commentedon Feb 24, 2026
When I started aarch64-cpu back then, the choice of tock-registers was a very deliberate one.
I found their API and readability much cleaner and more elegant than all the alternatives at the time, and it therefore was the perfect fit for the Pi OS tutorials.
One alternative would be to hold out some more in hope that the tock folks get the issues fixed sometime soon.
I saw the GitHub issue you opened in their repo where they say they just restarted their efforts on this.
jonathanpallant commentedon Feb 24, 2026
I'll be honest, I'm not having a great time reading the docs generated by tock-registers.
Like, given https://docs.rs/aarch64-cpu/latest/aarch64_cpu/registers/MAIR_EL1/index.html, how would someone work out how to read or write the fields within that register?
Actually writing code though, yeah, it has its charms compared to the very closure based svd2rust code (and actually that API is also not very discoverable through the docs either).
alevy commentedon Feb 25, 2026
@jonathanpallant suggestion for or explanation of the "ideal" documentation in an issue somewhere would (hopefully) help put that on the todo list at least (perhaps post a version that fixes the core issues)
jonathanpallant commentedon Feb 27, 2026
So I have a blog post (a big blog post) digging into safe-mmio vs derive-mmio vs tock-registers vs svd2rust. But to start, I've made a very simple UART driver and built it four ways.
https://github.com/ferrous-systems/handling-system-registers/tree/main/tock-registers-example
I don't know where I'm going to host the docs (pushing to crates.io seems wrong?) but perhaps you could do two things:
cargo docand and try and use it (and only it) to answer the question "How do I make a UART object and configure my UART with it". I actually found it really quite tricky to even write the example, and auto-complete wasn't really helping thanks to having both modules and types with the same name.alevy commentedon Feb 27, 2026
@jonathanpallant OK, this is very helpful. First, yes, I would say this is pretty canonical use of tock-registers. No notes.
Second, yes, it's pretty clear from looking at these docs what you mean.
Basically, two things: your documentation of the specific fields in the control register are not present at all anywhere in the generated documentation. For a UART that looks very similar to any other UART, it's pretty self explanatory, but for anything more complicated or any deviation from typical/expected meanings of fields (e.g. I've seen baud rate being derived by dividing or multiplying the value in the field) you would basically have to have have the datasheet sitting next to you to write driver code on top of this, even though your comments basically have (or certainly could have) all of that information.
Next, the general interface for using tock-registers is neither typical, canonical Rust-isms, so things like tab-completion aren't going to help much, nor is it documented for the generated structs themselves. So you basically need to know (and remember) how to use tock-registers when you're using them. You don't get to re-learn it from the docs, or from tab-completing methods.
derive_mmio seems to do much better especially on the latter (documentation itself is a bit thin in general, but how much is there to say, really about "this field is a baud rate").
berkus commentedon Mar 10, 2026
The discussion from 2026-03-10 WG meeting - the crate does NOT use tock-registers' mmio so it should be safe to keep, although
bitbybitand #71 could be interesting follow ups.