Skip to content

Commit e2a47e6

Browse files
committed
first commit
0 parents  commit e2a47e6

File tree

8 files changed

+120
-0
lines changed

8 files changed

+120
-0
lines changed

.cargo/config.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[build]
2+
target = "xtensa-esp32-espidf"
3+
4+
[target.xtensa-esp32-espidf]
5+
linker = "ldproxy"
6+
runner = "espflash flash --monitor"
7+
rustflags = [ "--cfg", "espidf_time64"]
8+
9+
[unstable]
10+
build-std = ["std", "panic_abort"]
11+
12+
[env]
13+
MCU="esp32"
14+
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
15+
ESP_IDF_VERSION = "v5.2.3"
16+

.github/workflows/rust_ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- "**/README.md"
7+
pull_request:
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
14+
jobs:
15+
rust-checks:
16+
name: Rust Checks
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
action:
22+
- command: build
23+
args: --release
24+
- command: fmt
25+
args: --all -- --check --color always
26+
- command: clippy
27+
args: --all-targets --all-features --workspace -- -D warnings
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
- name: Setup Rust
32+
uses: esp-rs/xtensa-toolchain@v1.5
33+
with:
34+
default: true
35+
buildtargets: esp32
36+
ldproxy: true
37+
- name: Enable caching
38+
uses: Swatinem/rust-cache@v2
39+
- name: Run command
40+
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.vscode
2+
/.embuild
3+
/target
4+
/Cargo.lock

Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "ego-esp"
3+
version = "0.1.0"
4+
authors = ["noreplydev <contact.cristiansanchez@gmail.com>"]
5+
edition = "2021"
6+
resolver = "2"
7+
rust-version = "1.77"
8+
9+
[[bin]]
10+
name = "ego-esp"
11+
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
12+
13+
[profile.release]
14+
opt-level = "s"
15+
16+
[profile.dev]
17+
debug = true # Symbols are nice and they don't increase the size on Flash
18+
opt-level = "z"
19+
20+
[features]
21+
default = []
22+
23+
experimental = ["esp-idf-svc/experimental"]
24+
25+
[dependencies]
26+
log = "0.4"
27+
esp-idf-svc = { version = "0.50", features = ["critical-section", "embassy-time-driver", "embassy-sync"] }
28+
self_vm = {git = "https://github.com/ego-programming-language/ego", package = "self-vm"}
29+
30+
[build-dependencies]
31+
embuild = "0.33"

build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
embuild::espidf::sysenv::output();
3+
}

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "esp"

sdkconfig.defaults

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
2+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8000
3+
4+
# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default).
5+
# This allows to use 1 ms granularity for thread sleeps (10 ms by default).
6+
#CONFIG_FREERTOS_HZ=1000
7+
8+
# Workaround for https://github.com/espressif/esp-idf/issues/7631
9+
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
10+
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n

src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fn main() {
2+
// It is necessary to call this function once. Otherwise some patches to the runtime
3+
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
4+
esp_idf_svc::sys::link_patches();
5+
6+
// Bind the log crate to the ESP Logging facilities
7+
esp_idf_svc::log::EspLogger::initialize_default();
8+
9+
// do your stuff here
10+
log::info!("Hello, ego!");
11+
// "HELLO" bytecode
12+
let mut vm = self_vm::new(vec![1, 5, 3, 5, 0, 0, 0, 72, 69, 76, 76, 79, 2, 1, 0, 0, 0]);
13+
vm.run(&vec![]);
14+
}

0 commit comments

Comments
 (0)