commit c428b78cd4793ab91296a2f904e727d333eaab04 Author: Evan Feenstra Date: Wed May 18 15:40:24 2022 -0700 setup esp32-c3 project, target: riscv32imc-esp-espidf, toolchain: nightly diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..ff90964 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,34 @@ +[build] +# Uncomment the relevant target for your chip here (ESP32, ESP32-S2, ESP32-S3 or ESP32-C3) +#target = "xtensa-esp32-espidf" +#target = "xtensa-esp32s2-espidf" +#target = "xtensa-esp32s3-espidf" +target = "riscv32imc-esp-espidf" + +[target.xtensa-esp32-espidf] +linker = "ldproxy" + +[target.xtensa-esp32s2-espidf] +linker = "ldproxy" + +[target.xtensa-esp32s3-espidf] +linker = "ldproxy" + +[target.riscv32imc-esp-espidf] +linker = "ldproxy" + +# Future - necessary for the experimental "native build" of esp-idf-sys with ESP32C3 +# See also https://github.com/ivmarkov/embuild/issues/16 +rustflags = ["-C", "default-linker-libraries"] + +[unstable] + +build-std = ["std", "panic_abort"] +#build-std-features = ["panic_immediate_abort"] # Required for older ESP-IDF versions without a realpath implementation + +[env] +# Note: these variables are not used when using pio builder +# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF stable (v4.4) +ESP_IDF_VERSION = { value = "branch:release/v4.4" } +# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF master (mainline) +#ESP_IDF_VERSION = { value = "master" } 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..d7ab80d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "sphinx-key" +version = "0.1.0" +authors = ["Evan Feenstra "] +edition = "2018" +resolver = "2" + +[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] +pio = ["esp-idf-sys/pio"] + +[dependencies] +esp-idf-sys = { version = "0.31.5", features = ["binstart"] } + + +[build-dependencies] +embuild = "0.29" +anyhow = "1" diff --git a/README.md b/README.md new file mode 100644 index 0000000..3733f68 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# sphinx-key + +### deps + +##### cargo nightly: + +`rustup install nightly` + +`rustup component add rust-src --toolchain nightly` + +##### python 3.7 or higher is required + +##### cargo sub-commands + +`cargo install cargo-generate` + +`cargo install ldproxy` + +`cargo install espflash` + +`cargo install espmonitor` + +### build + +`cargo build` + +### flash + +`espflash /dev/ttyUSB0 target/riscv32imc-esp-espidf/debug/sphinx-key` + +replace dev/ttyUSB0 with the usb where board is connected diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..4dd5e1f --- /dev/null +++ b/build.rs @@ -0,0 +1,5 @@ +// Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641 +fn main() -> anyhow::Result<()> { + embuild::build::CfgArgs::output_propagated("ESP_IDF")?; + embuild::build::LinkArgs::output_propagated("ESP_IDF") +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..fb33ae1 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] + +channel = "nightly" \ No newline at end of file diff --git a/sdkconfig.defaults b/sdkconfig.defaults new file mode 100644 index 0000000..0ac9af4 --- /dev/null +++ b/sdkconfig.defaults @@ -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=7000 + +# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default). +# This allows to use 1 ms granuality 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 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..2d3bfaf --- /dev/null +++ b/src/main.rs @@ -0,0 +1,9 @@ +use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported + +fn main() { + // Temporary. Will disappear once ESP-IDF 4.4 is released, but for now it is necessary to call this function once, + // or else some patches to the runtime implemented by esp-idf-sys might not link properly. + esp_idf_sys::link_patches(); + + println!("Hello, world!"); +}