diff --git a/factory/.cargo/config.toml b/factory/.cargo/config.toml index 548a46d..230e455 100644 --- a/factory/.cargo/config.toml +++ b/factory/.cargo/config.toml @@ -1,30 +1,16 @@ [build] 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"] +# runner = "espflash --monitor" # Select this runner for espflash v1.x.x +runner = "espflash flash --monitor" # Select this runner for espflash v2.x.x +rustflags = ["--cfg", "espidf_time64", "-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 = "tag:v4.4.2" } -# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF master (mainline) -#ESP_IDF_VERSION = { value = "master" } +# Note: these variables are not used when using pio builder (`cargo build --features pio`) +ESP_IDF_VERSION = "tag:v5.0.2" +MCU = { value = "esp32c3" } diff --git a/factory/Cargo.lock b/factory/Cargo.lock index 196d3bf..d642e0c 100644 --- a/factory/Cargo.lock +++ b/factory/Cargo.lock @@ -77,6 +77,12 @@ dependencies = [ "critical-section", ] +[[package]] +name = "atomic-waker" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" + [[package]] name = "autocfg" version = "1.1.0" @@ -494,46 +500,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys 0.3.7", -] - -[[package]] -name = "dirs" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dece029acd3353e3a58ac2e3eb3c8d6c35827a892edc6cc4138ef9c33df46ecd" -dependencies = [ - "dirs-sys 0.4.0", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "dirs-sys" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04414300db88f70d74c5ff54e50f9e1d1737d9a5b90f53fcf2e95ca2a9ab554b" -dependencies = [ - "libc", - "redox_users", - "windows-sys 0.45.0", -] - [[package]] name = "edge-executor" version = "0.3.0" @@ -552,6 +518,12 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "embassy-futures" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e5367165d347c039360f784812f493b001583ab6a3dd8622f4ce9c30374ec3" + [[package]] name = "embedded-can" version = "0.4.1" @@ -573,40 +545,40 @@ dependencies = [ [[package]] name = "embedded-hal" -version = "1.0.0-alpha.9" +version = "1.0.0-alpha.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129b101ddfee640565f7c07b301a31d95aa21e5acef21a491c307139f5fa4c91" +checksum = "f65c4d073f5d91c66e629b216818a4c9747eeda0debedf2deda9a0a947e4e93b" [[package]] name = "embedded-hal-nb" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0760ec0a3bf76859d5e33f39542af103f157d5b2ecfb00ace56dd461472e3a" +checksum = "1465fffd56a95bbc105c17965bca1c1d5815027b1cc6bb183bc05d04563d065c" dependencies = [ - "embedded-hal 1.0.0-alpha.9", + "embedded-hal 1.0.0-alpha.10", "nb 1.0.0", ] [[package]] name = "embedded-io" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36673b79844ff4ec0e3f00aeca0b2cfff564ff6739ab9801d13f45a8ec6cc1c7" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" dependencies = [ "futures", ] [[package]] name = "embedded-svc" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2079f8182848872fb6e8eed2c1ba3aea409fc71984a9e8090733c08c404e7864" +checksum = "c4b70d70bd45c40027ed1c997ec3fb63ffb7237d5b2ad7b7da89adf0c3b93c71" dependencies = [ "anyhow", + "atomic-waker", "defmt", "embedded-io", "enumset", - "futures", "heapless", "log", "no-std-net", @@ -618,38 +590,18 @@ dependencies = [ [[package]] name = "embuild" -version = "0.29.3" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd1dd6c90e28cfc361281a692320fcd820bcae71d327215e87c7d749bf8ddd26" -dependencies = [ - "anyhow", - "bitflags", - "dirs 4.0.0", - "filetime", - "log", - "serde", - "serde_json", - "shlex", - "strum 0.24.1", - "thiserror", - "toml 0.5.9", - "xmas-elf", -] - -[[package]] -name = "embuild" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "481bc7905b77810b66783faeb8c30d466fc7d128d7e4bdf2415e5f6ae1550dfe" +checksum = "3ad838e9b86748e477f1d882c41777978947ca3a1f0cdde572234bc7dc68ed3d" dependencies = [ "anyhow", "bindgen", "bitflags", "cargo_toml", "cmake", - "dirs 5.0.0", "filetime", "globwalk", + "home", "log", "remove_dir_all 0.8.2", "serde", @@ -696,17 +648,19 @@ dependencies = [ [[package]] name = "esp-idf-hal" -version = "0.40.1" +version = "0.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4354dcc4d157de675c55eb2e98f4985a526ea56fff316aa0939a63636c4952b" +checksum = "6a96e45aac076e5ba2e98a650c22a7deca22dff9ee34b817898de60b14264381" dependencies = [ "anyhow", + "atomic-waker", "edge-executor", "embedded-can", "embedded-hal 0.2.7", - "embedded-hal 1.0.0-alpha.9", + "embedded-hal 1.0.0-alpha.10", "embedded-hal-nb", - "embuild 0.31.1", + "embuild", + "enumset", "esp-idf-sys", "heapless", "nb 1.0.0", @@ -714,13 +668,14 @@ dependencies = [ [[package]] name = "esp-idf-svc" -version = "0.45.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6035126eeaf81d19ca5342fa8f36e85489c6fba1148ec8af167a6b9bff39e0f" +checksum = "665233a26567d141f1bab603b9a868dc28bb8bea1188e7d927bab44329b84d63" dependencies = [ "anyhow", + "embassy-futures", "embedded-svc", - "embuild 0.31.1", + "embuild", "enumset", "esp-idf-hal", "esp-idf-sys", @@ -731,16 +686,16 @@ dependencies = [ [[package]] name = "esp-idf-sys" -version = "0.32.1" +version = "0.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b3458faf5c04761cb9a122ba30714afda5e88848e2f99c6e6c05c77ecf626d8" +checksum = "0d793b605e8037907f0e6697b0995a355238f065f321dd389fdf866aa9f8d140" dependencies = [ "anyhow", "bindgen", "build-time", "cargo_metadata", "const_format", - "embuild 0.31.1", + "embuild", "envy", "libc", "regex", @@ -965,6 +920,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "iana-time-zone" version = "0.1.54" @@ -1366,17 +1330,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall", - "thiserror", -] - [[package]] name = "regex" version = "1.6.0" @@ -1636,9 +1589,9 @@ version = "0.1.0" dependencies = [ "anyhow", "bitflags", - "embedded-hal 0.2.7", + "embedded-hal 1.0.0-alpha.10", "embedded-svc", - "embuild 0.29.3", + "embuild", "esp-idf-hal", "esp-idf-svc", "esp-idf-sys", @@ -2315,18 +2268,3 @@ checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" dependencies = [ "memchr", ] - -[[package]] -name = "xmas-elf" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d29b4d8e7beaceb4e77447ba941a7600d23d0319ab52da0461abea214832d5a" -dependencies = [ - "zero", -] - -[[package]] -name = "zero" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f1bc8a6b2005884962297587045002d8cfb8dcec9db332f4ca216ddc5de82c5" diff --git a/factory/Cargo.toml b/factory/Cargo.toml index df1c24e..a2d28ea 100644 --- a/factory/Cargo.toml +++ b/factory/Cargo.toml @@ -3,27 +3,8 @@ name = "sphinx-key-factory" version = "0.1.0" authors = ["decentclock "] edition = "2021" - -[features] -pio = ["esp-idf-sys/pio"] - -[dependencies] -esp-idf-sys = { version = "0.32.1", features = ["binstart"] } -esp-idf-svc = { version = "0.45.0", features = ["experimental", "alloc"] } -esp-idf-hal = "0.40.1" -embedded-svc = "0.24.0" -embedded-hal = "0.2.7" -anyhow = { version = "1.0.65", features = ["backtrace"] } -rand = "0.8.5" -log = "0.4.17" -bitflags = "1.3.2" - -[build-dependencies] -embuild = "0.29" -anyhow = "1" - -[package.metadata.espflash] -partition_table = "table.csv" +resolver = "2" +rust-version = "1.66" [profile.release] strip = true # Automatically strip symbols from the binary. @@ -31,3 +12,27 @@ opt-level = "z" # Optimize for size. lto = true codegen-units = 1 panic = "abort" + +[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.33.1", features = ["binstart"] } +esp-idf-svc = { version = "0.46.0", features = ["experimental", "alloc"] } +esp-idf-hal = "0.41.1" +embedded-svc = "0.25.0" +embedded-hal = "=1.0.0-alpha.10" +anyhow = { version = "1", features = ["backtrace"]} +rand = "0.8.5" +log = "0.4.17" +bitflags = "1.3.2" + +[build-dependencies] +embuild = "0.31.2" + +[package.metadata.espflash] +partition_table = "table.csv" diff --git a/factory/build.rs b/factory/build.rs index 4dd5e1f..ccb6e75 100644 --- a/factory/build.rs +++ b/factory/build.rs @@ -1,5 +1,6 @@ // Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641 -fn main() -> anyhow::Result<()> { +fn main() -> Result<(), Box> { embuild::build::CfgArgs::output_propagated("ESP_IDF")?; - embuild::build::LinkArgs::output_propagated("ESP_IDF") + embuild::build::LinkArgs::output_propagated("ESP_IDF")?; + Ok(()) } diff --git a/factory/rust-toolchain.toml b/factory/rust-toolchain.toml index 4f79377..33fa244 100644 --- a/factory/rust-toolchain.toml +++ b/factory/rust-toolchain.toml @@ -1,2 +1,3 @@ [toolchain] -channel = "nightly-2022-10-20" +channel = "nightly-2023-06-13" +components = ["rust-src"] diff --git a/factory/src/led.rs b/factory/src/led.rs index cc40c3e..5ee2df2 100644 --- a/factory/src/led.rs +++ b/factory/src/led.rs @@ -1,4 +1,3 @@ -use embedded_hal::blocking::delay::DelayMs; use esp_idf_hal::delay::Ets; use esp_idf_hal::delay::FreeRtos; use esp_idf_hal::peripherals::Peripherals; diff --git a/factory/src/sdcard.rs b/factory/src/sdcard.rs index 64da52c..d3b8bc3 100644 --- a/factory/src/sdcard.rs +++ b/factory/src/sdcard.rs @@ -61,6 +61,7 @@ fn setup() -> anyhow::Result<()> { format_if_mount_failed: false, max_files: 5, allocation_unit_size: 16 * 1024, + disk_status_check_enable: false, }; let mut card: *mut sdmmc_card_t = ptr::null_mut(); diff --git a/sphinx-key/.cargo/config.toml b/sphinx-key/.cargo/config.toml index 6d4c078..227eedc 100644 --- a/sphinx-key/.cargo/config.toml +++ b/sphinx-key/.cargo/config.toml @@ -1,36 +1,18 @@ [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"] +# runner = "espflash --monitor" # Select this runner for espflash v1.x.x +runner = "espflash flash --monitor" # Select this runner for espflash v2.x.x +rustflags = ["--cfg", "espidf_time64", "-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 = "tag:v4.4.2" } -# Enables the esp-idf-sys "native" build feature (`cargo build --features native`) to build against ESP-IDF master (mainline) -#ESP_IDF_VERSION = { value = "master" } -CC = { value = "../factory/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-patch3-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc", relative = true } +# Note: these variables are not used when using pio builder (`cargo build --features pio`) +ESP_IDF_VERSION = "tag:v5.0.2" +CC = { value = "../factory/.embuild/espressif/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc", relative = true } CFLAGS = { value = "-fno-pic" } +MCU = { value = "esp32c3" } diff --git a/sphinx-key/Cargo.lock b/sphinx-key/Cargo.lock index 9341024..2c79a14 100644 --- a/sphinx-key/Cargo.lock +++ b/sphinx-key/Cargo.lock @@ -100,6 +100,12 @@ dependencies = [ "critical-section", ] +[[package]] +name = "atomic-waker" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" + [[package]] name = "autocfg" version = "1.1.0" @@ -284,7 +290,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f83bc2e401ed041b7057345ebc488c005efa0341d5541ce7004d30458d0090b" dependencies = [ "serde", - "toml 0.7.3", + "toml", ] [[package]] @@ -569,46 +575,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys 0.3.7", -] - -[[package]] -name = "dirs" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dece029acd3353e3a58ac2e3eb3c8d6c35827a892edc6cc4138ef9c33df46ecd" -dependencies = [ - "dirs-sys 0.4.0", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "dirs-sys" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04414300db88f70d74c5ff54e50f9e1d1737d9a5b90f53fcf2e95ca2a9ab554b" -dependencies = [ - "libc", - "redox_users", - "windows-sys", -] - [[package]] name = "edge-executor" version = "0.3.0" @@ -627,6 +593,12 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +[[package]] +name = "embassy-futures" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e5367165d347c039360f784812f493b001583ab6a3dd8622f4ce9c30374ec3" + [[package]] name = "embedded-can" version = "0.4.1" @@ -648,40 +620,40 @@ dependencies = [ [[package]] name = "embedded-hal" -version = "1.0.0-alpha.9" +version = "1.0.0-alpha.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "129b101ddfee640565f7c07b301a31d95aa21e5acef21a491c307139f5fa4c91" +checksum = "f65c4d073f5d91c66e629b216818a4c9747eeda0debedf2deda9a0a947e4e93b" [[package]] name = "embedded-hal-nb" -version = "1.0.0-alpha.1" +version = "1.0.0-alpha.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0760ec0a3bf76859d5e33f39542af103f157d5b2ecfb00ace56dd461472e3a" +checksum = "1465fffd56a95bbc105c17965bca1c1d5815027b1cc6bb183bc05d04563d065c" dependencies = [ - "embedded-hal 1.0.0-alpha.9", + "embedded-hal 1.0.0-alpha.10", "nb 1.1.0", ] [[package]] name = "embedded-io" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33dfba9e6c113f2fd8537c943780a7345945e66c86972e356b1152e19481bcf5" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" dependencies = [ "futures", ] [[package]] name = "embedded-svc" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2079f8182848872fb6e8eed2c1ba3aea409fc71984a9e8090733c08c404e7864" +checksum = "c4b70d70bd45c40027ed1c997ec3fb63ffb7237d5b2ad7b7da89adf0c3b93c71" dependencies = [ "anyhow", + "atomic-waker", "defmt", "embedded-io", "enumset", - "futures", "heapless", "log", "no-std-net", @@ -693,38 +665,18 @@ dependencies = [ [[package]] name = "embuild" -version = "0.29.3" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd1dd6c90e28cfc361281a692320fcd820bcae71d327215e87c7d749bf8ddd26" -dependencies = [ - "anyhow", - "bitflags", - "dirs 4.0.0", - "filetime", - "log", - "serde", - "serde_json", - "shlex", - "strum 0.24.1", - "thiserror", - "toml 0.5.11", - "xmas-elf", -] - -[[package]] -name = "embuild" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "481bc7905b77810b66783faeb8c30d466fc7d128d7e4bdf2415e5f6ae1550dfe" +checksum = "3ad838e9b86748e477f1d882c41777978947ca3a1f0cdde572234bc7dc68ed3d" dependencies = [ "anyhow", "bindgen", "bitflags", "cargo_toml", "cmake", - "dirs 5.0.0", "filetime", "globwalk", + "home", "log", "remove_dir_all", "serde", @@ -733,7 +685,7 @@ dependencies = [ "strum 0.24.1", "tempfile", "thiserror", - "toml 0.7.3", + "toml", "ureq", "which", ] @@ -777,7 +729,7 @@ checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" dependencies = [ "errno-dragonfly", "libc", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -792,17 +744,19 @@ dependencies = [ [[package]] name = "esp-idf-hal" -version = "0.40.1" +version = "0.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4354dcc4d157de675c55eb2e98f4985a526ea56fff316aa0939a63636c4952b" +checksum = "6a96e45aac076e5ba2e98a650c22a7deca22dff9ee34b817898de60b14264381" dependencies = [ "anyhow", + "atomic-waker", "edge-executor", "embedded-can", "embedded-hal 0.2.7", - "embedded-hal 1.0.0-alpha.9", + "embedded-hal 1.0.0-alpha.10", "embedded-hal-nb", - "embuild 0.31.1", + "embuild", + "enumset", "esp-idf-sys", "heapless", "nb 1.1.0", @@ -810,13 +764,14 @@ dependencies = [ [[package]] name = "esp-idf-svc" -version = "0.45.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6035126eeaf81d19ca5342fa8f36e85489c6fba1148ec8af167a6b9bff39e0f" +checksum = "665233a26567d141f1bab603b9a868dc28bb8bea1188e7d927bab44329b84d63" dependencies = [ "anyhow", + "embassy-futures", "embedded-svc", - "embuild 0.31.1", + "embuild", "enumset", "esp-idf-hal", "esp-idf-sys", @@ -827,16 +782,16 @@ dependencies = [ [[package]] name = "esp-idf-sys" -version = "0.32.1" +version = "0.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b3458faf5c04761cb9a122ba30714afda5e88848e2f99c6e6c05c77ecf626d8" +checksum = "0d793b605e8037907f0e6697b0995a355238f065f321dd389fdf866aa9f8d140" dependencies = [ "anyhow", "bindgen", "build-time", "cargo_metadata", "const_format", - "embuild 0.31.1", + "embuild", "envy", "libc", "regex", @@ -862,7 +817,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall 0.2.16", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -902,7 +857,7 @@ dependencies = [ "libc", "nix", "smart-default", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1104,6 +1059,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "iana-time-zone" version = "0.1.54" @@ -1198,7 +1162,7 @@ checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1313,7 +1277,7 @@ dependencies = [ [[package]] name = "lss-connector" version = "0.1.0" -source = "git+https://github.com/stakwork/sphinx-rs.git#5641870bb8a5dcd5c10e411baa86d431549869af" +source = "git+https://github.com/stakwork/sphinx-rs.git#057476d30a233d82d85456a83a10401b72533a8c" dependencies = [ "anyhow", "log", @@ -1410,7 +1374,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "972dec05f98e7c787ede35d7a9ea4735eb7788c299287352757b3def6cc1f7b5" dependencies = [ - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1627,17 +1591,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall 0.2.16", - "thiserror", -] - [[package]] name = "regex" version = "1.7.3" @@ -1668,7 +1621,7 @@ dependencies = [ "lazy_static", "libc", "normpath", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1740,7 +1693,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1965,7 +1918,7 @@ dependencies = [ [[package]] name = "sphinx-auther" version = "0.1.12" -source = "git+https://github.com/stakwork/sphinx-rs.git#5641870bb8a5dcd5c10e411baa86d431549869af" +source = "git+https://github.com/stakwork/sphinx-rs.git#057476d30a233d82d85456a83a10401b72533a8c" dependencies = [ "anyhow", "base64", @@ -1977,7 +1930,7 @@ dependencies = [ [[package]] name = "sphinx-crypter" version = "0.1.0" -source = "git+https://github.com/stakwork/sphinx-rs.git#5641870bb8a5dcd5c10e411baa86d431549869af" +source = "git+https://github.com/stakwork/sphinx-rs.git#057476d30a233d82d85456a83a10401b72533a8c" dependencies = [ "anyhow", "chacha20poly1305", @@ -1988,7 +1941,7 @@ dependencies = [ [[package]] name = "sphinx-glyph" version = "0.1.2" -source = "git+https://github.com/stakwork/sphinx-rs.git#5641870bb8a5dcd5c10e411baa86d431549869af" +source = "git+https://github.com/stakwork/sphinx-rs.git#057476d30a233d82d85456a83a10401b72533a8c" dependencies = [ "anyhow", "hex", @@ -2004,9 +1957,9 @@ version = "0.1.0" dependencies = [ "anyhow", "bitflags", - "embedded-hal 1.0.0-alpha.9", + "embedded-hal 1.0.0-alpha.10", "embedded-svc", - "embuild 0.29.3", + "embuild", "esp-idf-hal", "esp-idf-svc", "esp-idf-sys", @@ -2025,7 +1978,7 @@ dependencies = [ [[package]] name = "sphinx-signer" version = "0.1.0" -source = "git+https://github.com/stakwork/sphinx-rs.git#5641870bb8a5dcd5c10e411baa86d431549869af" +source = "git+https://github.com/stakwork/sphinx-rs.git#057476d30a233d82d85456a83a10401b72533a8c" dependencies = [ "anyhow", "bip39", @@ -2156,7 +2109,7 @@ dependencies = [ "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -2225,15 +2178,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "toml" version = "0.7.3" @@ -2608,7 +2552,7 @@ version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", ] [[package]] @@ -2617,7 +2561,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] @@ -2626,13 +2579,28 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -2641,42 +2609,84 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "winnow" version = "0.4.1" @@ -2686,21 +2696,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "xmas-elf" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d29b4d8e7beaceb4e77447ba941a7600d23d0319ab52da0461abea214832d5a" -dependencies = [ - "zero", -] - -[[package]] -name = "zero" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe21bcc34ca7fe6dd56cc2cb1261ea59d6b93620215aefb5ea6032265527784" - [[package]] name = "zeroize" version = "1.6.0" diff --git a/sphinx-key/Cargo.toml b/sphinx-key/Cargo.toml index 131afe0..a77d06e 100644 --- a/sphinx-key/Cargo.toml +++ b/sphinx-key/Cargo.toml @@ -2,8 +2,9 @@ name = "sphinx-key" version = "0.1.0" authors = ["Evan Feenstra "] -edition = "2018" +edition = "2021" resolver = "2" +rust-version = "1.66" [profile.release] opt-level = "s" @@ -26,11 +27,11 @@ sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false } sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git" } bitflags = "1.3.2" -esp-idf-sys = { version = "0.32.1", features = ["binstart"] } -embedded-svc = "0.24.0" -esp-idf-svc = { version = "0.45.0", features = ["experimental", "alloc"] } -esp-idf-hal = "0.40.1" -embedded-hal = "=1.0.0-alpha.9" +esp-idf-sys = { version = "0.33.1", features = ["binstart"] } +embedded-svc = "0.25.0" +esp-idf-svc = { version = "0.46.0", features = ["experimental", "alloc"] } +esp-idf-hal = "0.41.1" +embedded-hal = "=1.0.0-alpha.10" anyhow = {version = "1", features = ["backtrace"]} log = "0.4" url = "2" @@ -41,8 +42,7 @@ hex = "0.4.3" rmp-serde = "1.1.0" [build-dependencies] -embuild = "0.29" -anyhow = "1" +embuild = "0.31.2" [[bin]] name = "clear" @@ -50,4 +50,4 @@ path = "src/clear.rs" [[bin]] name = "btn" -path = "src/btn.rs" \ No newline at end of file +path = "src/btn.rs" diff --git a/sphinx-key/build.rs b/sphinx-key/build.rs index 4dd5e1f..ccb6e75 100644 --- a/sphinx-key/build.rs +++ b/sphinx-key/build.rs @@ -1,5 +1,6 @@ // Necessary because of this issue: https://github.com/rust-lang/cargo/issues/9641 -fn main() -> anyhow::Result<()> { +fn main() -> Result<(), Box> { embuild::build::CfgArgs::output_propagated("ESP_IDF")?; - embuild::build::LinkArgs::output_propagated("ESP_IDF") + embuild::build::LinkArgs::output_propagated("ESP_IDF")?; + Ok(()) } diff --git a/sphinx-key/rust-toolchain.toml b/sphinx-key/rust-toolchain.toml index f2f405b..33fa244 100644 --- a/sphinx-key/rust-toolchain.toml +++ b/sphinx-key/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] - -channel = "nightly-2022-10-20" +channel = "nightly-2023-06-13" +components = ["rust-src"] diff --git a/sphinx-key/src/conn/mqtt.rs b/sphinx-key/src/conn/mqtt.rs index 9199e41..d0f9dcd 100644 --- a/sphinx-key/src/conn/mqtt.rs +++ b/sphinx-key/src/conn/mqtt.rs @@ -113,7 +113,7 @@ pub fn make_client( tx.send(CoreEvent::VlsMessage(data)) .expect("couldnt send Event::VlsMessage"); } else if topic.ends_with(topics::LSS_MSG) { - log::info!("received data len {}", data.len()); + log::debug!("received data len {}", data.len()); tx.send(CoreEvent::LssMessage(data)) .expect("couldnt send Event::LssMessage"); } else if topic.ends_with(topics::CONTROL) { diff --git a/sphinx-key/src/conn/wifi.rs b/sphinx-key/src/conn/wifi.rs index 1281894..c80d9bc 100644 --- a/sphinx-key/src/conn/wifi.rs +++ b/sphinx-key/src/conn/wifi.rs @@ -23,71 +23,35 @@ pub fn start_client( modem: impl peripheral::Peripheral

