thx linux
This commit is contained in:
parent
945e6ba2ff
commit
1eb00aea6e
16
esp/rust/03_aht20/.cargo/config.toml
Normal file
16
esp/rust/03_aht20/.cargo/config.toml
Normal file
@ -0,0 +1,16 @@
|
||||
[build]
|
||||
target = "xtensa-esp32-espidf"
|
||||
|
||||
[target.xtensa-esp32-espidf]
|
||||
linker = "ldproxy"
|
||||
runner = "espflash flash --monitor"
|
||||
rustflags = [ "--cfg", "espidf_time64"]
|
||||
|
||||
[unstable]
|
||||
build-std = ["std", "panic_abort"]
|
||||
|
||||
[env]
|
||||
MCU="esp32"
|
||||
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
|
||||
ESP_IDF_VERSION = "v5.3.3"
|
||||
|
42
esp/rust/03_aht20/.github/workflows/rust_ci.yml
vendored
Normal file
42
esp/rust/03_aht20/.github/workflows/rust_ci.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- "**/README.md"
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
rust-checks:
|
||||
name: Rust Checks
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
action:
|
||||
- command: build
|
||||
args: --release
|
||||
- command: fmt
|
||||
args: --all -- --check --color always
|
||||
- command: clippy
|
||||
args: --all-targets --all-features --workspace -- -D warnings
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Rust
|
||||
uses: esp-rs/xtensa-toolchain@v1.6
|
||||
with:
|
||||
default: true
|
||||
buildtargets: esp32
|
||||
ldproxy: true
|
||||
- name: Enable caching
|
||||
uses: Swatinem/rust-cache@v2
|
||||
- name: Run command
|
||||
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }}
|
4
esp/rust/03_aht20/.gitignore
vendored
Normal file
4
esp/rust/03_aht20/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/.vscode
|
||||
/.embuild
|
||||
/target
|
||||
/Cargo.lock
|
47
esp/rust/03_aht20/Cargo.toml
Normal file
47
esp/rust/03_aht20/Cargo.toml
Normal file
@ -0,0 +1,47 @@
|
||||
[package]
|
||||
name = "aht20"
|
||||
version = "0.1.0"
|
||||
authors = ["shaun"]
|
||||
edition = "2021"
|
||||
resolver = "2"
|
||||
rust-version = "1.77"
|
||||
|
||||
[[bin]]
|
||||
name = "aht20"
|
||||
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
|
||||
[profile.dev]
|
||||
debug = true # Symbols are nice and they don't increase the size on Flash
|
||||
opt-level = "z"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
experimental = ["esp-idf-svc/experimental"]
|
||||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
esp-idf-svc = "0.51"
|
||||
|
||||
# --- Optional Embassy Integration ---
|
||||
# esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync"] }
|
||||
|
||||
# If you enable embassy-time-driver, you MUST also add one of:
|
||||
|
||||
# a) Standalone Embassy libs ( embassy-time, embassy-sync etc) with a foreign async runtime:
|
||||
# embassy-time = { version = "0.4.0", features = ["generic-queue-8"] } # NOTE: any generic-queue variant will work
|
||||
|
||||
# b) With embassy-executor:
|
||||
# embassy-executor = { version = "0.7", features = ["executor-thread", "arch-std"] }
|
||||
|
||||
# NOTE: if you use embassy-time with embassy-executor you don't need the generic-queue-8 feature
|
||||
|
||||
# --- Temporary workaround for embassy-executor < 0.8 ---
|
||||
# esp-idf-svc = { version = "0.51", features = ["embassy-time-driver", "embassy-sync"] }
|
||||
# critical-section = { version = "1.1", features = ["std"], default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
embuild = "0.33"
|
3
esp/rust/03_aht20/build.rs
Normal file
3
esp/rust/03_aht20/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
embuild::espidf::sysenv::output();
|
||||
}
|
2
esp/rust/03_aht20/rust-toolchain.toml
Normal file
2
esp/rust/03_aht20/rust-toolchain.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "esp"
|
10
esp/rust/03_aht20/sdkconfig.defaults
Normal file
10
esp/rust/03_aht20/sdkconfig.defaults
Normal file
@ -0,0 +1,10 @@
|
||||
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
|
||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8000
|
||||
|
||||
# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default).
|
||||
# This allows to use 1 ms granularity for thread sleeps (10 ms by default).
|
||||
#CONFIG_FREERTOS_HZ=1000
|
||||
|
||||
# Workaround for https://github.com/espressif/esp-idf/issues/7631
|
||||
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
|
||||
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n
|
10
esp/rust/03_aht20/src/main.rs
Normal file
10
esp/rust/03_aht20/src/main.rs
Normal file
@ -0,0 +1,10 @@
|
||||
fn main() {
|
||||
// It is necessary to call this function once. Otherwise some patches to the runtime
|
||||
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
|
||||
esp_idf_svc::sys::link_patches();
|
||||
|
||||
// Bind the log crate to the ESP Logging facilities
|
||||
esp_idf_svc::log::EspLogger::initialize_default();
|
||||
|
||||
log::info!("Hello, world!");
|
||||
}
|
@ -10,6 +10,24 @@ shaunrd0/klips/esp/rust
|
||||
|
||||
## Development Setup
|
||||
|
||||
Install Rust
|
||||
|
||||
```bash
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
```
|
||||
|
||||
You must run these commands to set up ESP before building any of these examples.
|
||||
|
||||
```bash
|
||||
sudo apt install python3-venv
|
||||
mkdir /tmp/espup && cd /tmp/espup
|
||||
cargo install espup --locked
|
||||
espup install
|
||||
cargo install ldproxy
|
||||
sudo usermod -aG dialout $USER
|
||||
newgrp dialout
|
||||
```
|
||||
|
||||
Some notes I took while setting this up for the first time: [Knoats](https://knoats.com/books/esp32/page/rust)
|
||||
|
||||
[Espressif Rust book](https://docs.espressif.com/projects/rust/book/introduction.html)
|
||||
|
Loading…
x
Reference in New Issue
Block a user