diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index eacd00e..afdde1d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -44,6 +44,9 @@ jobs: - name: cargo fmt --check (examples) run: cargo fmt --check working-directory: "./examples/rt685s" + - name: cargo fmt --check (bootloader-tool) + run: cargo fmt --check + working-directory: "./bootloader-tool" clippy: runs-on: ubuntu-latest @@ -65,7 +68,7 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} - components: clippy + components: clippy,rustfmt - name: rustup target add ${{ matrix.target }} run: rustup target add ${{ matrix.target }} - name: cargo clippy (libs) @@ -82,6 +85,13 @@ jobs: clippy_flags: -- -F clippy::suspicious -D clippy::correctness -F clippy::perf -F clippy::style github_token: ${{ secrets.GITHUB_TOKEN }} workdir: "./examples/rt685s" + - name: cargo clippy (bootloader-tool) + uses: giraffate/clippy-action@v1 + with: + reporter: "github-pr-check" + clippy_flags: -- -D clippy::suspicious -D clippy::correctness -D clippy::perf -D clippy::style + github_token: ${{ secrets.GITHUB_TOKEN }} + workdir: "./bootloader-tool" # Enable once we have a released crate # semver: @@ -116,6 +126,8 @@ jobs: submodules: true - name: Install nightly uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt # required for device-driver - name: rustup target add ${{ matrix.target }} run: rustup target add ${{ matrix.target }} - name: cargo doc (libs) @@ -145,6 +157,8 @@ jobs: - name: Install stable uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt # required for device-driver - name: rustup target add thumbv8m.main-none-eabihf run: rustup target add thumbv8m.main-none-eabihf @@ -202,6 +216,10 @@ jobs: target: [thumbv8m.main-none-eabihf] name: ubuntu / MSRV ${{ matrix.msrv }} steps: + - name: Install libudev (linux) + run: | + sudo apt update + sudo apt install -y libudev-dev - uses: actions/checkout@v4 with: submodules: true @@ -209,6 +227,7 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.msrv }} + components: rustfmt # required for device-driver - name: rustup target add ${{ matrix.target }} run: rustup target add ${{ matrix.target }} - name: cargo +${{ matrix.msrv }} check (libs) @@ -217,3 +236,6 @@ jobs: - name: cargo +${{ matrix.msrv }} check (examples) run: cargo check working-directory: "./examples/rt685s" + - name: cargo +${{ matrix.msrv }} check (bootloader-tool) + run: cargo check + working-directory: "./bootloader-tool" diff --git a/bootloader-tool/Cargo.lock b/bootloader-tool/Cargo.lock index 0edd081..c7ea25e 100644 --- a/bootloader-tool/Cargo.lock +++ b/bootloader-tool/Cargo.lock @@ -39,9 +39,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -105,7 +105,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror", + "thiserror 2.0.17", "time", ] @@ -117,7 +117,7 @@ checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", "synstructure", ] @@ -129,7 +129,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -147,18 +147,7 @@ dependencies = [ "polling", "rustix 1.1.2", "slab", - "windows-sys 0.61.1", -] - -[[package]] -name = "async-trait" -version = "0.1.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "windows-sys 0.61.2", ] [[package]] @@ -183,7 +172,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.37.3", "rustc-demangle", "windows-link", ] @@ -200,26 +189,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" -[[package]] -name = "bincode" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" -dependencies = [ - "bincode_derive", - "serde", - "unty", -] - -[[package]] -name = "bincode_derive" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09" -dependencies = [ - "virtue", -] - [[package]] name = "bitfield" version = "0.19.2" @@ -237,7 +206,7 @@ checksum = "52511b09931f7d5fe3a14f23adefbc23e5725b184013e96c8419febb61f14734" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -251,9 +220,6 @@ name = "bitflags" version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" -dependencies = [ - "serde", -] [[package]] name = "bitvec" @@ -284,16 +250,15 @@ dependencies = [ "anyhow", "clap", "hmac", - "indicatif", "itertools", "log", - "object", + "object 0.37.3", "pretty_env_logger", "probe-rs", "rand 0.9.2", "rsa", "serde", - "serde_yml", + "serde_json", "sha2", "tempfile", "tokio", @@ -301,30 +266,24 @@ dependencies = [ "x509-parser", ] -[[package]] -name = "bumpalo" -version = "3.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" - [[package]] name = "bytemuck" -version = "1.23.2" +version = "1.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" +checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.10.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f154e572231cb6ba2bd1176980827e3d5dc04cc183a75dea38109fbdd672d29" +checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -335,9 +294,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.2.39" +version = "1.2.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1354349954c6fc9cb0deab020f27f783cf0b604e8bb754dc4658ecf0d29c35f" +checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb" dependencies = [ "find-msvc-tools", "shlex", @@ -349,12 +308,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - [[package]] name = "chrono" version = "0.4.42" @@ -394,7 +347,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.1", ] [[package]] @@ -406,7 +359,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -415,15 +368,6 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" -[[package]] -name = "cobs" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea6d1b751c55bd9c0dda7d4ff752074e98f4765ae969664648bd193bb326d15" -dependencies = [ - "thiserror", -] - [[package]] name = "colorchoice" version = "1.0.4" @@ -439,19 +383,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "console" -version = "0.15.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" -dependencies = [ - "encode_unicode", - "libc", - "once_cell", - "unicode-width 0.2.1", - "windows-sys 0.59.0", -] - [[package]] name = "const-oid" version = "0.9.6" @@ -470,9 +401,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" dependencies = [ "core-foundation-sys", "libc", @@ -541,9 +472,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.11" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ "darling_core", "darling_macro", @@ -551,27 +482,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.11" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim", - "syn", + "strsim 0.10.0", + "syn 1.0.109", ] [[package]] name = "darling_macro" -version = "0.20.11" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -582,27 +513,25 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" [[package]] name = "deku" -version = "0.18.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9711031e209dc1306d66985363b4397d4c7b911597580340b93c9729b55f6eb" +checksum = "819b87cc7a05b3abe3fc38e59b3980a5fd3162f25a247116441a9171d3e84481" dependencies = [ "bitvec", "deku_derive", - "no_std_io2", - "rustversion", ] [[package]] name = "deku_derive" -version = "0.18.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cb0719583cbe4e81fb40434ace2f0d22ccc3e39a74bb3796c22b451b4f139d" +checksum = "4e2ca12572239215a352a74ad7c776d7e8a914f8a23511c6cbedddd887e5009e" dependencies = [ "darling", "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -659,7 +588,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -679,7 +608,7 @@ checksum = "4673f83edb6dfabfbc26704bd89ee95f4b164cd5db5fe8c88efda48fb0fca8d7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -694,12 +623,6 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" -[[package]] -name = "encode_unicode" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" - [[package]] name = "env_logger" version = "0.10.2" @@ -726,35 +649,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] name = "esp-idf-part" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5ebc2381d030e4e89183554c3fcd4ad44dc5ab34961ab09e09b4adbe4f94b61" +checksum = "59f50b6c32370067087b46087cd5333f2dfe678f0b01223fa70fde6f15449844" dependencies = [ - "bitflags 2.9.4", "csv", "deku", - "md-5", + "heapless", + "md5", "parse_int", "regex", "serde", "serde_plain", "strum", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "espflash" -version = "4.1.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c63d954132db04edb660af5a554a46f909f7b172d7601b4af3fea994b926821" +checksum = "75ee2834a4000ab046f7a2a439ac1c54366a2f6b91db92a147ca7fbaf7c2e1eb" dependencies = [ "base64", - "bitflags 2.9.4", "bytemuck", "esp-idf-part", "flate2", @@ -762,12 +684,11 @@ dependencies = [ "log", "md-5", "miette", - "nix 0.30.1", - "object", "serde", "sha2", "strum", - "thiserror", + "thiserror 2.0.17", + "xmas-elf", ] [[package]] @@ -778,15 +699,15 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "find-msvc-tools" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" +checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3" [[package]] name = "flate2" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9" dependencies = [ "crc32fast", "miniz_oxide", @@ -880,6 +801,15 @@ version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + [[package]] name = "hashbrown" version = "0.15.5" @@ -895,6 +825,17 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "serde", + "stable_deref_trait", +] + [[package]] name = "heck" version = "0.5.0" @@ -1080,19 +1021,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "indicatif" -version = "0.17.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" -dependencies = [ - "console", - "number_prefix", - "portable-atomic", - "unicode-width 0.2.1", - "web-time", -] - [[package]] name = "inout" version = "0.1.4" @@ -1175,16 +1103,6 @@ dependencies = [ "serde", ] -[[package]] -name = "js-sys" -version = "0.3.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305" -dependencies = [ - "once_cell", - "wasm-bindgen", -] - [[package]] name = "lazy_static" version = "1.5.0" @@ -1216,16 +1134,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "libyml" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3302702afa434ffa30847a83305f0a69d6abd74293b6554c18ec85c7ef30c980" -dependencies = [ - "anyhow", - "version_check", -] - [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -1246,11 +1154,10 @@ checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] @@ -1279,6 +1186,12 @@ dependencies = [ "digest", ] +[[package]] +name = "md5" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" + [[package]] name = "memchr" version = "2.7.6" @@ -1293,7 +1206,7 @@ checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" dependencies = [ "cfg-if", "miette-derive", - "unicode-width 0.1.14", + "unicode-width", ] [[package]] @@ -1304,7 +1217,7 @@ checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -1320,6 +1233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -1355,27 +1269,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nix" -version = "0.30.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" -dependencies = [ - "bitflags 2.9.4", - "cfg-if", - "cfg_aliases", - "libc", -] - -[[package]] -name = "no_std_io2" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3564ce7035b1e4778d8cb6cacebb5d766b5e8fe5a75b9e441e33fb61a872c6" -dependencies = [ - "memchr", -] - [[package]] name = "nom" version = "7.1.3" @@ -1449,12 +1342,6 @@ dependencies = [ "libm", ] -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "nusb" version = "0.1.14" @@ -1474,6 +1361,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + [[package]] name = "object" version = "0.37.3" @@ -1517,9 +1413,9 @@ checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -1527,22 +1423,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-link", ] [[package]] name = "parse_int" -version = "0.9.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c464266693329dd5a8715098c7f86e6c5fd5d985018b8318f53d9c6c2b21a31" +checksum = "2d695b79916a2c08bcff7be7647ab60d1402885265005a6658ffe6d763553c5a" dependencies = [ "num-traits", ] @@ -1612,15 +1508,9 @@ dependencies = [ "hermit-abi 0.5.2", "pin-project-lite", "rustix 1.1.2", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] -[[package]] -name = "portable-atomic" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" - [[package]] name = "potential_utf" version = "0.1.3" @@ -1657,16 +1547,14 @@ dependencies = [ [[package]] name = "probe-rs" -version = "0.29.0" -source = "git+https://github.com/probe-rs/probe-rs.git?rev=6b0c108#6b0c108e067cc70d5e000e664b549eb23f6a7e96" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbe3ebd35648720efb8ae8ac516d2e4b01ae599e4852b7c4e58cad57faa98a9c" dependencies = [ "anyhow", "async-io", - "async-trait", - "bincode", "bitfield", "bitvec", - "cobs", "docsplay", "dunce", "espflash", @@ -1677,7 +1565,7 @@ dependencies = [ "itertools", "jep106", "nusb", - "object", + "object 0.36.7", "parking_lot", "probe-rs-target", "rmp-serde", @@ -1685,7 +1573,7 @@ dependencies = [ "serde", "serde_yaml", "serialport", - "thiserror", + "thiserror 2.0.17", "tracing", "uf2-decode", "zerocopy", @@ -1693,8 +1581,9 @@ dependencies = [ [[package]] name = "probe-rs-target" -version = "0.29.0" -source = "git+https://github.com/probe-rs/probe-rs.git?rev=6b0c108#6b0c108e067cc70d5e000e664b549eb23f6a7e96" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2e8b139e00c1616dc404fa9b7c9ad8bd62616982cf769846ed7be2c18bfa576" dependencies = [ "base64", "indexmap", @@ -1706,10 +1595,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.4.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ + "once_cell", "toml_edit", ] @@ -1724,9 +1614,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.41" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -1803,9 +1693,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ "bitflags 2.9.4", ] @@ -1934,7 +1824,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.11.0", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -1966,9 +1856,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scroll" -version = "0.13.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1257cd4248b4132760d6524d6dda4e053bc648c9070b960929bf50cfb1e7add" +checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" [[package]] name = "serde" @@ -1997,7 +1887,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2033,16 +1923,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c522100790450cf78eeac1507263d0a350d4d5b30df0c8e1fe051a10c22b376e" +checksum = "6093cd8c01b25262b84927e0f7151692158fab02d961e04c979d3903eba7ecc5" dependencies = [ "base64", "chrono", "hex", "indexmap", - "serde", - "serde_derive", + "serde_core", "serde_json", "time", ] @@ -2060,37 +1949,23 @@ dependencies = [ "unsafe-libyaml", ] -[[package]] -name = "serde_yml" -version = "0.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e2dd588bf1597a252c3b920e0143eb99b0f76e4e082f4c92ce34fbc9e71ddd" -dependencies = [ - "indexmap", - "itoa", - "libyml", - "memchr", - "ryu", - "serde", - "version_check", -] - [[package]] name = "serialport" -version = "4.7.3" +version = "4.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2acaf3f973e8616d7ceac415f53fc60e190b2a686fbcf8d27d0256c741c5007b" +checksum = "639bd15c42cb6106d2212f5b8fa139de031e7d96e28882c9f105ff076d32acc3" dependencies = [ "bitflags 2.9.4", "cfg-if", - "core-foundation 0.10.1", + "core-foundation 0.10.0", "core-foundation-sys", "io-kit-sys", "mach2", "nix 0.26.4", + "quote", "scopeguard", "unescaper", - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -2120,6 +1995,12 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "slab" version = "0.4.11" @@ -2154,6 +2035,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strsim" version = "0.11.1" @@ -2162,23 +2049,24 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.27.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.27.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "rustversion", + "syn 2.0.106", ] [[package]] @@ -2187,6 +2075,17 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.106" @@ -2206,7 +2105,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2225,7 +2124,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix 1.1.2", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -2237,13 +2136,33 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.17", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", ] [[package]] @@ -2254,7 +2173,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2321,7 +2240,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2333,12 +2252,18 @@ dependencies = [ "indexmap", "serde_core", "serde_spanned", - "toml_datetime", + "toml_datetime 0.7.2", "toml_parser", "toml_writer", - "winnow", + "winnow 0.7.13", ] +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" + [[package]] name = "toml_datetime" version = "0.7.2" @@ -2350,14 +2275,13 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.23.6" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", - "toml_datetime", - "toml_parser", - "winnow", + "toml_datetime 0.6.11", + "winnow 0.5.40", ] [[package]] @@ -2366,7 +2290,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627" dependencies = [ - "winnow", + "winnow 0.7.13", ] [[package]] @@ -2394,7 +2318,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2414,9 +2338,9 @@ checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c" [[package]] name = "typenum" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "udev" @@ -2442,7 +2366,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c01d12e3a56a4432a8b436f293c25f4808bdf9e9f9f98f9260bba1f1bc5a1f26" dependencies = [ - "thiserror", + "thiserror 2.0.17", ] [[package]] @@ -2457,12 +2381,6 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" -[[package]] -name = "unicode-width" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" - [[package]] name = "unsafe-libyaml" version = "0.2.11" @@ -2475,12 +2393,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "unty" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" - [[package]] name = "url" version = "2.5.7" @@ -2511,12 +2423,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "virtue" -version = "0.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" - [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -2541,111 +2447,20 @@ dependencies = [ "wit-bindgen", ] -[[package]] -name = "wasm-bindgen" -version = "0.2.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-link" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-sys" @@ -2680,14 +2495,14 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.4", + "windows-targets 0.53.5", ] [[package]] name = "windows-sys" -version = "0.61.1" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f109e41dd4a3c848907eb83d5a42ea98b3769495597450cf6d153507b166f0f" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ "windows-link", ] @@ -2725,19 +2540,19 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.4" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ "windows-link", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -2754,9 +2569,9 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" @@ -2772,9 +2587,9 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" @@ -2790,9 +2605,9 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" @@ -2802,9 +2617,9 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" @@ -2820,9 +2635,9 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" @@ -2838,9 +2653,9 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" @@ -2856,9 +2671,9 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" @@ -2874,19 +2689,25 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" -version = "0.7.13" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" + [[package]] name = "wit-bindgen" version = "0.46.0" @@ -2910,9 +2731,9 @@ dependencies = [ [[package]] name = "x509-parser" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569f339c0c402346d4a75a9e39cf8dad310e287eef1ff56d4c68e5067f53460" +checksum = "eb3e137310115a65136898d2079f003ce33331a6c4b0d51f1531d1be082b6425" dependencies = [ "asn1-rs", "data-encoding", @@ -2922,10 +2743,19 @@ dependencies = [ "oid-registry", "ring", "rusticata-macros", - "thiserror", + "thiserror 2.0.17", "time", ] +[[package]] +name = "xmas-elf" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42c49817e78342f7f30a181573d82ff55b88a35f86ccaf07fc64b3008f56d1c6" +dependencies = [ + "zero", +] + [[package]] name = "yoke" version = "0.8.0" @@ -2946,10 +2776,16 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", "synstructure", ] +[[package]] +name = "zero" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fe21bcc34ca7fe6dd56cc2cb1261ea59d6b93620215aefb5ea6032265527784" + [[package]] name = "zerocopy" version = "0.8.27" @@ -2967,7 +2803,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -2987,7 +2823,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", "synstructure", ] @@ -3027,5 +2863,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] diff --git a/bootloader-tool/Cargo.toml b/bootloader-tool/Cargo.toml index 8d60dca..118024c 100644 --- a/bootloader-tool/Cargo.toml +++ b/bootloader-tool/Cargo.toml @@ -2,13 +2,13 @@ name = "bootloader-tool" version = "0.1.0" edition = "2024" +license = "MIT" [dependencies] clap = { version = "4.5", features = ["derive"] } -indicatif = "0.17.11" object = { version = "0.37.3", features = ["build"] } -probe-rs = { git = "https://github.com/probe-rs/probe-rs.git", rev = "6b0c108" } +probe-rs = { version = "0.29.1", default-features = false } tokio = { version = "1.47.1", features = ["macros", "rt", "rt-multi-thread"] } @@ -19,7 +19,7 @@ rand = "0.9" serde = { version = "1.0", features = ["derive"] } toml = { version = "0.9", features = ["serde"] } -serde_yml = "0.0" +serde_json = "1.0" pretty_env_logger = "0.5" log = "0.4" @@ -28,6 +28,6 @@ hmac = "0.12" sha2 = "0.10" aes = "0.8" rsa = { version = "0.9.8", features = ["sha2"] } -x509-parser = { version = "0.17.0", features = ["verify"] } +x509-parser = { version = "0.18.0", features = ["verify"] } tempfile = "3.20.0" diff --git a/bootloader-tool/deny.toml b/bootloader-tool/deny.toml new file mode 100644 index 0000000..f490d95 --- /dev/null +++ b/bootloader-tool/deny.toml @@ -0,0 +1,234 @@ +# This template contains all of the possible sections and their default values + +# Note that all fields that take a lint level have these possible values: +# * deny - An error will be produced and the check will fail +# * warn - A warning will be produced, but the check will not fail +# * allow - No warning or error will be produced, though in some cases a note +# will be + +# The values provided in this template are the default values that will be used +# when any section or field is not specified in your own configuration + +# Root options + +# The graph table configures how the dependency graph is constructed and thus +# which crates the checks are performed against +[graph] +# If 1 or more target triples (and optionally, target_features) are specified, +# only the specified targets will be checked when running `cargo deny check`. +# This means, if a particular package is only ever used as a target specific +# dependency, such as, for example, the `nix` crate only being used via the +# `target_family = "unix"` configuration, that only having windows targets in +# this list would mean the nix crate, as well as any of its exclusive +# dependencies not shared by any other crates, would be ignored, as the target +# list here is effectively saying which targets you are building for. +targets = [ + # The triple can be any string, but only the target triples built in to + # rustc (as of 1.40) can be checked against actual config expressions + #"x86_64-unknown-linux-musl", + # You can also specify which target_features you promise are enabled for a + # particular target. target_features are currently not validated against + # the actual valid features supported by the target architecture. + #{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, +] +# When creating the dependency graph used as the source of truth when checks are +# executed, this field can be used to prune crates from the graph, removing them +# from the view of cargo-deny. This is an extremely heavy hammer, as if a crate +# is pruned from the graph, all of its dependencies will also be pruned unless +# they are connected to another crate in the graph that hasn't been pruned, +# so it should be used with care. The identifiers are [Package ID Specifications] +# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) +#exclude = [] +# If true, metadata will be collected with `--all-features`. Note that this can't +# be toggled off if true, if you want to conditionally enable `--all-features` it +# is recommended to pass `--all-features` on the cmd line instead +all-features = false +# If true, metadata will be collected with `--no-default-features`. The same +# caveat with `all-features` applies +no-default-features = false +# If set, these feature will be enabled when collecting metadata. If `--features` +# is specified on the cmd line they will take precedence over this option. +#features = [] + +# The output table provides options for how/if diagnostics are outputted +[output] +# When outputting inclusion graphs in diagnostics that include features, this +# option can be used to specify the depth at which feature edges will be added. +# This option is included since the graphs can be quite large and the addition +# of features from the crate(s) to all of the graph roots can be far too verbose. +# This option can be overridden via `--feature-depth` on the cmd line +feature-depth = 1 + +# This section is considered when running `cargo deny check advisories` +# More documentation for the advisories section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html +[advisories] +# The path where the advisory databases are cloned/fetched into +#db-path = "$CARGO_HOME/advisory-dbs" +# The url(s) of the advisory databases to use +#db-urls = ["https://github.com/rustsec/advisory-db"] +# A list of advisory IDs to ignore. Note that ignored advisories will still +# output a note when they are encountered. +ignore = [ + #"RUSTSEC-0000-0000", + #{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, + #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish + #{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, + { id = "RUSTSEC-2024-0436", reason = "paste is unmaintained, no safe upgrade available, need upstream dependencies to migrate away from it." }, + { id = "RUSTSEC-2023-0071", reason = "rsa timing side-channels are irrelevant as bootloader-tool is a dev-only CLI and not a publicly accessible web service" }, + { id = "RUSTSEC-2025-0018", reason = "malicious binaries to induce an out-of-bounds read are irrelevant for this usecase" }, +] +# If this is true, then cargo deny will use the git executable to fetch advisory database. +# If this is false, then it uses a built-in git library. +# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. +# See Git Authentication for more information about setting up git authentication. +#git-fetch-with-cli = true + +# This section is considered when running `cargo deny check licenses` +# More documentation for the licenses section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html +[licenses] +# List of explicitly allowed licenses +# See https://spdx.org/licenses/ for list of possible licenses +# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. +allow = [ + "MIT", + "Apache-2.0", + "Unicode-3.0", + #"Apache-2.0 WITH LLVM-exception", +] +# The confidence threshold for detecting a license from license text. +# The higher the value, the more closely the license text must be to the +# canonical license text of a valid SPDX license file. +# [possible values: any between 0.0 and 1.0]. +confidence-threshold = 0.8 +# Allow 1 or more licenses on a per-crate basis, so that particular licenses +# aren't accepted for every possible crate as with the normal allow list +exceptions = [] + +# Some crates don't have (easily) machine readable licensing information, +# adding a clarification entry for it allows you to manually specify the +# licensing information +#[[licenses.clarify]] +# The package spec the clarification applies to +#crate = "ring" +# The SPDX expression for the license requirements of the crate +#expression = "MIT AND ISC AND OpenSSL" +# One or more files in the crate's source used as the "source of truth" for +# the license expression. If the contents match, the clarification will be used +# when running the license check, otherwise the clarification will be ignored +# and the crate will be checked normally, which may produce warnings or errors +# depending on the rest of your configuration +#license-files = [ +# Each entry is a crate relative path, and the (opaque) hash of its contents +#{ path = "LICENSE", hash = 0xbd0eed23 } +#] + +[licenses.private] +# If true, ignores workspace crates that aren't published, or are only +# published to private registries. +# To see how to mark a crate as unpublished (to the official registry), +# visit https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field. +ignore = false +# One or more private registries that you might publish crates to, if a crate +# is only published to private registries, and ignore is true, the crate will +# not have its license(s) checked +registries = [ + #"https://sekretz.com/registry +] + +# This section is considered when running `cargo deny check bans`. +# More documentation about the 'bans' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html +[bans] +# Lint level for when multiple versions of the same crate are detected +multiple-versions = "warn" +# Lint level for when a crate version requirement is `*` +wildcards = "allow" +# The graph highlighting used when creating dotgraphs for crates +# with multiple versions +# * lowest-version - The path to the lowest versioned duplicate is highlighted +# * simplest-path - The path to the version with the fewest edges is highlighted +# * all - Both lowest-version and simplest-path are used +highlight = "all" +# The default lint level for `default` features for crates that are members of +# the workspace that is being checked. This can be overridden by allowing/denying +# `default` on a crate-by-crate basis if desired. +workspace-default-features = "allow" +# The default lint level for `default` features for external crates that are not +# members of the workspace. This can be overridden by allowing/denying `default` +# on a crate-by-crate basis if desired. +external-default-features = "allow" +# List of crates that are allowed. Use with care! +allow = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, +] +# List of crates to deny +deny = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, + # Wrapper crates can optionally be specified to allow the crate when it + # is a direct dependency of the otherwise banned crate + #{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, +] + +# List of features to allow/deny +# Each entry the name of a crate and a version range. If version is +# not specified, all versions will be matched. +#[[bans.features]] +#crate = "reqwest" +# Features to not allow +#deny = ["json"] +# Features to allow +#allow = [ +# "rustls", +# "__rustls", +# "__tls", +# "hyper-rustls", +# "rustls", +# "rustls-pemfile", +# "rustls-tls-webpki-roots", +# "tokio-rustls", +# "webpki-roots", +#] +# If true, the allowed features must exactly match the enabled feature set. If +# this is set there is no point setting `deny` +#exact = true + +skip = [ + #"ansi_term@0.11.0", + #{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, +] # Certain crates/versions that will be skipped when doing duplicate detection. +# Similarly to `skip` allows you to skip certain crates during duplicate +# detection. Unlike skip, it also includes the entire tree of transitive +# dependencies starting at the specified crate, up to a certain depth, which is +# by default infinite. +skip-tree = [ + #"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies + #{ crate = "ansi_term@0.11.0", depth = 20 }, +] + +# This section is considered when running `cargo deny check sources`. +# More documentation about the 'sources' section can be found here: +# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html +[sources] +# Lint level for what to happen when a crate from a crate registry that is not +# in the allow list is encountered +unknown-registry = "warn" +# Lint level for what to happen when a crate from a git repository that is not +# in the allow list is encountered +unknown-git = "warn" +# List of URLs for allowed crate registries. Defaults to the crates.io index +# if not specified. If it is specified but empty, no registries are allowed. +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +# List of URLs for allowed Git repositories +allow-git = [] + +[sources.allow-org] +# github.com organizations to allow git sources for +github = [] +# gitlab.com organizations to allow git sources for +gitlab = [] +# bitbucket.org organizations to allow git sources for +bitbucket = [] diff --git a/bootloader-tool/src/commands/download.rs b/bootloader-tool/src/commands/download.rs index ea6d6dc..d73ee82 100644 --- a/bootloader-tool/src/commands/download.rs +++ b/bootloader-tool/src/commands/download.rs @@ -1,13 +1,15 @@ +use std::path::Path; + +use DownloadCommands::Other; +use anyhow::Context; +use probe_rs::flashing::ElfOptions; +use probe_rs::{Session, flashing}; + use crate::commands::sign::SignOutput; use crate::config::Config; use crate::processors::certificates::Rkth; use crate::processors::probe; use crate::{DownloadCommands, ProbeArgs, RunCommands, SignCommands}; -use DownloadCommands::Other; -use anyhow::Context; -use probe_rs::flashing::ElfOptions; -use probe_rs::{Session, flashing}; -use std::path::Path; pub async fn process(config: &Config, command: DownloadCommands) -> anyhow::Result<()> { match command { diff --git a/bootloader-tool/src/commands/generate.rs b/bootloader-tool/src/commands/generate.rs index 8ba400c..f1699dc 100644 --- a/bootloader-tool/src/commands/generate.rs +++ b/bootloader-tool/src/commands/generate.rs @@ -1,4 +1,5 @@ -use crate::{GenerateCommands, config::Config, processors}; +use crate::config::Config; +use crate::{GenerateCommands, processors}; pub async fn process(config: &Config, command: GenerateCommands) -> anyhow::Result<()> { match command { diff --git a/bootloader-tool/src/commands/mod.rs b/bootloader-tool/src/commands/mod.rs index 5adb3ba..316c1bf 100644 --- a/bootloader-tool/src/commands/mod.rs +++ b/bootloader-tool/src/commands/mod.rs @@ -3,7 +3,8 @@ mod generate; mod run; mod sign; -use crate::{Commands, config::Config}; +use crate::Commands; +use crate::config::Config; pub async fn process(config: &Config, command: Commands) -> anyhow::Result<()> { match command { diff --git a/bootloader-tool/src/commands/run.rs b/bootloader-tool/src/commands/run.rs index d821012..588d764 100644 --- a/bootloader-tool/src/commands/run.rs +++ b/bootloader-tool/src/commands/run.rs @@ -1,6 +1,9 @@ use probe_rs::MemoryInterface; -use crate::{RunCommands, commands::download::DownloadOutput, config::Config, processors::otp}; +use crate::RunCommands; +use crate::commands::download::DownloadOutput; +use crate::config::Config; +use crate::processors::otp; pub async fn process(config: &Config, command: RunCommands) -> anyhow::Result<()> { let otp = otp::get_otp(config)?; diff --git a/bootloader-tool/src/commands/sign.rs b/bootloader-tool/src/commands/sign.rs index 238b2ff..a2d2aab 100644 --- a/bootloader-tool/src/commands/sign.rs +++ b/bootloader-tool/src/commands/sign.rs @@ -1,12 +1,14 @@ +use std::path::PathBuf; + +use anyhow::Context; +use object::read::elf::ElfFile32; + use crate::SignCommands; use crate::config::Config; use crate::processors::certificates::Rkth; use crate::processors::mbi::cert_block; use crate::processors::otp::get_otp; use crate::processors::{mbi, objcopy}; -use anyhow::Context; -use object::read::elf::ElfFile32; -use std::path::PathBuf; pub struct SignOutput { pub output_path: Option, diff --git a/bootloader-tool/src/config.rs b/bootloader-tool/src/config.rs index 27be7b9..dc5a14d 100644 --- a/bootloader-tool/src/config.rs +++ b/bootloader-tool/src/config.rs @@ -1,8 +1,9 @@ #![allow(unused)] -use serde::Deserialize; use std::path::{Path, PathBuf}; +use serde::Deserialize; + #[derive(Deserialize, Debug)] pub struct Config { /// Path of the directory where artifacts are put and can be found. diff --git a/bootloader-tool/src/lib.rs b/bootloader-tool/src/lib.rs index 5e1b10e..655916a 100644 --- a/bootloader-tool/src/lib.rs +++ b/bootloader-tool/src/lib.rs @@ -1,7 +1,9 @@ -pub use crate::config::Config; -use clap::{Args, Parser, Subcommand}; use std::path::PathBuf; +use clap::{Args, Parser, Subcommand}; + +pub use crate::config::Config; + pub mod commands; mod config; pub mod processors; diff --git a/bootloader-tool/src/main.rs b/bootloader-tool/src/main.rs index ae0b5ca..e87cc95 100644 --- a/bootloader-tool/src/main.rs +++ b/bootloader-tool/src/main.rs @@ -11,8 +11,8 @@ async fn main() -> anyhow::Result<()> { let cli = Cli::parse(); - let config = Config::read(&cli.config) - .with_context(|| format!("Tried to open --config {}", cli.config.display()))?; + let config = + Config::read(&cli.config).with_context(|| format!("Tried to open --config {}", cli.config.display()))?; if let Some(command) = cli.commands { commands::process(&config, command).await diff --git a/bootloader-tool/src/processors/certificates.rs b/bootloader-tool/src/processors/certificates.rs index 56a63f0..af68e78 100644 --- a/bootloader-tool/src/processors/certificates.rs +++ b/bootloader-tool/src/processors/certificates.rs @@ -1,16 +1,12 @@ -use std::{ - path::{Path, PathBuf}, - process::{Command, Stdio}, -}; +use std::path::{Path, PathBuf}; +use std::process::{Command, Stdio}; use anyhow::Context; use serde::Serialize; -use crate::{ - GenerateCertificatesArguments, - config::{Certificate, CertificatePrototype, Config}, - util::{bytes_to_u32_le, generate_hex, parse_hex}, -}; +use crate::GenerateCertificatesArguments; +use crate::config::{Certificate, CertificatePrototype, Config}; +use crate::util::{bytes_to_u32_le, generate_hex, parse_hex}; #[derive(Serialize)] struct BasicConstraints { @@ -98,7 +94,7 @@ fn generate_certificate( }; let mut input_file = tempfile::NamedTempFile::new()?; - serde_yml::to_writer(&mut input_file, &input)?; + serde_json::to_writer(&mut input_file, &input)?; let output_path = &certificate.path; if std::fs::exists(output_path)? { diff --git a/bootloader-tool/src/processors/mbi/cert_block.rs b/bootloader-tool/src/processors/mbi/cert_block.rs index 935de09..b08792c 100644 --- a/bootloader-tool/src/processors/mbi/cert_block.rs +++ b/bootloader-tool/src/processors/mbi/cert_block.rs @@ -1,19 +1,19 @@ -use std::{ - collections::BTreeMap, - path::{Path, PathBuf}, - process::{Command, Stdio}, -}; +use std::collections::BTreeMap; +use std::path::{Path, PathBuf}; +use std::process::{Command, Stdio}; use anyhow::Context; -use rsa::{RsaPublicKey, pkcs1v15::VerifyingKey, pkcs8::DecodePublicKey, traits::PublicKeyParts}; +use rsa::RsaPublicKey; +use rsa::pkcs1v15::VerifyingKey; +use rsa::pkcs8::DecodePublicKey; +use rsa::traits::PublicKeyParts; use serde::Serialize; use sha2::{Digest, Sha256}; use x509_parser::public_key::PublicKey; -use crate::{ - Config, - processors::{certificates::Rkth, mbi::parse_x509_cert}, -}; +use crate::Config; +use crate::processors::certificates::Rkth; +use crate::processors::mbi::parse_x509_cert; #[derive(Serialize)] #[serde(rename_all = "camelCase")] @@ -67,7 +67,7 @@ pub fn generate(nxpimage: impl AsRef, config: &Config, certificate_idx: us let mut input_file = tempfile::NamedTempFile::new()?; let output_file = tempfile::NamedTempFile::new()?; - serde_yml::to_writer( + serde_json::to_writer( &mut input_file, &generate_config(config, certificate_idx, Some(output_file.path())), )?; diff --git a/bootloader-tool/src/processors/mbi/mod.rs b/bootloader-tool/src/processors/mbi/mod.rs index 2b2cbed..a14a7d1 100644 --- a/bootloader-tool/src/processors/mbi/mod.rs +++ b/bootloader-tool/src/processors/mbi/mod.rs @@ -2,26 +2,26 @@ pub mod cert_block; -use sha2::Digest; use std::collections::BTreeMap; use std::path::Path; use std::process::{Command, Stdio}; -use tempfile::NamedTempFile; -use crate::processors::certificates::Rkth; -use crate::processors::mbi::cert_block::{CertBlock, CertBlockConfig}; -use crate::processors::otp::Otp; use anyhow::{Context, anyhow, bail}; use hmac::{Hmac, Mac}; use rsa::RsaPrivateKey; use rsa::pkcs1v15::{Signature, SigningKey}; use rsa::pkcs8::DecodePrivateKey; use rsa::signature::{SignatureEncoding, SignerMut, Verifier}; -use sha2::Sha256; +use sha2::{Digest, Sha256}; +use tempfile::NamedTempFile; use x509_parser::asn1_rs::FromDer; use x509_parser::certificate::X509Certificate; use x509_parser::oid_registry::Oid; +use crate::processors::certificates::Rkth; +use crate::processors::mbi::cert_block::{CertBlock, CertBlockConfig}; +use crate::processors::otp::Otp; + type HmacSha256 = Hmac; /// Image header, this is a vector table with some fields modified @@ -412,7 +412,7 @@ pub fn generate_nxp( let mut config: BTreeMap = BTreeMap::default(); let mut cert_block_file = NamedTempFile::new()?; - serde_yml::to_writer(&mut cert_block_file, &cert_block)?; + serde_json::to_writer(&mut cert_block_file, &cert_block)?; config.insert( "certBlock".to_owned(), diff --git a/bootloader-tool/src/processors/objcopy.rs b/bootloader-tool/src/processors/objcopy.rs index 0647133..11019e0 100644 --- a/bootloader-tool/src/processors/objcopy.rs +++ b/bootloader-tool/src/processors/objcopy.rs @@ -1,8 +1,9 @@ +use std::ops::Range; + use anyhow::Context; use object::elf::{SHT_NOBITS, SHT_PROGBITS}; use object::read::elf::{ElfFile32, ProgramHeader}; use object::{Object, ObjectSegment}; -use std::ops::Range; const PRELUDE_ADDRESS_RANGE: Range = 0x08000000..0x08001000; @@ -78,8 +79,7 @@ pub fn objcopy(file: &ElfFile32) -> anyhow::Result<(Vec, u32)> { for segment in segments { let paddr = segment.elf_program_header().p_paddr(file.endianness()); - image[paddr as usize - base_addr as usize - ..paddr as usize - base_addr as usize + segment.size() as usize] + image[paddr as usize - base_addr as usize..paddr as usize - base_addr as usize + segment.size() as usize] .copy_from_slice(segment.data().unwrap()); } diff --git a/bootloader-tool/src/processors/otp.rs b/bootloader-tool/src/processors/otp.rs index 5d895e4..cf5059d 100644 --- a/bootloader-tool/src/processors/otp.rs +++ b/bootloader-tool/src/processors/otp.rs @@ -1,13 +1,10 @@ -use aes::{ - Aes256, - cipher::{BlockEncrypt, KeyInit, generic_array::GenericArray}, -}; +use aes::Aes256; +use aes::cipher::generic_array::GenericArray; +use aes::cipher::{BlockEncrypt, KeyInit}; use anyhow::Context; -use crate::{ - config::Config, - util::{bytes_to_u32_be, generate_hex, parse_hex}, -}; +use crate::config::Config; +use crate::util::{bytes_to_u32_be, generate_hex, parse_hex}; #[derive(Clone)] pub struct Otp(pub [u8; 32]); @@ -24,9 +21,11 @@ impl Otp { } pub fn from_hex(str: &str) -> anyhow::Result { - Ok(Self(parse_hex(str)?.try_into().map_err(|_| { - anyhow::anyhow!("Input not appropriate size") - })?)) + Ok(Self( + parse_hex(str)? + .try_into() + .map_err(|_| anyhow::anyhow!("Input not appropriate size"))?, + )) } pub fn as_reversed_u32_be(&self) -> Vec { @@ -49,10 +48,7 @@ pub struct HmacKey(pub [u8; 16]); pub fn generate(config: &Config) -> anyhow::Result { if std::fs::exists(&config.otp_path)? { - log::warn!( - "OTP file {} already generated, skipping...", - &config.otp_path.display() - ); + log::warn!("OTP file {} already generated, skipping...", &config.otp_path.display()); return get_otp(config); } diff --git a/bootloader-tool/src/processors/probe.rs b/bootloader-tool/src/processors/probe.rs index 8450d62..ff566c4 100644 --- a/bootloader-tool/src/processors/probe.rs +++ b/bootloader-tool/src/processors/probe.rs @@ -1,15 +1,12 @@ -use probe_rs::{ - Permissions, Session, - probe::{DebugProbeSelector, list::Lister}, -}; +use probe_rs::probe::DebugProbeSelector; +use probe_rs::probe::list::Lister; +use probe_rs::{Permissions, Session}; pub async fn start_session(chip: &str, probe_selector: Option) -> anyhow::Result { let session = if let Some(ref probe) = probe_selector { - Lister::new() - .open(DebugProbeSelector::try_from(&**probe)?) - .await? + Lister::new().open(DebugProbeSelector::try_from(&**probe)?)? } else { - let probes = Lister::new().list_all().await; + let probes = Lister::new().list_all(); let probe = match probes.len() { 0 => return Err(anyhow::anyhow!("No probe found")), 1 => probes.first().unwrap(), diff --git a/bootloader-tool/tests/behavior_matches_nxpimage.rs b/bootloader-tool/tests/behavior_matches_nxpimage.rs index be9368f..40f40e1 100644 --- a/bootloader-tool/tests/behavior_matches_nxpimage.rs +++ b/bootloader-tool/tests/behavior_matches_nxpimage.rs @@ -1,12 +1,10 @@ use std::path::PathBuf; use anyhow::Context; -use bootloader_tool::processors::{ - mbi::{self, cert_block}, - objcopy, - otp::Otp, -}; use bootloader_tool::Config; +use bootloader_tool::processors::mbi::{self, cert_block}; +use bootloader_tool::processors::objcopy; +use bootloader_tool::processors::otp::Otp; use object::read::elf::ElfFile32; fn get_private_key(config: &Config, certificate_idx: usize) -> PathBuf { diff --git a/libs/ci.sh b/libs/ci.sh index 86b429d..b82fdb4 100755 --- a/libs/ci.sh +++ b/libs/ci.sh @@ -23,9 +23,11 @@ BUILD_EXTRA="" FEATURE_COMBINATIONS=( "mimxrt633s" "mimxrt633s,defmt" + "mimxrt633s,log" "mimxrt633s,non-secure" "mimxrt685s" "mimxrt685s,defmt" + "mimxrt685s,log" "mimxrt685s,non-secure" ) cargo batch \ diff --git a/libs/ec-slimloader-imxrt/Cargo.toml b/libs/ec-slimloader-imxrt/Cargo.toml index 0141fcd..95cbf76 100644 --- a/libs/ec-slimloader-imxrt/Cargo.toml +++ b/libs/ec-slimloader-imxrt/Cargo.toml @@ -46,7 +46,12 @@ defmt = [ "embassy-imxrt/defmt", "partition-manager/defmt", ] -log = ["defmt-or-log/log", "imxrt-rom/log"] +log = [ + "dep:log", + "defmt-or-log/log", + "imxrt-rom/log", + "ec-slimloader-state/log", +] default = [] @@ -64,6 +69,7 @@ mimxrt600-fcb = { version = "0.2.2", optional = true } defmt = { workspace = true, optional = true } defmt-or-log = { workspace = true } +log = { workspace = true, optional = true } embassy-embedded-hal = "0.5.0" diff --git a/libs/ec-slimloader-imxrt/src/lib.rs b/libs/ec-slimloader-imxrt/src/lib.rs index 7bb97f2..5e035fe 100644 --- a/libs/ec-slimloader-imxrt/src/lib.rs +++ b/libs/ec-slimloader-imxrt/src/lib.rs @@ -193,7 +193,7 @@ impl Board for Imxrt { return e; } - info!("Booting into application @ {:x}...", ram_ivt.target_ptr); + info!("Booting into application @ {:?}...", ram_ivt.target_ptr); // Boot to application, and we do not return from this function. unsafe { bootload::boot_application(ram_ivt.target_ptr) } diff --git a/libs/ec-slimloader-imxrt/src/verification.rs b/libs/ec-slimloader-imxrt/src/verification.rs index 71ee980..1a213f3 100644 --- a/libs/ec-slimloader-imxrt/src/verification.rs +++ b/libs/ec-slimloader-imxrt/src/verification.rs @@ -41,10 +41,6 @@ impl Rkh { } } -fn rkth(rkth: Rkth) -> [u8; 32] { - rkth.into() -} - impl CheckImage for Imxrt { fn check_image(&mut self, ram_ivt: &Ivt) -> Result<(), BootError> { // Compute RKTH from image. @@ -79,14 +75,14 @@ impl CheckImage for Imxrt { Rkh::to_rkth(&rkhs, self.hashcrypt.reborrow()) }; - info!("RKTH (image) {:x}", rkth(image_rkth)); + info!("RKTH (image) {:?}", image_rkth); let mut shadow = ShadowRegisters::new(); { - info!("Boot0 (shadow) {}", unwrap!(shadow.boot_cfg_0().read())); - info!("Boot1 (shadow) {}", unwrap!(shadow.boot_cfg_1().read())); - info!("RKTH (shadow) {:x}", rkth(unwrap!(shadow.rkth().read()))); + info!("Boot0 (shadow) {:?}", unwrap!(shadow.boot_cfg_0().read())); + info!("Boot1 (shadow) {:?}", unwrap!(shadow.boot_cfg_1().read())); + info!("RKTH (shadow) {:?}", unwrap!(shadow.rkth().read())); } // Reload shadow registers. @@ -94,9 +90,9 @@ impl CheckImage for Imxrt { let mut otp = Otp::init(SYSTEM_CORE_CLOCK_HZ); { let mut fuses = OtpFuses::readonly(&mut otp); - info!("Boot0 (fuse): {}", unwrap!(fuses.boot_cfg_0().read())); - info!("Boot1 (fuse): {}", unwrap!(fuses.boot_cfg_1().read())); - info!("RKTH (fuse): {:x}", rkth(unwrap!(fuses.rkth().read()))); + info!("Boot0 (fuse): {:?}", unwrap!(fuses.boot_cfg_0().read())); + info!("Boot1 (fuse): {:?}", unwrap!(fuses.boot_cfg_1().read())); + info!("RKTH (fuse): {:?}", unwrap!(fuses.rkth().read())); } unwrap!(otp.reload_shadow()); info!("Shadow registers reloaded from fuses"); @@ -114,9 +110,9 @@ impl CheckImage for Imxrt { } { - info!("Boot0 (shadow reloaded) {}", unwrap!(shadow.boot_cfg_0().read())); - info!("Boot1 (shadow reloaded) {}", unwrap!(shadow.boot_cfg_1().read())); - info!("RKTH (shadow reloaded) {:x}", rkth(unwrap!(shadow.rkth().read()))); + info!("Boot0 (shadow reloaded) {:?}", unwrap!(shadow.boot_cfg_0().read())); + info!("Boot1 (shadow reloaded) {:?}", unwrap!(shadow.boot_cfg_1().read())); + info!("RKTH (shadow reloaded) {}", unwrap!(shadow.rkth().read())); } // Whether the hardware is in 'development mode' is dependent on the secure_boot_en bit being asserted. @@ -125,7 +121,7 @@ impl CheckImage for Imxrt { if image_rkth != unwrap!(shadow.rkth().read()) { if dev_mode { // If no SECURE_BOOT fuse set => overwrite shadow RKTH with image RKTH - warn!("Development mode detected, using new image RKTH {:x}", rkth(image_rkth)); + warn!("Development mode detected, using new image RKTH {}", image_rkth); unwrap!(shadow.rkth().write(|w| *w = image_rkth)); } else { // If SECURE_BOOT fuse set => do nothing as skboot_authenticate should be annoyed (perhaps assert afterwards) diff --git a/libs/ec-slimloader-state/Cargo.toml b/libs/ec-slimloader-state/Cargo.toml index 375ab9c..43629cb 100644 --- a/libs/ec-slimloader-state/Cargo.toml +++ b/libs/ec-slimloader-state/Cargo.toml @@ -11,9 +11,12 @@ num_enum = { version = "0.7.4", default-features = false } embedded-storage-async = { workspace = true } defmt = { workspace = true, optional = true } +defmt-or-log = { workspace = true } +log = { workspace = true, optional = true } [dev-dependencies] embassy-futures = "0.1.1" [features] -defmt = ["dep:defmt"] +defmt = ["dep:defmt", "defmt-or-log/defmt"] +log = ["dep:log", "defmt-or-log/log"] diff --git a/libs/ec-slimloader-state/src/flash.rs b/libs/ec-slimloader-state/src/flash.rs index c22c6d6..b1e987e 100644 --- a/libs/ec-slimloader-state/src/flash.rs +++ b/libs/ec-slimloader-state/src/flash.rs @@ -82,19 +82,27 @@ impl FlashJournal { /// Walk through the entire NVM range, and find the last valid [State] entry /// and find the first empty slot of a [State] entry, if any. - async fn compute_cache(inner: &mut T) -> Result { - let mut buf = [0u8; N]; - let block_count = inner.capacity().div_ceil(N); + /// + /// `BLOCK_SIZE` denotes the number of bytes that are read in a single batch + /// and are analysed, before reading the next block. + /// A larger block size generally improves performance, and needs to be a non-zero multiple of 2 bytes. + async fn compute_cache(inner: &mut T) -> Result { + const CHUNK_SIZE: usize = 2; + + defmt_or_log::assert!(BLOCK_SIZE >= CHUNK_SIZE); + defmt_or_log::assert!(BLOCK_SIZE.is_multiple_of(CHUNK_SIZE)); + + let mut buf = [0u8; BLOCK_SIZE]; + let block_count = inner.capacity().div_ceil(BLOCK_SIZE); let mut result = Cache::default(); for block_i in 0..block_count { - let block_start = block_i * N; - let block_end = (block_start + N).min(inner.capacity()); + let block_start = block_i * BLOCK_SIZE; + let block_end = (block_start + BLOCK_SIZE).min(inner.capacity()); let slice = &mut buf[0..block_end - block_start]; inner.read(block_start as u32, slice).await?; - const CHUNK_SIZE: usize = 2; for (chunk_i, chunk) in slice.chunks_exact(CHUNK_SIZE).enumerate() { // Note(unsafe): we are using chunks_exact and then cast the slice into the same size array. let chunk: [u8; CHUNK_SIZE] = unsafe { chunk.try_into().unwrap_unchecked() }; @@ -235,13 +243,13 @@ mod tests { #[test] fn journal_normal() { - let mut mock: MockFlashBase<3, 2, 8> = MockFlashBase::new(None, true); + let mut mock: MockFlashBase<3, 2, 8> = MockFlashBase::new(None, false); embassy_futures::block_on(test_journal(&mut mock, true)); } #[test] fn journal_garbage() { - let mut mock: MockFlashBase<3, 2, 8> = MockFlashBase::new(None, true); + let mut mock: MockFlashBase<3, 2, 8> = MockFlashBase::new(None, false); embassy_futures::block_on(async { // Write garbage to pages 1 and 2. let bytes = [0xaa; 32]; @@ -258,7 +266,7 @@ mod tests { #[test] fn journal_realistic() { // Use a realistic page count and size. - let mut mock: MockFlashBase<2, 2, 2048> = MockFlashBase::new(None, true); + let mut mock: MockFlashBase<2, 2, 2048> = MockFlashBase::new(None, false); embassy_futures::block_on(async { for status in [Status::Initial, Status::Attempting, Status::Confirmed, Status::Failed] { for i in 0b0..0b111u8 { diff --git a/libs/ec-slimloader-state/src/state.rs b/libs/ec-slimloader-state/src/state.rs index 34769b6..9f3c7c8 100644 --- a/libs/ec-slimloader-state/src/state.rs +++ b/libs/ec-slimloader-state/src/state.rs @@ -33,6 +33,12 @@ impl From for u8 { } } +impl core::fmt::Display for Slot { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + core::fmt::Debug::fmt(self, f) + } +} + #[derive(Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum ParseResult { diff --git a/libs/imxrt-rom/Cargo.toml b/libs/imxrt-rom/Cargo.toml index cb55e41..0670cd8 100644 --- a/libs/imxrt-rom/Cargo.toml +++ b/libs/imxrt-rom/Cargo.toml @@ -8,12 +8,8 @@ repository.workspace = true [features] rt = [] -log = ["defmt-or-log/log"] -defmt = [ - "dep:defmt", - "defmt-or-log/defmt", - "device-driver/defmt-03" -] +log = ["dep:log", "defmt-or-log/log"] +defmt = ["dep:defmt", "defmt-or-log/defmt", "device-driver/defmt-03"] mimxrt685s = ["embassy-imxrt/mimxrt685s"] mimxrt633s = ["embassy-imxrt/mimxrt633s"] @@ -21,13 +17,16 @@ mimxrt633s = ["embassy-imxrt/mimxrt633s"] [dependencies] defmt = { workspace = true, optional = true } defmt-or-log = { workspace = true } +log = { workspace = true, optional = true } cortex-m = { workspace = true } embassy-imxrt = { git = "https://github.com/OpenDevicePartnership/embassy-imxrt.git", default-features = false, features = [ "unstable-pac", ] } -device-driver = { version = "1.0", default-features = false, features = ["json"] } +device-driver = { version = "1.0", default-features = false, features = [ + "json", +] } [lints] workspace = true diff --git a/libs/imxrt-rom/src/registers.rs b/libs/imxrt-rom/src/registers.rs index 95fb8df..a4beefc 100644 --- a/libs/imxrt-rom/src/registers.rs +++ b/libs/imxrt-rom/src/registers.rs @@ -1,16 +1,15 @@ //! Registers that are available as OTP fuses and as shadow registers. #![allow(dead_code)] -mod device; - -use device_driver::RegisterInterface; +use device_driver::{FieldSet, RegisterInterface}; use crate::otp::Otp; -// Include the device driver definition. -// Can be regenerated by running `device-driver-cli -m registers.json -o src/registers/device.rs --device-name Device`. -// Will cause the GH workflow to SIGPIPE if included directly. -include!("registers/device.rs"); +// Define a Device for all OTP registers,that exist both as fuses accessible from the OTP ROM API as well as the shadow registers. +device_driver::create_device!( + device_name: Device, + manifest: "registers.json" +); /// Interface to access the shadow registers. pub struct ShadowInterface { @@ -242,6 +241,15 @@ impl core::ops::DerefMut for OtpFuses<'_> { } } +impl core::fmt::Display for field_sets::Rkth { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + for b in self.get_inner_buffer() { + f.write_fmt(format_args!("{:02x}", b))?; + } + Ok(()) + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/libs/imxrt-rom/src/registers/device.rs b/libs/imxrt-rom/src/registers/device.rs deleted file mode 100644 index 42e4f5b..0000000 --- a/libs/imxrt-rom/src/registers/device.rs +++ /dev/null @@ -1,1784 +0,0 @@ -/// Root block of the Device driver - -#[derive(Debug)] -pub struct Device { - pub(crate) interface: I, - - #[doc(hidden)] - base_address: u8, -} - -impl Device { - /// Create a new instance of the block based on device interface - pub const fn new(interface: I) -> Self { - Self { - interface, - base_address: 0, - } - } - - /// A reference to the interface used to communicate with the device - pub(crate) fn interface(&mut self) -> &mut I { - &mut self.interface - } - - /// Read all readable register values in this block from the device. - /// The callback is called for each of them. - /// Any registers in child blocks are not included. - /// - /// The callback has three arguments: - /// - /// - The address of the register - /// - The name of the register (with index for repeated registers) - /// - The read value from the register - /// - /// This is useful for e.g. debug printing all values. - /// The given [field_sets::FieldSetValue] has a Debug and Format implementation that forwards to the concrete type - /// the lies within so it can be printed without matching on it. - #[allow(unused_mut)] - #[allow(unused_variables)] - pub fn read_all_registers( - &mut self, - mut callback: impl FnMut(u32, &'static str, field_sets::FieldSetValue), - ) -> Result<(), I::Error> - where - I: ::device_driver::RegisterInterface, - { - let reg = self.boot_cfg_0().read()?; - - callback(96 + 0 * 0, "boot_cfg_0", reg.into()); - - let reg = self.boot_cfg_1().read()?; - - callback(97 + 0 * 0, "boot_cfg_1", reg.into()); - - let reg = self.sec_boot_cfg_5().read()?; - - callback(101 + 0 * 0, "sec_boot_cfg_5", reg.into()); - - let reg = self.rkth().read()?; - - callback(120 + 0 * 0, "rkth", reg.into()); - - Ok(()) - } - - /// Read all readable register values in this block from the device. - /// The callback is called for each of them. - /// Any registers in child blocks are not included. - /// - /// The callback has three arguments: - /// - /// - The address of the register - /// - The name of the register (with index for repeated registers) - /// - The read value from the register - /// - /// This is useful for e.g. debug printing all values. - /// The given [field_sets::FieldSetValue] has a Debug and Format implementation that forwards to the concrete type - /// the lies within so it can be printed without matching on it. - #[allow(unused_mut)] - #[allow(unused_variables)] - pub async fn read_all_registers_async( - &mut self, - mut callback: impl FnMut(u32, &'static str, field_sets::FieldSetValue), - ) -> Result<(), I::Error> - where - I: ::device_driver::AsyncRegisterInterface, - { - let reg = self.boot_cfg_0().read_async().await?; - - callback(96 + 0 * 0, "boot_cfg_0", reg.into()); - - let reg = self.boot_cfg_1().read_async().await?; - - callback(97 + 0 * 0, "boot_cfg_1", reg.into()); - - let reg = self.sec_boot_cfg_5().read_async().await?; - - callback(101 + 0 * 0, "sec_boot_cfg_5", reg.into()); - - let reg = self.rkth().read_async().await?; - - callback(120 + 0 * 0, "rkth", reg.into()); - - Ok(()) - } - - pub fn boot_cfg_0( - &mut self, - ) -> ::device_driver::RegisterOperation<'_, I, u32, field_sets::BootCfg0, ::device_driver::RW> { - let address = self.base_address + 96; - - ::device_driver::RegisterOperation::<'_, I, u32, field_sets::BootCfg0, ::device_driver::RW>::new( - self.interface(), - address as u32, - field_sets::BootCfg0::new, - ) - } - - pub fn boot_cfg_1( - &mut self, - ) -> ::device_driver::RegisterOperation<'_, I, u32, field_sets::BootCfg1, ::device_driver::RW> { - let address = self.base_address + 97; - - ::device_driver::RegisterOperation::<'_, I, u32, field_sets::BootCfg1, ::device_driver::RW>::new( - self.interface(), - address as u32, - field_sets::BootCfg1::new, - ) - } - - pub fn sec_boot_cfg_5( - &mut self, - ) -> ::device_driver::RegisterOperation<'_, I, u32, field_sets::SecBootCfg5, ::device_driver::RW> { - let address = self.base_address + 101; - - ::device_driver::RegisterOperation::<'_, I, u32, field_sets::SecBootCfg5, ::device_driver::RW>::new( - self.interface(), - address as u32, - field_sets::SecBootCfg5::new, - ) - } - - pub fn rkth(&mut self) -> ::device_driver::RegisterOperation<'_, I, u32, field_sets::Rkth, ::device_driver::RW> { - let address = self.base_address + 120; - - ::device_driver::RegisterOperation::<'_, I, u32, field_sets::Rkth, ::device_driver::RW>::new( - self.interface(), - address as u32, - field_sets::Rkth::new, - ) - } -} - -/// Module containing the generated fieldsets of the registers and commands -pub mod field_sets { - #[allow(unused_imports)] - use super::*; - - #[derive(Copy, Clone, Eq, PartialEq)] - pub struct BootCfg0 { - /// The internal bits - bits: [u8; 4], - } - - impl ::device_driver::FieldSet for BootCfg0 { - const SIZE_BITS: u32 = 32; - fn new_with_zero() -> Self { - Self::new_zero() - } - fn get_inner_buffer(&self) -> &[u8] { - &self.bits - } - fn get_inner_buffer_mut(&mut self) -> &mut [u8] { - &mut self.bits - } - } - - impl BootCfg0 { - /// Create a new instance, loaded with the reset value (if any) - pub const fn new() -> Self { - Self { bits: [0, 0, 0, 0] } - } - /// Create a new instance, loaded with all zeroes - pub const fn new_zero() -> Self { - Self { bits: [0; 4] } - } - - ///Read the `primary_boot_src` field of the register. - /// - - pub fn primary_boot_src(&self) -> Result>::Error> { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 0, 4) }; - - raw.try_into() - } - - ///Read the `default_isp_mode` field of the register. - /// - - pub fn default_isp_mode(&self) -> Result>::Error> { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 4, 7) }; - - raw.try_into() - } - - ///Read the `boot_clk_speed` field of the register. - /// - - pub fn boot_clk_speed(&self) -> super::BootClkSpeed { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 7, 8) }; - - unsafe { raw.try_into().unwrap_unchecked() } - } - - ///Read the `rsa_4_k_en` field of the register. - /// - /// Use 4096 bit RSA keys only for certificate validations. By default the ROM assume 2048-bit keys. - - pub fn rsa_4_k_en(&self) -> bool { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 8, 9) }; - - raw > 0 - } - - ///Read the `tzm_image_type` field of the register. - /// - - pub fn tzm_image_type(&self) -> super::TzmImageType { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 13, 15) }; - - unsafe { raw.try_into().unwrap_unchecked() } - } - - ///Read the `psa_bstate_skip` field of the register. - /// - /// If set, ROM skips computation of boot state defined by PSA specification. As part of boot state computation ROM includes OTP words - /// - Shadow register values of 95 to 104 - /// - Fuse values of words 128 to 147 - - pub fn psa_bstate_skip(&self) -> bool { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 15, 16) }; - - raw > 0 - } - - ///Read the `psa_bstate_inc_keys` field of the register. - /// - /// If set, boot state computation includes OTP shadow register values of words 106 to 127. - - pub fn psa_bstate_inc_keys(&self) -> bool { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 16, 17) }; - - raw > 0 - } - - ///Read the `redundant_spi_port` field of the register. - /// - - pub fn redundant_spi_port(&self) -> super::RedundantSpiPort { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 17, 20) }; - - unsafe { raw.try_into().unwrap_unchecked() } - } - - ///Read the `secure_boot_en` field of the register. - /// - - pub fn secure_boot_en(&self) -> super::SecureBoot { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 20, 22) }; - - unsafe { raw.try_into().unwrap_unchecked() } - } - - ///Read the `dice_inc_otp` field of the register. - /// - /// Include non-field updatable OTP Fields in DICE computation. OTP values in shadow registers are used in computation for words 95, 96, 98, 99, 104, 120 - 127. - - pub fn dice_inc_otp(&self) -> bool { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 22, 23) }; - - raw > 0 - } - - ///Read the `dice_skip` field of the register. - /// - /// If set, ROM skips computation of Composite Device Identifier (CDI) defined in DICE specification. But ROM will continue to hide UDS source in OTP and PUF (index 15) before passing control to user code. - - pub fn dice_skip(&self) -> bool { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 23, 24) }; - - raw > 0 - } - - ///Read the `boot_fail_pin_port` field of the register. - /// - /// GPIO port to use for indicating boot failure. Boot ROM will drive this pin high before locking the chip on error conditions. Applications can use this pin to power cycle the system. - - pub fn boot_fail_pin_port(&self) -> u8 { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 24, 27) }; - - raw - } - - ///Read the `boot_fail_pin_num` field of the register. - /// - /// GPIO pin number to use for indicating boot failure. Boot ROM will drive this pin high before locking the chip on error conditions. Applications can use this pin to power cycle the system. - - pub fn boot_fail_pin_num(&self) -> u8 { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 27, 32) }; - - raw - } - - ///Write the `primary_boot_src` field of the register. - /// - - pub fn set_primary_boot_src(&mut self, value: super::BootSrc) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 0, 4, &mut self.bits) }; - } - - ///Write the `default_isp_mode` field of the register. - /// - - pub fn set_default_isp_mode(&mut self, value: super::DefaultIspMode) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 4, 7, &mut self.bits) }; - } - - ///Write the `boot_clk_speed` field of the register. - /// - - pub fn set_boot_clk_speed(&mut self, value: super::BootClkSpeed) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 7, 8, &mut self.bits) }; - } - - ///Write the `rsa_4_k_en` field of the register. - /// - /// Use 4096 bit RSA keys only for certificate validations. By default the ROM assume 2048-bit keys. - - pub fn set_rsa_4_k_en(&mut self, value: bool) { - let raw = value as _; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 8, 9, &mut self.bits) }; - } - - ///Write the `tzm_image_type` field of the register. - /// - - pub fn set_tzm_image_type(&mut self, value: super::TzmImageType) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 13, 15, &mut self.bits) }; - } - - ///Write the `psa_bstate_skip` field of the register. - /// - /// If set, ROM skips computation of boot state defined by PSA specification. As part of boot state computation ROM includes OTP words - /// - Shadow register values of 95 to 104 - /// - Fuse values of words 128 to 147 - - pub fn set_psa_bstate_skip(&mut self, value: bool) { - let raw = value as _; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 15, 16, &mut self.bits) }; - } - - ///Write the `psa_bstate_inc_keys` field of the register. - /// - /// If set, boot state computation includes OTP shadow register values of words 106 to 127. - - pub fn set_psa_bstate_inc_keys(&mut self, value: bool) { - let raw = value as _; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 16, 17, &mut self.bits) }; - } - - ///Write the `redundant_spi_port` field of the register. - /// - - pub fn set_redundant_spi_port(&mut self, value: super::RedundantSpiPort) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 17, 20, &mut self.bits) }; - } - - ///Write the `secure_boot_en` field of the register. - /// - - pub fn set_secure_boot_en(&mut self, value: super::SecureBoot) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 20, 22, &mut self.bits) }; - } - - ///Write the `dice_inc_otp` field of the register. - /// - /// Include non-field updatable OTP Fields in DICE computation. OTP values in shadow registers are used in computation for words 95, 96, 98, 99, 104, 120 - 127. - - pub fn set_dice_inc_otp(&mut self, value: bool) { - let raw = value as _; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 22, 23, &mut self.bits) }; - } - - ///Write the `dice_skip` field of the register. - /// - /// If set, ROM skips computation of Composite Device Identifier (CDI) defined in DICE specification. But ROM will continue to hide UDS source in OTP and PUF (index 15) before passing control to user code. - - pub fn set_dice_skip(&mut self, value: bool) { - let raw = value as _; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 23, 24, &mut self.bits) }; - } - - ///Write the `boot_fail_pin_port` field of the register. - /// - /// GPIO port to use for indicating boot failure. Boot ROM will drive this pin high before locking the chip on error conditions. Applications can use this pin to power cycle the system. - - pub fn set_boot_fail_pin_port(&mut self, value: u8) { - let raw = value; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 24, 27, &mut self.bits) }; - } - - ///Write the `boot_fail_pin_num` field of the register. - /// - /// GPIO pin number to use for indicating boot failure. Boot ROM will drive this pin high before locking the chip on error conditions. Applications can use this pin to power cycle the system. - - pub fn set_boot_fail_pin_num(&mut self, value: u8) { - let raw = value; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 27, 32, &mut self.bits) }; - } - } - - impl From<[u8; 4]> for BootCfg0 { - fn from(bits: [u8; 4]) -> Self { - Self { bits } - } - } - - impl From for [u8; 4] { - fn from(val: BootCfg0) -> Self { - val.bits - } - } - - impl core::fmt::Debug for BootCfg0 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { - let mut d = f.debug_struct("BootCfg0"); - - d.field("primary_boot_src", &self.primary_boot_src()); - - d.field("default_isp_mode", &self.default_isp_mode()); - - d.field("boot_clk_speed", &self.boot_clk_speed()); - - d.field("rsa_4_k_en", &self.rsa_4_k_en()); - - d.field("tzm_image_type", &self.tzm_image_type()); - - d.field("psa_bstate_skip", &self.psa_bstate_skip()); - - d.field("psa_bstate_inc_keys", &self.psa_bstate_inc_keys()); - - d.field("redundant_spi_port", &self.redundant_spi_port()); - - d.field("secure_boot_en", &self.secure_boot_en()); - - d.field("dice_inc_otp", &self.dice_inc_otp()); - - d.field("dice_skip", &self.dice_skip()); - - d.field("boot_fail_pin_port", &self.boot_fail_pin_port()); - - d.field("boot_fail_pin_num", &self.boot_fail_pin_num()); - - d.finish() - } - } - - #[cfg(feature = "defmt")] - impl defmt::Format for BootCfg0 { - fn format(&self, f: defmt::Formatter) { - defmt::write!(f, "BootCfg0 {{ "); - - defmt::write!(f, "primary_boot_src: {}, ", &self.primary_boot_src()); - - defmt::write!(f, "default_isp_mode: {}, ", &self.default_isp_mode()); - - defmt::write!(f, "boot_clk_speed: {}, ", &self.boot_clk_speed()); - - defmt::write!(f, "rsa_4_k_en: {=bool}, ", &self.rsa_4_k_en()); - - defmt::write!(f, "tzm_image_type: {}, ", &self.tzm_image_type()); - - defmt::write!(f, "psa_bstate_skip: {=bool}, ", &self.psa_bstate_skip()); - - defmt::write!(f, "psa_bstate_inc_keys: {=bool}, ", &self.psa_bstate_inc_keys()); - - defmt::write!(f, "redundant_spi_port: {}, ", &self.redundant_spi_port()); - - defmt::write!(f, "secure_boot_en: {}, ", &self.secure_boot_en()); - - defmt::write!(f, "dice_inc_otp: {=bool}, ", &self.dice_inc_otp()); - - defmt::write!(f, "dice_skip: {=bool}, ", &self.dice_skip()); - - defmt::write!(f, "boot_fail_pin_port: {=u8}, ", &self.boot_fail_pin_port()); - - defmt::write!(f, "boot_fail_pin_num: {=u8}, ", &self.boot_fail_pin_num()); - - defmt::write!(f, "}}"); - } - } - - impl core::ops::BitAnd for BootCfg0 { - type Output = Self; - fn bitand(mut self, rhs: Self) -> Self::Output { - self &= rhs; - self - } - } - - impl core::ops::BitAndAssign for BootCfg0 { - fn bitand_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l &= *r; - } - } - } - - impl core::ops::BitOr for BootCfg0 { - type Output = Self; - fn bitor(mut self, rhs: Self) -> Self::Output { - self |= rhs; - self - } - } - - impl core::ops::BitOrAssign for BootCfg0 { - fn bitor_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l |= *r; - } - } - } - - impl core::ops::BitXor for BootCfg0 { - type Output = Self; - fn bitxor(mut self, rhs: Self) -> Self::Output { - self ^= rhs; - self - } - } - - impl core::ops::BitXorAssign for BootCfg0 { - fn bitxor_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l ^= *r; - } - } - } - - impl core::ops::Not for BootCfg0 { - type Output = Self; - fn not(mut self) -> Self::Output { - for val in self.bits.iter_mut() { - *val = !*val; - } - self - } - } - - #[derive(Copy, Clone, Eq, PartialEq)] - pub struct BootCfg1 { - /// The internal bits - bits: [u8; 4], - } - - impl ::device_driver::FieldSet for BootCfg1 { - const SIZE_BITS: u32 = 32; - fn new_with_zero() -> Self { - Self::new_zero() - } - fn get_inner_buffer(&self) -> &[u8] { - &self.bits - } - fn get_inner_buffer_mut(&mut self) -> &mut [u8] { - &mut self.bits - } - } - - impl BootCfg1 { - /// Create a new instance, loaded with the reset value (if any) - pub const fn new() -> Self { - Self { bits: [0, 0, 0, 0] } - } - /// Create a new instance, loaded with all zeroes - pub const fn new_zero() -> Self { - Self { bits: [0; 4] } - } - - ///Read the `qspi_reset_pin_enable` field of the register. - /// - /// Use QSPI_RESET_PIN to reset the flash device. - - pub fn qspi_reset_pin_enable(&self) -> bool { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 14, 15) }; - - raw > 0 - } - - ///Read the `qspi_reset_pin_port` field of the register. - /// - /// GPIO port to use for O/QSPI reset function. - - pub fn qspi_reset_pin_port(&self) -> u8 { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 15, 18) }; - - raw - } - - ///Read the `qspi_reset_pin_num` field of the register. - /// - /// GPIO pin number to use for O/QSPI reset function. - - pub fn qspi_reset_pin_num(&self) -> u8 { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 18, 23) }; - - raw - } - - ///Write the `qspi_reset_pin_enable` field of the register. - /// - /// Use QSPI_RESET_PIN to reset the flash device. - - pub fn set_qspi_reset_pin_enable(&mut self, value: bool) { - let raw = value as _; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 14, 15, &mut self.bits) }; - } - - ///Write the `qspi_reset_pin_port` field of the register. - /// - /// GPIO port to use for O/QSPI reset function. - - pub fn set_qspi_reset_pin_port(&mut self, value: u8) { - let raw = value; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 15, 18, &mut self.bits) }; - } - - ///Write the `qspi_reset_pin_num` field of the register. - /// - /// GPIO pin number to use for O/QSPI reset function. - - pub fn set_qspi_reset_pin_num(&mut self, value: u8) { - let raw = value; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 18, 23, &mut self.bits) }; - } - } - - impl From<[u8; 4]> for BootCfg1 { - fn from(bits: [u8; 4]) -> Self { - Self { bits } - } - } - - impl From for [u8; 4] { - fn from(val: BootCfg1) -> Self { - val.bits - } - } - - impl core::fmt::Debug for BootCfg1 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { - let mut d = f.debug_struct("BootCfg1"); - - d.field("qspi_reset_pin_enable", &self.qspi_reset_pin_enable()); - - d.field("qspi_reset_pin_port", &self.qspi_reset_pin_port()); - - d.field("qspi_reset_pin_num", &self.qspi_reset_pin_num()); - - d.finish() - } - } - - #[cfg(feature = "defmt")] - impl defmt::Format for BootCfg1 { - fn format(&self, f: defmt::Formatter) { - defmt::write!(f, "BootCfg1 {{ "); - - defmt::write!(f, "qspi_reset_pin_enable: {=bool}, ", &self.qspi_reset_pin_enable()); - - defmt::write!(f, "qspi_reset_pin_port: {=u8}, ", &self.qspi_reset_pin_port()); - - defmt::write!(f, "qspi_reset_pin_num: {=u8}, ", &self.qspi_reset_pin_num()); - - defmt::write!(f, "}}"); - } - } - - impl core::ops::BitAnd for BootCfg1 { - type Output = Self; - fn bitand(mut self, rhs: Self) -> Self::Output { - self &= rhs; - self - } - } - - impl core::ops::BitAndAssign for BootCfg1 { - fn bitand_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l &= *r; - } - } - } - - impl core::ops::BitOr for BootCfg1 { - type Output = Self; - fn bitor(mut self, rhs: Self) -> Self::Output { - self |= rhs; - self - } - } - - impl core::ops::BitOrAssign for BootCfg1 { - fn bitor_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l |= *r; - } - } - } - - impl core::ops::BitXor for BootCfg1 { - type Output = Self; - fn bitxor(mut self, rhs: Self) -> Self::Output { - self ^= rhs; - self - } - } - - impl core::ops::BitXorAssign for BootCfg1 { - fn bitxor_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l ^= *r; - } - } - } - - impl core::ops::Not for BootCfg1 { - type Output = Self; - fn not(mut self) -> Self::Output { - for val in self.bits.iter_mut() { - *val = !*val; - } - self - } - } - - #[derive(Copy, Clone, Eq, PartialEq)] - pub struct SecBootCfg5 { - /// The internal bits - bits: [u8; 2], - } - - impl ::device_driver::FieldSet for SecBootCfg5 { - const SIZE_BITS: u32 = 16; - fn new_with_zero() -> Self { - Self::new_zero() - } - fn get_inner_buffer(&self) -> &[u8] { - &self.bits - } - fn get_inner_buffer_mut(&mut self) -> &mut [u8] { - &mut self.bits - } - } - - impl SecBootCfg5 { - /// Create a new instance, loaded with the reset value (if any) - pub const fn new() -> Self { - Self { bits: [0, 0] } - } - /// Create a new instance, loaded with all zeroes - pub const fn new_zero() -> Self { - Self { bits: [0; 2] } - } - - ///Read the `revoke_rootkey` field of the register. - /// - /// Revoke upto 4 root keys. When a bit is set corresponding root key is revoked. - - pub fn revoke_rootkey(&self) -> u8 { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 0, 4) }; - - raw - } - - ///Read the `fa_mode_en` field of the register. - /// - /// Enable Fault Analysis mode. - /// - When set ROM checks and erases customer sensitive assets (AES keys or key codes) stored in IFR/OTP. - /// - Issues zeroized command to PUF (disables key decoding until POR). - /// - Blocks all HW routed OTP keys and set lock bits on those registers. - /// - Enables all debug ports and waits in loop for tester. - - pub fn fa_mode_en(&self) -> bool { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 4, 5) }; - - raw > 0 - } - - ///Read the `enable_crc_check` field of the register. - /// - /// Enable CRC checking of OTP words. - - pub fn enable_crc_check(&self) -> super::CrcCheck { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 5, 7) }; - - unsafe { raw.try_into().unwrap_unchecked() } - } - - ///Read the `use_puf` field of the register. - /// - /// Use PUF to store AES keys and UDS. - - pub fn use_puf(&self) -> super::KeyIn { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 7, 8) }; - - unsafe { raw.try_into().unwrap_unchecked() } - } - - ///Read the `puf_block_enroll` field of the register. - /// - /// Block further enrollement of PUF block. When this bit is set ROM blocks generation of new activation codes. - - pub fn puf_block_enroll(&self) -> super::Enroll { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 8, 9) }; - - unsafe { raw.try_into().unwrap_unchecked() } - } - - ///Read the `puf_block_set_key` field of the register. - /// - /// Block further enrollement of PUF block. When this bit is set ROM blocks generation of new key codes. - - pub fn puf_block_set_key(&self) -> super::KeyGen { - let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 9, 10) }; - - unsafe { raw.try_into().unwrap_unchecked() } - } - - ///Write the `revoke_rootkey` field of the register. - /// - /// Revoke upto 4 root keys. When a bit is set corresponding root key is revoked. - - pub fn set_revoke_rootkey(&mut self, value: u8) { - let raw = value; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 0, 4, &mut self.bits) }; - } - - ///Write the `fa_mode_en` field of the register. - /// - /// Enable Fault Analysis mode. - /// - When set ROM checks and erases customer sensitive assets (AES keys or key codes) stored in IFR/OTP. - /// - Issues zeroized command to PUF (disables key decoding until POR). - /// - Blocks all HW routed OTP keys and set lock bits on those registers. - /// - Enables all debug ports and waits in loop for tester. - - pub fn set_fa_mode_en(&mut self, value: bool) { - let raw = value as _; - - unsafe { ::device_driver::ops::store_lsb0::(raw, 4, 5, &mut self.bits) }; - } - - ///Write the `enable_crc_check` field of the register. - /// - /// Enable CRC checking of OTP words. - - pub fn set_enable_crc_check(&mut self, value: super::CrcCheck) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 5, 7, &mut self.bits) }; - } - - ///Write the `use_puf` field of the register. - /// - /// Use PUF to store AES keys and UDS. - - pub fn set_use_puf(&mut self, value: super::KeyIn) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 7, 8, &mut self.bits) }; - } - - ///Write the `puf_block_enroll` field of the register. - /// - /// Block further enrollement of PUF block. When this bit is set ROM blocks generation of new activation codes. - - pub fn set_puf_block_enroll(&mut self, value: super::Enroll) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 8, 9, &mut self.bits) }; - } - - ///Write the `puf_block_set_key` field of the register. - /// - /// Block further enrollement of PUF block. When this bit is set ROM blocks generation of new key codes. - - pub fn set_puf_block_set_key(&mut self, value: super::KeyGen) { - let raw = value.into(); - - unsafe { ::device_driver::ops::store_lsb0::(raw, 9, 10, &mut self.bits) }; - } - } - - impl From<[u8; 2]> for SecBootCfg5 { - fn from(bits: [u8; 2]) -> Self { - Self { bits } - } - } - - impl From for [u8; 2] { - fn from(val: SecBootCfg5) -> Self { - val.bits - } - } - - impl core::fmt::Debug for SecBootCfg5 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { - let mut d = f.debug_struct("SecBootCfg5"); - - d.field("revoke_rootkey", &self.revoke_rootkey()); - - d.field("fa_mode_en", &self.fa_mode_en()); - - d.field("enable_crc_check", &self.enable_crc_check()); - - d.field("use_puf", &self.use_puf()); - - d.field("puf_block_enroll", &self.puf_block_enroll()); - - d.field("puf_block_set_key", &self.puf_block_set_key()); - - d.finish() - } - } - - #[cfg(feature = "defmt")] - impl defmt::Format for SecBootCfg5 { - fn format(&self, f: defmt::Formatter) { - defmt::write!(f, "SecBootCfg5 {{ "); - - defmt::write!(f, "revoke_rootkey: {=u8}, ", &self.revoke_rootkey()); - - defmt::write!(f, "fa_mode_en: {=bool}, ", &self.fa_mode_en()); - - defmt::write!(f, "enable_crc_check: {}, ", &self.enable_crc_check()); - - defmt::write!(f, "use_puf: {}, ", &self.use_puf()); - - defmt::write!(f, "puf_block_enroll: {}, ", &self.puf_block_enroll()); - - defmt::write!(f, "puf_block_set_key: {}, ", &self.puf_block_set_key()); - - defmt::write!(f, "}}"); - } - } - - impl core::ops::BitAnd for SecBootCfg5 { - type Output = Self; - fn bitand(mut self, rhs: Self) -> Self::Output { - self &= rhs; - self - } - } - - impl core::ops::BitAndAssign for SecBootCfg5 { - fn bitand_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l &= *r; - } - } - } - - impl core::ops::BitOr for SecBootCfg5 { - type Output = Self; - fn bitor(mut self, rhs: Self) -> Self::Output { - self |= rhs; - self - } - } - - impl core::ops::BitOrAssign for SecBootCfg5 { - fn bitor_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l |= *r; - } - } - } - - impl core::ops::BitXor for SecBootCfg5 { - type Output = Self; - fn bitxor(mut self, rhs: Self) -> Self::Output { - self ^= rhs; - self - } - } - - impl core::ops::BitXorAssign for SecBootCfg5 { - fn bitxor_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l ^= *r; - } - } - } - - impl core::ops::Not for SecBootCfg5 { - type Output = Self; - fn not(mut self) -> Self::Output { - for val in self.bits.iter_mut() { - *val = !*val; - } - self - } - } - - #[derive(Copy, Clone, Eq, PartialEq)] - pub struct Rkth { - /// The internal bits - bits: [u8; 32], - } - - impl ::device_driver::FieldSet for Rkth { - const SIZE_BITS: u32 = 256; - fn new_with_zero() -> Self { - Self::new_zero() - } - fn get_inner_buffer(&self) -> &[u8] { - &self.bits - } - fn get_inner_buffer_mut(&mut self) -> &mut [u8] { - &mut self.bits - } - } - - impl Rkth { - /// Create a new instance, loaded with the reset value (if any) - pub const fn new() -> Self { - Self { - bits: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - } - } - /// Create a new instance, loaded with all zeroes - pub const fn new_zero() -> Self { - Self { bits: [0; 32] } - } - } - - impl From<[u8; 32]> for Rkth { - fn from(bits: [u8; 32]) -> Self { - Self { bits } - } - } - - impl From for [u8; 32] { - fn from(val: Rkth) -> Self { - val.bits - } - } - - impl core::fmt::Debug for Rkth { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { - let mut d = f.debug_struct("Rkth"); - - d.finish() - } - } - - #[cfg(feature = "defmt")] - impl defmt::Format for Rkth { - fn format(&self, f: defmt::Formatter) { - defmt::write!(f, "Rkth {{ "); - - defmt::write!(f, "}}"); - } - } - - impl core::ops::BitAnd for Rkth { - type Output = Self; - fn bitand(mut self, rhs: Self) -> Self::Output { - self &= rhs; - self - } - } - - impl core::ops::BitAndAssign for Rkth { - fn bitand_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l &= *r; - } - } - } - - impl core::ops::BitOr for Rkth { - type Output = Self; - fn bitor(mut self, rhs: Self) -> Self::Output { - self |= rhs; - self - } - } - - impl core::ops::BitOrAssign for Rkth { - fn bitor_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l |= *r; - } - } - } - - impl core::ops::BitXor for Rkth { - type Output = Self; - fn bitxor(mut self, rhs: Self) -> Self::Output { - self ^= rhs; - self - } - } - - impl core::ops::BitXorAssign for Rkth { - fn bitxor_assign(&mut self, rhs: Self) { - for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { - *l ^= *r; - } - } - } - - impl core::ops::Not for Rkth { - type Output = Self; - fn not(mut self) -> Self::Output { - for val in self.bits.iter_mut() { - *val = !*val; - } - self - } - } - - /// Enum containing all possible field set types - pub enum FieldSetValue { - BootCfg0(BootCfg0), - - BootCfg1(BootCfg1), - - SecBootCfg5(SecBootCfg5), - - Rkth(Rkth), - } - impl core::fmt::Debug for FieldSetValue { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Self::BootCfg0(val) => core::fmt::Debug::fmt(val, f), - - Self::BootCfg1(val) => core::fmt::Debug::fmt(val, f), - - Self::SecBootCfg5(val) => core::fmt::Debug::fmt(val, f), - - Self::Rkth(val) => core::fmt::Debug::fmt(val, f), - - #[allow(unreachable_patterns)] - _ => unreachable!(), - } - } - } - - #[cfg(feature = "defmt")] - impl defmt::Format for FieldSetValue { - fn format(&self, f: defmt::Formatter) { - match self { - Self::BootCfg0(val) => defmt::Format::format(val, f), - - Self::BootCfg1(val) => defmt::Format::format(val, f), - - Self::SecBootCfg5(val) => defmt::Format::format(val, f), - - Self::Rkth(val) => defmt::Format::format(val, f), - } - } - } - - impl From for FieldSetValue { - fn from(val: BootCfg0) -> Self { - Self::BootCfg0(val) - } - } - - impl From for FieldSetValue { - fn from(val: BootCfg1) -> Self { - Self::BootCfg1(val) - } - } - - impl From for FieldSetValue { - fn from(val: SecBootCfg5) -> Self { - Self::SecBootCfg5(val) - } - } - - impl From for FieldSetValue { - fn from(val: Rkth) -> Self { - Self::Rkth(val) - } - } -} - -/// Primary boot Source. (a.k.a. Master boot source) - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum BootSrc { - /// ISP pins will determine boot source. - IspPinBoot = 0, - - /// Boot from Octal/Quad SPI flash device using FlexSpi channel A interface pins. - QpsiABoot = 1, - - /// Boot from eMMC device or SD card connected to SDHC0 port. - Sdhc0Boot = 2, - - /// Boot from eMMC device or SD card connected to SDHC0 port. - Sdhc1Boot = 3, - - /// Boot using SPI slave interface using master boot mode. - SpiSlvBoot = 4, - - /// Boot from Octal/Quad SPI flash device using FlexSpi channel B interface pins. Only load-to-RAM image are supported in this mode. - QspiBBoot = 5, - - /// Boot using UART interface using master boot mode. - UartBoot = 6, - - /// Boot from 1-bit SPI flash device from FlexCom interface pins selected by REDUNDANT_SPI_PORT field. Only load-to-RAM images are supported in this mode. - SpiFcBoot = 7, - - /// Always enter ISP mode. DEFAULT_ISP_MODE field will determine the ISP interface. - IspMode = 9, - - /// Boot from Octal/Quad SPI flash device using FlexSPI channel B interface pins. If image is not found check recovery boot using SPI-flash device through FlexComm. - QspiBRecBoot = 11, - - /// Boot from Octal/Quad SPI flash device using FlexSPI channel A interface pins. If image is not found check recovery boot using SPI-flash device through FlexComm. - QspiARecBoot = 12, - - /// Boot from SDHC0 port device. If image is not found check recovery boot using SPI-flash device through FlexComm. - Sdhc0RecBoot = 13, - - /// Boot from SDHC1 port device. If image is not found check recovery boot using SPI-flash device through FlexComm. - Sdhc1RecBoot = 15, -} - -impl core::convert::TryFrom for BootSrc { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::IspPinBoot), - - 1 => Ok(Self::QpsiABoot), - - 2 => Ok(Self::Sdhc0Boot), - - 3 => Ok(Self::Sdhc1Boot), - - 4 => Ok(Self::SpiSlvBoot), - - 5 => Ok(Self::QspiBBoot), - - 6 => Ok(Self::UartBoot), - - 7 => Ok(Self::SpiFcBoot), - - 9 => Ok(Self::IspMode), - - 11 => Ok(Self::QspiBRecBoot), - - 12 => Ok(Self::QspiARecBoot), - - 13 => Ok(Self::Sdhc0RecBoot), - - 15 => Ok(Self::Sdhc1RecBoot), - - val => Err(::device_driver::ConversionError { - source: val, - target: "BootSrc", - }), - } - } -} - -impl From for u8 { - fn from(val: BootSrc) -> Self { - match val { - BootSrc::IspPinBoot => 0, - - BootSrc::QpsiABoot => 1, - - BootSrc::Sdhc0Boot => 2, - - BootSrc::Sdhc1Boot => 3, - - BootSrc::SpiSlvBoot => 4, - - BootSrc::QspiBBoot => 5, - - BootSrc::UartBoot => 6, - - BootSrc::SpiFcBoot => 7, - - BootSrc::IspMode => 9, - - BootSrc::QspiBRecBoot => 11, - - BootSrc::QspiARecBoot => 12, - - BootSrc::Sdhc0RecBoot => 13, - - BootSrc::Sdhc1RecBoot => 15, - } - } -} - -/// When a valid image is not available to master boot, ROM switches to ISP mode for programming primary boot devices. This field determines the default ISP mode. - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum DefaultIspMode { - /// Auto detect ISP mode. ROM monitors USB, UART, SPI and I2C interfaces for any activity. - AutoIsp = 0, - - /// Support ISP command interface using USB HID class only. - UsbHidIsp = 1, - - /// Support ISP command interface on UART port only. - UartIsp = 2, - - /// Support ISP command interface on SPI port only. - SpiIsp = 3, - - /// Support ISP command interface on I2C port only. - I2CIsp = 4, - - /// Disable ISP fall through when proper image is not found on primary boot device. - DisableIsp = 7, -} - -impl core::convert::TryFrom for DefaultIspMode { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::AutoIsp), - - 1 => Ok(Self::UsbHidIsp), - - 2 => Ok(Self::UartIsp), - - 3 => Ok(Self::SpiIsp), - - 4 => Ok(Self::I2CIsp), - - 7 => Ok(Self::DisableIsp), - - val => Err(::device_driver::ConversionError { - source: val, - target: "DefaultIspMode", - }), - } - } -} - -impl From for u8 { - fn from(val: DefaultIspMode) -> Self { - match val { - DefaultIspMode::AutoIsp => 0, - - DefaultIspMode::UsbHidIsp => 1, - - DefaultIspMode::UartIsp => 2, - - DefaultIspMode::SpiIsp => 3, - - DefaultIspMode::I2CIsp => 4, - - DefaultIspMode::DisableIsp => 7, - } - } -} - -/// Defines clock speeds during boot. - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum BootClkSpeed { - /// Normal boot. All clocks are set to 48MHz using IRC48M, except USB block. USB block will use external XTAL clock. - NormalClk = 0, - - /// High-speed boot. - /// * Core clock is set to 198MHz using main_pll with IRC48M as input - /// * UART, I2C : 48MHz (IRC48M) - /// * SPI, SDHC: 198MHz (main_pll) - /// * USB: external XTAL - /// * OSPI: Set to differnet speed using aux0_pll. Speed of OSPI interface is obtained from Boot Configuration Block present on OSPI-flash device. - /// - SDR: 30/50/60/72/80/90/100 MHz - /// - DDR: 30/50/60/72/80 MHz - HispeedClk = 1, -} - -impl core::convert::TryFrom for BootClkSpeed { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::NormalClk), - - 1 => Ok(Self::HispeedClk), - - val => Err(::device_driver::ConversionError { - source: val, - target: "BootClkSpeed", - }), - } - } -} - -impl From for u8 { - fn from(val: BootClkSpeed) -> Self { - match val { - BootClkSpeed::NormalClk => 0, - - BootClkSpeed::HispeedClk => 1, - } - } -} - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum TzmImageType { - /// TrustZone-M mode is determined by the image header. - TzmNormal = 0, - - /// Disable TrustZone-M features. ROM will always boot to a non-secure code and all TZ-M features are disabled. - TzmDisable = 1, - - /// TrustZone-M features are enabled. ROM will always boot to secure code. - TzmEnable = 2, - - /// TrustZone-M features are enabled and setting are loaded from image header and locked before branching to user code. - TzmPreset = 3, -} - -impl core::convert::TryFrom for TzmImageType { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::TzmNormal), - - 1 => Ok(Self::TzmDisable), - - 2 => Ok(Self::TzmEnable), - - 3 => Ok(Self::TzmPreset), - - val => Err(::device_driver::ConversionError { - source: val, - target: "TzmImageType", - }), - } - } -} - -impl From for u8 { - fn from(val: TzmImageType) -> Self { - match val { - TzmImageType::TzmNormal => 0, - - TzmImageType::TzmDisable => 1, - - TzmImageType::TzmEnable => 2, - - TzmImageType::TzmPreset => 3, - } - } -} - -/// FlexComm port to use for redundant SPI flash boot. - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum RedundantSpiPort { - /// Use FlexCom0 pins P0_0 (SCK), P0_1 (MISO), P0_2 (MOSI), P0_3 (SEL) - Fc0 = 0, - - /// Use FlexCom1 pins P0_7 (SCK), P0_8 (MISO), P0_9 (MOSI), P0_10 (SEL) - Fc1 = 1, - - /// Use FlexCom2 pins P0_14 (SCK), P0_15 (MISO), P0_16 (MOSI), P0_17 (SEL) - Fc2 = 2, - - /// Use FlexCom3 pins P0_21 (SCK), P0_22 (MISO), P0_23 (MOSI), P0_24 (SEL) - Fc3 = 3, - - /// Use FlexCom4 pins P0_28 (SCK), P0_29 (MISO), P0_30 (MOSI), P0_31 (SEL) - Fc4 = 4, - - /// Use FlexCom5 pins P1_3 (SCK), P1_4 (MISO), P1_5 (MOSI), P1_6 (SEL) - Fc5 = 5, - - /// Use FlexCom6 pins P3_25 (SCK), P3_26 (MISO), P3_27 (MOSI), P3_28 (SEL) - Fc6 = 6, - - /// Use FlexCom7 pins P4_0 (SCK), P4_1 (MISO), P4_2 (MOSI), P4_3 (SEL) - Fc7 = 7, -} - -impl core::convert::TryFrom for RedundantSpiPort { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::Fc0), - - 1 => Ok(Self::Fc1), - - 2 => Ok(Self::Fc2), - - 3 => Ok(Self::Fc3), - - 4 => Ok(Self::Fc4), - - 5 => Ok(Self::Fc5), - - 6 => Ok(Self::Fc6), - - 7 => Ok(Self::Fc7), - - val => Err(::device_driver::ConversionError { - source: val, - target: "RedundantSpiPort", - }), - } - } -} - -impl From for u8 { - fn from(val: RedundantSpiPort) -> Self { - match val { - RedundantSpiPort::Fc0 => 0, - - RedundantSpiPort::Fc1 => 1, - - RedundantSpiPort::Fc2 => 2, - - RedundantSpiPort::Fc3 => 3, - - RedundantSpiPort::Fc4 => 4, - - RedundantSpiPort::Fc5 => 5, - - RedundantSpiPort::Fc6 => 6, - - RedundantSpiPort::Fc7 => 7, - } - } -} - -/// Force secure image only. - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum SecureBoot { - Disabled = 0, - - Enabled = 1, -} - -impl Default for SecureBoot { - fn default() -> Self { - Self::Enabled - } -} - -impl From for SecureBoot { - fn from(val: u8) -> Self { - match val { - 0 => Self::Disabled, - - _ => Self::default(), - } - } -} - -impl From for u8 { - fn from(val: SecureBoot) -> Self { - match val { - SecureBoot::Disabled => 0, - - SecureBoot::Enabled => 1, - } - } -} - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum CrcCheck { - Disable = 0, - - Enable = 1, - - NxpOnly = 2, - - Enable2 = 3, -} - -impl core::convert::TryFrom for CrcCheck { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::Disable), - - 1 => Ok(Self::Enable), - - 2 => Ok(Self::NxpOnly), - - 3 => Ok(Self::Enable2), - - val => Err(::device_driver::ConversionError { - source: val, - target: "CrcCheck", - }), - } - } -} - -impl From for u8 { - fn from(val: CrcCheck) -> Self { - match val { - CrcCheck::Disable => 0, - - CrcCheck::Enable => 1, - - CrcCheck::NxpOnly => 2, - - CrcCheck::Enable2 => 3, - } - } -} - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum KeyIn { - Otp = 0, - - Ouf = 1, -} - -impl core::convert::TryFrom for KeyIn { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::Otp), - - 1 => Ok(Self::Ouf), - - val => Err(::device_driver::ConversionError { - source: val, - target: "KeyIn", - }), - } - } -} - -impl From for u8 { - fn from(val: KeyIn) -> Self { - match val { - KeyIn::Otp => 0, - - KeyIn::Ouf => 1, - } - } -} - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum Enroll { - Enable = 0, - - Disable = 1, -} - -impl core::convert::TryFrom for Enroll { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::Enable), - - 1 => Ok(Self::Disable), - - val => Err(::device_driver::ConversionError { - source: val, - target: "Enroll", - }), - } - } -} - -impl From for u8 { - fn from(val: Enroll) -> Self { - match val { - Enroll::Enable => 0, - - Enroll::Disable => 1, - } - } -} - -#[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] - -pub enum KeyGen { - Enable = 0, - - Disable = 1, -} - -impl core::convert::TryFrom for KeyGen { - type Error = ::device_driver::ConversionError; - fn try_from(val: u8) -> Result { - match val { - 0 => Ok(Self::Enable), - - 1 => Ok(Self::Disable), - - val => Err(::device_driver::ConversionError { - source: val, - target: "KeyGen", - }), - } - } -} - -impl From for u8 { - fn from(val: KeyGen) -> Self { - match val { - KeyGen::Enable => 0, - - KeyGen::Disable => 1, - } - } -}