-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Experiment: Devicetree and device driver access in Rust #76199
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
a0611a1
rust: Initial config option
d3zd3z 79eb8a2
rust: Simple main wrapper
d3zd3z 6646068
rust: Basic `zephyr` crate
d3zd3z 62af97a
rust: Add cmake support for building rust apps
d3zd3z 775a3a0
rust: Simple rust hello_world application
d3zd3z 564d96d
MAINTAINERS: Add Rust to maintainers file
d3zd3z 191eca3
rust: Move Kconfig bool values into crate
d3zd3z 98f0291
rust: Make Kconfig values available to Rust code
d3zd3z 62770bf
samples: rust: Access CONFIG_BOARD
d3zd3z 6f55e18
doc: languages: Add Rust documentation
d3zd3z cf88e6f
samples: rust: Rename hello
d3zd3z 6052ca4
doc: Use proper quote block for shell
d3zd3z c95dc43
rust: Support negative Kconfig int values
d3zd3z db90a84
rust: Mark RUST support as experimental
d3zd3z 285c9d5
cmake: rust: Use proper FPU config
d3zd3z a8d1745
doc: rust: Fix code block
d3zd3z 2f39272
doc: rust: Use real config settings
d3zd3z f883380
cmake: rust: Fix Cortex-M4 non-fp target
d3zd3z b72fdeb
rust: Fix prototype for rust_main
d3zd3z 157448e
remove board specific options
mjaun 98d0bf7
target mapping for cortex m7
mjaun 680250e
first trial of providing dts information to rust
mjaun e3abd1c
add zephyr-sys library with bindgen
mjaun 05652a7
control gpio from rust
mjaun 96f4e06
call sleep directly
mjaun 57e361e
cleaner implementation for allocator and panic handler
mjaun 1a12f04
better print support
mjaun 9059699
more generic way of determining clang args
mjaun f041979
move gpio driver
mjaun fe62b92
start implementing gpio driver
mjaun f80d219
improved errno handling
mjaun 8f14bb7
support more types in rust dts
mjaun 9eb9540
include generated device tree
mjaun 74afe70
make device tree accessible in application
mjaun dea5646
cleanups
mjaun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "zephyr-sys" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
|
||
[build-dependencies] | ||
bindgen = { version = "0.69.4", features = ["experimental"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
let bindings = bindgen::Builder::default() | ||
.clang_arg("-I/home/ubuntu/zephyrproject/zephyr/include") | ||
.clang_arg("-I/home/ubuntu/zephyrproject/zephyr/build/zephyr/include/generated") | ||
.clang_arg("-imacros/home/ubuntu/zephyrproject/zephyr/build/zephyr/include/generated/zephyr/autoconf.h") | ||
.wrap_static_fns(true) | ||
.allowlist_function("gpio_.*") | ||
.header("wrapper.h") | ||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) | ||
.generate() | ||
.expect("Unable to generate bindings"); | ||
|
||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
|
||
bindings | ||
.write_to_file(out_path.join("bindings.rs")) | ||
.expect("Couldn't write bindings!"); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#![allow(non_upper_case_globals)] | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_snake_case)] | ||
|
||
include!(concat!(env!("OUT_DIR"), "/bindings.rs")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include <zephyr/drivers/gpio.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol. I was going to try to figure out how to get the include path out of cmake. Turns out it is rather challenging to do. We do need to figure out how to do it correctly, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did figure out how to do this, I'll push some code hopefully tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like you were looking at an old version. Here is the best solution I could come up with for this: https://github.com/mjaun/zephyr/blob/dea56463ebbf469118ed34ee5c9e343586bf27da/cmake/modules/rust.cmake#L42