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