From 7542e733c1b1193f2584d8ddbb5df92eb6618538 Mon Sep 17 00:00:00 2001 From: Wyatt Marchand Date: Tue, 25 Aug 2026 20:24:08 -0700 Subject: [PATCH] Initial project creation --- .cargo/config.toml | 19 +++++++++++++++++++ .gitignore | 4 ++++ Cargo.toml | 26 ++++++++++++++++++++++++++ build.rs | 3 +++ rust-toolchain.toml | 2 ++ sdkconfig.defaults | 12 ++++++++++++ src/main.rs | 10 ++++++++++ 7 files changed, 76 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 build.rs create mode 100644 rust-toolchain.toml create mode 100644 sdkconfig.defaults create mode 100644 src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..e8cb976 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,19 @@ +[build] +target = "xtensa-esp32s3-espidf" + +[target.'cfg(target_os = "espidf")'] +linker = "ldproxy" +runner = "espflash flash --monitor" +rustflags = [ "--cfg", "espidf_time64"] + +[unstable] +build-std = ["std", "panic_abort"] + +[env] +MCU = "esp32s3" +ESP_IDF_VERSION = "v5.3.4" +ESP_IDF_TOOLS_INSTALL_DIR = "global" + +# Uncomment this if you have moved the target dir by setting CARGO_TARGET_DIR or similar. +# Required for now due to embuild limitations. +#CARGO_WORKSPACE_DIR = { value = "", relative = true } diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73a638b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.vscode +/.embuild +/target +/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..2d23c28 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "esp32s3_remote_i2c_lcd" +version = "0.1.0" +authors = ["Wyatt Marchand "] +edition = "2021" +resolver = "2" +rust-version = "1.82" + +[[bin]] +name = "esp32s3_remote_i2c_lcd" +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" + +[dependencies] +esp-idf-svc = { version = "0.51", features = ["std"] } +anyhow = "1" +log = "0.4" + +[build-dependencies] +embuild = "0.33" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..112ec3f --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + embuild::espidf::sysenv::output(); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..a2f5ab5 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "esp" diff --git a/sdkconfig.defaults b/sdkconfig.defaults new file mode 100644 index 0000000..2d610c9 --- /dev/null +++ b/sdkconfig.defaults @@ -0,0 +1,12 @@ +# Increase a bit these stack sizes as they are also a bit too small by default +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=4096 +CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=4096 + +# You might have to increase this further if you spawn your own Rust threads +# that allocate large stack variables; or better yet - use +# `std::thread::Builder::new().stack_size(XXX)` for spawning +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=4096 + +CONFIG_ETH_SPI_ETHERNET_W5500=y +CONFIG_ESP_MAIN_TASK_STACK_SIZE=8000 +CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..419e7f7 --- /dev/null +++ b/src/main.rs @@ -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!"); +}