-
Notifications
You must be signed in to change notification settings - Fork 99
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
RTOS implementations / bindings #45
Comments
I think there are two pieces to the RTOS story - the API and the implementation(s). The first implementation might be a FreeRTOS wrapper but I'd love to write a Rust port of it in due course. The API would involve:
|
In this context, can you go further into what you mean by static and dynamic? Do you mean static creation before starting up tasks vs. creating / destroying these objects within tasks? Looking at your list, I wonder how far it is possible to get using a SPSC queue supporting zero-sized objects as the main communications primitive. |
In brief, yes. Sometimes you know the resource requirements at compile time - six threads, six queues, one event group, etc. Allocating static space means you don't take up heap/pools. Sometimes you also want to spin up background threads, or bring up a new queue for a test that you later want to delete. It's good to support both models. I imagine the former would use an RTFM style macro. |
The CMSIS-RTOS (v1, v2) APIs might be a useful reference too. In theory a wide range of RTOSs implement them, so Rust bindings to that API would allow you to plug in multiple RTOSs under the hood. This includes FreeRTOS: https://github.com/ARM-software/CMSIS-FreeRTOS In general the CMSIS RTOS APIs provide access to all the common and standard RTOS stuff, but many RTOSs have a few extra things on top that might require additional/special-cased bindings. Another good and open-source (though GPL only) RTOS for Cortex-M devices is ChibiOS which I'd love to see/write Rust bindings for! |
Really like the idea of a It seems to be falling out of favour but just to chime in, I think predictability is critical if rust is going to be taken seriously for embedded, and hopefully that could be reflected in these APIs. Static allocation, Mutexes and primitives that work from ISRs, NO runtime exceptions etc. (which are all features of most of the modern/iot rtos's). One of the reasons we struggle to use c++ is that while it's possible to write safe embedded code in c++, it's not obvious / a chore to get it right / remember what's ok and what's not. |
There seems to be agreement on the direction of a standardized RTOS API / traits. Could someone |
If we select a target RTOS to bind against (seems like FreeRTOS or cmsis-rtos are the frontrunners), I would be happy to apply the same techniques I used with https://github.com/jamesmunns/nrf52dk-sys. A word of warning: Most C based project rely HEAVILY on compile time macro settings to change configuration settings, and Cargo/Rust does not really have the same kind of mechanisms to deal with this, as the |
I saw this FreeRTOS bindings on reddit today. I don't know how it maps to what you folks have in mind. Also, I have turned this issue into an RTOS-only discussion since that's the multitasking model that has been discussed so far. |
Discovered drone today: |
Hi. Has there been any progress on this? It has been a while since a post in this issue. |
is there some graceful ways to comm with threads by rusty, in RTOS such freertos, threadx |
It depends on the RTOS of course, but most of the native rust RTOS' have similar mechanisms to ThreadX/FreeRTOS. Maybe take a look at |
I was actually looking for something like this and would love to work on it. I am not sure what the actual RFC procedure is though. Would love to get some inputs. Also I think there are more parts to the RTOS ecosystem than just basic tasks, timers and synchronization, but we can definitely start from there. |
Closing as part of today's issue triage. A number of RTOSs have Rust bindings (see https://arewertosyet.com/), but in the years since this issue was created it's turned out that alternative frameworks such as RTIC and Embassy are also viable for embedded Rust and have become very popular. In particular, I don't think we need standard RTOS traits now - some RTOSs can implement std (Espressif do this, for instance), which is probably the best set of common interfaces imaginable, and for Embedded-specific things, embedded-hal has become popular and widely used. |
Parent issue: #55
Place to discuss RTOS implementations / bindings.
There's some agreement on making some standard RTOS API (traits) and then have the implementation adhere to that.
TODO
Define tasks to tackle
The text was updated successfully, but these errors were encountered: