hashmismatch / freertos.rs Goto Github PK
View Code? Open in Web Editor NEWA Rust wrapper for FreeRTOS.
A Rust wrapper for FreeRTOS.
This is an FYI, that I just created a crate that compiles the FreeRTOS C code and creates the rust bindings for it: https://github.com/axos88/libfreertos-sys.
It's uncomplete, but it might help people get started.
Hi,
Any idea how to run a simple program for stm32 using this wrapper?
#![no_std]
extern crate freertos_rs;
use freertos_rs::*;
use prelude::v1::*;
#[no_mangle]
pub extern fn main_entry() {
}
error[E0603]: module `prelude` is private
--> src/main.rs:6:18
|
6 | use prelude::v1::*;
The changes made in #20 allow this to successfully compile. Can you push it to crates.io? Additionally, #![feature(alloc)]
can be removed, as alloc
is now stable.
Hello. I just started new project and added freertos_rs as a dependecy.
When I try to compile I get following message:
cargo.exe test --no-run --message-format=json
Compiling freertos_rs v0.1.0
{"reason":"compiler-message","package_id":"freertos_rs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"name":"freertos_rs","src_path":"\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\freertos_rs-0.1.0\\src\\lib.rs"},"message":{"children":[],"code":{"code":"E0554","explanation":null},"level":"error","message":"#[feature] may not be used on the stable release channel","rendered":null,"spans":[{"byte_end":1787,"byte_start":1769,"column_end":19,"column_start":1,"expansion":null,"file_name":"\.cargo\registry\src\github.com-1ecc6299db9ec823\freertos_rs-0.1.0\src\lib.rs","is_primary":true,"label":null,"line_end":56,"line_start":56,"suggested_replacement":null,"text":[{"highlight_end":19,"highlight_start":1,"text":"#![feature(alloc)]"}]}]}}
{"reason":"compiler-message","package_id":"freertos_rs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"name":"freertos_rs","src_path":"\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\freertos_rs-0.1.0\\src\\lib.rs"},"message":{"children":[],"code":{"code":"E0554","explanation":null},"level":"error","message":"#[feature] may not be used on the stable release channel","rendered":null,"spans":[{"byte_end":1812,"byte_start":1788,"column_end":25,"column_start":1,"expansion":null,"file_name":"\.cargo\registry\src\github.com-1ecc6299db9ec823\freertos_rs-0.1.0\src\lib.rs","is_primary":true,"label":null,"line_end":57,"line_start":57,"suggested_replacement":null,"text":[{"highlight_end":25,"highlight_start":1,"text":"#![feature(collections)]"}]}]}}
{"reason":"compiler-message","package_id":"freertos_rs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"name":"freertos_rs","src_path":"\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\freertos_rs-0.1.0\\src\\lib.rs"},"message":{"children":[],"code":{"code":"E0554","explanation":null},"level":"error","message":"#[feature] may not be used on the stable release channel","rendered":null,"spans":[{"byte_end":1831,"byte_start":1813,"column_end":19,"column_start":1,"expansion":null,"file_name":"\.cargo\registry\src\github.com-1ecc6299db9ec823\freertos_rs-0.1.0\src\lib.rs","is_primary":true,"label":null,"line_end":58,"line_start":58,"suggested_replacement":null,"text":[{"highlight_end":19,"highlight_start":1,"text":"#![feature(fnbox)]"}]}]}}
{"reason":"compiler-message","package_id":"freertos_rs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"name":"freertos_rs","src_path":"\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\freertos_rs-0.1.0\\src\\lib.rs"},"message":{"children":[],"code":null,"level":"error","message":"aborting due to 3 previous errors","rendered":null,"spans":[]}}
error: Could not compile freertos_rs
.
/tmp//libkvm.a(freertos_rs-4d6cd4cda3cfed3d.freertos_rs0.rcgu.o): In function `freertos_rs::task::Task::get_stack_high_water_mark::h2ebc848c0d006b62':
/home/mpiechotka/.cargo/registry/src/github.com-1ecc6299db9ec823/freertos_rs-0.2.0/src/task.rs:257: undefined reference to `freertos_rs_get_stack_high_water_mark'
/tmp//libkvm.a(freertos_rs-4d6cd4cda3cfed3d.freertos_rs0.rcgu.o): In function `freertos_rs::task::CurrentTask::get_stack_high_water_mark::ha19f8026cb3c6f12':
/home/mpiechotka/.cargo/registry/src/github.com-1ecc6299db9ec823/freertos_rs-0.2.0/src/task.rs:275: undefined reference to `freertos_rs_get_stack_high_water_mark'
freertos_rs_get_stack_high_water_mark
is not compiled as INCLUDE_uxTaskGetStackHighWaterMark
is not equal to 1.
Hello,
Thank you for such good crate. I tried version 0.1.0 from crates.io, basically all fine, but there is issue with Duration::ms(). As I see you made some fixes/modification since 0.1.0, would you like to publish new version to crates.io ?
Thanks in advance.
Multiple QEMU projects for different releases would help here.
I assume this is due to changes in the latest Rust version. Also happens to me using rustc 1.28.0
and rustc 1.30.0-nightly
error[E0207]: the type parameter `O` is not constrained by the impl trait, self type, or predicates
--> src/patterns/processor.rs:164:9
|
164 | impl<I, O> ProcessorClient<I, SharedClientWithReplyQueue<O>> where I: ReplyableMessage + Copy, O: Copy {
| ^ unconstrained type parameter
error[E0207]: the type parameter `O` is not constrained by the impl trait, self type, or predicates
--> src/patterns/processor.rs:175:9
|
175 | impl<I, O> ProcessorClient<InputMessage<I>, SharedClientWithReplyQueue<O>> where I: Copy, O: Copy {
| ^ unconstrained type parameter
I created a new project. After that I copied all files from "qemu_stm32_tests" to my project (including cargo.toml).
I've changed Cargo.toml to load freertos_rs from the repository:
[dependencies]
freertos_rs = "0.1"
xargo = "0.3.5"
...
Now I'm trying to compile the project, but it fails with the following error:
Compiling FreeRtos v0.1.0 (file:///C:/Electronics/Rust/FreeRtos)
error[E0433]: failed to resolve. Use of undeclared type or moduleFreeRtosUtils
--> src\test_delay.rs:9:15
|
9 | let start = FreeRtosUtils::get_tick_count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use of undeclared type or moduleFreeRtosUtils
.
The current (0.1.0) shim API returns the number of ticks elapsed for a single millisecond, stored in an integer. With a tick rate of, for instance, 600Hz, a 1-second duration cannot be accurately expressed.
Note that such high tick rates aren't typical of embedded projects and higher precision would be better served with hardware timers.
It seems the Cortex-M0 doesn't have LDREX
and STREX
opcodes, so atomics are not implemented, so std::sync
is not compiled into the alloc
crate.
Either we should use our own implementation of Arc
(using disabling interrupts or using the FreeRTOS critical sections), or figure out some way to avoid using them (at least) on platforms without atomic support
Once again, after the latest updates for nightly Rust, the current master is broken. I can't replicate the Travis build failure on my local machine.
https://travis-ci.org/hashmismatch/freertos.rs/builds/485077268
Pulled this for some work on an RTL8710, looks like it doesn't compile anymore on nightly because collections has been merged into alloc. I've got it compiling on my own fork making some small changes here and there but not sure about any implications of what i've been doing.
Is it possible to pass huge struct through queue without copying whole struct?
It seems that freertos.rs
makes copying of item
in Queue::send()
(though it possibly be removed by optimizations), then FreeRTOS' xQueueSend
also does copy.
Box<T>
could be used for this purpose but as I see, Box
doesn't implement Copy
trait that required by Queue
.
A small type detected by compiling with warnings
// from shim.rs
extern {
// ...
pub fn freertos_rs_queue_delete(queue: FreeRtosQueueHandle);
// ...
And in C code:
// queue.c
void vQueueDelete( QueueHandle_t xQueue )
// shim.c
void freertos_rs_queue_delete(UBaseType_t queue)
There are also a few minor problems:
uint8_t
is used and passed as char *
when transforming string (strict aliasing violation) (freertos_rs_spawn_task
and freertos_rs_timer_create
)freertos_rs_queue_send_isr
have unused variable ret
.I can send a pull request for them later today but they should be easy enough to fix
tasosxak@tasosxak:~/Documents/RustProjects/frtos$ cargo +nightly build
Compiling freertos_rs v0.2.0
error[E0432]: unresolved import `alloc::arc`
--> /home/tasosxak/.cargo/registry/src/github.com-1ecc6299db9ec823/freertos_rs-0.2.0/src/prelude/no_std.rs:17:16
|
17 | pub use alloc::arc::{Arc, Weak};
| ^^^ could not find `arc` in `alloc`
error[E0207]: the type parameter `O` is not constrained by the impl trait, self type, or predicates
--> /home/tasosxak/.cargo/registry/src/github.com-1ecc6299db9ec823/freertos_rs-0.2.0/src/patterns/processor.rs:164:9
|
164 | impl<I, O> ProcessorClient<I, SharedClientWithReplyQueue<O>> where I: ReplyableMessage + Copy, O: Copy {
| ^ unconstrained type parameter
error[E0207]: the type parameter `O` is not constrained by the impl trait, self type, or predicates
--> /home/tasosxak/.cargo/registry/src/github.com-1ecc6299db9ec823/freertos_rs-0.2.0/src/patterns/processor.rs:175:9
|
175 | impl<I, O> ProcessorClient<InputMessage<I>, SharedClientWithReplyQueue<O>> where I: Copy, O: Copy {
| ^ unconstrained type parameter
error: aborting due to 3 previous errors
Some errors occurred: E0207, E0432.
For more information about an error, try `rustc --explain E0207`.
error: Could not compile `freertos_rs`.
To learn more, run the command again with --verbose.
main.rs
extern crate freertos_rs;
use freertos_rs::*;
use prelude::v1::*;
#[no_mangle]
pub extern fn main_entry() {
let mut s = Serial::new();
s.tx_string("Hello from Rust!\n");
loop {
let data = s.rx_i32();
s.tx_string("Received: ");
s.tx_i32(data);
s.tx_string("\n");
}
}
Rust version:
tasosxak@tasosxak:~/Documents/RustProjects/frtos$ rustup default nightly
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'
nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.35.0-nightly (26b4cb484 2019-03-09)
.cargo/config
[target.thumbv7em-none-eabi]
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "gdb-multiarch -q -x openocd.gdb"
rustflags = [
"-C", "link-arg=-Tlink.x",
]
[build]
target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
Can't seem to find the equivalent of vTaskStartScheduler();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.