hashmismatch / freertos.rs

A Rust wrapper for FreeRTOS.
232 stars 22 forks source link

error[E0432]: unresolved import `alloc::arc` [stm32l475] #22

Closed tasosxak closed 5 years ago

tasosxak commented 5 years ago
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)
MathiasKoch commented 5 years ago

+1 Getting the same issue.

hargoniX commented 5 years ago

So I seem to have gotten this working, the problem appears to be this line

pub use alloc::arc::{Arc, Weak};

in the latest versions of rust this has to be

pub use alloc::sync::{Arc, Weak};

replace that and its going to work (or at least it did for me)

hargoniX commented 5 years ago

Small update: In fact this issue has already been addressed in https://github.com/hashmismatch/freertos.rs/pull/19 (in fact this is the only issue the PR is addressing as of now) so if the maintainer would merge this (and the travis ci tests would magically pass) this issue would be resolved.

MathiasKoch commented 5 years ago

But it seems like the changes in #19 was already fixed in f056dcbb357597aa7c8f603b8b7e57c3f7e02a4c

Guess thats why its not passing and not being merged?

@rudib When can we expect to see a new release with the 12 latest commits since 0.2.0?

MathiasKoch commented 5 years ago

@hargoniX Do you have a small minimal example on a repository that compiles and runs with freertos_rs?

I can get mine to compile, but the linking process results in a zero sized binary no matter what i try, as soon as i am using xargo (or any other custom sysroot in cargo).

tasosxak commented 5 years ago
#![no_std]

extern crate freertos_rs;

use freertos_rs::*;
use prelude::v1::*;

#[no_mangle]
#[entry]
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");
    }
}
error[E0601]: `main` function not found in crate `frtos`
  |
  = note: consider adding a `main` function to `src/main.rs`

error: `#[panic_handler]` function required, but not found

error: `#[alloc_error_handler]` function required, but not found

error: aborting due to 6 previous errors
hargoniX commented 5 years ago

@smilykoch I actually just modified the local version of freertos_rs with that small changed, then compiled it and started wondering how this would actually be useful to me (Im developing a HAL for the stm32h7x3 series at the moment) without HAL (yes I never used RTOS before so I didnt really have an idea what i was doing there) so I didnt perform any further work on it.

Long story short I actually have no idea how to use this project and just stumbled upon the fix during a bit of research.

rudib commented 5 years ago

As you've guys probably noticed, this project has found itself at a bit of an impasse. xargo was deprecated and left unusable with the latest Rust nightly, rendering the current build approach with this library's test suite outdated. I've tried reworking the build to accommodate the new approach using the core and alloc downloaded using rustup, but wasn't able to produce binaries that would pass the test suite (allocation and stack issues with tasks, difficult to debug). Since I'm not actively using this library right now and free time is quite sparse, I plan to pick this up once the alloc crate is stabilized. There's simply too much work in keeping up with the nightly Rust changes.

rudib commented 5 years ago

Released and published 0.3.0 which downgrades the required compiler version to beta, soon to be stable!