trotz folgendem Hinweis oder vielleicht auch gerade deswegen, wurde ich sehr neugierig:
Ich habe zum großen Teil das offizielle Rust-Tutorial durchgearbeitet und habe auch sehr kleine lauffähige Programme erfolgreich erstellt.
Das habe ich aber nur gemacht, weil ich ja gerne den ESP mit Rust steuern möchte. Ich wollte einfach starten und nur eine LED blinken lassen. Irgendwie fand ich mich nicht so ganz zu recht und das ist wahrscheinlich auch der Grund, wieso ich nicht erfolgreich war. Ich arbeite mit Fedora und habe folgendes gemacht:
ESP-IDF installiert wie hier:
Code: Alles auswählen
mkdir -p ~/esp
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git
cd ~/esp/esp-idf
./install.sh all
. $HOME/esp/esp-idf/export.sh
Dann habe ich folgende 'cargo'-Befehle ausgeführt, wie hier beschrieben:
Code: Alles auswählen
cargo install cargo-generate
cargo install ldproxy
cargo install espup
cargo install espflash
cargo install cargo-espflash
Dann bin ich in dieses Tutorial eingestiegen.
Mit
Code: Alles auswählen
cargo generate esp-rs/esp-idf-template cargo
Code: Alles auswählen
use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
use log::*;
use esp_idf_hal::delay::FreeRtos;
use esp_idf_hal::gpio::*;
use esp_idf_hal::peripherals::Peripherals;
fn main(){
esp_idf_sys::link_patches();
esp_idf_svc::log::EspLogger::initialize_default();
info!("Author: Zacchaeus Oluwole!");
let peripherals = Peripherals::take().unwrap();
let mut r_pin = PinDriver::output(peripherals.pins.gpio16).expect("Error: Unable to set pin(r) gpio2 Output");
loop{
r_pin.set_high().expect("Error: Unable to set pin r high");
FreeRtos::delay_ms(1000);
r_pin.set_low().expect("Error: Unable to set pin r low");
FreeRtos::delay_ms(1000);
}
}
In meinem Projekt-Ordner habe ich dann folgendes gemacht:
Code: Alles auswählen
espup install
. ~/export-esp.sh
Code: Alles auswählen
cargo build
Code: Alles auswählen
[dennis@dennis test]$ cargo build
Updating crates.io index
Compiling compiler_builtins v0.1.101
Compiling core v0.0.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core)
Compiling proc-macro2 v1.0.70
Compiling unicode-ident v1.0.12
Compiling libc v0.2.148
Compiling cc v1.0.79
Compiling memchr v2.5.0
Compiling quote v1.0.33
Compiling syn v2.0.39
Compiling std v0.0.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std)
Compiling serde v1.0.193
Compiling autocfg v1.1.0
Compiling unwind v0.0.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/unwind)
Compiling cfg-if v1.0.0
Compiling memchr v2.6.4
Compiling libc v0.2.150
Compiling aho-corasick v1.1.2
Compiling memoffset v0.9.0
Compiling semver v1.0.20
Compiling regex-syntax v0.8.2
Compiling crossbeam-utils v0.8.16
Compiling regex-automata v0.4.3
Compiling rustc-std-workspace-core v1.99.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/rustc-std-workspace-core)
Compiling serde_derive v1.0.193
Compiling alloc v0.0.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/alloc)
Compiling rustc-std-workspace-alloc v1.99.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
Compiling gimli v0.28.0
Compiling adler v1.0.2
Compiling miniz_oxide v0.7.1
Compiling object v0.32.0
Compiling panic_unwind v0.0.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_unwind)
Compiling std_detect v0.1.5 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
Compiling panic_abort v0.0.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_abort)
Compiling hashbrown v0.14.0
Compiling addr2line v0.21.0
Compiling rustc-demangle v0.1.23
Compiling crossbeam-epoch v0.9.15
Compiling syn v1.0.109
Compiling rustix v0.38.28
Compiling bitflags v1.3.2
Compiling glob v0.3.1
Compiling clang-sys v1.6.1
Compiling linux-raw-sys v0.4.12
Compiling scopeguard v1.2.0
Compiling rustversion v1.0.14
Compiling log v0.4.20
Compiling bitflags v2.4.1
Compiling bstr v1.8.0
Compiling minimal-lexical v0.2.1
Compiling thiserror v1.0.50
Compiling serde_json v1.0.108
Compiling proc_macro v0.0.0 (/home/dennis/.rustup/toolchains/esp/lib/rustlib/src/rust/library/proc_macro)
Compiling same-file v1.0.6
Compiling walkdir v2.4.0
Compiling nom v7.1.3
Compiling globset v0.4.14
Compiling crossbeam-deque v0.8.3
Compiling nix v0.26.4
Compiling thiserror-impl v1.0.50
Compiling cvt v0.1.2
Compiling libloading v0.7.4
Compiling itoa v1.0.10
Compiling ryu v1.0.16
Compiling heck v0.4.1
Compiling home v0.5.5
Compiling anyhow v1.0.75
Compiling bindgen v0.63.0
Compiling either v1.9.0
Compiling lazy_static v1.4.0
Compiling strum_macros v0.24.3
Compiling which v4.4.2
Compiling fs_at v0.1.10
Compiling ignore v0.4.21
Compiling cexpr v0.6.0
Compiling regex v1.10.2
Compiling cc v1.0.83
Compiling fastrand v2.0.1
Compiling peeking_take_while v0.1.2
Compiling shlex v1.2.0
Compiling lazycell v1.3.0
Compiling rustc-hash v1.1.0
Compiling normpath v1.1.1
Compiling remove_dir_all v0.8.2
Compiling cmake v0.1.50
Compiling tempfile v3.8.1
Compiling strum v0.24.1
Compiling globwalk v0.8.1
Compiling filetime v0.2.23
Compiling camino v1.1.6
Compiling embuild v0.31.4
Compiling cargo-platform v0.1.5
Compiling cargo_metadata v0.15.4
Compiling rustc_version v0.4.0
Compiling envy v0.4.2
Compiling fnv v1.0.7
Compiling ident_case v1.0.1
Compiling darling_core v0.20.3
Compiling heapless v0.7.17
Compiling byteorder v1.5.0
Compiling nb v1.1.0
Compiling num-traits v0.2.17
Compiling futures-core v0.3.29
Compiling futures-task v0.3.29
Compiling hash32 v0.2.1
Compiling stable_deref_trait v1.2.0
Compiling futures-util v0.3.29
Compiling pin-utils v0.1.0
Compiling pin-project-lite v0.2.13
Compiling iana-time-zone v0.1.58
Compiling embassy-time v0.1.5
Compiling unicode-xid v0.2.4
Compiling const_format_proc_macros v0.2.32
Compiling darling_macro v0.20.3
Compiling chrono v0.4.31
Compiling darling v0.20.3
Compiling enumset_derive v0.8.1
Compiling esp-idf-sys v0.33.7
Compiling esp-idf-hal v0.42.5
Compiling nb v0.1.3
Compiling critical-section v1.1.2
Compiling void v1.0.2
Compiling embassy-sync v0.3.0
Compiling once_cell v1.19.0
Compiling version_check v0.9.4
Compiling build-time v0.1.3
Compiling embedded-hal v0.2.7
Compiling uncased v0.9.9
Compiling enumset v1.1.3
Compiling const_format v0.2.32
Compiling esp-idf-svc v0.47.3
Compiling atomic-waker v1.1.2
Compiling embedded-hal v1.0.0-rc.1
Compiling embedded-io v0.6.1
Compiling num_enum_derive v0.7.1
Compiling embedded-hal-nb v1.0.0-rc.1
Compiling embedded-can v0.4.1
Compiling no-std-net v0.5.0
Compiling num_enum v0.7.1
Compiling test v0.1.0 (/home/dennis/Rust/test)
Compiling embassy-futures v0.1.1
Compiling embedded-svc v0.26.4
error[E0433]: failed to resolve: use of undeclared crate or module `esp_idf_hal`
--> src/main.rs:5:5
|
5 | use esp_idf_hal::gpio::*;
| ^^^^^^^^^^^ use of undeclared crate or module `esp_idf_hal`
|
help: there is a crate or module with a similar name
|
5 | use esp_idf_svc::gpio::*;
| ~~~~~~~~~~~
error[E0433]: failed to resolve: use of undeclared crate or module `esp_idf_hal`
--> src/main.rs:4:5
|
4 | use esp_idf_hal::delay::FreeRtos;
| ^^^^^^^^^^^ use of undeclared crate or module `esp_idf_hal`
|
help: there is a crate or module with a similar name
|
4 | use esp_idf_svc::delay::FreeRtos;
| ~~~~~~~~~~~
error[E0433]: failed to resolve: use of undeclared crate or module `esp_idf_hal`
--> src/main.rs:6:5
|
6 | use esp_idf_hal::peripherals::Peripherals;
| ^^^^^^^^^^^ use of undeclared crate or module `esp_idf_hal`
|
help: there is a crate or module with a similar name
|
6 | use esp_idf_svc::peripherals::Peripherals;
| ~~~~~~~~~~~
error[E0432]: unresolved import `esp_idf_sys`
--> src/main.rs:1:5
|
1 | use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always k...
| ^^^^^^^^^^^^^^^^ no external crate `esp_idf_sys`
error[E0433]: failed to resolve: use of undeclared type `PinDriver`
--> src/main.rs:15:21
|
15 | let mut r_pin = PinDriver::output(peripherals.pins.gpio16).expect("Error: Unab...
| ^^^^^^^^^ use of undeclared type `PinDriver`
|
help: consider importing this struct
|
1 + use esp_idf_svc::hal::gpio::PinDriver;
|
error[E0433]: failed to resolve: use of undeclared crate or module `esp_idf_sys`
--> src/main.rs:10:5
|
10 | esp_idf_sys::link_patches();
| ^^^^^^^^^^^ use of undeclared crate or module `esp_idf_sys`
|
help: there is a crate or module with a similar name
|
10 | esp_idf_svc::link_patches();
| ~~~~~~~~~~~
Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `test` (bin "test") due to 6 previous errors
Ist die Vorgehensweise zum aufsetzen des Projekts richtig so? Das mit den 'generate' aus dem Tutorial, dass dann auf ein GitHub-Repository zurückgreift, kommt mir irgendwie komisch vor.
Habe mir schon gedacht, es wäre vielleicht sinnvoller gewesen, das erst mal in einer virtuellen Maschine aufzusetzen, nicht das ich jetzt schon so viel Mist auf meinem System installiert habe, das ich gar nicht brauche.
Ich wäre sehr dankbar, wenn mir jemand hier weiterhelfen könnte. Habe schon sehr große Lust darauf, so ein Rust-ESP-Projekt zu machen.
Hätte auch schon sehr coole Ideen, besonders sowas würde ich genial finden. Aber da bin ich eher realistisch gestimmt und werde erst mal die grundlegenden Dinge (LED, Taster und Co) lernen und verstehen (und natürlich die Sprache an sich).
Viele Grüße
Dennis