rhaiscript / rhai

Rhai - An embedded scripting language for Rust.
https://crates.io/crates/rhai
Apache License 2.0
3.83k stars 180 forks source link

no_std error #186

Closed ahmtcn123 closed 4 years ago

ahmtcn123 commented 4 years ago

I keep getting can't find crate for std even with "no_std" feature

[dependencies.rhai]
git = "https://github.com/jonathandturner/rhai"
features = ["no_std"]
default-features = false

Here is some of the output

Blocking waiting for file lock on build directory
   Compiling core-error v0.0.0
   Compiling stm32f4 v0.11.0
error[E0463]: can't find crate for `std`
  |                                                                                                                                  ing waiting for file lock on package cache
  = note: the `thumbv7em-none-eabihf` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `core-error`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
schungx commented 4 years ago

First of all you'll need the nightly compiler for no-std, so make sure you have +nightly on.

Second, I'm not very sure where that error came from. I've pushed the latest changes into master. You can try pulling it again to see if it solves your problem.

Third, from the error message, it looks like you're compiling for an ARMv7 target (stm32f4?) and you have not installed the target into your toolchain.

the `thumbv7em-none-eabihf` target may not be installed

From https://gist.github.com/adamgreig/b47fe9159e721e368601 it looks like you might need to install thumbv7em-none-eabihf manually.

ahmtcn123 commented 4 years ago

Im sure nigtly is on I even set it to default. I tried new version but it didnt worked. Also when I remove rhai project builds successfully. I think problem is on core-error libary, I removed rhai and imported core-error like in rhai's cargo.toml It gave me same error.

schungx commented 4 years ago

How about the compilation target thumbv7em-none-eabihf? Do you have it installed?

ahmtcn123 commented 4 years ago

I tried installing with

rustup target add thumbv7em-none-eabihf It gave me: info: component 'rust-std' for target 'thumbv7em-none-eabihf' is up to date

Edit:

I tried re installing by

rustup target remove thumbv7em-none-eabihf rustup target add thumbv7em-none-eabihf

schungx commented 4 years ago

https://github.com/rust-embedded/cortex-m-quickstart/issues/58

Do you have #![no_std]? Silly question, I know...

ahmtcn123 commented 4 years ago