+ 'static, default_nvs: EspDefaultNvsPartition, config: &Config, -) -> Result>> { +) -> Result>> { // let netif_stack = Arc::new(EspNetifStack::new()?); // let sys_loop_stack = Arc::new(EspSysLoopStack::new()?); - let sysloop = EspSystemEventLoop::take()?; - let mut wifi = Box::new(EspWifi::new(modem, sysloop.clone(), Some(default_nvs))?); - let ap_infos = wifi.scan()?; + let mut wifi = BlockingWifi::wrap( + EspWifi::new(modem, sysloop.clone(), Some(default_nvs))?, + sysloop, + )?; + let ssid = config.ssid.as_str(); let pass = config.pass.as_str(); - - let ours = ap_infos.into_iter().find(|a| a.ssid == ssid); - let channel = if let Some(ours) = ours { - info!( - "Found configured access point {} on channel {}", - ssid, ours.channel - ); - Some(ours.channel) - } else { - info!( - "Configured access point {} not found during scanning, will go with unknown channel", - ssid - ); - None - }; - wifi.set_configuration(&Configuration::Client(ClientConfiguration { ssid: ssid.into(), password: pass.into(), - channel, + channel: None, ..Default::default() }))?; + info!("Wifi configured"); wifi.start()?; - - info!("...Wifi client configuration set, get status"); - // match wifi.wait_status_with_timeout(Duration::from_secs(20), |status| !status.is_transitional()) - // { - // Ok(_) => (), - // Err(e) => warn!("Unexpected Wifi status: {:?}", e), - // }; - - if !WifiWait::new(&sysloop)? - .wait_with_timeout(Duration::from_secs(20), || wifi.is_started().unwrap()) - { - warn!("Wifi did not start"); - } - - info!("Connecting wifi..."); - + info!("Wifi started"); wifi.connect()?; - - if !EspNetifWait::new::(wifi.sta_netif(), &sysloop)?.wait_with_timeout( - Duration::from_secs(20), - || { - wifi.is_connected().unwrap() - && wifi.sta_netif().get_ip_info().unwrap().ip != std::net::Ipv4Addr::new(0, 0, 0, 0) - }, - ) { - warn!("Wifi did not connect or did not receive a DHCP lease"); - } - - let ip_info = wifi.sta_netif().get_ip_info()?; - + info!("Wifi connected"); + wifi.wait_netif_up()?; + info!("Wifi netif up"); + let ip_info = wifi.wifi().sta_netif().get_ip_info()?; info!("Wifi DHCP info: {:?}", ip_info); + // let status = wifi.get_status(); // println!("=> wifi STATUS {:?}", status); // println!("=> is transitional? {:?}", status.is_transitional()); @@ -115,11 +79,14 @@ pub fn start_client( pub fn start_access_point( modem: impl peripheral::Peripheral

