Mount EKV on a separate partition

This commit is contained in:
Jakub Hlusička 2026-01-24 00:42:16 +01:00
parent 2a5779ffcf
commit 6cd7b32bee
5 changed files with 330 additions and 148 deletions

236
firmware/Cargo.lock generated
View file

@ -14,12 +14,14 @@ dependencies = [
"const-gen", "const-gen",
"critical-section", "critical-section",
"data-encoding-macro", "data-encoding-macro",
"ekv",
"embassy-embedded-hal", "embassy-embedded-hal",
"embassy-executor", "embassy-executor",
"embassy-sync 0.7.2", "embassy-sync 0.7.2",
"embassy-time", "embassy-time",
"embedded-cli", "embedded-cli",
"embedded-io 0.6.1", "embedded-io 0.7.1",
"embedded-storage-async",
"embuild", "embuild",
"enumset", "enumset",
"esp-alloc", "esp-alloc",
@ -30,6 +32,7 @@ dependencies = [
"esp-radio", "esp-radio",
"esp-rtos", "esp-rtos",
"esp-storage", "esp-storage",
"esp-sync",
"gix", "gix",
"hmac", "hmac",
"i-slint-common", "i-slint-common",
@ -41,9 +44,9 @@ dependencies = [
"mutually_exclusive_features", "mutually_exclusive_features",
"panic-rtt-target", "panic-rtt-target",
"password-hash 0.1.0", "password-hash 0.1.0",
"paste", "pastey 0.2.1",
"printf-compat", "printf-compat",
"rand_core 0.6.4", "rand_core 0.9.5",
"rmk", "rmk",
"rtt-target", "rtt-target",
"sha2", "sha2",
@ -407,7 +410,7 @@ dependencies = [
"log", "log",
"num-rational", "num-rational",
"num-traits", "num-traits",
"pastey", "pastey 0.1.1",
"rayon", "rayon",
"thiserror 2.0.18", "thiserror 2.0.18",
"v_frame", "v_frame",
@ -760,9 +763,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.2.53" version = "1.2.54"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932" checksum = "6354c81bbfd62d9cfa9cb3c773c2b7b2a3a482d569de977fd0e961f6e7c00583"
dependencies = [ dependencies = [
"find-msvc-tools", "find-msvc-tools",
"jobserver", "jobserver",
@ -1564,6 +1567,16 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]]
name = "ekv"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab888debca410aa6f2726fb363926ca73539378c5e8880c8f08f35ae4b24d938"
dependencies = [
"embassy-sync 0.6.2",
"heapless 0.8.0",
]
[[package]] [[package]]
name = "elliptic-curve" name = "elliptic-curve"
version = "0.13.8" version = "0.13.8"
@ -2275,6 +2288,7 @@ dependencies = [
"embassy-sync 0.6.2", "embassy-sync 0.6.2",
"embassy-sync 0.7.2", "embassy-sync 0.7.2",
"esp-metadata-generated", "esp-metadata-generated",
"log",
"riscv", "riscv",
"xtensa-lx", "xtensa-lx",
] ]
@ -2806,9 +2820,9 @@ dependencies = [
[[package]] [[package]]
name = "gix" name = "gix"
version = "0.76.0" version = "0.78.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0da205378175c7e08c1d9357be8e6056c541d5907c29842d025b2a732ce06d52" checksum = "3428a03ace494ae40308bd3df0b37e7eb7403e24389f27abdff30abf2b5adf17"
dependencies = [ dependencies = [
"gix-actor", "gix-actor",
"gix-attributes", "gix-attributes",
@ -2819,6 +2833,7 @@ dependencies = [
"gix-diff", "gix-diff",
"gix-dir", "gix-dir",
"gix-discover", "gix-discover",
"gix-error",
"gix-features", "gix-features",
"gix-filter", "gix-filter",
"gix-fs", "gix-fs",
@ -2855,9 +2870,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-actor" name = "gix-actor"
version = "0.36.1" version = "0.38.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "636ca0d7bf8f7ad8ba84a5dda8312c8944b275be09d88b072e08f57d3e47c1e8" checksum = "b50ce5433eaa46187349e59089eea71b0397caa71991b2fa3e124120426d7d15"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-date", "gix-date",
@ -2869,9 +2884,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-attributes" name = "gix-attributes"
version = "0.29.0" version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f47dabf8a50f1558c3a55d978440c7c4f22f87ac897bef03b4edbc96f6115966" checksum = "f868f013fee0ebb5c85fae848c34a0b9ef7438acfbaec0c82a3cdbd5eac730a0"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-glob", "gix-glob",
@ -2895,18 +2910,18 @@ dependencies = [
[[package]] [[package]]
name = "gix-chunk" name = "gix-chunk"
version = "0.4.12" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c356b3825677cb6ff579551bb8311a81821e184453cbd105e2fc5311b288eeb" checksum = "63e516efaac951ed21115b11d5514b120c26ccb493d0c0b9ea6cc10edf4fdf44"
dependencies = [ dependencies = [
"thiserror 2.0.18", "gix-error",
] ]
[[package]] [[package]]
name = "gix-command" name = "gix-command"
version = "0.6.5" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46f9c425730a654835351e6da8c3c69ba1804f8b8d4e96d027254151138d5c64" checksum = "745bc165b7da500acc26d24888379ae0dfd1ecabe3a47420cdcb92feefb0561d"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-path", "gix-path",
@ -2917,22 +2932,22 @@ dependencies = [
[[package]] [[package]]
name = "gix-commitgraph" name = "gix-commitgraph"
version = "0.31.0" version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efdcba8048045baf15225daf949d597c3e6183d130245e22a7fbd27084abe63a" checksum = "d0dda2e4d5a61d4a16a780f61f2b7e9406ad1f8da97c35c09ef501f3fdf74de0"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-chunk", "gix-chunk",
"gix-error",
"gix-hash", "gix-hash",
"memmap2", "memmap2",
"thiserror 2.0.18",
] ]
[[package]] [[package]]
name = "gix-config" name = "gix-config"
version = "0.49.0" version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f15f96a354d296b505575870c4ebe279552a67132b61223869181d11894859d" checksum = "9a153dd4f5789fdf242e19e3f7105f2a114df198570225976fe4a108bac9dee4"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-config-value", "gix-config-value",
@ -2950,9 +2965,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-config-value" name = "gix-config-value"
version = "0.16.0" version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2409cffa4fe8b303847d5b6ba8df9da9ba65d302fc5ee474ea0cac5afde79840" checksum = "563361198101cedc975fe5760c91ac2e4126eec22216e81b659b45289feaf1ea"
dependencies = [ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"bstr", "bstr",
@ -2963,22 +2978,22 @@ dependencies = [
[[package]] [[package]]
name = "gix-date" name = "gix-date"
version = "0.11.1" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0a1259955c76335c9d1a8c511811b10dbc800ffeeca3daea1e0aadd0c98f6b7" checksum = "12553b32d1da25671f31c0b084bf1e5cb6d5ef529254d04ec33cdc890bd7f687"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-error",
"itoa", "itoa",
"jiff", "jiff",
"smallvec", "smallvec",
"thiserror 2.0.18",
] ]
[[package]] [[package]]
name = "gix-diff" name = "gix-diff"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ebc8f56f3300d3c5f98d927b11762ef98e35ddbf9ebf3bdbdb53dbc6d9cbb7e" checksum = "26bcd367b2c5dbf6bec9ce02ca59eab179fc82cf39f15ec83549ee25c255c99f"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-attributes", "gix-attributes",
@ -3000,9 +3015,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-dir" name = "gix-dir"
version = "0.18.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40d285a847a95b3c76c0f7b17143bdc68c917d3f9f772bfd4c83fbadb7497067" checksum = "004129e2c93798141d68ff08cb7f1b3d909c0212747fb8b05c8989635ba90a4e"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-discover", "gix-discover",
@ -3020,14 +3035,13 @@ dependencies = [
[[package]] [[package]]
name = "gix-discover" name = "gix-discover"
version = "0.44.0" version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f2fe2922c3358a93f5e5b62c1c6d856f59ed863f5fd2da1929f66567d3b0e12" checksum = "950b027b861c6863ddf1b075672ec1ef2006b95c4d12284fc1ec4cdb1ab6639e"
dependencies = [ dependencies = [
"bstr", "bstr",
"dunce", "dunce",
"gix-fs", "gix-fs",
"gix-hash",
"gix-path", "gix-path",
"gix-ref", "gix-ref",
"gix-sec", "gix-sec",
@ -3035,10 +3049,19 @@ dependencies = [
] ]
[[package]] [[package]]
name = "gix-features" name = "gix-error"
version = "0.45.2" version = "0.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56aad357ae016449434705033df644ac6253dfcf1281aad3af3af9e907560d1" checksum = "7dffc9ca4dfa4f519a3d2cf1c038919160544923577ac60f45bcb602a24d82c6"
dependencies = [
"bstr",
]
[[package]]
name = "gix-features"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a407957e21dc5e6c87086e50e5114a2f9240f9cb11699588a6d900d53cb6c70"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"crossbeam-channel", "crossbeam-channel",
@ -3056,9 +3079,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-filter" name = "gix-filter"
version = "0.23.0" version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22c005832d42de07bacdef53d3b87f6067e765b9753f85788655a1b4a20fc2b6" checksum = "7240442915cdd74e1f889566695ce0d0c23c7185b13318a1232ce646af0d18ad"
dependencies = [ dependencies = [
"bstr", "bstr",
"encoding_rs", "encoding_rs",
@ -3077,9 +3100,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-fs" name = "gix-fs"
version = "0.18.2" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "785b9c499e46bc78d7b81c148c21b3fca18655379ee729a856ed19ce50d359ec" checksum = "ba74fa163d3b2ba821d5cd207d55fe3daac3d1099613a8559c812d2b15b3c39a"
dependencies = [ dependencies = [
"bstr", "bstr",
"fastrand", "fastrand",
@ -3091,9 +3114,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-glob" name = "gix-glob"
version = "0.23.0" version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8546300aee4c65c5862c22a3e321124a69b654a61a8b60de546a9284812b7e2" checksum = "b03e6cd88cc0dc1eafa1fddac0fb719e4e74b6ea58dd016e71125fde4a326bee"
dependencies = [ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"bstr", "bstr",
@ -3103,9 +3126,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-hash" name = "gix-hash"
version = "0.21.2" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e153930f42ccdab8a3306b1027cd524879f6a8996cd0c474d18b0e56cae7714d" checksum = "2b8e11ea6bbd0fd4ab4a1c66812dd3cc25921a41315b120f352997725a4c79d6"
dependencies = [ dependencies = [
"faster-hex", "faster-hex",
"gix-features", "gix-features",
@ -3115,9 +3138,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-hashtable" name = "gix-hashtable"
version = "0.11.0" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "222f7428636020bef272a87ed833ea48bf5fb3193f99852ae16fbb5a602bd2f0" checksum = "52f1eecdd006390cbed81f105417dbf82a6fe40842022006550f2e32484101da"
dependencies = [ dependencies = [
"gix-hash", "gix-hash",
"hashbrown 0.16.1", "hashbrown 0.16.1",
@ -3126,9 +3149,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-ignore" name = "gix-ignore"
version = "0.18.0" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa727fdf54fd9fb53fa3fbb1a5c17172d3073e8e336bf155f3cac3e25b81b21" checksum = "8953d87c13267e296d547f0fc7eaa8aa8fa5b2a9a34ab1cd5857f25240c7d299"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-glob", "gix-glob",
@ -3139,9 +3162,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-index" name = "gix-index"
version = "0.44.0" version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "015374c00aff762bb21dafbb73a2267583392b320cb4aef156805838752a4152" checksum = "e31c6b3664efe5916c539c50e610f9958f2993faf8e29fa5a40fb80b6ac8486a"
dependencies = [ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"bstr", "bstr",
@ -3167,9 +3190,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-lock" name = "gix-lock"
version = "20.0.1" version = "21.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "115268ae5e3b3b7bc7fc77260eecee05acca458e45318ca45d35467fa81a3ac5" checksum = "e16d406220ef9df105645a9ddcaa42e8c882ba920344ace866d0403570aea599"
dependencies = [ dependencies = [
"gix-tempfile", "gix-tempfile",
"gix-utils", "gix-utils",
@ -3178,9 +3201,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-object" name = "gix-object"
version = "0.53.0" version = "0.55.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ec9557a30ab9abfec4d67975413e3099509ed5da599c901ea40f7da52755128" checksum = "4d3f705c977d90ace597049252ae1d7fec907edc0fa7616cc91bf5508d0f4006"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-actor", "gix-actor",
@ -3199,12 +3222,11 @@ dependencies = [
[[package]] [[package]]
name = "gix-odb" name = "gix-odb"
version = "0.73.0" version = "0.75.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a7eb6f7017bf94ce8cf00da03a8a32d4199fcbee6940c5bba213ca98d01d78f" checksum = "1d59882d2fdab5e609b0c452a6ef9a3bd12ef6b694be4f82ab8f126ad0969864"
dependencies = [ dependencies = [
"arc-swap", "arc-swap",
"gix-date",
"gix-features", "gix-features",
"gix-fs", "gix-fs",
"gix-hash", "gix-hash",
@ -3220,12 +3242,13 @@ dependencies = [
[[package]] [[package]]
name = "gix-pack" name = "gix-pack"
version = "0.63.0" version = "0.65.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0811847c93e98e1694ae0f519fb52af62da1cebeaf0a764840e392c6e41b38" checksum = "8c44db57ebbbeaad9972c2a60662142660427a1f0a7529314d53fefb4fedad24"
dependencies = [ dependencies = [
"clru", "clru",
"gix-chunk", "gix-chunk",
"gix-error",
"gix-features", "gix-features",
"gix-hash", "gix-hash",
"gix-hashtable", "gix-hashtable",
@ -3239,9 +3262,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-packetline" name = "gix-packetline"
version = "0.20.0" version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad0ffb982a289888087a165d3e849cbac724f2aa5431236b050dd2cb9c7de31" checksum = "6c333badf342e9c2392800a96b9f2cf5bcb33906d2577d6ec923756ff4008a3f"
dependencies = [ dependencies = [
"bstr", "bstr",
"faster-hex", "faster-hex",
@ -3251,9 +3274,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-path" name = "gix-path"
version = "0.10.22" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cb06c3e4f8eed6e24fd915fa93145e28a511f4ea0e768bae16673e05ed3f366" checksum = "c7c3cd795cad18c7acbc6bafe34bfb34ac7273ee81133793f9d1516dd9faf922"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-trace", "gix-trace",
@ -3263,9 +3286,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-pathspec" name = "gix-pathspec"
version = "0.14.0" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed9e0c881933c37a7ef45288d6c5779c4a7b3ad240b4c37657e1d9829eb90085" checksum = "3df6fd8e514d8b99ec5042ee17909a17750ccf54d0b8b30c850954209c800322"
dependencies = [ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"bstr", "bstr",
@ -3278,9 +3301,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-protocol" name = "gix-protocol"
version = "0.54.0" version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21348ce0b01fb5e3850e9014733d5ddf6bfeebb100967246572e6b02a29a4fef" checksum = "54f20837b0c70b65f6ac77886be033de3b69d5879f99128b47c42665ab0a17c2"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-date", "gix-date",
@ -3308,9 +3331,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-ref" name = "gix-ref"
version = "0.56.0" version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16f21c66e188cb95207d30c9b2d21b0d234f570dbb97d8fd493081b6990dcb9d" checksum = "5cf780dcd9ac99fd3fcfc8523479a0e2ffd55f5e0be63e5e3248fb7e46cff966"
dependencies = [ dependencies = [
"gix-actor", "gix-actor",
"gix-features", "gix-features",
@ -3329,11 +3352,12 @@ dependencies = [
[[package]] [[package]]
name = "gix-refspec" name = "gix-refspec"
version = "0.34.0" version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "853157fd71394f7f382af2e28a7cd78c5c7bd28b7c5d7de7272e1ec97a869159" checksum = "60ce400a770a7952e45267803192cc2d1fe0afa08e2c08dde32e04c7908c6e61"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-error",
"gix-glob", "gix-glob",
"gix-hash", "gix-hash",
"gix-revision", "gix-revision",
@ -3344,27 +3368,28 @@ dependencies = [
[[package]] [[package]]
name = "gix-revision" name = "gix-revision"
version = "0.38.0" version = "0.40.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63c1956637d13fe273178f425c04b0458ea678c150cb8ed325957a63cb1136f6" checksum = "c719cf7d669439e1fca735bd1c4de54d43c5d30e8883fd6063c4924b213d70c9"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-commitgraph", "gix-commitgraph",
"gix-date", "gix-date",
"gix-error",
"gix-hash", "gix-hash",
"gix-object", "gix-object",
"gix-revwalk", "gix-revwalk",
"thiserror 2.0.18",
] ]
[[package]] [[package]]
name = "gix-revwalk" name = "gix-revwalk"
version = "0.24.0" version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "276d6ce81e71c18e6c9c3de2c5015e85a7495d1bf33e0a7587e997b8bd040715" checksum = "194a50b30aa0c6e6de43c723359c5809a96275a3aa92d323ef7f58b1cdd60f16"
dependencies = [ dependencies = [
"gix-commitgraph", "gix-commitgraph",
"gix-date", "gix-date",
"gix-error",
"gix-hash", "gix-hash",
"gix-hashtable", "gix-hashtable",
"gix-object", "gix-object",
@ -3374,9 +3399,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-sec" name = "gix-sec"
version = "0.12.2" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea9962ed6d9114f7f100efe038752f41283c225bb507a2888903ac593dffa6be" checksum = "beeb3bc63696cf7acb5747a361693ebdbcaf25b5d27d2308f38e9782983e7bce"
dependencies = [ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"gix-path", "gix-path",
@ -3386,9 +3411,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-shallow" name = "gix-shallow"
version = "0.7.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c1c467fb9f7ec1d33613c2ea5482de514bcb84b8222a793cdc4c71955832356" checksum = "f4f4660fed3786d28e7e57d31b2de9ab3bf846068e187ccc52ee513de19a0073"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-hash", "gix-hash",
@ -3398,9 +3423,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-status" name = "gix-status"
version = "0.23.0" version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1084eb17030ddbda1705c94ff6f79678dd7f15762deda74edf0f38e33711079c" checksum = "b0c994dbca7f038cfcde6337673523bab6e6b4f544b5046f5120a02bdeafff33"
dependencies = [ dependencies = [
"bstr", "bstr",
"filetime", "filetime",
@ -3421,9 +3446,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-submodule" name = "gix-submodule"
version = "0.23.0" version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0b0d02a3c5968a2d86de2a56ab28c3b50aa28d8324d49383b7bd71d26e6d84" checksum = "db1840fe723c6264ee596e5a179e1b9a2df59351f09bae9cea570a472a790bc0"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-config", "gix-config",
@ -3436,9 +3461,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-tempfile" name = "gix-tempfile"
version = "20.0.1" version = "21.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad89218e74850f42d364ed3877c7291f0474c8533502df91bb877ecc5cb0dd40" checksum = "d280bba7c547170e42d5228fc6e76c191fb5a7c88808ff61af06460404d1fd91"
dependencies = [ dependencies = [
"dashmap", "dashmap",
"gix-fs", "gix-fs",
@ -3455,9 +3480,9 @@ checksum = "6e42a4c2583357721ba2d887916e78df504980f22f1182df06997ce197b89504"
[[package]] [[package]]
name = "gix-transport" name = "gix-transport"
version = "0.51.0" version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03c5445af84383b949856a36accfde9f90bdfc10bb1f640f105917f9d5419509" checksum = "de1064c7ffa5a915014a6a5b71fbc5299462ae655348bed23e083b4a735076c3"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-command", "gix-command",
@ -3471,9 +3496,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-traverse" name = "gix-traverse"
version = "0.50.0" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1f7582730a236aba16b4c9a5e9ac64bcbe7f155a38ae5938320de96760beb23" checksum = "37f8b53b4c56b01c43a4491c4edfe2ce66c654eb86232205172ceb1650d21c55"
dependencies = [ dependencies = [
"bitflags 2.10.0", "bitflags 2.10.0",
"gix-commitgraph", "gix-commitgraph",
@ -3488,12 +3513,11 @@ dependencies = [
[[package]] [[package]]
name = "gix-url" name = "gix-url"
version = "0.34.0" version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff1996dfb9430b3699d89224c674169c1ae355eacc52bf30a03c0b8bffe73d9" checksum = "1ca2e50308a8373069e71970939f43ea4a1b5f422cf807d048ebcf07dcc02b2c"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-features",
"gix-path", "gix-path",
"percent-encoding", "percent-encoding",
"thiserror 2.0.18", "thiserror 2.0.18",
@ -3512,23 +3536,21 @@ dependencies = [
[[package]] [[package]]
name = "gix-validate" name = "gix-validate"
version = "0.10.1" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b1e63a5b516e970a594f870ed4571a8fdcb8a344e7bd407a20db8bd61dbfde4" checksum = "0ec1eff98d91941f47766367cba1be746bab662bad761d9891ae6f7882f7840b"
dependencies = [ dependencies = [
"bstr", "bstr",
"thiserror 2.0.18",
] ]
[[package]] [[package]]
name = "gix-worktree" name = "gix-worktree"
version = "0.45.0" version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0ac49293df83b81da60ad8313f0376a5a7d6b11739ea7e97c0e1ba17b63d2a6" checksum = "ef2ad658586ec0039b03e96c664f08b7cb7a2b7cca6947a9c856c9ed59b807b1"
dependencies = [ dependencies = [
"bstr", "bstr",
"gix-attributes", "gix-attributes",
"gix-features",
"gix-fs", "gix-fs",
"gix-glob", "gix-glob",
"gix-hash", "gix-hash",
@ -5421,6 +5443,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec"
[[package]]
name = "pastey"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b867cad97c0791bbd3aaa6472142568c6c9e8f71937e98379f584cfb0cf35bec"
[[package]] [[package]]
name = "pathdiff" name = "pathdiff"
version = "0.2.3" version = "0.2.3"
@ -5725,9 +5753,9 @@ dependencies = [
[[package]] [[package]]
name = "prodash" name = "prodash"
version = "30.0.1" version = "31.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6efc566849d3d9d737c5cb06cc50e48950ebe3d3f9d70631490fff3a07b139" checksum = "962200e2d7d551451297d9fdce85138374019ada198e30ea9ede38034e27604c"
dependencies = [ dependencies = [
"parking_lot", "parking_lot",
] ]
@ -5777,9 +5805,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.43" version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]

View file

@ -30,6 +30,8 @@ limit-fps = []
develop = ["limit-fps", "alt-log"] develop = ["limit-fps", "alt-log"]
develop-usb = ["limit-fps", "usb-log", "no-usb", "ble"] develop-usb = ["limit-fps", "usb-log", "no-usb", "ble"]
probe = ["limit-fps", "rtt-log", "no-usb", "ble"] probe = ["limit-fps", "rtt-log", "no-usb", "ble"]
# Formats the EKV database on boot.
format-db = []
[dependencies] [dependencies]
rmk = { version = "0.8.2", default-features = false, features = [ rmk = { version = "0.8.2", default-features = false, features = [
@ -47,19 +49,20 @@ esp-backtrace = { version = "0.18", default-features = false, features = [
"println", "println",
] } ] }
esp-hal = { version = "1.0", features = ["esp32s3", "unstable", "psram", "log-04"] } esp-hal = { version = "1.0", features = ["esp32s3", "unstable", "psram", "log-04"] }
esp-storage = { version = "0.8.0", features = ["esp32s3"] } esp-storage = { version = "0.8", features = ["esp32s3"] }
esp-alloc = { version = "0.9.0", features = ["nightly"] } esp-alloc = { version = "0.9", features = ["nightly"] }
esp-println = { version = "0.16.0", features = ["esp32s3", "log-04"] } esp-println = { version = "0.16", features = ["esp32s3", "log-04"] }
esp-radio = { version = "0.17", features = ["esp32s3", "unstable", "ble"], optional = true } esp-radio = { version = "0.17", features = ["esp32s3", "unstable", "ble"], optional = true }
esp-rtos = { version = "0.2", features = ["esp32s3", "esp-radio", "embassy"] } esp-rtos = { version = "0.2", features = ["esp32s3", "esp-radio", "embassy"] }
esp-bootloader-esp-idf = { version = "0.4", features = ["esp32s3", "log-04"] } esp-bootloader-esp-idf = { version = "0.4", features = ["esp32s3", "log-04"] }
bt-hci = { version = "0.6", optional = true } esp-sync = { version = "0.1.1", features = ["esp32s3", "log-04"] }
rand_core = { version = "0.6", default-features = false } bt-hci = { version = "0.6", optional = true } # Must be updated with esp-radio and rmk
rand_core = { version = "0.9", default-features = false }
static_cell = "2" static_cell = "2"
lazy_static = { version = "1.5.0", features = ["spin_no_std"], default-features = false } lazy_static = { version = "1.5.0", features = ["spin_no_std"], default-features = false }
log = "0.4.29" log = "0.4.29"
bitflags = "2.10.0" bitflags = "2.10.0"
paste = "1.0.15" paste = { package = "pastey", version = "0.2.1" }
itertools = { version = "0.14.0", default-features = false } itertools = { version = "0.14.0", default-features = false }
bytemuck = "1.24.0" bytemuck = "1.24.0"
slint = { version = "1.14.1", default-features = false, features = ["compat-1-2", "libm", "log", "unsafe-single-threaded", "renderer-software"]} slint = { version = "1.14.1", default-features = false, features = ["compat-1-2", "libm", "log", "unsafe-single-threaded", "renderer-software"]}
@ -70,18 +73,32 @@ xkbcommon = { git = "https://github.com/Limeth/xkbcommon-rs", branch = "esp32s3"
rtt-target = { version = "0.6.2", features = ["log"], optional = true } rtt-target = { version = "0.6.2", features = ["log"], optional = true }
panic-rtt-target = { version = "0.2.0", optional = true } panic-rtt-target = { version = "0.2.0", optional = true }
enumset = "1.1.10" enumset = "1.1.10"
printf-compat = { version = "0.2.1", default-features = false } printf-compat = { version = "0.2.1", default-features = false } # Kept older because of the outdated esp toolchain's VaList
spectre-api-sys = { git = "https://github.com/Limeth/spectre-api-sys" } spectre-api-sys = { git = "https://github.com/Limeth/spectre-api-sys" }
sha2 = { version = "0.10.9", default-features = false } sha2 = { version = "0.10.9", default-features = false }
password-hash = { path = "../password-hash", default-features = false } password-hash = { path = "../password-hash", default-features = false }
hmac = "0.12.1" hmac = "0.12.1"
data-encoding-macro = "0.1.19" data-encoding-macro = "0.1.19"
embedded-storage-async = "0.4.1"
# Crates for serial UART CLI # Crates for serial UART CLI
embedded-cli = { version = "0.2.1", default-features = false, features = ["help", "macros"] } embedded-cli = { version = "0.2.1", default-features = false, features = ["help", "macros"] }
embedded-io = "0.6.1" embedded-io = "0.7"
mutually_exclusive_features = "0.1.0" mutually_exclusive_features = "0.1.0"
[dependencies.ekv]
version = "1.0.0"
features = [
# TODO: "defmt",
"crc",
"max-page-count-2048",
"max-key-size-256",
"max-value-size-65536",
# These must adhere to `FlashStorage`'s parameters.
"align-4",
"page-size-4096",
]
[build-dependencies] [build-dependencies]
xz2 = "0.1.7" xz2 = "0.1.7"
json = "0.12" json = "0.12"
@ -89,7 +106,7 @@ const-gen = "1.6"
embuild = "0.33" embuild = "0.33"
cc = "1.2.9" cc = "1.2.9"
slint-build = "1.14.1" slint-build = "1.14.1"
gix = { version = "0.76.0", default-features = false, features = ["max-performance", "status"] } gix = { version = "0.78", default-features = false, features = ["max-performance", "status"] }
indoc = "2.0.7" indoc = "2.0.7"
[[bin]] [[bin]]

View file

@ -22,10 +22,13 @@ use core::sync::atomic::{AtomicBool, Ordering};
use alloc::boxed::Box; use alloc::boxed::Box;
use alloc::vec; use alloc::vec;
use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_embedded_hal::flash::partition::Partition;
use embassy_executor::Spawner; use embassy_executor::Spawner;
use embassy_sync::blocking_mutex; use embassy_sync::blocking_mutex;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::channel::Channel; use embassy_sync::channel::Channel;
use embassy_sync::mutex::Mutex;
use embassy_sync::signal::Signal; use embassy_sync::signal::Signal;
use embassy_time::Duration; use embassy_time::Duration;
use esp_alloc::{HeapRegion, MemoryCapability}; use esp_alloc::{HeapRegion, MemoryCapability};
@ -39,6 +42,7 @@ use esp_hal::lcd_cam::LcdCam;
use esp_hal::lcd_cam::lcd::dpi::Dpi; use esp_hal::lcd_cam::lcd::dpi::Dpi;
use esp_hal::mcpwm::{McPwm, PeripheralClockConfig}; use esp_hal::mcpwm::{McPwm, PeripheralClockConfig};
use esp_hal::psram::{FlashFreq, PsramConfig, PsramSize, SpiRamFreq, SpiTimingConfigCoreClock}; use esp_hal::psram::{FlashFreq, PsramConfig, PsramSize, SpiRamFreq, SpiTimingConfigCoreClock};
use esp_hal::rng::TrngSource;
use esp_hal::sha::{Sha, ShaBackend}; use esp_hal::sha::{Sha, ShaBackend};
use esp_hal::system::Stack; use esp_hal::system::Stack;
use esp_hal::timer::timg::TimerGroup; use esp_hal::timer::timg::TimerGroup;
@ -196,16 +200,16 @@ async fn main(_spawner: Spawner) {
info!("ESP-RTOS started!"); info!("ESP-RTOS started!");
// Enable the TRNG source, so `Trng` can be constructed.
let _trng_source = TrngSource::new(peripherals.RNG, peripherals.ADC1);
#[cfg(feature = "ble")] #[cfg(feature = "ble")]
let mut host_resources = rmk::HostResources::new(); let mut host_resources = rmk::HostResources::new();
#[cfg(feature = "ble")] #[cfg(feature = "ble")]
let stack = { let stack = {
// Enable the TRNG source, so `Trng` can be constructed.
use bt_hci::controller::ExternalController; use bt_hci::controller::ExternalController;
use esp_hal::rng::TrngSource;
use esp_radio::{Controller as RadioController, ble::controller::BleConnector}; use esp_radio::{Controller as RadioController, ble::controller::BleConnector};
let _trng_source = TrngSource::new(peripherals.RNG, peripherals.ADC1);
let mut rng = esp_hal::rng::Trng::try_new().unwrap(); let mut rng = esp_hal::rng::Trng::try_new().unwrap();
static RADIO: StaticCell<RadioController<'static>> = StaticCell::new(); static RADIO: StaticCell<RadioController<'static>> = StaticCell::new();
let radio = RADIO.init(esp_radio::init().unwrap()); let radio = RADIO.init(esp_radio::init().unwrap());
@ -241,6 +245,9 @@ async fn main(_spawner: Spawner) {
}; };
// Initialize the flash // Initialize the flash
static FLASH: StaticCell<Mutex<CriticalSectionRawMutex, BlockingAsync<FlashStorage>>> =
StaticCell::new();
let flash = FLASH.init_with(|| {
let flash = FlashStorage::new(peripherals.FLASH) let flash = FlashStorage::new(peripherals.FLASH)
// Flash memory may not be written to while another core is executing from it. // Flash memory may not be written to while another core is executing from it.
// By default, `FlashStorage` is configured to abort the operation and log an error message. // By default, `FlashStorage` is configured to abort the operation and log an error message.
@ -250,7 +257,19 @@ async fn main(_spawner: Spawner) {
// to avoid having to park the other core, which could result in better performance. // to avoid having to park the other core, which could result in better performance.
// Invalid configuration would then present itself as freezing/UB. // Invalid configuration would then present itself as freezing/UB.
.multicore_auto_park(); .multicore_auto_park();
let flash = async_flash_wrapper(flash);
Mutex::<CriticalSectionRawMutex, _>::new(async_flash_wrapper(flash))
});
const FLASH_SIZE_TOTAL: u32 = 16 * 1024 * 1024;
const FLASH_PART_FIRMWARE_OFFSET: u32 = 0;
const FLASH_PART_FIRMWARE_SIZE: u32 = 0x3f0000;
const FLASH_PART_RMK_OFFSET: u32 = FLASH_PART_FIRMWARE_OFFSET + FLASH_PART_FIRMWARE_SIZE;
const FLASH_PART_RMK_SIZE_IN_SECTORS: u32 = 16;
const FLASH_PART_RMK_SIZE: u32 = FLASH_PART_RMK_SIZE_IN_SECTORS * FlashStorage::SECTOR_SIZE;
const FLASH_PART_ACID_OFFSET: u32 = FLASH_PART_RMK_OFFSET + FLASH_PART_RMK_SIZE;
const FLASH_PART_ACID_SIZE: u32 = FLASH_SIZE_TOTAL - FLASH_PART_ACID_OFFSET;
let flash_part_rmk = Partition::new(flash, FLASH_PART_RMK_OFFSET, FLASH_PART_RMK_SIZE);
let flash_part_acid = Partition::new(flash, FLASH_PART_ACID_OFFSET, FLASH_PART_ACID_SIZE);
info!("Flash memory configured!"); info!("Flash memory configured!");
@ -296,8 +315,8 @@ async fn main(_spawner: Spawner) {
// RMK config // RMK config
let vial_config = VialConfig::new(VIAL_KEYBOARD_ID, VIAL_KEYBOARD_DEF, &[(0, 0), (1, 1)]); let vial_config = VialConfig::new(VIAL_KEYBOARD_ID, VIAL_KEYBOARD_DEF, &[(0, 0), (1, 1)]);
let storage_config = StorageConfig { let storage_config = StorageConfig {
start_addr: 0x3f0000, start_addr: 0,
num_sectors: 16, num_sectors: FLASH_PART_RMK_SIZE_IN_SECTORS as u8,
..Default::default() ..Default::default()
}; };
let rmk_config = RmkConfig { let rmk_config = RmkConfig {
@ -313,7 +332,7 @@ async fn main(_spawner: Spawner) {
let mut per_key_config = PositionalConfig::default(); let mut per_key_config = PositionalConfig::default();
let (keymap, mut storage) = initialize_keymap_and_storage( let (keymap, mut storage) = initialize_keymap_and_storage(
&mut default_keymap, &mut default_keymap,
flash, flash_part_rmk,
&storage_config, &storage_config,
&mut behavior_config, &mut behavior_config,
&mut per_key_config, &mut per_key_config,
@ -379,7 +398,7 @@ async fn main(_spawner: Spawner) {
window: RefCell::new(None), window: RefCell::new(None),
framebuffer: framebuffer_ptr, framebuffer: framebuffer_ptr,
}; };
spawner.must_spawn(ui::run_renderer_task(slint_backend)); spawner.must_spawn(ui::run_renderer_task(slint_backend, flash_part_acid));
}); });
}, },
); );

View file

@ -1,8 +1,17 @@
// #![cfg_attr(not(feature = "simulator"), no_main)] // #![cfg_attr(not(feature = "simulator"), no_main)]
use core::ops::{Deref, DerefMut};
use alloc::{boxed::Box, ffi::CString}; use alloc::{boxed::Box, ffi::CString};
use ekv::{Database, MountError, flash::PageID};
use embassy_embedded_hal::{adapter::BlockingAsync, flash::partition::Partition};
use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, RawMutex};
use embassy_time::{Duration, Instant}; use embassy_time::{Duration, Instant};
use embedded_storage_async::nor_flash::{NorFlash, ReadNorFlash};
use esp_hal::rng::Trng;
use esp_storage::FlashStorage;
use log::{info, warn}; use log::{info, warn};
use rmk::futures::TryFutureExt;
use slint::SharedString; use slint::SharedString;
use spectre_api_sys::{SpectreAlgorithm, SpectreCounter, SpectreKeyPurpose, SpectreUserKey}; use spectre_api_sys::{SpectreAlgorithm, SpectreCounter, SpectreKeyPurpose, SpectreUserKey};
@ -15,8 +24,114 @@ pub mod window_adapter;
slint::include_modules!(); slint::include_modules!();
type PartitionAcid =
Partition<'static, CriticalSectionRawMutex, BlockingAsync<FlashStorage<'static>>>;
// Workaround for alignment requirements.
#[repr(C, align(4))]
struct AlignedBuf<const N: usize>(pub [u8; N]);
struct EkvFlash<T> {
flash: T,
buffer: Box<AlignedBuf<{ ekv::config::PAGE_SIZE }>>,
}
impl<T> EkvFlash<T> {
fn new(flash: T) -> Self {
Self {
flash,
buffer: {
// Allocate the buffer directly on the heap.
let buffer = Box::new_zeroed();
unsafe { buffer.assume_init() }
},
}
}
}
impl<T> Deref for EkvFlash<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.flash
}
}
impl<T> DerefMut for EkvFlash<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.flash
}
}
impl<T: NorFlash + ReadNorFlash> ekv::flash::Flash for EkvFlash<T> {
type Error = T::Error;
fn page_count(&self) -> usize {
ekv::config::MAX_PAGE_COUNT
}
async fn erase(
&mut self,
page_id: PageID,
) -> Result<(), <EkvFlash<T> as ekv::flash::Flash>::Error> {
self.flash
.erase(
(page_id.index() * ekv::config::PAGE_SIZE) as u32,
((page_id.index() + 1) * ekv::config::PAGE_SIZE) as u32,
)
.await
}
async fn read(
&mut self,
page_id: PageID,
offset: usize,
data: &mut [u8],
) -> Result<(), <EkvFlash<T> as ekv::flash::Flash>::Error> {
let address = page_id.index() * ekv::config::PAGE_SIZE + offset;
self.flash
.read(address as u32, &mut self.buffer.0[..data.len()])
.await?;
data.copy_from_slice(&self.buffer.0[..data.len()]);
Ok(())
}
async fn write(
&mut self,
page_id: PageID,
offset: usize,
data: &[u8],
) -> Result<(), <EkvFlash<T> as ekv::flash::Flash>::Error> {
let address = page_id.index() * ekv::config::PAGE_SIZE + offset;
self.buffer.0[..data.len()].copy_from_slice(data);
self.flash
.write(address as u32, &self.buffer.0[..data.len()])
.await
}
}
#[embassy_executor::task] #[embassy_executor::task]
pub async fn run_renderer_task(backend: SlintBackend) { pub async fn run_renderer_task(backend: SlintBackend, flash_part_acid: PartitionAcid) {
let mut db_config = ekv::Config::default();
db_config.random_seed = Trng::try_new()
.expect("A `TrngSource` was not initialized before constructing this `Trng`.")
.random();
let mut db = Database::<_, esp_sync::RawMutex>::new(EkvFlash::new(flash_part_acid), db_config);
#[cfg(feature = "format-db")]
{
warn!("Formatting EKV database...");
db.format()
.await
.unwrap_or_else(|error| panic!("Failed to format the EKV database: {error:?}"));
warn!("EKV database formatted successfully.");
}
match db.mount().await {
Ok(()) => info!("EKV database mounted."),
Err(error) => panic!("Failed to mount the EKV database: {error:?}"),
};
slint::platform::set_platform(Box::new(backend)).expect("backend already initialized"); slint::platform::set_platform(Box::new(backend)).expect("backend already initialized");
let main = AppWindow::new().unwrap(); let main = AppWindow::new().unwrap();
@ -57,10 +172,13 @@ pub async fn run_renderer_task(backend: SlintBackend) {
} }
}); });
// Instead of having a `loop` in the non-async `SlintBackend::run_event_loop`, we achieve run_event_loop(main).await;
// async by having only one iteration of the loop run, and `await`ing here. }
// The following block is analogous to `main.run()`.
{ /// Instead of having a `loop` in the non-async `SlintBackend::run_event_loop`, we achieve
/// async by having only one iteration of the loop run, and `await`ing here.
/// The following block is analogous to `main.run()`.
async fn run_event_loop(main: AppWindow) {
main.show().unwrap(); main.show().unwrap();
loop { loop {
@ -74,4 +192,3 @@ pub async fn run_renderer_task(backend: SlintBackend) {
#[expect(unreachable_code)] #[expect(unreachable_code)]
main.hide().unwrap(); main.hide().unwrap();
} }
}

View file

@ -14,6 +14,7 @@ import { Button, VerticalBox, LineEdit, GridBox } from "std-widgets.slint";
import "../fonts/IBM_Plex_Mono/IBMPlexMono-Regular.ttf"; import "../fonts/IBM_Plex_Mono/IBMPlexMono-Regular.ttf";
/* /*
TODO: A bigger stack for the 2nd core might be needed to prevent crashing.
export enum AppState { export enum AppState {
PasswordForm, PasswordForm,
} }