-
Notifications
You must be signed in to change notification settings - Fork 187
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
Develop resources for Rust integration with RTOSs #62
Comments
The main components to getting Rust working with an existing RTOS are, imo:
I can get my ChibiOS repo cleaned up (it's rotted quite a bit) if we want something to point to. I've never used FreeRTOS in this way, but there are a few repos out there. I feel like my approach (a more "pure" one that only uses build.rs to build ChibiOS as a static lib, and then bindgen for bindings) is easier to understand than some of the more complicated approaches I've seen elsewhere, but comparisons may be educational. |
63: Add links to interop issues r=therealprof a=adamgreig See rust-embedded#61 and rust-embedded#62. Co-authored-by: Adam Greig <[email protected]>
A similar issue to the inline functions are the "polymorphic" C APIs which, for reasons of size optimizations, rely on one of macros, inline functions and non-inlined functions to implement any given public APIs, depending on the OS configuration. If the inline functions are difficult, but solvable, for macros, I would consider them extremely difficult to bind to, without maybe doing some analysis of the RTOS interface sources, before the preprocessor. OTOH, I am thinking that for such cases, since typically the Still, I am unsure how we could make sure the Rust caller code of an RTOS API would be identified before the generation of the object files, so Rust bindings can be correctly generated for all the RTOS APIs implemented as macros. |
There is a working RIOT-OS integration library that can become a candidate for inclusion here once it's matured a bit further and gathered some reviews. Build system integration is interesting there because a typical RIOT application receives quite some configuration in its Makefile, and the RIOT API changes subtly in response to that (additional fields in structs, presence of functions etc). Static inline functions are a pain point as with other OSes. |
@chrysn I suppose RIOT has similar optimizations and macro abuse as the ones listed by me, right? |
I'd call none of them abuse, but there are some complex areas. Preprocessor functions are not so much used for a polymorphic C API but more for triggering various other optimizations (many of which, in my impression, would be moot if LTO were universally implemented, but AFAIR some of the targeted compilers can't do that), eg. around the conversion of times to ticks. On the other hand, most workarounds I do are for |
To clarify, by "polymorphic API" I mean something similar to what you said, the API signature will look the same, but it is possible the types are defined differently, some function calls might be turned into function-like macros or inline functions. All of these are problematic for any bindgen-like tool and have to be taken into account. |
Zephyr is another rtos that is getting popular rust support for it would be nice. |
This repo uses freertos-rust to run FreeRTOS tasks written in Rust. |
I have just started playing with doing this on top of Zephyr. Basics of building aren't too difficult, so I started with log. There is a bit of a semantic mismatch between rust's logging and Zephyr's logging system, mostly because the Zephyr one is built around C-style format strings. |
In regards to Zephyr, this project looks really promising: https://github.com/tylerwhall/zephyr-rust |
Could you also consider ThreadX for the book, please? Thanks a lot for all your work. |
I think we should have a wrapper to bind the CMSIS-RTOS2 api. |
Related to #1.
We won't block the book on this, but it would be great to have some examples to point at and documentation around integrating Rust with common RTOSs. We can collect links and resources in this issue, and add them to the interoperability chapter.
Suggestions for RTOSs to consider:
The text was updated successfully, but these errors were encountered: