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