rsiot/doc/dev_prepare/riscv32imc_esp_espidf.rs
1//! # riscv32imc-esp-espidf
2//!
3//! ## Подготовка среды разработки
4//!
5//! **toolchain**
6//!
7//! ```bash
8//! rustup toolchain install nightly-2024-02-01-x86_64-unknown-linux-gnu --component rust-src
9//! ```
10//!
11//! TODO - обновить когда пофиксят
12//!
13//! **ESP-IDF**
14//!
15//! Зависимости для ESP-IDF <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html#for-linux-users>:
16//!
17//! ```bash
18//! sudo apt-get install git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
19//! ```
20//!
21//! **ldproxy**
22//!
23//! ```bash
24//! cargo install ldproxy
25//! ```
26//!
27//! **LLVM**
28//!
29//! ```bash
30//! sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
31//! ```
32//!
33//! **espflash**
34//!
35//! ```bash
36//! sudo usermod -a -G dialout $USER
37//!
38//! sudo apt install libudev-dev
39//!
40//! cargo install espflash
41//! ```
42//!
43//! **cargo generate**
44//!
45//! ```bash
46//! cargo install cargo-generate
47//! ```
48//!
49//! ## Создание проекта
50//!
51//! ```bash
52//! cargo generate esp-rs/esp-idf-template cargo
53//! ```
54//!
55//! **`.zed/settings.json`**
56//!
57//! ```json
58//! {
59//! "lsp": {
60//! "rust-analyzer": {
61//! "initialization_options": {
62//! "check": {
63//! "command": "clippy"
64//! },
65//! "cargo": {
66//! "target": "riscv32imc-esp-espidf"
67//! }
68//! }
69//! }
70//! }
71//! }
72//! ```
73//!
74//! **`.cargo/config.toml`**
75//!
76//! ```toml
77//! [build]
78//! target = "riscv32imc-esp-espidf"
79//!
80//! [target.riscv32imc-esp-espidf]
81//! linker = "ldproxy"
82//! runner = "espflash flash --monitor"
83//! rustflags = [
84//! "--cfg",
85//! "espidf_time64",
86//! "--cfg",
87//! "mio_unsupported_force_poll_poll", # https://github.com/tokio-rs/tokio/issues/5866
88//! ]
89//!
90//! [unstable]
91//! build-std = ["std", "panic_abort"]
92//!
93//! [env]
94//! MCU = "esp32c3"
95//! # install all libraries globally, in folder ~/.espressif
96//! ESP_IDF_TOOLS_INSTALL_DIR = "global"
97//! # check current version on https://github.com/espressif/esp-idf/releases
98//! ESP_IDF_VERSION = "v5.3.1"
99//! ```
100//!
101//! **`build.rs`**
102//!
103//! ```ignore
104//! fn main() {
105//! embuild::espidf::sysenv::output();
106//! }
107//! ```
108//!
109//! **`rust-toolchain.toml`**
110//!
111//! ```toml
112#![doc = include_str!("../../../rust-toolchain.toml")]
113//! ```
114//!
115//! **`sdkconfig.defaults`**
116//!
117//! ```toml
118#![doc = include_str!("../../../sdkconfig.defaults")]
119//! ```
120//!
121//! **`Cargo.toml`**
122//!
123//! ```toml
124//! [dependencies]
125//! esp-idf-svc = { version = "*" }
126//!
127//! [build-dependencies]
128//! embuild = { version = "*", features = ["espidf"] }
129//! ```
130//!
131//! **`main.rs`**
132//!
133//! Первой строкой в функции main():
134//!
135//! ```rust
136//! esp_idf_svc::sys::link_patches();
137//! ```