-
Notifications
You must be signed in to change notification settings - Fork 61
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
Moving to embassy-nrf and proposed changes #125
Comments
What, in your view as a maintainer, should the scope of the Is it one Rust board support crate among many, for people who want an nRF5x dev board and happen to have a micro:bit for that purpose? Is it for people interested in the educational purposes the micro:bit was designed for, and happen to think that Rust is a good language to use? |
That's a good question, and I would like to hear what others think too!
I think probably closest to the latter, but with a twist that it's for people new to Rust itself as well, not only for introducing microcontroller programming. I view a board support crate mostly relevant for the use cases where you are unfamiliar with the hardware and it can simplify the experience since it uses terminology close to the board documentation. Since we have crates.io in Rust, the traditional 'all the code you would need to use the board' is less useful because adding dependencies and new crates is super easy. And if you are doing a production firmware at a company, you're most likely not going to be using the microbit. Probably you're already using the Nordic devkits for prototyping, and then you have your own PCB etc. If my vision is in conflict with existing uses of the crate, I'm fine with that and will not 'force my world view' in any way. This is why I raised this proposal now to see what others think. |
Here are my opinions:
But:
Because:
|
Thanks for sharing!
Since existing code is primarily mapping a Board and other types to a HAL, yes it would most likely be replaced. It's true that existing users of the microbit would probably need to update their code for it to compile. We could keep the type names to make that transition easier, but I think naming pins after the microbit docs is more intuitive considering the official documentation for the board.
I want to emphasize that there is no runtime that would be added to the microbit crate, it would only be using the embassy HAL (embassy-nrf) for peripherals and pins, which is comparable to nrf-hal, but with both blocking and async support. The runtime (embassy-executor) is something that could be added per-example (i.e. many examples would remain without a runtime, others might have it added depending on what makes most sense). The nrf-hal maintainer issue remains unsolved though even if the above PRs are merged. My scope is more long term though, and I really think the usability of the microbit could improve with these changes. |
Given a choice between rewriting most of the code in this project, and starting a new project (which could of course copy in any code from this one it found valuable), what are the advantages of the first option? I think the advantage of the second option is that it makes it easier for people who are currently using this crate to choose when they want to switch to the rewrite. |
This is already the case, https://github.com/lulf/microbit-bsp. I'd like to unify these into one because I think there are advantages to joining the efforts as you pointed out initially, especially since it would remove the dependency on the unmaintained nrf-hal.
Maybe there is a path forward where we can keep the disruptions at a minimum? I'm will create a PR trying switching the HAL only, no other changes than necessary, to show what it would look like in practice and help the discussion further. |
I don't know how on-topic this is but I've been programming micro:bit with MicroPython and since I'm also learning Rust, I wanted to experiment with running Rust on this platform. I have close to zero experience with embedded apart from tinkering with the micro:bit. For my use-case, @lulf 's crate seems to be way more ergonomic since AFAIK (looking at examples) this one does not implement the more high-level stuff like writing text to the display or abstracting away details of the sensors. My use-case is "idea to working code as soon as possible" and then if I want to dig into details how the abstractions work, I can. For that it seems way more useful to have interfaces for micro:bit similar to the MicroPython one. I know that there are other crates for stuff like writing text to the display (microbit-text) or crates for different sensors but for me the selling point of micro:bit is that I don't have to spend hours trying to make different sensors and libraries work together, it "just works". I suspect that mine is a common opinion among people using micro:bit. |
I think "something like micro:bit MicroPython but for Rust" is a good goal, and that's the sort of project I'd like to contribute to. I agree that that means it would be better to have all the bells and whistles in one project. I think it would also make sense for the project to be "opinionated" (in particular, to pick a "runtime" to use). And quite likely it should take over one or more of the peripherals (eg timers) for its own use, like the C++-based runtime that most other languages use for the micro:bit does. But it's also reasonable for people to want something that's less opinionated, and is basically just a "Board Support Crate". In particular, the rust-embedded "discovery book" currently uses this That's why I think it might be better to make a clean start rather than changing the direction of this project. NB the only reason that |
Thanks much for all your feedback. Please don't start merging external crate source into the project. Linking them is fine. I think this crate is a good basis for a more full-featured one, if one can figure out what the API should look like and what functionality would be supported. I am working on a fork of There's also Embassy, if folks can put up with some async/await in tutorials. |
I'm not sure what/which external crate sources you're referring to here?
I've made a preview PR porting the v2 board and a few examples to embassy here #130 . There is no async/await required for embassy. |
No for embassy-nrf, but yes for microbit-bsp. I really need to look more closely at your PR and try it out: give me a day or two I think. |
For "external crate sources", I was responding to @mattheww's
I 'm not sure this is ideal? |
The other thing visible on crates.io depending on (I think the only thing of any value left in it that hasn't made it to this project or If there's no appetite for integrating the code any more closely, I think it still might sense to move those crates into this project now that it's a workspace, so that people can modify them without needing me to do it. |
Ah, I had missed that you wrote these crates. Apologies and thank you! Yeah, in that case I think it makes sense to move these crates into this workspace and maintain them here. Folks may still want to use them without the BSP crate, so maybe not merge the source into this crate. I for one would love a cleaner button-handling API for the MB2 BSP. I started to write a thing but wasn't happy with it. Let me know if I can help somehow with yours. |
The buttons stuff is visible here. This was all in the micro:bit v1 days. If I don't get round to doing anything with it I'd be perfectly happy if anyone else wants to copy it out and work it into shape. |
If I may add my personal opinion to this discussion as a complete newbie to embedded programming (I do have experience with rust for a while though): Especially given the nature of the micro:bit as learning device I think the idea of having a rust-equivalent to the MicroPython environment as Having a Motivation: |
@lulf I wanted to ask on the state of this task. Is there a publicly available branch I can test? |
I think we can close this issue though, since the consensus is to keep this crate as is. |
I recentliy volunteered to work on moving this crate over to using Embassy HAL (see nrf-rs/nrf-hal#432 (comment)), and having spent some time going through the existing crate and comparing it to my own experiments in microbit-bsp, I'd like to propose some specific changes that I think improves the usability for what I believe is the primary audience: people new to Rust and maybe also embedded.
the embassy HAL allows (for clock setup).
probe-run
withprobe-rs
.There are more things that would be great to sort out, but I would be interested to know what others think of the above fundamentals first.
The text was updated successfully, but these errors were encountered: