-
Notifications
You must be signed in to change notification settings - Fork 101
[RFC] The embedded Rust initiative: Scope #1
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
Conversation
CC @nastevens |
One thing that might be pertinent for this RFC is to define how embedded is separate from OS-dev. Or is it? There's some bleed-over, but OS dev on x86 seems to have slightly different needs than these kinds of devices would. |
A lot of bare metal embedded development looks like kernel development. After all, the reason we have kernels is to bundle up a bunch of commonly used services that we'd otherwise be rolling ourselves. I also tend to use RTOSes in my embedded work and am specifically interested in using Rust there (I designed Brittle to be eventually rewritten in Rust). This is literally OS-dev and embedded work. So I think there's a lot of overlap in the sorts of language/library features we are likely to push for. I do think it's worth separately representing the interest of embedded, as Jorge has done here, because most OS-dev work seems to be happening on either x86 or ARMv7-A processors these days, and in our world we deal with significantly trickier beasts. (24-bit integer DSPs with ones-complement arithmetic, say.) For similar reasons, I'm not sure I understand the inclusion of OpenWRT here. It's a traditional Linux environment with memory in excess, well-served by existing tools. Is it just because they are also interested in cross-compilation? (RaspPi, on the other hand, is a hardware platform that people are doing bare metal development for.) |
To be clear, I do as well, specifically because it can tease out things like
I'm not arguing OSdev needs should be rolled into this group, but more clearly defining how this group is different. |
I think we need to clarify our sub-ecosystems and combine them where necessary:
Also, as someone who does embedded systems work in my day job I would appreciate if we develop this community with an eye towards testing/testability, reliability and as a long term goal I would love to see Rust be at the point where it could be used in a medical device, car, etc. It is a lofty goal maybe, but currently we use C and a large portion of our risk factors come from problems rust could in theory solve with its memory safety. (as a side note I wonder if rust could ever provide similar compile time contracts and constraints as SPARK) |
One of my use cases for Rust is similar to the ones you listed, but doesn't really fit in one of the categories. I plan on using Rust for code which runs under a mainstream OS (eg. Linux) but without linking to libc. The basic idea is that this is code that will be inject into another running process. Because there is already another process in the address space, the code has to work in a very restricted environment ( |
It's certainly relevant to this RFC. It's even in the unresolved questions. The definition of embedded that this document uses is pretty much the one that @cwoodall gave:
and
Under this definition, a Raspberry Pi running Debian hooked up to a wheeled robot and a camera is an Whereas @cbiffle's definition of embedded seems to only include bare-metal development to me. I think of the devices in |
I think embedded has at least two specific differences from OS-dev:
|
BTW, this is, of course, mucky rhetorical territory. Many people would consider Android an embedded system because at the end of the day, device vendors have to customize it to their particular chipset and board, while many others (like me) would consider it general-purpose because the majority of the system is basically constant across deployments. Even a browser is kind of an operating system in a certain light. At the end of the day we're all just playing around with bits instead of getting real jobs, so it's obviously more up to what folks want to focus on. |
I think the main cross-cutting concern for "embedded systems" is that of dealing with hardware. The method for interacting with hardware resources can be decomposed into a few basic categories (as I see it). These categories are a little different from what has been previously proposed:
Much of the work I have done professionally has been in the userspace embedded (in Rust and other languages) and Linux kernel development (no Rust OS dev for me yet). I have done some work on bare metal (including work on Zinc) as well. From my perspective I don't think the differences between distros like debian/fedora on a RPi and things like OpenWRT/Yocto on custom hardware are too relevant to the language story for rust embedded. There are important projects that need to go on to make Rust easier in various environments (e.g. https://github.com/meta-rust/meta-rust / https://github.com/rust-embedded/meta-rust-bin) but that concern seems orthogonal. |
cc @jcsoo -- I think this would interest you. |
I kind of agree with @alevy about the risk of getting lost in semantic weeds here. I did not intend (as @japaric noted) to include only bare-metal, since I tend to use an RTOS. Let me approach this from a different direction: here are some classes of programs that may be worth our consideration. This is not intended to be exhaustive.
Finally, I would like to call attention to this: Having to rely on unstable features in Rust currently makes hermetic, reproduceable builds difficult. The need to use |
Thanks @posborne. I found your comment, and also the others, very insightful.
I feel that this is key here. But feel that we should go a step further and say "dealing with hardware as directly as the underlying kernel/OS (if any at all) allows" so high-level things like "using TCP" can be filtered even though they ultimately also "dealt with hardware" (e.g. an Ethernet port). I also want to point out something I realized which seems obvious now: You can write "non-embedded" Rust programs targeted for embedded systems. A good example is writing daemons/services for OpenWRT devices, which I believe is or would be the typical use case of Rust, that don't deal directly with "hardware" but instead use high level abstractions like unix sockets. I think it ultimately boils down to whether we want to focus on "Rust on embedded systems" or "embedded development with Rust". Oh, and I haven't addressed OSdev up there but I think that "embedded" ultimate goal are applications (but writing libraries, say a HAL, for those applications is also embedded development IMO) whereas OS dev is about, well, writing OS services. Given that OSdev also involves dealing directly with hardware (at its lower layers?), the question would be if their problems are similar enough to the ones of embedded developers so we can all share this medium. I feel that ("traditional" x86/ARMv7-A) OS devs should be allowed to participate here but their OSdev specific problems, I don't what those are, should be discussed elsewhere.
I tend to agree. What does feel relevant is that typical OpenWRT/Yocto devices have small memory footprints and still want use the IOW: Yes, it doesn't matter whether they run OpenWRT or Debian because both use share same Linux API but I still find useful to separate these "userspace embedded" devices in two as the ones in the low-end don't face the same problems as the ones on the high-end. |
@cbiffle That's an interesting approach. Perhaps we can define the scope in terms of the scenarios developers usually deal with rather than in terms of the devices developers may target. Here's how the scenarios you described fit in the scope defined in the RFC and on which category they fit:
It'd be interesting to know if the x86/ARMv7-A OS devs also face scenarios similar to the ones you listed. |
I'm using the term "program" quite generically, deliberately, to describe a computer program. This might be a kernel, application, driver, loadable module, etc. Many OS kernels also choose to avoid dynamic memory allocation for predictability under load. (RTOSes like Integrity, but also systems like L4/seL4.) As do many avionics systems, for the same reason. In cases where it's avoided for principled reasons it usually is due to real-time constraints; some shops avoid it for other reasons. OS drivers tend to directly control hardware, as do some userland applications (e.g. through The other class of application that often avoids dynamic memory allocation and has an intimate relationship with the processor is games. The requirements of a high-end game have a lot in common with real-time embedded applications, and we will probably wind up aligning with the game community on some of our desires. Neither I'd be careful using |
There's already been a lot of good discussion of the different types of qualifiers for what make an embedded system from @posborne and @cbiffle, but one thing that I haven't seen yet is concrete recommendations for naming sub-ecosystems. I would like to propose the following: utilize a "tag" system as opposed to over-arching categories. There are always going to be designs that include multiple characteristics. For example, a hardware driver may utilize the heap or it may not. Or it may provide a hardware abstraction layer or it may not. Using tags means that multiple characteristics may apply to a piece of code. Here are my proposed tags, open for some serious bikeshedding:
As an application of the tag system's use:
I doubt I have captured all the possibilities above, and would love to hear other ideas. |
On a separate topic: @posborne and I have been maintaining the rust-embedded org on GitHub. I think that this initiative would be a great fit for that org if other people are interested. We are open to adding other admins as appropriate. On the PR front, I have purchased rust-embedded.org, rust-embedded.com, and areweembeddedyet.com. Right now all three point to a parking page on github.io. If someone with some web development chops was interested in putting something on those, that'd be great! This could also be an opportunity for another RFC defining what content we'd like on those pages (blogs, how-tos, link rolls, etc). Note: the DNS records don't seem to have propagated yet for the new domains... hopefully by the time you're reading this the links are active! |
Lots of great discussion here! I've been spending a lot of time recently working on something like this in the IoT space, and getting Rust to the point where it is a viable choice (and someday the preferred choice) on the device side seems hugely important. I'll offer up a slightly different perspective focused a bit more on the different parts of the community that are impacted. Language - These are improvements and changes to the core language that are especially important to embedded environments - for instance, the ongoing discussions on memory allocation, intrinsics / volatile, code generation for floating point environments, etc. There should be a place where the embedded community can see what's going on in the various RFCs and collaborate on proposing, shepherding, and implementing them. Tooling - There is an enormous amount of tooling that needs to be developed and integrated so that the experience of developing in Rust is as good as or better than any other language environment. This in itself is really two related sub-problems: for existing Rust developers, it should be as easy to target and deploy to embedded platforms as it is to desktop / server platforms, and for existing embedded developers, it should be as easy to use Rust as it is to use C / C++. Libraries - A lot of discussion has been focused here because everybody wants to use well-designed, well-implemented and well-tested code instead of writing things from scratch. Here I again see two related sub-problems: first is making sure that there are great low-level libraries of the type needed for embedded applications (e.g. hardware access, filesystems, network stacks), but also making sure that enough general-purpose libraries (e.g. data structure, crypto and high-level network protocols) are implemented such that they can be used successfully in constrained environments. Runtime - This area includes everything from simple platform-specific bare-metal frameworks to multi-platform RTOSs to Linux-based environments of varying complexity to other open source and commercial operating systems. Often this is the first and biggest decision to make after the choice of hardware platform. There's definitely some amount of overlap between these different areas - for instance, Runtime can't be completely separated from Libraries and Tooling. However it seems to me that for the most part these groups are distinct and require different approaches and people, and within each area there is plenty of room to identify and prioritize specific goals. Feedback appreciated! |
Even though it’s very popular and recognizable I’d prefer to avoid using the term "Arduino" as synonymous to micro-controllers. This name can refer to a company, a trademark, an IDE, a family of hardware, a physical layout of pins compatible with such hardware, a C/C++ API, an implementation of this API, and/or libraries that depend on this API. In any given micro-controller project, only some of these or maybe none of these might be relevant. |
I agree with this 100% @cbiffle and @SimonSapin Some suggestions for alternative labels
|
I think |
I generally agree with the recent comments above and I'm really pleased with this discussion so far! @nastevens 's tags seem descriptive and reasonable. @jcsoo 's areas also seem appropriately descriptive. I think we should forge ahead using terms like this to discuss what we are doing without necessarily limiting our approach. I might suggest that we also consider, and perhaps enumerate in a doc, "allies" in non-embedded fields who are likely to be pushing on the same parts of the language/runtime/ecosystem as we are. For example, game developers, and non-embedded OSdev. Nit: @alevy , virtual memory usually distinguishes an application-level processor, but external memory shouldn't. I'm personally not convinced that "microcontroller" is descriptive enough to serve as anything other than a placeholder in discussion -- i.e. we should not be making decisions based on whether something makes sense or does not make sense for a "microcontroller." It is more precise than "arduino" though. |
I like the idea of using tags. I think it makes a lot of sense to use them for the issue tracker and also to categorize crates. But, IMO, for documentation having a larger category like As for the tags themselves I like most of the ones you have listed except for That brings me to the next point: If we are going to use a more rich tag system, we should group some related labels. For example, Also, about this:
I think I have opened #11 to discuss this idea of a richer tag system. Please comment over there to reduce the volume of comments in this thread. |
I think your idea of Language, Tooling, Libraries and Runtime can be integrated with @nastevens Language issues are always "upstream" issues. Tooling issues can either by "upstream" (e.g. Cargo) but can also be "community" issues like svd2rust (#10)
This is interesting. We must not only concern ourselves with crates that we, as the embedded community, create but also about being able to integrate crates from the general Rust ecosystem. This last part could be a simple as this crate just needs an extra Also, I'm wondering what should we call these issues about integrating with crates from the general Rust ecosystem. They don't quite fit in
Right, this sounds like we should have/form teams focused on these different areas; just like the Rust teams. Some of these teams will have to work more closely with the Rust teams, for example our |
re: rust-embedded org. I'm favor of moving this repo under the org though I'm not quite sure what to Another advantage of having an org is that we can create teams around specific issues like tooling, Is everyone else in favor of moving this repo? You can just 👍 this comment. |
embedded-rust/rfcs might be another option. |
OK, seems everyone's on board, or at least nobody has raised any concern so let's go ahead with this. @posborne do I just hand this repo to @rust-embedded and then you take it from there (the rename to rfcs and so on)? |
Hi @japaric I have sent you an invite to the org as a co-owner. Once you accept, this should allow you to move the repository under the settings for this repository to the new location. That will retain watcher, move everything, add redirects, etc. Strictly speaking, adding you as an owner on https://help.github.com/articles/transferring-a-repository-owned-by-your-personal-account/ |
Thanks, @posborne. I've moved the repo and renamed it to rust-embedded/rfcs. I've also created a @rust-embedded/rfcs-team; I'm the only member for now but I hope we'll have more members in the future. |
Announcement: I've created a #rust-embedded channel on Mozilla's IRC network. Join us! (if gitter's not your thing) |
I just wanted jump on and quickly say thanks to @japaric for the invite. I'm very keen to help out - my end goal is to stop using C for writing embedded code at work and currently that's a difficult sell. |
Hope this doesn't count as spam, but as new information becomes available for rust on embedded I invite everyone to contribute to this awesome-list! I hope it will promote people just looking for tools to take a serious look at rust on embedded and maybe also act as a way to guide people towards some of the high quality resources out there as they are developed! https://github.com/embedded-boston/awesome-embedded-systems#rust |
Wow, this was opened only 8 months ago and the landscape has changed dramatically. Should this RFC be revised? |
I think we can safely close this PR, as it has been superseded. Closing this PR, please let me know if anyone would like it reopened. |
Hello!
I'm a Rustacean that wants to see Rust become a great language and ecosystem for embedded projects (but I'm sure I'm not the only one!).
This repository is an attempt at mobilizing efforts towards that goal and this RFC (rendered) defines the scope and contents of this repository.
I'd love to hear your thoughts about this RFC. Also, I'll soon be opening more issues about the "obstacles" (term defined in the RFC) that I see right now and it'd be great if you can participate in the discussion about those as well.
cc-ing people that may be interested. Apologies if you are not! You can unsubscribe from this issue by clicking the unsubscribe button on the right side of this page.
"Arduino" sub-ecosystem
@SimonSapin
@alevy
@cbiffle
@cwoodall
@hackndev
"OpenWRT" sub-ecosystem
@Manishearth (as a proxy 😄. IIRC, you know people who are interested in Rust+OpenWRT)
@kteza1
"Raspberry Pi" sub-ecosystem
@posborne
Also, cc @alexcrichton, @aturon and @nikomatsakis. This repository could become a valuable source of information about the needs of embedded developers.