+ 'static, default_nvs: EspDefaultNvsPartition, -) -> Result>> { +) -> Result>> { let sysloop = EspSystemEventLoop::take()?; // let netif_stack = Arc::new(EspNetifStack::new()?); // let sys_loop_stack = Arc::new(EspSysLoopStack::new()?); - let mut wifi = Box::new(EspWifi::new(modem, sysloop.clone(), Some(default_nvs))?); + let mut wifi = BlockingWifi::wrap( + EspWifi::new(modem, sysloop.clone(), Some(default_nvs))?, + sysloop, + )?; let ssid: &'static str = env!("SSID"); let password: &'static str = env!("PASS"); @@ -134,15 +101,12 @@ pub fn start_access_point( auth_method: AuthMethod::WPA2Personal, ..Default::default() }))?; + info!("Wifi configured"); wifi.start()?; - - info!("Wifi configuration set, about to get status"); - if !WifiWait::new(&sysloop)? - .wait_with_timeout(Duration::from_secs(20), || wifi.is_started().unwrap()) - { - return Err(anyhow::anyhow!("Wifi did not start")); - } + info!("Wifi started"); + wifi.wait_netif_up()?; + info!("Wifi netif up"); info!( "Wifi started!\n \nWIFI NAME: {}\nWIFI PASSWORD: {}\n", diff --git a/sphinx-key/src/core/config.rs b/sphinx-key/src/core/config.rs index a255610..85d1366 100644 --- a/sphinx-key/src/core/config.rs +++ b/sphinx-key/src/core/config.rs @@ -45,7 +45,7 @@ pub fn start_wifi_client( modem: impl peripheral::Peripheral

+ 'static, default_nvs: EspDefaultNvsPartition, config: &Config, -) -> Result> { +) -> Result> { let wifi = conn::wifi::start_client(modem, default_nvs, config)?; println!("CLIENT CONNECTED!!!!!! {:?}", wifi.is_connected()); Ok(wifi) @@ -79,7 +79,7 @@ pub fn decrypt_seed(dto: ConfigDTO, sk1: SecretKey) -> Result<(Config, [u8; 32]) pub fn start_config_server_and_wait( modem: impl peripheral::Peripheral

+ 'static, default_nvs: EspDefaultNvsPartition, -) -> Result<(Box>, Config, [u8; 32])> { +) -> Result<(BlockingWifi>, Config, [u8; 32])> { let mutex = Arc::new((Mutex::new(None), Condvar::new())); #[allow(clippy::redundant_clone)] diff --git a/sphinx-key/src/main.rs b/sphinx-key/src/main.rs index 760bc4d..e2e5438 100644 --- a/sphinx-key/src/main.rs +++ b/sphinx-key/src/main.rs @@ -163,7 +163,7 @@ fn make_and_launch_client( // let mqtt_client = conn::mqtt::start_listening(mqtt, connection, tx)?; // this blocks forever... the "main thread" - let do_log = true; + let do_log = false; log::info!("Network set to {:?}", network); log::info!(">>>>>>>>>>> blocking forever..."); log::info!("{:?}", config); diff --git a/sphinx-key/src/periph/sd.rs b/sphinx-key/src/periph/sd.rs index 7a64da3..d08ce20 100644 --- a/sphinx-key/src/periph/sd.rs +++ b/sphinx-key/src/periph/sd.rs @@ -58,6 +58,7 @@ pub fn mount_sd_card() -> anyhow::Result<()> { format_if_mount_failed: false, max_files: 5, allocation_unit_size: 16 * 1024, + disk_status_check_enable: false, }; let mut card: *mut sdmmc_card_t = ptr::null_mut();