I have :(

#![no_main]
#![no_std]

extern crate panic_halt;

use cortex_m;
use cortex_m_rt::entry;

use crate::hal::{prelude::*, stm32};
use stm32f4xx_hal as hal;

#[entry]
fn main() -> ! {

    // Access the device peripherals (dp) and cortex peripherals (cp):
    if let (Some(dp), Some(cp)) = (
        stm32::Peripherals::take(),
        cortex_m::peripheral::Peripherals::take(),
    ) {
        // Set up the LED: it's connected to pin PA5 on the microcontroler
        let gpioa = dp.GPIOA.split();
        let mut led = gpioa.pa5.into_push_pull_output();

        // The external LED, on the next pin down:
        let mut xled = gpioa.pa6.into_push_pull_output();

        // Set up the system clock. We want to run at 48MHz for this one.
        let rcc = dp.RCC.constrain();
        let clocks = rcc.cfgr.sysclk(48.mhz()).freeze();

        // Create a delay abstraction based on SysTick
        let mut delay = hal::delay::Delay::new(cp.SYST, clocks);

        loop {
            // On for 1s, off for 1s.
            // https://doc.rust-lang.org/std/convert/enum.Infallible.html
            led.set_high().unwrap();
            xled.set_low().unwrap();
            delay.delay_ms(1000_u32);
            led.set_low().unwrap();
            xled.set_high().unwrap();
            delay.delay_ms(1000_u32);
        }
    } else {
        panic!("failed to access peripherals");
    }
}
ahmtcn123 commented 4 years ago

I used --verbose option maybe this can help

Caused by:
  process didn't exit successfully: `rustc --crate-name core_error C:\Users\ahmet\.cargo\registry\src\github.com-1ecc6299db9ec823\core-error-0.0.0\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg "feature=\"alloc\"" --cfg "feature=\"default\"" --cfg "feature=\"std\"" -C metadata=dcec00e7bf7cf4d4 -C extra-filename=-dcec00e7bf7cf4d4 --out-dir C:\Users\ahmet\rust-brighton-embedded-day-2\target\thumbv7em-none-eabihf\debug\deps --target thumbv7em-none-eabihf -L dependency=C:\Users\ahmet\rust-brighton-embedded-day-2\target\thumbv7em-none-eabihf\debug\deps -L dependency=C:\Users\ahmet\rust-brighton-embedded-day-2\target\debug\deps --cap-lints allow -C link-arg=-Tlink.x --cfg rustc_1_0_0 --cfg rustc_1_1_0 --cfg rustc_1_2_0 --cfg rustc_1_3_0 --cfg rustc_1_4_0 --cfg rustc_1_5_0 --cfg rustc_1_6_0 --cfg rustc_1_7_0 --cfg rustc_1_8_0 --cfg rustc_1_9_0 --cfg rustc_1_10_0 --cfg rustc_1_11_0 --cfg rustc_1_12_0 --cfg rustc_1_13_0 --cfg rustc_1_14_0 --cfg rustc_1_15_0 --cfg rustc_1_16_0 --cfg rustc_1_17_0 --cfg rustc_1_18_0 --cfg rustc_1_19_0 --cfg rustc_1_20_0 --cfg rustc_1_21_0 --cfg rustc_1_22_0 --cfg rustc_1_23_0 --cfg rustc_1_24_0 --cfg rustc_1_25_0 --cfg rustc_1_26_0 --cfg rustc_1_27_0 --cfg rustc_1_28_0 --cfg rustc_1_29_0 --cfg rustc_1_30_0 --cfg rustc_1_31_0 --cfg rustc_1_32_0 --cfg rustc_1_33_0 --cfg rustc_1_34_0 --cfg rustc_1_35_0 --cfg rustc_1_36_0 --cfg rustc_1_37_0 --cfg rustc_1_38_0 --cfg rustc_1_39_0 --cfg rustc_1_40_0 --cfg rustc_1_41_0 --cfg rustc_1_42_0 --cfg rustc_1_43_0 --cfg rustc_1_44_0 --cfg rustc_1_45_0 --cfg rustc_1_46_0` (exit code: 1)
schungx commented 4 years ago

Looks like feature="std" is the culprit.

Try:

core-error = { version = "0.0.0", features = ["alloc"] }
ahmtcn123 commented 4 years ago

It worked :D

core-error = { version = "0.0.0", features = ["alloc"], default-features = false}

using with default-features works

schungx commented 4 years ago

That is because features are additive. Rhai only pull in alloc, but if you use this dependency and does not do default-features then it'll also pull in std.

ahmtcn123 commented 4 years ago

Oh, I get it Im new in rust :D. Thank you for help.

schungx commented 4 years ago

Just out of curiosity, may I ask what you're planning to use Rhai for on this microcontroller?

ahmtcn123 commented 4 years ago

Im trying to create a retro console which will use arm. With rhai I will give users a easy way to create games.

schungx commented 4 years ago

You may find that Rhai doesn't run fast enough to create video games though... it is an interpreter. You might way to go with Lua or others.

For text-based or other simple games which do not require lots of CPU power, Rhai should be OK.

ahmtcn123 commented 4 years ago

Games will be realy simple just like commodore games lines pixel arts etc. I actually don't know hardware is capable of doing theese. Im just prototyping it

ahmtcn123 commented 4 years ago

Sorry for asking again but, I didnt realy tried installing again. I tought if I set the core-error before rhai It will work apperantly its not working

schungx commented 4 years ago

You do not need core-error at all if you don't use it yourself. Rhai will pull it in automatically.

Do you see the same error?

What if you turn on verbose mode in cargo?

ahmtcn123 commented 4 years ago

I removed core-error just added rhai

Cargo.toml

[package]
name = "berzah"
version = "0.1.0"
authors = ["Ahmetcan Aksu <ahmetcanco@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
embedded-hal = "0.2"
nb = "0.1.2"
cortex-m = "0.6"
cortex-m-rt = "0.6"
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
panic-halt = "0.2"

[dependencies.rhai]
git = "https://github.com/jonathandturner/rhai/"
features = ["no_std"]
default-features = false

[dependencies.stm32f4xx-hal]
version = "0.8"
features = ["rt", "stm32f411"] # replace the model of your

[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
opt-level = "z"     # optimize for size

Verbose:

PS C:\Users\ahmet\Desktop\Projects\Try\berzah> cargo build --verbose
    Blocking waiting for file lock on package cache
    Updating git repository `https://github.com/jonathandturner/rhai/`
    Updating crates.io index
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
       Fresh semver-parser v0.7.0     
       Fresh autocfg v1.0.0
       Fresh unicode-xid v0.2.1       
       Fresh cfg-if v0.1.10
       Fresh proc-macro-hack v0.5.16  
       Fresh stable_deref_trait v1.2.0
       Fresh vcell v0.1.2
       Fresh version_check v0.9.2     
       Fresh nb v1.0.0
       Fresh r0 v0.2.2
       Fresh void v1.0.2
       Fresh rand_core v0.5.1
       Fresh panic-halt v0.2.0       
       Fresh semver v0.9.0
       Fresh volatile-register v0.2.0
       Fresh nb v0.1.3
       Fresh rustc_version v0.2.3    
       Fresh typenum v1.12.0
       Fresh proc-macro2 v1.0.18     
       Fresh getrandom v0.1.14       
       Fresh libm v0.2.1
       Fresh quote v1.0.7
       Fresh generic-array v0.13.2
       Fresh generic-array v0.12.3
       Fresh const-random-macro v0.1.8
       Fresh embedded-hal v0.2.4
   Compiling core-error v0.0.0
       Fresh as-slice v0.1.3
       Fresh syn v1.0.34
       Fresh const-random v0.1.8
       Fresh num-traits v0.2.12
     Running `rustc --crate-name core_error C:\Users\ahmet\.cargo\registry\src\github.com-1ecc6299db9ec823\core-error-0.0.0\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg "feature=\"alloc\"" --cfg "feature=\"default\"" --cfg "feature=\"std\"" -C metadata=dcec00e7bf7cf4d4 -C extra-filename=-dcec00e7bf7cf4d4 --out-dir C:\Users\ahmet\Desktop\Projects\Try\berzah\target\thumbv7em-none-eabihf\debug\deps --target thumbv7em-none-eabihf -L dependency=C:\Users\ahmet\Desktop\Projects\Try\berzah\target\thumbv7em-none-eabihf\debug\deps -L dependency=C:\Users\ahmet\Desktop\Projects\Try\berzah\target\debug\deps --cap-lints allow -C link-arg=-Tlink.x --cfg rustc_1_0_0 --cfg rustc_1_1_0 --cfg rustc_1_2_0 --cfg rustc_1_3_0 --cfg rustc_1_4_0 --cfg rustc_1_5_0 --cfg rustc_1_6_0 --cfg rustc_1_7_0 --cfg rustc_1_8_0 --cfg rustc_1_9_0 --cfg rustc_1_10_0 --cfg rustc_1_11_0 --cfg rustc_1_12_0 --cfg rustc_1_13_0 --cfg rustc_1_14_0 --cfg rustc_1_15_0 --cfg rustc_1_16_0 --cfg rustc_1_17_0 --cfg rustc_1_18_0 --cfg rustc_1_19_0 --cfg rustc_1_20_0 --cfg rustc_1_21_0 --cfg rustc_1_22_0 --cfg rustc_1_23_0 --cfg rustc_1_24_0 --cfg rustc_1_25_0 
--cfg rustc_1_26_0 --cfg rustc_1_27_0 --cfg rustc_1_28_0 --cfg rustc_1_29_0 --cfg rustc_1_30_0 --cfg rustc_1_31_0 --cfg rustc_1_32_0 --cfg rustc_1_33_0 --cfg rustc_1_34_0 --cfg rustc_1_35_0 --cfg rustc_1_36_0 --cfg rustc_1_37_0 --cfg rustc_1_38_0 --cfg rustc_1_39_0 --cfg rustc_1_40_0 --cfg rustc_1_41_0 --cfg rustc_1_42_0 --cfg rustc_1_43_0 --cfg rustc_1_44_0 --cfg rustc_1_45_0 --cfg rustc_1_46_0`
       Fresh bare-metal v0.2.5
       Fresh aligned v0.3.2
       Fresh cortex-m-rt-macros v0.1.8
       Fresh ahash v0.3.8
       Fresh cast v0.2.3
       Fresh cortex-m v0.6.2
       Fresh cortex-m-rt v0.6.12
       Fresh hashbrown v0.7.2
       Fresh stm32f4 v0.11.0
       Fresh stm32f4xx-hal v0.8.3
error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7em-none-eabihf` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `core-error`.

Caused by:
  process didn't exit successfully: `rustc --crate-name core_error C:\Users\ahmet\.cargo\registry\src\github.com-1ecc6299db9ec823\core-error-0.0.0\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg "feature=\"alloc\"" --cfg "feature=\"default\"" --cfg "feature=\"std\"" -C metadata=dcec00e7bf7cf4d4 -C extra-filename=-dcec00e7bf7cf4d4 --out-dir C:\Users\ahmet\Desktop\Projects\Try\berzah\target\thumbv7em-none-eabihf\debug\deps --target thumbv7em-none-eabihf -L dependency=C:\Users\ahmet\Desktop\Projects\Try\berzah\target\thumbv7em-none-eabihf\debug\deps -L dependency=C:\Users\ahmet\Desktop\Projects\Try\berzah\target\debug\deps --cap-lints allow -C link-arg=-Tlink.x --cfg rustc_1_0_0 --cfg rustc_1_1_0 --cfg rustc_1_2_0 --cfg rustc_1_3_0 --cfg rustc_1_4_0 --cfg rustc_1_5_0 --cfg rustc_1_6_0 --cfg rustc_1_7_0 --cfg rustc_1_8_0 --cfg rustc_1_9_0 --cfg rustc_1_10_0 --cfg rustc_1_11_0 --cfg rustc_1_12_0 --cfg rustc_1_13_0 --cfg rustc_1_14_0 --cfg rustc_1_15_0 --cfg rustc_1_16_0 --cfg rustc_1_17_0 --cfg rustc_1_18_0 --cfg rustc_1_19_0 --cfg rustc_1_20_0 --cfg rustc_1_21_0 --cfg rustc_1_22_0 --cfg rustc_1_23_0 --cfg rustc_1_24_0 --cfg rustc_1_25_0 --cfg rustc_1_26_0 --cfg rustc_1_27_0 --cfg rustc_1_28_0 --cfg rustc_1_29_0 --cfg rustc_1_30_0 --cfg 
rustc_1_31_0 --cfg rustc_1_32_0 --cfg rustc_1_33_0 --cfg rustc_1_34_0 --cfg rustc_1_35_0 --cfg rustc_1_36_0 --cfg rustc_1_37_0 --cfg rustc_1_38_0 --cfg rustc_1_39_0 --cfg rustc_1_40_0 --cfg rustc_1_41_0 --cfg rustc_1_42_0 --cfg rustc_1_43_0 --cfg rustc_1_44_0 --cfg rustc_1_45_0 --cfg rustc_1_46_0` (exit code: 1)
schungx commented 4 years ago

For some reason core-error still wants to pull in default-features which includes std.

ahmtcn123 commented 4 years ago

Is it problem with core-error?

schungx commented 4 years ago

Try compiling the no_std example with nightly. See if it works for you.

I just did it on my PC and it worked. Obviously I'm not cross-compiling to ARM...

ahmtcn123 commented 4 years ago

Libary works well in my computer (nightly) but no success in thumbv7em-none-eabihf target

schungx commented 4 years ago

Seems like you may need to put #![no_std] in every single file. Did you miss one anywhere?

ahmtcn123 commented 4 years ago

Just only main.rs available #![no_std] already in top

#![deny(unsafe_code)]
#![no_main]
#![no_std]

// Halt on panic
#[allow(unused_extern_crates)] // NOTE(allow) bug rust-lang/rust#53964
extern crate panic_halt; // panic handler

use cortex_m;
use cortex_m_rt::entry;
use stm32f4xx_hal as hal;
//use rhai::{Engine, EvalAltResult};

use crate::hal::{prelude::*, stm32};

#[entry]
fn main() -> ! {

    if let (Some(dp), Some(cp)) = (
        stm32::Peripherals::take(),
        cortex_m::peripheral::Peripherals::take(),
    ) {

        // Set up the system clock. We want to run at 48MHz for this one.
        let rcc = dp.RCC.constrain();
        let clocks = rcc.cfgr.sysclk(100.mhz()).freeze();
        let mut delay = hal::delay::Delay::new(cp.SYST, clocks);

        loop {
        }
    }

    loop {}
}

Edit: build.rs

use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

fn main() {
    // Put the linker script somewhere the linker can find it
    let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
    File::create(out.join("memory.x"))
        .unwrap()
        .write_all(include_bytes!("memory.x"))
        .unwrap();
    println!("cargo:rustc-link-search={}", out.display());

    // Only re-run the build script when memory.x is changed,
    // instead of when any part of the source code changes.
    println!("cargo:rerun-if-changed=memory.x");
}

I tried to delete build.rs but not worked

Cargo.toml

[package]
name = "berzah"
version = "0.1.0"
authors = ["Ahmetcan Aksu <ahmetcanco@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
embedded-hal = "0.2"
nb = "0.1.2"
cortex-m = "0.6"
cortex-m-rt = "0.6"
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
panic-halt = "0.2"

[dependencies.rhai]
git = "https://github.com/jonathandturner/rhai/"
features = ["no_std", "no_module", "no_function"]
default-features = false

[dependencies.stm32f4xx-hal]
version = "0.8"
features = ["rt", "stm32f411"] # replace the model of your

[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
opt-level = "z"     # optimize for size
ahmtcn123 commented 4 years ago

This cargo.toml works well why package giving error in rhai

[package]
name = "berzah"
version = "0.1.0"
authors = ["Ahmetcan Aksu <ahmetcanco@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
core-error = { version = "0.0.0", features = ["alloc"], default-features = false}
embedded-hal = "0.2"
nb = "0.1.2"
cortex-m = "0.6"
cortex-m-rt = "0.6"
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
panic-halt = "0.2"

[dependencies.stm32f4xx-hal]
version = "0.8"
features = ["rt", "stm32f411"] # replace the model of your

[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
opt-level = "z"     # optimize for size

Verbose output for core-error

Running `rustc --crate-name core_error C:\Users\ahmet\.cargo\registry\src\github.com-1ecc6299db9ec823\core-error-0.0.0\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg "feature=\"alloc\"" -C metadata=b04ee0efdbbd7d00 -C extra-filename=-b04ee0efdbbd7d00 --out-dir C:\Users\ahmet\Desktop\Projects\Try\berzah\target\thumbv7em-none-eabihf\debug\deps --target thumbv7em-none-eabihf -L dependency=C:\Users\ahmet\Desktop\Projects\Try\berzah\target\thumbv7em-none-eabihf\debug\deps -L dependency=C:\Users\ahmet\Desktop\Projects\Try\berzah\target\debug\deps --cap-lints allow -C link-arg=-Tlink.x --cfg rustc_1_0_0 --cfg rustc_1_1_0 --cfg rustc_1_2_0 --cfg rustc_1_3_0 --cfg rustc_1_4_0 --cfg rustc_1_5_0 --cfg rustc_1_6_0 --cfg rustc_1_7_0 --cfg rustc_1_8_0 --cfg rustc_1_9_0 --cfg rustc_1_10_0 --cfg rustc_1_11_0 --cfg rustc_1_12_0 --cfg rustc_1_13_0 --cfg rustc_1_14_0 --cfg rustc_1_15_0 --cfg rustc_1_16_0 --cfg rustc_1_17_0 --cfg rustc_1_18_0 --cfg rustc_1_19_0 --cfg rustc_1_20_0 --cfg rustc_1_21_0 --cfg rustc_1_22_0 --cfg rustc_1_23_0 --cfg rustc_1_24_0 --cfg rustc_1_25_0 --cfg rustc_1_26_0 --cfg rustc_1_27_0 --cfg rustc_1_28_0 --cfg rustc_1_29_0 
--cfg rustc_1_30_0 --cfg rustc_1_31_0 --cfg rustc_1_32_0 --cfg rustc_1_33_0 --cfg rustc_1_34_0 --cfg rustc_1_35_0 --cfg rustc_1_36_0 --cfg rustc_1_37_0 --cfg rustc_1_38_0 --cfg rustc_1_39_0 --cfg rustc_1_40_0 --cfg rustc_1_41_0 --cfg rustc_1_42_0 --cfg rustc_1_43_0 --cfg rustc_1_44_0 --cfg rustc_1_45_0 --cfg rustc_1_46_0`
schungx commented 4 years ago
Running `rustc --crate-name core_error C:\Users\ahmet\.cargo\registry\src\github.com-1ecc6299db9ec823\core-error-0.0.0\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg "feature=\"alloc\"" -C metadata=b04ee0efdbbd7d00 -C extra-filename=-b04ee0efdbbd7d00 --out-dir C:\Users\ahmet\Desktop\Projects\Try\berzah\target\thumbv7em-none-eabihf\debug\deps --target thumbv7em-none-eabihf -L dependency=C:\Users\ahmet\Desktop\Projects\Try\berzah\target\thumbv7em-none-eabihf\debug\deps -L dependency=C:\Users\ahmet\Desktop\Projects\Try\berzah\target\debug\deps --cap-lints allow -C link-arg=-Tlink.x --cfg rustc_1_0_0 --cfg rustc_1_1_0 --cfg rustc_1_2_0 --cfg rustc_1_3_0 --cfg rustc_1_4_0 --cfg rustc_1_5_0 --cfg rustc_1_6_0 --cfg rustc_1_7_0 --cfg rustc_1_8_0 --cfg rustc_1_9_0 --cfg rustc_1_10_0 --cfg rustc_1_11_0 --cfg rustc_1_12_0 --cfg rustc_1_13_0 --cfg rustc_1_14_0 --cfg rustc_1_15_0 --cfg rustc_1_16_0 --cfg rustc_1_17_0 --cfg rustc_1_18_0 --cfg rustc_1_19_0 --cfg rustc_1_20_0 --cfg rustc_1_21_0 --cfg rustc_1_22_0 --cfg rustc_1_23_0 --cfg rustc_1_24_0 --cfg rustc_1_25_0 --cfg rustc_1_26_0 --cfg rustc_1_27_0 --cfg rustc_1_28_0 --cfg rustc_1_29_0 
--cfg rustc_1_30_0 --cfg rustc_1_31_0 --cfg rustc_1_32_0 --cfg rustc_1_33_0 --cfg rustc_1_34_0 --cfg rustc_1_35_0 --cfg rustc_1_36_0 --cfg rustc_1_37_0 --cfg rustc_1_38_0 --cfg rustc_1_39_0 --cfg rustc_1_40_0 --cfg rustc_1_41_0 --cfg rustc_1_42_0 --cfg rustc_1_43_0 --cfg rustc_1_44_0 --cfg rustc_1_45_0 --cfg rustc_1_46_0`

This one looks better. It doesn't pull in std.

ahmtcn123 commented 4 years ago

So, are you gonna change Cargo.toml in rhai?

schungx commented 4 years ago

Rhai only pulls in alloc from core-error.

But let me change it to also put in default_features = false.

schungx commented 4 years ago

Can you pull from my latest and see if it works now.

I've taken care not to pull in std, especially from core-error and libm.

ahmtcn123 commented 4 years ago

It works fine now Thank you a lot!

tcpipchip commented 4 years ago

Hi image I can compile my application! But when i try to run probe tools image Got this error!

tcpipchip commented 4 years ago

cargo.toml image config image

schungx commented 4 years ago

The error seems to think that you're missing the spin_no_std feature for lazy_static. Otherwise, lazy_static requires std.

Are you sure your cargo build is building for no_std? I'm quite sure you need nightly for it... cargo +nightly build...

Remember, pulling in rhai with no_std does NOT automatically build your project in no_std. You need to do all the right things, such as setting up the environment, allocator, etc.

Check out the no_std example in Rhai.

tcpipchip commented 4 years ago

@schungx

First of all, thanks to help me!

About this image is it enough to me have the binary code and runs on NRF52840, if yes, where is the bin and about cargo +nightly install probe-run image i am newer with RUST! I want learn it :+1:

schungx commented 4 years ago

I suggest you read up on no_std first. It is not as simple as people led you to think... actually setting up the whole environment and template is complex.

The best thing to do is to go through a detailed online tutorial on no_std builds.

You can also start with the no_std example in Rhai. That one works with no_std. So you can see how to put in an allocator and panic handling etc. Missing any of this and you end up in std again.

tcpipchip commented 4 years ago

ok! Thank you @schungx

schungx commented 4 years ago

Frankly speaking, I myself do not use no_std, nor do I know how to program microcontrollers, so you better get yourself some good web tutorials to go through! Something that teaches you step-by-step on building a bin for a microcontroller.

tcpipchip commented 4 years ago

well, i wrote many blogs to microcontrollers, circuitpython, micropython, lua, arduino, rtos, etc; now i want to write about RUST.

Yes, i will do your suggestion!

tcpipchip commented 4 years ago

but, please test there if you got sucess until https://nitschinger.at/Getting-Started-with-the-nRF52840-in-Rust/ cargo install probe-run --git https://....

schungx commented 4 years ago

All I know is... no_std in Rust is quite tricky. If you're not careful enough, one small slip and you end up pulling in std and don't realize it until at the end. This was my experience.

So I suggest you start with something bare minimum that works, something with rhai, which compiles and runs. Then add Rhai to it.

schungx commented 4 years ago

@tcpipchip how is this working out for you?

tcpipchip commented 4 years ago

hi @schungx

How are you ?

Still tryng to solve that problem!

tryng to install probe-run

schungx commented 4 years ago

Your error messages seem to think that probe-run is not a no-std binary, and you're trying to compile it as no_std.

In fact, the source for probe-run doesn't seem that it even supports no_std. Therefore you need to figure out why your cargo install is compiling probe-run under no_std.

schungx commented 4 years ago

My suggestion is:

1) Try running cargo install probe-run under a clean new directory,

2) Try using the stable compiler instead of nightly.

tcpipchip commented 4 years ago

Hi, thanks to the feeback I will do all on linux and then w10 Looks a w7 problem :(

schungx commented 4 years ago

OK, closing this one for now. Feel free to open up another issue if there is a problem.

tcpipchip commented 4 years ago

Getting good progress in the rust programming!