diff --git a/README.md b/README.md index bae2c67..79ac66a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,14 @@ A Lightning Hardware Wallet based on [Validating Lightning Signer](https://gitla `cargo build --release` +Find your port (`ls /dev/tty.*`) + +`PORT=/dev/tty.usbserial-1420` + +`espflash $PORT target/riscv32imc-esp-espidf/release/sphinx-key-factory` + +`esptool.py --chip esp32c3 elf2image target/riscv32imc-esp-espidf/release/sphinx-key-factory` + ### build `cd ../sphinx-key` @@ -24,10 +32,6 @@ The wifi SSID and password needs to be in env to build the firmware. SSID must b `esptool.py --chip esp32c3 elf2image target/riscv32imc-esp-espidf/release/sphinx-key` -Find your port (`ls /dev/tty.*`) - -`PORT=/dev/tty.usbserial-1420` - `esptool.py --chip esp32c3 -p $PORT -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 4MB 0x10000 target/riscv32imc-esp-espidf/release/sphinx-key.bin` ### monitor @@ -36,7 +40,7 @@ Find your port (`ls /dev/tty.*`) ### configure the hardware -make a seed: `./newseed.sh` +make a seed: `./newseed.sh` make a `.env` file like: @@ -113,4 +117,4 @@ nightly `espmonitor /dev/tty.usbserial-1420` -for ESP-IDF#4.3.2: `export CC=$PWD/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc` \ No newline at end of file +for ESP-IDF#4.3.2: `export CC=$PWD/.embuild/espressif/tools/riscv32-esp-elf/esp-2021r2-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc` diff --git a/factory/Cargo.lock b/factory/Cargo.lock index 24612a5..196d3bf 100644 --- a/factory/Cargo.lock +++ b/factory/Cargo.lock @@ -26,6 +26,24 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80a21b9440a626c7fc8573a9e3d3a06b75c7c97754c2949bc7857b90353ca655" +dependencies = [ + "as-slice", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.65" @@ -35,6 +53,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "async-task" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" + [[package]] name = "atomic-polyfill" version = "0.1.10" @@ -44,17 +77,6 @@ dependencies = [ "critical-section", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -99,15 +121,13 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bindgen" -version = "0.60.1" +version = "0.63.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" +checksum = "36d860121800b2a9a94f9b5604b332d5cffb234ce17609ea479d723dbc9d3885" dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap", - "env_logger", "lazy_static", "lazycell", "log", @@ -117,6 +137,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", + "syn 1.0.109", "which", ] @@ -147,6 +168,19 @@ dependencies = [ "memchr", ] +[[package]] +name = "build-time" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b516fccffbcd4c007256d0d620522ea9fcc6f008c9ebb7173eeb349dfcf99786" +dependencies = [ + "chrono", + "once_cell", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bumpalo" version = "3.11.0" @@ -192,12 +226,12 @@ dependencies = [ [[package]] name = "cargo_toml" -version = "0.12.2" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee685beed1fe2ab3cb9eb95d65727413b5e27f2b34014a3ea9c92053f8c230fc" +checksum = "7f83bc2e401ed041b7057345ebc488c005efa0341d5541ce7004d30458d0090b" dependencies = [ "serde", - "toml", + "toml 0.7.3", ] [[package]] @@ -221,6 +255,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits", + "time", + "wasm-bindgen", + "winapi", +] + [[package]] name = "chunked_transfer" version = "1.4.0" @@ -238,30 +287,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "3.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" -dependencies = [ - "atty", - "bitflags", - "clap_lex", - "indexmap", - "strsim", - "termcolor", - "textwrap", -] - -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "cmake" version = "0.1.48" @@ -271,6 +296,42 @@ dependencies = [ "cc", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "const_format" +version = "0.2.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7309d9b4d3d2c0641e018d449232f2e28f1b22933c137f157d3dbc14228b8c0e" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f47bf7270cf70d370f8f98c1abb6d2d4cf60a6845d30e05bfb90c6568650" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + [[package]] name = "cortex-m" version = "0.7.6" @@ -304,41 +365,6 @@ dependencies = [ "riscv", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", - "once_cell", - "scopeguard", -] - [[package]] name = "crossbeam-utils" version = "0.8.11" @@ -350,20 +376,57 @@ dependencies = [ ] [[package]] -name = "cstr_core" -version = "0.2.6" +name = "cvt" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd98742e4fdca832d40cab219dc2e3048de17d873248f83f17df47c1bea70956" +checksum = "d2ae9bf77fbf2d39ef573205d554d87e86c12f1994e9ea335b0651b9b278bcf1" dependencies = [ - "cty", - "memchr", + "cfg-if", ] [[package]] -name = "cty" -version = "0.2.2" +name = "cxx" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn 2.0.13", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.13", +] [[package]] name = "darling" @@ -385,7 +448,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -396,7 +459,39 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "defmt" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d03193cde597714ff8a5005ccd61cd1b7aff5616eaca7c67905982cb6f347ff4" +dependencies = [ + "bitflags", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82610855c67a4dc36299cc6bfcf140f329e4f013582531c7ba7d32512ddabc47" +dependencies = [ + "defmt-parser", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "defmt-parser" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e15e994575e38332cf4a2dc9dc745ff6a65695d37a41e00efadd57fcd42c1ba4" +dependencies = [ + "thiserror", ] [[package]] @@ -405,7 +500,16 @@ version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "dirs-sys", + "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]] @@ -419,12 +523,44 @@ dependencies = [ "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc1d66feda51959c8bb07b752c20f1d061eceb178bc91b793a0b32c792c631cf" +dependencies = [ + "async-task", + "heapless", + "log", + "waker-fn", +] + [[package]] name = "either" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "embedded-can" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" +dependencies = [ + "nb 1.0.0", +] + [[package]] name = "embedded-hal" version = "0.2.7" @@ -437,10 +573,17 @@ dependencies = [ [[package]] name = "embedded-hal" -version = "1.0.0-alpha.8" +version = "1.0.0-alpha.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3babfc7fd332142a0b11aebf592992f211f4e01b6222fb04b03aba1bd80018d" +checksum = "129b101ddfee640565f7c07b301a31d95aa21e5acef21a491c307139f5fa4c91" + +[[package]] +name = "embedded-hal-nb" +version = "1.0.0-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e0760ec0a3bf76859d5e33f39542af103f157d5b2ecfb00ace56dd461472e3a" dependencies = [ + "embedded-hal 1.0.0-alpha.9", "nb 1.0.0", ] @@ -455,11 +598,12 @@ dependencies = [ [[package]] name = "embedded-svc" -version = "0.22.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85fb2cc875d8cb13978429beb5af7dea5f7f84d5d41187ff9593b83374d3fe77" +checksum = "2079f8182848872fb6e8eed2c1ba3aea409fc71984a9e8090733c08c404e7864" dependencies = [ "anyhow", + "defmt", "embedded-io", "enumset", "futures", @@ -468,7 +612,6 @@ dependencies = [ "no-std-net", "num_enum", "serde", - "serde_json", "strum 0.23.0", "strum_macros 0.23.1", ] @@ -481,7 +624,7 @@ checksum = "cd1dd6c90e28cfc361281a692320fcd820bcae71d327215e87c7d749bf8ddd26" dependencies = [ "anyhow", "bitflags", - "dirs", + "dirs 4.0.0", "filetime", "log", "serde", @@ -489,33 +632,33 @@ dependencies = [ "shlex", "strum 0.24.1", "thiserror", - "toml", + "toml 0.5.9", "xmas-elf", ] [[package]] name = "embuild" -version = "0.30.4" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ca66d283ba92dc33ce461ba27bb5085a769dd740bad3f66e60e70926b34d05" +checksum = "481bc7905b77810b66783faeb8c30d466fc7d128d7e4bdf2415e5f6ae1550dfe" dependencies = [ "anyhow", "bindgen", "bitflags", "cargo_toml", "cmake", - "dirs", + "dirs 5.0.0", "filetime", "globwalk", "log", - "remove_dir_all 0.7.0", + "remove_dir_all 0.8.2", "serde", "serde_json", "shlex", "strum 0.24.1", "tempfile", "thiserror", - "toml", + "toml 0.7.3", "ureq", "which", ] @@ -539,20 +682,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "env_logger" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "syn 1.0.109", ] [[package]] @@ -566,29 +696,31 @@ dependencies = [ [[package]] name = "esp-idf-hal" -version = "0.38.1" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa416b08c24fc6439b59b7de329738e041af9bbddc733267e47085399f372487" +checksum = "c4354dcc4d157de675c55eb2e98f4985a526ea56fff316aa0939a63636c4952b" dependencies = [ "anyhow", + "edge-executor", + "embedded-can", "embedded-hal 0.2.7", - "embedded-hal 1.0.0-alpha.8", - "embedded-svc", - "embuild 0.29.3", + "embedded-hal 1.0.0-alpha.9", + "embedded-hal-nb", + "embuild 0.31.1", "esp-idf-sys", - "nb 0.1.3", + "heapless", + "nb 1.0.0", ] [[package]] name = "esp-idf-svc" -version = "0.42.3" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "387d825a34a24ff5572385a6d42d94dc3b58f16b7f166a765f612178d4c16dcc" +checksum = "f6035126eeaf81d19ca5342fa8f36e85489c6fba1148ec8af167a6b9bff39e0f" dependencies = [ "anyhow", - "cstr_core", "embedded-svc", - "embuild 0.29.3", + "embuild 0.31.1", "enumset", "esp-idf-hal", "esp-idf-sys", @@ -599,14 +731,16 @@ dependencies = [ [[package]] name = "esp-idf-sys" -version = "0.31.9" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c64736a18d2bf2a4d661d787ca69499e59192ad11ae1cec50c4686303bed39" +checksum = "7b3458faf5c04761cb9a122ba30714afda5e88848e2f99c6e6c05c77ecf626d8" dependencies = [ "anyhow", "bindgen", + "build-time", "cargo_metadata", - "embuild 0.30.4", + "const_format", + "embuild 0.31.1", "envy", "libc", "regex", @@ -632,7 +766,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -660,6 +794,21 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_at" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37047c0d530b3aefc64e4c4d7c6b1e23030c65973661b70e12c826f426f3f675" +dependencies = [ + "aligned", + "cfg-if", + "cvt", + "libc", + "nix", + "smart-default", + "windows-sys 0.45.0", +] + [[package]] name = "futures" version = "0.3.24" @@ -733,7 +882,7 @@ checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -817,19 +966,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] -name = "hermit-abi" -version = "0.1.19" +name = "iana-time-zone" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "0c17cc76786e99f8d2f055c11159e7f0091c42474dcc3189fbab96072e873e6d" dependencies = [ - "libc", + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", ] [[package]] -name = "humantime" -version = "2.1.0" +name = "iana-time-zone-haiku" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] [[package]] name = "ident_case" @@ -913,9 +1071,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.133" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libloading" @@ -927,6 +1085,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "link-cplusplus" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +dependencies = [ + "cc", +] + [[package]] name = "lock_api" version = "0.4.9" @@ -952,15 +1119,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -991,6 +1149,18 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" +[[package]] +name = "nix" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "static_assertions", +] + [[package]] name = "no-std-net" version = "0.5.0" @@ -1011,13 +1181,31 @@ dependencies = [ ] [[package]] -name = "num_cpus" -version = "1.13.1" +name = "normpath" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "ec60c60a693226186f5d6edf073232bfb6464ed97eb22cf3b01c1e8198fd97f5" dependencies = [ - "hermit-abi", - "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", ] [[package]] @@ -1038,7 +1226,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1056,12 +1244,6 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" -[[package]] -name = "os_str_bytes" -version = "6.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -1100,23 +1282,47 @@ checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" dependencies = [ "once_cell", "thiserror", - "toml", + "toml 0.5.9", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", ] [[package]] name = "proc-macro2" -version = "1.0.44" +version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd7356a8122b6c4a24a82b278680c73357984ca2fc79a0f9fa6dea7dced7c58" +checksum = "1d0dd4be24fcdcfeaa12a432d588dc59bbad6cad3510c67e74a2b6b2fc950564" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -1151,30 +1357,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rayon" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" -dependencies = [ - "autocfg", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "redox_syscall" version = "0.2.16" @@ -1223,15 +1405,18 @@ dependencies = [ [[package]] name = "remove_dir_all" -version = "0.7.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882f368737489ea543bc5c340e6f3d34a28c39980bd9a979e47322b26f60ac40" +checksum = "23895cfadc1917fed9c6ed76a8c2903615fa3704f7493ff82b364c6540acc02b" dependencies = [ + "aligned", + "cfg-if", + "cvt", + "fs_at", + "lazy_static", "libc", - "log", - "num_cpus", - "rayon", - "winapi", + "normpath", + "windows-sys 0.45.0", ] [[package]] @@ -1339,6 +1524,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" + [[package]] name = "sct" version = "0.7.0" @@ -1375,22 +1566,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.13", ] [[package]] @@ -1404,6 +1595,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +dependencies = [ + "serde", +] + [[package]] name = "shlex" version = "1.1.0" @@ -1419,6 +1619,17 @@ dependencies = [ "autocfg", ] +[[package]] +name = "smart-default" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "sphinx-key-factory" version = "0.1.0" @@ -1457,10 +1668,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] -name = "strsim" -version = "0.10.0" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strum" @@ -1490,7 +1701,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] @@ -1503,14 +1714,25 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] name = "syn" -version = "1.0.100" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" dependencies = [ "proc-macro2", "quote", @@ -1540,12 +1762,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" - [[package]] name = "thiserror" version = "1.0.36" @@ -1563,7 +1779,7 @@ checksum = "3a891860d3c8d66fec8e73ddb3765f90082374dbaaa833407b904a94f1a7eb43" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1575,6 +1791,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -1599,6 +1826,40 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "uncased" version = "0.9.7" @@ -1635,6 +1896,18 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "untrusted" version = "0.7.1" @@ -1696,6 +1969,12 @@ dependencies = [ "vcell", ] +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + [[package]] name = "walkdir" version = "2.3.2" @@ -1707,6 +1986,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1734,7 +2019,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -1756,7 +2041,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1838,49 +2123,199 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "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]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "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]] +name = "windows_aarch64_gnullvm" +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.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[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.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[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.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[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.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[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.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +dependencies = [ + "memchr", +] + [[package]] name = "xmas-elf" version = "0.8.0" diff --git a/factory/Cargo.toml b/factory/Cargo.toml index 417c9d3..df1c24e 100644 --- a/factory/Cargo.toml +++ b/factory/Cargo.toml @@ -8,11 +8,11 @@ edition = "2021" pio = ["esp-idf-sys/pio"] [dependencies] -esp-idf-sys = { version = "0.31.8", features = ["binstart"] } -esp-idf-svc = { version = "0.42.3", features = ["experimental", "alloc"] } -esp-idf-hal = "0.38.1" +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" -embedded-svc = "0.22.1" anyhow = { version = "1.0.65", features = ["backtrace"] } rand = "0.8.5" log = "0.4.17" diff --git a/factory/src/led.rs b/factory/src/led.rs index 2db2012..cc40c3e 100644 --- a/factory/src/led.rs +++ b/factory/src/led.rs @@ -1,33 +1,35 @@ use embedded_hal::blocking::delay::DelayMs; use esp_idf_hal::delay::Ets; +use esp_idf_hal::delay::FreeRtos; use esp_idf_hal::peripherals::Peripherals; use esp_idf_hal::rmt::config::TransmitConfig; -use esp_idf_hal::rmt::{FixedLengthSignal, PinState, Pulse, Transmit}; +use esp_idf_hal::rmt::*; use std::time::Duration; -pub fn set_ota_led() { +pub fn set_ota_led() -> anyhow::Result<()> { let peripherals = Peripherals::take().unwrap(); - let led = peripherals.pins.gpio0.into_output().unwrap(); + let led = peripherals.pins.gpio0; let channel = peripherals.rmt.channel0; let config = TransmitConfig::new().clock_divider(1); - let mut tx = Transmit::new(led, channel, &config).unwrap(); + let mut tx = TxRmtDriver::new(channel, led, &config).unwrap(); - let rgb = 0xffa500; // Orange + neopixel( + RGB { + r: 255, + g: 55, + b: 00, + }, + &mut tx, + )?; + FreeRtos::delay_ms(10); - let ticks_hz = tx.counter_clock().unwrap(); - let t0h = Pulse::new_with_duration(ticks_hz, PinState::High, &ns(350)).unwrap(); - let t0l = Pulse::new_with_duration(ticks_hz, PinState::Low, &ns(800)).unwrap(); - let t1h = Pulse::new_with_duration(ticks_hz, PinState::High, &ns(700)).unwrap(); - let t1l = Pulse::new_with_duration(ticks_hz, PinState::Low, &ns(600)).unwrap(); + Ok(()) +} - let mut signal = FixedLengthSignal::<24>::new(); - for i in 0..24 { - let bit = 2_u32.pow(i) & rotate_rgb(rgb) != 0; - let (high_pulse, low_pulse) = if bit { (t1h, t1l) } else { (t0h, t0l) }; - signal.set(i as usize, &(high_pulse, low_pulse)).unwrap(); - } - tx.start_blocking(&signal).unwrap(); - Ets.delay_ms(10u8); +struct RGB { + r: u8, + g: u8, + b: u8, } fn ns(nanos: u64) -> Duration { @@ -39,3 +41,26 @@ fn rotate_rgb(rgb: u32) -> u32 { let blue = (rgb & b_mask) << 16; blue | (rgb >> 8) } + +fn neopixel(rgb: RGB, tx: &mut TxRmtDriver) -> anyhow::Result<()> { + // e.g. rgb: (1,2,4) + // G R B + // 7 0 7 0 7 0 + // 00000010 00000001 00000100 + let color: u32 = ((rgb.g as u32) << 16) | ((rgb.r as u32) << 8) | rgb.b as u32; + let ticks_hz = tx.counter_clock()?; + let t0h = Pulse::new_with_duration(ticks_hz, PinState::High, &ns(350))?; + let t0l = Pulse::new_with_duration(ticks_hz, PinState::Low, &ns(800))?; + let t1h = Pulse::new_with_duration(ticks_hz, PinState::High, &ns(700))?; + let t1l = Pulse::new_with_duration(ticks_hz, PinState::Low, &ns(600))?; + let mut signal = FixedLengthSignal::<24>::new(); + for i in (0..24).rev() { + let p = 2_u32.pow(i); + let bit = p & color != 0; + let (high_pulse, low_pulse) = if bit { (t1h, t1l) } else { (t0h, t0l) }; + signal.set(23 - i as usize, &(high_pulse, low_pulse))?; + } + tx.start_blocking(&signal)?; + + Ok(()) +} diff --git a/factory/src/sdcard.rs b/factory/src/sdcard.rs index f242438..64da52c 100644 --- a/factory/src/sdcard.rs +++ b/factory/src/sdcard.rs @@ -1,5 +1,5 @@ use bitflags::bitflags; -use esp_idf_sys::c_types::c_char; +use core::ffi::c_char; use esp_idf_sys::{ esp, esp_vfs_fat_sdmmc_mount_config_t, esp_vfs_fat_sdspi_mount, gpio_num_t, sdmmc_card_t, sdmmc_host_t, sdspi_device_config_t, spi_bus_config_t, spi_bus_initialize, spi_host_device_t, diff --git a/sphinx-key/src/clear.rs b/sphinx-key/src/clear.rs index 11cc0e1..c17803e 100644 --- a/sphinx-key/src/clear.rs +++ b/sphinx-key/src/clear.rs @@ -1,15 +1,13 @@ use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported -use embedded_svc::storage::StorageBase; -use esp_idf_svc::nvs::EspNvsStorage; +// use embedded_svc::storage::StorageBase; +use esp_idf_svc::nvs::EspNvs; use esp_idf_svc::nvs::*; -use std::sync::Arc; - fn main() -> anyhow::Result<()> { - let default_nvs = Arc::new(EspDefaultNvs::new()?); - let mut store = - EspNvsStorage::new_default(default_nvs.clone(), "sphinx", true).expect("no storage"); + // NvsDefault::new(); + let default_nvs = EspDefaultNvsPartition::take()?; + let mut store = EspNvs::new(default_nvs.clone(), "sphinx", true).expect("no storage"); store.remove("config").expect("couldnt remove config 1"); store.remove("seed").expect("couldnt remove seed 1"); store.remove("nonce").expect("couldnt remove nonce 1"); diff --git a/sphinx-key/src/conn/http.rs b/sphinx-key/src/conn/http.rs index d2b9bb4..ebb4695 100644 --- a/sphinx-key/src/conn/http.rs +++ b/sphinx-key/src/conn/http.rs @@ -5,7 +5,8 @@ use serde::Deserialize; use std::sync::{Arc, Condvar, Mutex}; // use embedded_svc::http::server::registry::Registry; -use embedded_svc::http::server::*; +// use embedded_svc::http::server::*; +#[allow(deprecated)] use embedded_svc::httpd::registry::Registry; use embedded_svc::httpd::Result; @@ -20,7 +21,7 @@ pub struct Params { pub config: String, } -#[allow(unused_variables)] +#[allow(unused_variables, deprecated)] pub fn config_server( mutex: Arc<(Mutex>, Condvar)>, ) -> Result { diff --git a/sphinx-key/src/conn/mqtt.rs b/sphinx-key/src/conn/mqtt.rs index 7611bad..e978902 100644 --- a/sphinx-key/src/conn/mqtt.rs +++ b/sphinx-key/src/conn/mqtt.rs @@ -2,10 +2,10 @@ use crate::core::events::Event as CoreEvent; use sphinx_signer::sphinx_glyph::topics; use anyhow::Result; -use embedded_svc::mqtt::client::utils::ConnState; use embedded_svc::mqtt::client::{Connection, Event, Message as MqttMessage, MessageImpl, QoS}; -use embedded_svc::utils::mqtt::client::Connection as MqttConnection; -use embedded_svc::utils::mutex::Condvar; +use embedded_svc::utils::mqtt::client::ConnState; +// use embedded_svc::utils::mqtt::client::Connection as MqttConnection; +// use embedded_svc::utils::mutex::Condvar; use esp_idf_svc::mqtt::client::*; use esp_idf_sys::EspError; use esp_idf_sys::{self}; @@ -35,7 +35,7 @@ pub fn make_client( }; let b = format!("mqtt://{}", broker); - let (mut client, mut connection) = EspMqttClient::new_with_conn(b, &conf)?; + let (client, mut connection) = EspMqttClient::new_with_conn(b, &conf)?; // let cc = EspMqttClient::new_with_conn(b, &conf)?; info!("MQTT client started"); @@ -91,7 +91,7 @@ pub fn make_client( //info!("MQTT connection loop exit"); }); - Ok(cc) + Ok(client) } // pub fn start_listening( diff --git a/sphinx-key/src/conn/sntp.rs b/sphinx-key/src/conn/sntp.rs index 8383fd3..8561872 100644 --- a/sphinx-key/src/conn/sntp.rs +++ b/sphinx-key/src/conn/sntp.rs @@ -5,9 +5,12 @@ use std::time::Duration; pub fn sync_time() { let sntp = EspSntp::new_default().unwrap(); - println!("SNTP initialized"); - while sntp.get_sync_status() != Completed { - println!("Waiting for sntp sync..."); + loop { + let status = sntp.get_sync_status(); + println!("SNTP status {:?}", status); + if status == Completed { + break; + } thread::sleep(Duration::from_secs(1)); } } diff --git a/sphinx-key/src/conn/wifi.rs b/sphinx-key/src/conn/wifi.rs index 6210b04..1281894 100644 --- a/sphinx-key/src/conn/wifi.rs +++ b/sphinx-key/src/conn/wifi.rs @@ -1,7 +1,7 @@ use sphinx_signer::sphinx_glyph::control::Config; use esp_idf_svc::netif::*; -use esp_idf_svc::nvs::EspDefaultNvs; +use esp_idf_svc::nvs::EspDefaultNvsPartition; use esp_idf_svc::ping; // use esp_idf_svc::sysloop::*; use esp_idf_svc::eventloop::EspSystemEventLoop; @@ -9,20 +9,19 @@ use esp_idf_svc::wifi::*; use embedded_svc::httpd::Result; use embedded_svc::ipv4; -use embedded_svc::ping::Ping; -use embedded_svc::wifi::Wifi; +// use embedded_svc::ping::Ping; +// use embedded_svc::wifi::Wifi; use embedded_svc::wifi::*; use esp_idf_hal::peripheral; use log::*; -use std::sync::Arc; -use std::thread; +// use std::thread; use std::time::Duration; pub fn start_client( modem: impl peripheral::Peripheral

+ 'static, - default_nvs: Arc, + default_nvs: EspDefaultNvsPartition, config: &Config, ) -> Result>> { // let netif_stack = Arc::new(EspNetifStack::new()?); @@ -30,7 +29,7 @@ pub fn start_client( let sysloop = EspSystemEventLoop::take()?; - let mut wifi = Box::new(EspWifi::new(modem, sysloop, Some(default_nvs))?); + let mut wifi = Box::new(EspWifi::new(modem, sysloop.clone(), Some(default_nvs))?); let ap_infos = wifi.scan()?; let ssid = config.ssid.as_str(); let pass = config.pass.as_str(); @@ -57,32 +56,57 @@ pub fn start_client( ..Default::default() }))?; - 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), - }; + wifi.start()?; - let status = wifi.get_status(); - println!("=> wifi STATUS {:?}", status); - println!("=> is transitional? {:?}", status.is_transitional()); - if let Status( - ClientStatus::Started(ClientConnectionStatus::Connected(ClientIpStatus::Done(ip_settings))), - ApStatus::Stopped, - ) = status + 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()) { - info!("Wifi started!"); - ping(&ip_settings)?; - } else { - thread::sleep(Duration::from_secs(13)); - // bail!("Unexpected Client Wifi status: {:?}", status); - return Err(anyhow::anyhow!( - "Unexpected Client Wifi status: {:?}", - status - )); + warn!("Wifi did not start"); } + info!("Connecting wifi..."); + + 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 DHCP info: {:?}", ip_info); + // let status = wifi.get_status(); + // println!("=> wifi STATUS {:?}", status); + // println!("=> is transitional? {:?}", status.is_transitional()); + // if let Status( + // ClientStatus::Started(ClientConnectionStatus::Connected(ClientIpStatus::Done(ip_settings))), + // ApStatus::Stopped, + // ) = status + // { + // info!("Wifi started!"); + // ping(&ip_settings)?; + // } else { + // thread::sleep(Duration::from_secs(13)); + // // bail!("Unexpected Client Wifi status: {:?}", status); + // return Err(anyhow::anyhow!( + // "Unexpected Client Wifi status: {:?}", + // status + // )); + // } + info!("wifi::start_client Ok(())"); Ok(wifi) @@ -90,12 +114,12 @@ pub fn start_client( pub fn start_access_point( modem: impl peripheral::Peripheral

+ 'static, - default_nvs: Arc, + default_nvs: EspDefaultNvsPartition, ) -> 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, default_nvs)?); + let mut wifi = Box::new(EspWifi::new(modem, sysloop.clone(), Some(default_nvs))?); let ssid: &'static str = env!("SSID"); let password: &'static str = env!("PASS"); @@ -111,24 +135,34 @@ pub fn start_access_point( ..Default::default() }))?; - info!("Wifi configuration set, about to get status"); - wifi.wait_status_with_timeout(Duration::from_secs(20), |status| !status.is_transitional()) - .map_err(|e| anyhow::anyhow!("Unexpected Wifi status: {:?}", e))?; + wifi.start()?; - let status = wifi.get_status(); - if let Status(ClientStatus::Stopped, ApStatus::Started(ApIpStatus::Done)) = status { - info!( - "Wifi started!\n \nWIFI NAME: {}\nWIFI PASSWORD: {}\n", - ssid, password - ); - } else { - return Err(anyhow::anyhow!("Unexpected AP Wifi status: {:?}", status)); + 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!\n \nWIFI NAME: {}\nWIFI PASSWORD: {}\n", + ssid, password + ); + + // let status = wifi.get_status(); + // if let Status(ClientStatus::Stopped, ApStatus::Started(ApIpStatus::Done)) = status { + // info!( + // "Wifi started!\n \nWIFI NAME: {}\nWIFI PASSWORD: {}\n", + // ssid, password + // ); + // } else { + // return Err(anyhow::anyhow!("Unexpected AP Wifi status: {:?}", status)); + // } + Ok(wifi) } -fn ping(ip_settings: &ipv4::ClientSettings) -> Result<()> { +fn _ping(ip_settings: &ipv4::ClientSettings) -> Result<()> { info!("About to do some pings for {:?}", ip_settings); let ping_summary = diff --git a/sphinx-key/src/core/config.rs b/sphinx-key/src/core/config.rs index 8994c54..a255610 100644 --- a/sphinx-key/src/core/config.rs +++ b/sphinx-key/src/core/config.rs @@ -43,11 +43,11 @@ arp -a pub fn start_wifi_client( modem: impl peripheral::Peripheral

+ 'static, - default_nvs: Arc, + default_nvs: EspDefaultNvsPartition, config: &Config, ) -> Result> { let wifi = conn::wifi::start_client(modem, default_nvs, config)?; - println!("CLIENT CONNECTED!!!!!! {:?}", wifi.get_status()); + println!("CLIENT CONNECTED!!!!!! {:?}", wifi.is_connected()); Ok(wifi) } @@ -78,7 +78,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: Arc, + default_nvs: EspDefaultNvsPartition, ) -> Result<(Box>, Config, [u8; 32])> { let mutex = Arc::new((Mutex::new(None), Condvar::new())); diff --git a/sphinx-key/src/core/control.rs b/sphinx-key/src/core/control.rs index b81df84..73460b8 100644 --- a/sphinx-key/src/core/control.rs +++ b/sphinx-key/src/core/control.rs @@ -1,8 +1,6 @@ use anyhow::{anyhow, Result}; use embedded_svc::storage::RawStorage; -use embedded_svc::storage::StorageBase; -use esp_idf_svc::nvs::EspDefaultNvs; -use esp_idf_svc::nvs::EspNvsStorage; +use esp_idf_svc::nvs::{EspDefaultNvs, EspDefaultNvsPartition}; use sphinx_signer::lightning_signer::bitcoin::Network; use sphinx_signer::sphinx_glyph::control::{Config, ControlPersist, Controller, FlashKey, Policy}; use std::convert::TryInto; @@ -18,11 +16,12 @@ pub fn controller_from_seed( Controller::new_with_persister(sk, pk, flash) } -pub struct FlashPersister(pub EspNvsStorage); +// EspDefaultNvsPartition +pub struct FlashPersister(pub EspDefaultNvs); impl FlashPersister { - pub fn new(nvs: Arc) -> Self { - let store = EspNvsStorage::new_default(nvs, "sphinx", true).expect("no storage"); + pub fn new(nvs: EspDefaultNvsPartition) -> Self { + let store = EspDefaultNvs::new(nvs, "sphinx", true).expect("no storage"); Self(store) } } @@ -34,12 +33,12 @@ impl ControlPersist for FlashPersister { if let None = existing { return Err(anyhow!("no existing nonce")); } - let r: [u8; 8] = existing.unwrap().0.try_into()?; + let r: [u8; 8] = existing.unwrap().try_into()?; Ok(u64::from_be_bytes(r)) } fn set_nonce(&mut self, nonce: u64) -> Result<()> { let n = nonce.to_be_bytes(); - self.0.put_raw(FlashKey::Nonce.as_str(), &n[..])?; + self.0.set_raw(FlashKey::Nonce.as_str(), &n[..])?; Ok(()) } fn read_config(&self) -> Result { @@ -48,11 +47,11 @@ impl ControlPersist for FlashPersister { if let None = existing { return Err(anyhow!("no existing config")); } - Ok(rmp_serde::from_slice(existing.unwrap().0)?) + Ok(rmp_serde::from_slice(existing.unwrap())?) } fn write_config(&mut self, conf: Config) -> Result<()> { let conf1 = rmp_serde::to_vec(&conf)?; - self.0.put_raw(FlashKey::Config.as_str(), &conf1[..])?; + self.0.set_raw(FlashKey::Config.as_str(), &conf1[..])?; Ok(()) } fn remove_config(&mut self) -> Result<()> { @@ -65,11 +64,11 @@ impl ControlPersist for FlashPersister { if let None = s { return Err(anyhow!("no existing seed")); } - let r: [u8; 32] = s.unwrap().0.try_into()?; + let r: [u8; 32] = s.unwrap().try_into()?; Ok(r) } fn write_seed(&mut self, s: [u8; 32]) -> Result<()> { - self.0.put_raw(FlashKey::Seed.as_str(), &s[..])?; + self.0.set_raw(FlashKey::Seed.as_str(), &s[..])?; Ok(()) } fn remove_seed(&mut self) -> Result<()> { @@ -82,11 +81,11 @@ impl ControlPersist for FlashPersister { if let None = existing { return Err(anyhow!("no existing config")); } - Ok(rmp_serde::from_slice(existing.unwrap().0)?) + Ok(rmp_serde::from_slice(existing.unwrap())?) } fn write_policy(&mut self, pol: Policy) -> Result<()> { let pol1 = rmp_serde::to_vec(&pol)?; - self.0.put_raw(FlashKey::Policy.as_str(), &pol1[..])?; + self.0.set_raw(FlashKey::Policy.as_str(), &pol1[..])?; Ok(()) } fn remove_policy(&mut self) -> Result<()> { diff --git a/sphinx-key/src/core/events.rs b/sphinx-key/src/core/events.rs index 24cd301..f162176 100644 --- a/sphinx-key/src/core/events.rs +++ b/sphinx-key/src/core/events.rs @@ -15,8 +15,8 @@ use std::sync::Arc; use std::thread; use embedded_svc::httpd::Result; -use embedded_svc::mqtt::client::Client; -use embedded_svc::mqtt::client::{MessageImpl, Publish}; +// use embedded_svc::mqtt::client::Client; +use embedded_svc::mqtt::client::MessageImpl; use embedded_svc::utils::mqtt::client::ConnState; use esp_idf_svc::mqtt::client::*; use esp_idf_sys; diff --git a/sphinx-key/src/main.rs b/sphinx-key/src/main.rs index c69e022..51a8123 100644 --- a/sphinx-key/src/main.rs +++ b/sphinx-key/src/main.rs @@ -39,9 +39,9 @@ fn main() -> Result<()> { thread::sleep(Duration::from_secs(1)); let peripherals = Peripherals::take().unwrap(); - let pins = peripherals.pins; + let _pins = peripherals.pins; - let (led_tx, led_rx) = mpsc::channel(); + let (led_tx, _led_rx) = mpsc::channel(); // LED control thread // led_control_loop(pins.gpio0, peripherals.rmt.channel0, led_rx); @@ -53,7 +53,9 @@ fn main() -> Result<()> { } println!("SD card mounted!"); - let default_nvs = Arc::new(EspDefaultNvs::new("sphinx", "sphinx", true)?); + // let default_nav_partition = EspDefaultNvs.take().unwrap(); + let default_nvs = EspDefaultNvsPartition::take()?; + // let default_nvs = Arc::new(); let mut flash = FlashPersister::new(default_nvs.clone()); if let Ok(exist) = flash.read_config() { let seed = flash.read_seed().expect("no seed..."); @@ -63,15 +65,16 @@ fn main() -> Result<()> { exist ); led_tx.send(Status::ConnectingToWifi).unwrap(); - let _wifi = loop { - if let Ok(wifi) = start_wifi_client(peripherals.modem, default_nvs.clone(), &exist) { - println!("Wifi connected!"); - break wifi; - } else { - println!("Failed to connect to wifi. Make sure the details are correct, trying again in 5 seconds..."); - thread::sleep(Duration::from_secs(5)); - } - }; + let wifi_ = start_wifi_client(peripherals.modem, default_nvs.clone(), &exist)?; + // let _wifi = loop { + // if let Ok(wifi) = start_wifi_client(peripherals.modem, default_nvs.clone(), &exist) { + // println!("Wifi connected!"); + // break wifi; + // } else { + // println!("Failed to connect to wifi. Make sure the details are correct, trying again in 5 seconds..."); + // thread::sleep(Duration::from_secs(5)); + // } + // }; led_tx.send(Status::SyncingTime).unwrap(); conn::sntp::sync_time(); diff --git a/sphinx-key/src/ota.rs b/sphinx-key/src/ota.rs index ac4018e..9d17aed 100644 --- a/sphinx-key/src/ota.rs +++ b/sphinx-key/src/ota.rs @@ -1,13 +1,11 @@ use crate::core::events::Status; use anyhow::{anyhow, Result}; use embedded_svc::http::client::Client; -use embedded_svc::http::client::Request; -use embedded_svc::http::client::Response; use embedded_svc::http::Status as HttpStatus; use embedded_svc::io::Read; -use embedded_svc::ota::Ota; +// use embedded_svc::ota::Ota; -use esp_idf_svc::http::client::Configuration as EspHttpClientConfiguration; +use esp_idf_svc::http::client::Configuration; use esp_idf_svc::http::client::EspHttpConnection; use esp_idf_svc::http::client::FollowRedirectsPolicy::FollowNone; use esp_idf_svc::ota::EspOta; @@ -35,17 +33,17 @@ fn factory_reset() -> Result<()> { } fn get_update(params: OtaParams, led_tx: mpsc::Sender) -> Result<()> { - let configuration = EspHttpClientConfiguration { + let configuration = Configuration { buffer_size: Some(BUFFER_LEN), buffer_size_tx: Some(BUFFER_LEN / 3), follow_redirects_policy: FollowNone, use_global_ca_store: true, - crt_bundle_attach: None, + ..Default::default() }; - let mut client = EspHttpConnection::new(&configuration)?; + let mut client = Client::wrap(EspHttpConnection::new(&configuration)?); let full_url = params_to_url(params); - let mut response = client.get(&full_url)?.submit()?; - let mut reader = response.reader(); + let mut reader = client.get(&full_url)?.submit()?; + // let mut reader = response.reader(); let _ = remove_file(UPDATE_BIN_PATH); let file = File::create(UPDATE_BIN_PATH)?; @@ -85,14 +83,14 @@ pub fn update_sphinx_key(params: OtaParams, led_tx: mpsc::Sender) -> Res } pub fn validate_ota_message(params: OtaParams) -> Result<()> { - let configuration = EspHttpClientConfiguration { + let configuration = Configuration { buffer_size: Some(BUFFER_LEN / 3), buffer_size_tx: Some(BUFFER_LEN / 3), follow_redirects_policy: FollowNone, use_global_ca_store: true, - crt_bundle_attach: None, + ..Default::default() }; - let mut client = EspHttpConnection::new(&configuration)?; + let mut client = Client::wrap(EspHttpConnection::new(&configuration)?); let full_url = params_to_url(params); info!("Pinging this url for an update: {}", full_url); let response = client.get(&full_url)?.submit()?; diff --git a/sphinx-key/src/periph/led.rs b/sphinx-key/src/periph/led.rs index ccaccf0..05fef42 100644 --- a/sphinx-key/src/periph/led.rs +++ b/sphinx-key/src/periph/led.rs @@ -1,8 +1,8 @@ use crate::core::events::Status; -use embedded_hal::delay::blocking::DelayUs; -use esp_idf_hal::delay::Ets; +// use embedded_hal::delay::blocking::DelayUs; +use esp_idf_hal::delay::FreeRtos; use esp_idf_hal::rmt::config::TransmitConfig; -use esp_idf_hal::rmt::{FixedLengthSignal, PinState, Pulse, Transmit}; +use esp_idf_hal::rmt::{FixedLengthSignal, PinState, Pulse, TxRmtDriver}; use esp_idf_hal::{gpio, rmt}; use std::collections::BTreeMap; use std::sync::{mpsc, Arc, Mutex}; @@ -33,9 +33,11 @@ fn states() -> BTreeMap { } pub fn led_control_loop(gpio0: gpio::Gpio0, channel0: rmt::CHANNEL0, rx: mpsc::Receiver) { - let led = gpio0.into_output().unwrap(); + let led = gpio0; let config = TransmitConfig::new().clock_divider(1); - let transmit = Arc::new(Mutex::new(Transmit::new(led, channel0, &config).unwrap())); + let transmit = Arc::new(Mutex::new( + TxRmtDriver::new(channel0, led, &config).unwrap(), + )); thread::spawn(move || { let mut led = Led::new(0x000001, 100); let states = states(); @@ -65,10 +67,7 @@ impl Led { self.blink_length = blink_length; } - pub fn blink( - &mut self, - transmit: Arc, rmt::CHANNEL0>>>, - ) { + pub fn blink(&mut self, transmit: Arc>) { // Prepare signal let mut tx = transmit.lock().unwrap(); let ticks_hz = tx.counter_clock().unwrap(); @@ -85,7 +84,7 @@ impl Led { } // Set high and wait tx.start_blocking(&signal).unwrap(); - Ets.delay_ms(self.blink_length).unwrap(); + FreeRtos::delay_ms(self.blink_length); // Set low let mut signal = FixedLengthSignal::<24>::new(); for i in 0..24 { diff --git a/sphinx-key/src/periph/mod.rs b/sphinx-key/src/periph/mod.rs index 49b3c2b..bb1f34b 100644 --- a/sphinx-key/src/periph/mod.rs +++ b/sphinx-key/src/periph/mod.rs @@ -1,2 +1,2 @@ -// pub mod led; +pub mod led; pub mod sd; diff --git a/sphinx-key/src/periph/sd.rs b/sphinx-key/src/periph/sd.rs index 5c5f7bc..7a64da3 100644 --- a/sphinx-key/src/periph/sd.rs +++ b/sphinx-key/src/periph/sd.rs @@ -1,5 +1,6 @@ use bitflags::bitflags; -use esp_idf_sys::c_types::c_char; +// use esp_idf_sys::c_types::c_char; +use core::ffi::c_char; use esp_idf_sys::{ esp, esp_vfs_fat_sdmmc_mount_config_t, esp_vfs_fat_sdspi_mount, gpio_num_t, sdmmc_card_t, sdmmc_host_t, sdspi_device_config_t, spi_bus_config_t, spi_bus_initialize, spi_host_device_t,