File tree Expand file tree Collapse file tree 4 files changed +117
-1
lines changed Expand file tree Collapse file tree 4 files changed +117
-1
lines changed Original file line number Diff line number Diff line change 1+ name : Compile Demo with Rust
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ branches :
7+ - main
8+ tags :
9+ - " *"
10+ paths :
11+ - demo_rust/**
12+ - .github/workflows/compile_demo_rust.yml
13+ pull_request :
14+ branches :
15+ - main
16+ paths :
17+ - demo_rust/**
18+ - .github/workflows/compile_demo_rust.yml
19+
20+ jobs :
21+ compile_demo_rust :
22+ runs-on : ubuntu-latest
23+
24+ steps :
25+ - uses : actions/checkout@v4
26+
27+ - name : Set up Rust
28+ uses : actions/setup-rust@v1
29+ with :
30+ rust-version : stable
31+
32+ - name : Install espup
33+ run : |
34+ cargo install espup
35+ espup install
36+
37+ - name : Add espup to PATH
38+ run : echo "$HOME/.cargo/bin" >> $GITHUB_PATH
39+
40+ - name : Build Rust project
41+ run : |
42+ cd demo_rust
43+ cargo build --release
44+
45+ - name : List all files
46+ if : always()
47+ continue-on-error : true
48+ run : |
49+ set -x
50+ pwd
51+ ls -all
52+ tree
53+
54+ - name : Upload firmware
55+ uses : actions/upload-artifact@v4
56+ with :
57+ path : demo_rust/target/xtensa-esp32-espidf/release/demo_rust
58+ name : demo_rust
59+ compression-level : 0
60+ if-no-files-found : error
Original file line number Diff line number Diff line change @@ -121,6 +121,30 @@ idf.py add-dependency
121121
122122---
123123
124+ ## Rust
125+
126+ ### Install Rust
127+
128+ ``` bash
129+ curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
130+ ```
131+
132+ ### Install espup
133+
134+ ``` bash
135+ cargo install espup
136+ espup install
137+ ```
138+
139+ ### Compile firmware with Rust
140+
141+ ``` bash
142+ cd demo_rust
143+ cargo build --release
144+ ```
145+
146+ ---
147+
124148## Flash firmware
125149
126150- Install esptool.py - ` pip install -U esptool `
@@ -178,4 +202,4 @@ https://github.com/esp-rs/esp-idf-template
178202- https://github.com/m5stack
179203- https://github.com/matthew-5pl
180204- https://github.com/bmorcelli
181- - https://github.com/7h30th3r0n3
205+ - https://github.com/7h30th3r0n3
Original file line number Diff line number Diff line change 1+ [package ]
2+ name = " demo_rust"
3+ version = " 0.1.0"
4+ authors = [" Your Name <you@example.com>" ]
5+ edition = " 2018"
6+
7+ [dependencies ]
8+ esp-idf-sys = " 0.25.0"
9+ esp-idf-hal = " 0.25.0"
10+ esp-idf-svc = " 0.25.0"
11+ esp-idf = " 0.25.0"
12+ log = " 0.4"
13+ anyhow = " 1.0"
Original file line number Diff line number Diff line change 1+ use esp_idf_sys as _; // If using the `std` feature of `esp-idf-sys`, always keep this module imported
2+ use esp_idf_hal:: prelude:: * ;
3+ use esp_idf_hal:: gpio:: { Gpio2 , Output } ;
4+
5+ fn main ( ) -> anyhow:: Result < ( ) > {
6+ esp_idf_sys:: link_patches ( ) ;
7+
8+ let peripherals = Peripherals :: take ( ) . unwrap ( ) ;
9+ let pins = peripherals. pins ;
10+
11+ let mut led = pins. gpio2 . into_output ( ) ?;
12+
13+ loop {
14+ led. set_high ( ) ?;
15+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 1000 ) ) ;
16+ led. set_low ( ) ?;
17+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 1000 ) ) ;
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments