From c25234054381671038472db2296e3c41d65cc9ed Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sat, 17 Feb 2024 23:06:26 +0000 Subject: [PATCH 01/16] Move old `bestool` code to `src/oldbestool` This is part of the refactor. Signed-off-by: Dom Rodriguez --- src/beslib/src/errors.rs | 25 +++++++++++++++++++ {bestool => src/oldbestool}/.gitignore | 0 {bestool => src/oldbestool}/Cargo.lock | 0 {bestool => src/oldbestool}/Cargo.toml | 4 +-- .../oldbestool}/src/beslink/bootloader.rs | 0 .../oldbestool}/src/beslink/errors.rs | 0 .../helper_sync_and_load_programmer.rs | 0 .../oldbestool}/src/beslink/memory_info.rs | 1 + .../oldbestool}/src/beslink/message.rs | 0 .../oldbestool}/src/beslink/mod.rs | 0 .../oldbestool}/src/beslink/read_flash.rs | 0 .../oldbestool}/src/beslink/reboot.rs | 0 .../oldbestool}/src/beslink/sync.rs | 0 .../oldbestool}/src/beslink/test_port.rs | 0 .../oldbestool}/src/beslink/write_flash.rs | 0 .../oldbestool}/src/cmds/list_ports.rs | 0 {bestool => src/oldbestool}/src/cmds/mod.rs | 0 .../oldbestool}/src/cmds/read_image.rs | 0 .../oldbestool}/src/cmds/serial_monitor.rs | 0 .../oldbestool}/src/cmds/write_image.rs | 0 .../src/cmds/write_image_then_monitor.rs | 0 {bestool => src/oldbestool}/src/main.rs | 0 .../oldbestool}/src/serial_monitor/mod.rs | 0 .../oldbestool}/src/serial_monitor/monitor.rs | 0 .../oldbestool}/src/serial_port_opener.rs | 0 .../oldbestool}/supply-chain/audits.toml | 0 .../oldbestool}/supply-chain/config.toml | 0 .../oldbestool}/supply-chain/imports.lock | 0 28 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/beslib/src/errors.rs rename {bestool => src/oldbestool}/.gitignore (100%) rename {bestool => src/oldbestool}/Cargo.lock (100%) rename {bestool => src/oldbestool}/Cargo.toml (90%) rename {bestool => src/oldbestool}/src/beslink/bootloader.rs (100%) rename {bestool => src/oldbestool}/src/beslink/errors.rs (100%) rename {bestool => src/oldbestool}/src/beslink/helper_sync_and_load_programmer.rs (100%) rename {bestool => src/oldbestool}/src/beslink/memory_info.rs (99%) rename {bestool => src/oldbestool}/src/beslink/message.rs (100%) rename {bestool => src/oldbestool}/src/beslink/mod.rs (100%) rename {bestool => src/oldbestool}/src/beslink/read_flash.rs (100%) rename {bestool => src/oldbestool}/src/beslink/reboot.rs (100%) rename {bestool => src/oldbestool}/src/beslink/sync.rs (100%) rename {bestool => src/oldbestool}/src/beslink/test_port.rs (100%) rename {bestool => src/oldbestool}/src/beslink/write_flash.rs (100%) rename {bestool => src/oldbestool}/src/cmds/list_ports.rs (100%) rename {bestool => src/oldbestool}/src/cmds/mod.rs (100%) rename {bestool => src/oldbestool}/src/cmds/read_image.rs (100%) rename {bestool => src/oldbestool}/src/cmds/serial_monitor.rs (100%) rename {bestool => src/oldbestool}/src/cmds/write_image.rs (100%) rename {bestool => src/oldbestool}/src/cmds/write_image_then_monitor.rs (100%) rename {bestool => src/oldbestool}/src/main.rs (100%) rename {bestool => src/oldbestool}/src/serial_monitor/mod.rs (100%) rename {bestool => src/oldbestool}/src/serial_monitor/monitor.rs (100%) rename {bestool => src/oldbestool}/src/serial_port_opener.rs (100%) rename {bestool => src/oldbestool}/supply-chain/audits.toml (100%) rename {bestool => src/oldbestool}/supply-chain/config.toml (100%) rename {bestool => src/oldbestool}/supply-chain/imports.lock (100%) diff --git a/src/beslib/src/errors.rs b/src/beslib/src/errors.rs new file mode 100644 index 0000000..a3c8bde --- /dev/null +++ b/src/beslib/src/errors.rs @@ -0,0 +1,25 @@ +use std::fmt; +use std::error; +use std::io::Error as IoError; + +#[derive(Debug)] +pub enum BesLinkError { + IoError(IoError), +} + +impl error::Error for BesLinkError {} + +impl fmt::Display for BesLinkError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + BesLinkError::IoError(ref e) => write!(f, "IO error: {}", e) + + } + } +} + +impl From for BesLinkError { + fn from(e: IoError) -> Self { + BesLinkError::IoError(e) + } +} diff --git a/bestool/.gitignore b/src/oldbestool/.gitignore similarity index 100% rename from bestool/.gitignore rename to src/oldbestool/.gitignore diff --git a/bestool/Cargo.lock b/src/oldbestool/Cargo.lock similarity index 100% rename from bestool/Cargo.lock rename to src/oldbestool/Cargo.lock diff --git a/bestool/Cargo.toml b/src/oldbestool/Cargo.toml similarity index 90% rename from bestool/Cargo.toml rename to src/oldbestool/Cargo.toml index 31a5fe3..00240f8 100644 --- a/bestool/Cargo.toml +++ b/src/oldbestool/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "bestool" -version = "0.1.2" +name = "oldbestool" +version = "0.1.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/bestool/src/beslink/bootloader.rs b/src/oldbestool/src/beslink/bootloader.rs similarity index 100% rename from bestool/src/beslink/bootloader.rs rename to src/oldbestool/src/beslink/bootloader.rs diff --git a/bestool/src/beslink/errors.rs b/src/oldbestool/src/beslink/errors.rs similarity index 100% rename from bestool/src/beslink/errors.rs rename to src/oldbestool/src/beslink/errors.rs diff --git a/bestool/src/beslink/helper_sync_and_load_programmer.rs b/src/oldbestool/src/beslink/helper_sync_and_load_programmer.rs similarity index 100% rename from bestool/src/beslink/helper_sync_and_load_programmer.rs rename to src/oldbestool/src/beslink/helper_sync_and_load_programmer.rs diff --git a/bestool/src/beslink/memory_info.rs b/src/oldbestool/src/beslink/memory_info.rs similarity index 99% rename from bestool/src/beslink/memory_info.rs rename to src/oldbestool/src/beslink/memory_info.rs index 8d7851b..1b940b1 100644 --- a/bestool/src/beslink/memory_info.rs +++ b/src/oldbestool/src/beslink/memory_info.rs @@ -14,6 +14,7 @@ pub fn query_memory_info(serial_port: &mut Box) -> Result<(), BE payload: vec![0x03, 0x01, 0x12], checksum: 0xC6, }; + send_message(serial_port, get_flash_id_cmd)?; let flash_id = sync(serial_port, MessageTypes::FlashCommand)?; send_message(serial_port, get_flash_unique_id_cmd)?; diff --git a/bestool/src/beslink/message.rs b/src/oldbestool/src/beslink/message.rs similarity index 100% rename from bestool/src/beslink/message.rs rename to src/oldbestool/src/beslink/message.rs diff --git a/bestool/src/beslink/mod.rs b/src/oldbestool/src/beslink/mod.rs similarity index 100% rename from bestool/src/beslink/mod.rs rename to src/oldbestool/src/beslink/mod.rs diff --git a/bestool/src/beslink/read_flash.rs b/src/oldbestool/src/beslink/read_flash.rs similarity index 100% rename from bestool/src/beslink/read_flash.rs rename to src/oldbestool/src/beslink/read_flash.rs diff --git a/bestool/src/beslink/reboot.rs b/src/oldbestool/src/beslink/reboot.rs similarity index 100% rename from bestool/src/beslink/reboot.rs rename to src/oldbestool/src/beslink/reboot.rs diff --git a/bestool/src/beslink/sync.rs b/src/oldbestool/src/beslink/sync.rs similarity index 100% rename from bestool/src/beslink/sync.rs rename to src/oldbestool/src/beslink/sync.rs diff --git a/bestool/src/beslink/test_port.rs b/src/oldbestool/src/beslink/test_port.rs similarity index 100% rename from bestool/src/beslink/test_port.rs rename to src/oldbestool/src/beslink/test_port.rs diff --git a/bestool/src/beslink/write_flash.rs b/src/oldbestool/src/beslink/write_flash.rs similarity index 100% rename from bestool/src/beslink/write_flash.rs rename to src/oldbestool/src/beslink/write_flash.rs diff --git a/bestool/src/cmds/list_ports.rs b/src/oldbestool/src/cmds/list_ports.rs similarity index 100% rename from bestool/src/cmds/list_ports.rs rename to src/oldbestool/src/cmds/list_ports.rs diff --git a/bestool/src/cmds/mod.rs b/src/oldbestool/src/cmds/mod.rs similarity index 100% rename from bestool/src/cmds/mod.rs rename to src/oldbestool/src/cmds/mod.rs diff --git a/bestool/src/cmds/read_image.rs b/src/oldbestool/src/cmds/read_image.rs similarity index 100% rename from bestool/src/cmds/read_image.rs rename to src/oldbestool/src/cmds/read_image.rs diff --git a/bestool/src/cmds/serial_monitor.rs b/src/oldbestool/src/cmds/serial_monitor.rs similarity index 100% rename from bestool/src/cmds/serial_monitor.rs rename to src/oldbestool/src/cmds/serial_monitor.rs diff --git a/bestool/src/cmds/write_image.rs b/src/oldbestool/src/cmds/write_image.rs similarity index 100% rename from bestool/src/cmds/write_image.rs rename to src/oldbestool/src/cmds/write_image.rs diff --git a/bestool/src/cmds/write_image_then_monitor.rs b/src/oldbestool/src/cmds/write_image_then_monitor.rs similarity index 100% rename from bestool/src/cmds/write_image_then_monitor.rs rename to src/oldbestool/src/cmds/write_image_then_monitor.rs diff --git a/bestool/src/main.rs b/src/oldbestool/src/main.rs similarity index 100% rename from bestool/src/main.rs rename to src/oldbestool/src/main.rs diff --git a/bestool/src/serial_monitor/mod.rs b/src/oldbestool/src/serial_monitor/mod.rs similarity index 100% rename from bestool/src/serial_monitor/mod.rs rename to src/oldbestool/src/serial_monitor/mod.rs diff --git a/bestool/src/serial_monitor/monitor.rs b/src/oldbestool/src/serial_monitor/monitor.rs similarity index 100% rename from bestool/src/serial_monitor/monitor.rs rename to src/oldbestool/src/serial_monitor/monitor.rs diff --git a/bestool/src/serial_port_opener.rs b/src/oldbestool/src/serial_port_opener.rs similarity index 100% rename from bestool/src/serial_port_opener.rs rename to src/oldbestool/src/serial_port_opener.rs diff --git a/bestool/supply-chain/audits.toml b/src/oldbestool/supply-chain/audits.toml similarity index 100% rename from bestool/supply-chain/audits.toml rename to src/oldbestool/supply-chain/audits.toml diff --git a/bestool/supply-chain/config.toml b/src/oldbestool/supply-chain/config.toml similarity index 100% rename from bestool/supply-chain/config.toml rename to src/oldbestool/supply-chain/config.toml diff --git a/bestool/supply-chain/imports.lock b/src/oldbestool/supply-chain/imports.lock similarity index 100% rename from bestool/supply-chain/imports.lock rename to src/oldbestool/supply-chain/imports.lock From 8701cd0a69d0785ada6dde94873374605ba482ab Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sat, 9 Mar 2024 23:58:01 +0000 Subject: [PATCH 02/16] refactor: Initial conversion to workspace structure - Use Cargo 'workspaces', specify shared dependencies. - Move blobs to `src/beslib/src/blobs`, so that Nix can build in a sandbox. - Copy `supply-chain` directory to both `beslib` and `bestool`. TODO: Regenerate once refactor complete. Signed-off-by: Dom Rodriguez --- Cargo.lock | 455 ++++++++++++++++ Cargo.toml | 24 + src/beslib/Cargo.toml | 14 + chunk1.bin => src/beslib/blobs/chunk1.bin | Bin chunk2.bin => src/beslib/blobs/chunk2.bin | Bin .../beslib/blobs/programmer.bin | Bin src/beslib/supply-chain/audits.toml | 253 +++++++++ src/beslib/supply-chain/config.toml | 87 +++ src/beslib/supply-chain/imports.lock | 495 ++++++++++++++++++ src/bestool/Cargo.toml | 16 + src/bestool/supply-chain/audits.toml | 253 +++++++++ src/bestool/supply-chain/config.toml | 87 +++ src/bestool/supply-chain/imports.lock | 495 ++++++++++++++++++ 13 files changed, 2179 insertions(+) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/beslib/Cargo.toml rename chunk1.bin => src/beslib/blobs/chunk1.bin (100%) rename chunk2.bin => src/beslib/blobs/chunk2.bin (100%) rename programmer.bin => src/beslib/blobs/programmer.bin (100%) create mode 100644 src/beslib/supply-chain/audits.toml create mode 100644 src/beslib/supply-chain/config.toml create mode 100644 src/beslib/supply-chain/imports.lock create mode 100644 src/bestool/Cargo.toml create mode 100644 src/bestool/supply-chain/audits.toml create mode 100644 src/bestool/supply-chain/config.toml create mode 100644 src/bestool/supply-chain/imports.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..ca28eda --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,455 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "beslib" +version = "0.3.0" +dependencies = [ + "crc", + "serialport", +] + +[[package]] +name = "bestool" +version = "0.3.0" +dependencies = [ + "beslib", + "clap", + "crc", + "serialport", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "io-kit-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4769cb30e5dcf1710fc6730d3e94f78c47723a014a567de385e113c737394640" +dependencies = [ + "core-foundation-sys", + "mach2", +] + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "libudev" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b324152da65df7bb95acfcaab55e3097ceaab02fb19b228a9eb74d55f135e0" +dependencies = [ + "libc", + "libudev-sys", +] + +[[package]] +name = "libudev-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serialport" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5a15d0be940df84846264b09b51b10b931fb2f275becb80934e3568a016828" +dependencies = [ + "bitflags 2.4.2", + "cfg-if", + "core-foundation-sys", + "io-kit-sys", + "libudev", + "mach2", + "nix", + "regex", + "scopeguard", + "unescaper", + "winapi", +] + +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + +[[package]] +name = "syn" +version = "2.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unescaper" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0adf6ad32eb5b3cadff915f7b770faaac8f7ff0476633aa29eb0d9584d889d34" +dependencies = [ + "thiserror", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[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-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..d629564 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,24 @@ +[workspace] +resolver = "2" +members = [ + "src/beslib", + "src/bestool", +] + +[workspace.package] +authors = ["Ben V. Brown ", "Dom Rodriguez "] +edition = "2021" +homepage = "https://github.com/Ralim/bestool" +readme = "/README.md" +repository = "https://github.com/Ralim/bestool.git" +rust-version = "1.67.0" +version = "0.3.0" + +[workspace.dependencies] +clap = { version = "4.5.1", features = ["derive"] } +crc = "3.0.1" +serde = { version = "1.0.196", features = ["derive"] } +serde_json = "1.0.113" +serialport = "4.3.0" +tracing = "0.1.40" +tracing-subscriber = "0.3.18" diff --git a/src/beslib/Cargo.toml b/src/beslib/Cargo.toml new file mode 100644 index 0000000..adca061 --- /dev/null +++ b/src/beslib/Cargo.toml @@ -0,0 +1,14 @@ +[package] +authors = { workspace = true } +description = "Support library for `bestool`; a command-line utility for BES2300 chips." +edition = { workspace = true } +homepage = { workspace = true } +# license = { workspace = true } # TODO: Specify license with REUSE. +name = "beslib" +repository = { workspace = true } +rust-version = { workspace = true } +version = { workspace = true } + +[dependencies] +crc = { workspace = true } +serialport = { workspace = true } diff --git a/chunk1.bin b/src/beslib/blobs/chunk1.bin similarity index 100% rename from chunk1.bin rename to src/beslib/blobs/chunk1.bin diff --git a/chunk2.bin b/src/beslib/blobs/chunk2.bin similarity index 100% rename from chunk2.bin rename to src/beslib/blobs/chunk2.bin diff --git a/programmer.bin b/src/beslib/blobs/programmer.bin similarity index 100% rename from programmer.bin rename to src/beslib/blobs/programmer.bin diff --git a/src/beslib/supply-chain/audits.toml b/src/beslib/supply-chain/audits.toml new file mode 100644 index 0000000..29f91fd --- /dev/null +++ b/src/beslib/supply-chain/audits.toml @@ -0,0 +1,253 @@ + +# cargo-vet audits file + +[[audits.bitflags]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "2.4.1 -> 2.4.2" + +[[audits.io-kit-sys]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +version = "0.4.0" + +[[audits.pkg-config]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "0.3.26 -> 0.3.27" + +[[audits.pkg-config]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "0.3.29 -> 0.3.30" + +[[audits.serialport]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "4.2.2 -> 4.3.0" + +[[audits.strsim]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "0.10.0 -> 0.11.0" + +[[audits.unescaper]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +version = "0.1.4" + +[[trusted.aho-corasick]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-03-28" +end = "2024-11-26" + +[[trusted.anstream]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-03-16" +end = "2024-11-26" + +[[trusted.anstyle]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2022-05-18" +end = "2024-11-26" + +[[trusted.anstyle-parse]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-03-08" +end = "2024-11-26" + +[[trusted.anstyle-query]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-04-13" +end = "2024-11-26" + +[[trusted.anstyle-wincon]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-03-08" +end = "2024-11-26" + +[[trusted.clap]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2021-12-08" +end = "2024-11-26" + +[[trusted.clap_builder]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-03-28" +end = "2024-11-26" + +[[trusted.clap_derive]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2021-12-08" +end = "2024-11-26" + +[[trusted.clap_lex]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2022-04-15" +end = "2024-11-26" + +[[trusted.colorchoice]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-04-13" +end = "2024-11-26" + +[[trusted.libc]] +criteria = "safe-to-deploy" +user-id = 2915 # Amanieu d'Antras (Amanieu) +start = "2021-01-27" +end = "2024-11-26" + +[[trusted.mach2]] +criteria = "safe-to-deploy" +user-id = 51017 # Yuki Okushi (JohnTitor) +start = "2021-11-15" +end = "2025-02-17" + +[[trusted.memchr]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-07-07" +end = "2024-11-26" + +[[trusted.proc-macro2]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-04-23" +end = "2024-11-26" + +[[trusted.quote]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-04-09" +end = "2024-11-26" + +[[trusted.regex]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-02-27" +end = "2024-11-26" + +[[trusted.regex-automata]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-02-25" +end = "2024-11-26" + +[[trusted.regex-syntax]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-03-30" +end = "2024-11-26" + +[[trusted.scopeguard]] +criteria = "safe-to-deploy" +user-id = 2915 # Amanieu d'Antras (Amanieu) +start = "2020-02-16" +end = "2024-11-26" + +[[trusted.smallvec]] +criteria = "safe-to-deploy" +user-id = 2017 # Matt Brubeck (mbrubeck) +start = "2019-10-28" +end = "2024-11-26" + +[[trusted.syn]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-03-01" +end = "2024-11-26" + +[[trusted.thiserror]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-10-09" +end = "2024-11-26" + +[[trusted.thiserror-impl]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-10-09" +end = "2024-11-26" + +[[trusted.thread_local]] +criteria = "safe-to-deploy" +user-id = 2915 # Amanieu d'Antras (Amanieu) +start = "2019-09-07" +end = "2024-11-26" + +[[trusted.unicode-ident]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2021-10-02" +end = "2024-11-26" + +[[trusted.valuable]] +criteria = "safe-to-deploy" +user-id = 10 # Carl Lerche (carllerche) +start = "2022-01-03" +end = "2024-11-26" + +[[trusted.windows-sys]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-11-15" +end = "2024-11-26" + +[[trusted.windows-targets]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2022-09-09" +end = "2024-11-26" + +[[trusted.windows_aarch64_gnullvm]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2022-09-01" +end = "2024-11-26" + +[[trusted.windows_aarch64_msvc]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-11-05" +end = "2024-11-26" + +[[trusted.windows_i686_gnu]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-10-28" +end = "2024-11-26" + +[[trusted.windows_i686_msvc]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-10-27" +end = "2024-11-26" + +[[trusted.windows_x86_64_gnu]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-10-28" +end = "2024-11-26" + +[[trusted.windows_x86_64_gnullvm]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2022-09-01" +end = "2024-11-26" + +[[trusted.windows_x86_64_msvc]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-10-27" +end = "2024-11-26" diff --git a/src/beslib/supply-chain/config.toml b/src/beslib/supply-chain/config.toml new file mode 100644 index 0000000..ee79313 --- /dev/null +++ b/src/beslib/supply-chain/config.toml @@ -0,0 +1,87 @@ + +# cargo-vet config file + +[cargo-vet] +version = "0.9" + +[imports.bytecode-alliance] +url = "https://raw.githubusercontent.com/bytecodealliance/wasmtime/main/supply-chain/audits.toml" + +[imports.fermyon] +url = "https://raw.githubusercontent.com/fermyon/spin/main/supply-chain/audits.toml" + +[imports.google] +url = "https://raw.githubusercontent.com/google/supply-chain/main/audits.toml" + +[imports.isrg] +url = "https://raw.githubusercontent.com/divviup/libprio-rs/main/supply-chain/audits.toml" + +[imports.mozilla] +url = "https://raw.githubusercontent.com/mozilla/supply-chain/main/audits.toml" + +[imports.zcash] +url = "https://raw.githubusercontent.com/zcash/rust-ecosystem/main/supply-chain/audits.toml" + +[[exemptions.bitflags]] +version = "1.3.2" +criteria = "safe-to-deploy" + +[[exemptions.crc]] +version = "3.0.1" +criteria = "safe-to-deploy" + +[[exemptions.crc-catalog]] +version = "2.4.0" +criteria = "safe-to-deploy" + +[[exemptions.libudev]] +version = "0.3.0" +criteria = "safe-to-deploy" + +[[exemptions.libudev-sys]] +version = "0.1.4" +criteria = "safe-to-deploy" + +[[exemptions.nix]] +version = "0.26.4" +criteria = "safe-to-deploy" + +[[exemptions.once_cell]] +version = "1.18.0" +criteria = "safe-to-deploy" + +[[exemptions.serialport]] +version = "4.2.2" +criteria = "safe-to-deploy" + +[[exemptions.strsim]] +version = "0.10.0" +criteria = "safe-to-deploy" + +[[exemptions.tracing]] +version = "0.1.40" +criteria = "safe-to-deploy" + +[[exemptions.tracing-attributes]] +version = "0.1.27" +criteria = "safe-to-deploy" + +[[exemptions.tracing-core]] +version = "0.1.32" +criteria = "safe-to-deploy" + +[[exemptions.tracing-log]] +version = "0.2.0" +criteria = "safe-to-deploy" + +[[exemptions.winapi]] +version = "0.3.9" +criteria = "safe-to-deploy" + +[[exemptions.winapi-i686-pc-windows-gnu]] +version = "0.4.0" +criteria = "safe-to-deploy" + +[[exemptions.winapi-x86_64-pc-windows-gnu]] +version = "0.4.0" +criteria = "safe-to-deploy" diff --git a/src/beslib/supply-chain/imports.lock b/src/beslib/supply-chain/imports.lock new file mode 100644 index 0000000..595672a --- /dev/null +++ b/src/beslib/supply-chain/imports.lock @@ -0,0 +1,495 @@ + +# cargo-vet imports lock + +[[publisher.aho-corasick]] +version = "1.1.2" +when = "2023-10-09" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.anstream]] +version = "0.6.11" +when = "2024-01-18" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.anstyle]] +version = "1.0.6" +when = "2024-02-05" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.anstyle-parse]] +version = "0.2.3" +when = "2023-12-04" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.anstyle-query]] +version = "1.0.2" +when = "2023-12-08" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.anstyle-wincon]] +version = "3.0.2" +when = "2023-12-04" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.clap]] +version = "4.5.1" +when = "2024-02-16" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.clap_builder]] +version = "4.5.1" +when = "2024-02-16" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.clap_derive]] +version = "4.5.0" +when = "2024-02-08" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.clap_lex]] +version = "0.7.0" +when = "2024-02-08" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.colorchoice]] +version = "1.0.0" +when = "2023-04-13" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.core-foundation-sys]] +version = "0.8.4" +when = "2023-04-03" +user-id = 5946 +user-login = "jrmuizel" +user-name = "Jeff Muizelaar" + +[[publisher.libc]] +version = "0.2.146" +when = "2023-06-06" +user-id = 2915 +user-login = "Amanieu" +user-name = "Amanieu d'Antras" + +[[publisher.mach2]] +version = "0.4.2" +when = "2023-12-19" +user-id = 51017 +user-login = "JohnTitor" +user-name = "Yuki Okushi" + +[[publisher.memchr]] +version = "2.7.1" +when = "2023-12-28" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.proc-macro2]] +version = "1.0.78" +when = "2024-01-21" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.quote]] +version = "1.0.35" +when = "2024-01-02" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.regex]] +version = "1.10.3" +when = "2024-01-21" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.regex-automata]] +version = "0.4.5" +when = "2024-01-25" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.regex-syntax]] +version = "0.8.2" +when = "2023-10-14" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.scopeguard]] +version = "1.2.0" +when = "2023-07-17" +user-id = 2915 +user-login = "Amanieu" +user-name = "Amanieu d'Antras" + +[[publisher.smallvec]] +version = "1.13.1" +when = "2024-01-19" +user-id = 2017 +user-login = "mbrubeck" +user-name = "Matt Brubeck" + +[[publisher.syn]] +version = "2.0.49" +when = "2024-02-16" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.thiserror]] +version = "1.0.57" +when = "2024-02-11" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.thiserror-impl]] +version = "1.0.57" +when = "2024-02-11" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.thread_local]] +version = "1.1.7" +when = "2023-02-12" +user-id = 2915 +user-login = "Amanieu" +user-name = "Amanieu d'Antras" + +[[publisher.unicode-ident]] +version = "1.0.12" +when = "2023-09-13" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.valuable]] +version = "0.1.0" +when = "2022-01-03" +user-id = 10 +user-login = "carllerche" +user-name = "Carl Lerche" + +[[publisher.windows-sys]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows-targets]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_aarch64_gnullvm]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_aarch64_msvc]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_i686_gnu]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_i686_msvc]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_x86_64_gnu]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_x86_64_gnullvm]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_x86_64_msvc]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[audits.bytecode-alliance.audits.bitflags]] +who = "Jamey Sharp " +criteria = "safe-to-deploy" +delta = "2.1.0 -> 2.2.1" +notes = """ +This version adds unsafe impls of traits from the bytemuck crate when built +with that library enabled, but I believe the impls satisfy the documented +safety requirements for bytemuck. The other changes are minor. +""" + +[[audits.bytecode-alliance.audits.bitflags]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "2.3.2 -> 2.3.3" +notes = """ +Nothing outside the realm of what one would expect from a bitflags generator, +all as expected. +""" + +[[audits.bytecode-alliance.audits.cfg-if]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "1.0.0" +notes = "I am the author of this crate." + +[[audits.bytecode-alliance.audits.core-foundation-sys]] +who = "Dan Gohman " +criteria = "safe-to-deploy" +delta = "0.8.4 -> 0.8.6" +notes = """ +The changes here are all typical bindings updates: new functions, types, and +constants. I have not audited all the bindings for ABI conformance. +""" + +[[audits.bytecode-alliance.audits.heck]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "0.4.0" +notes = "Contains `forbid_unsafe` and only uses `std::fmt` from the standard library. Otherwise only contains string manipulation." + +[[audits.bytecode-alliance.audits.libc]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.2.146 -> 0.2.147" +notes = "Only new type definitions and updating others for some platforms, no major changes" + +[[audits.bytecode-alliance.audits.libc]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.2.148 -> 0.2.149" +notes = "Lots of new functions and constants for new platforms and nothing out of the ordinary for what one would expect of the `libc` crate." + +[[audits.bytecode-alliance.audits.libc]] +who = "Dan Gohman " +criteria = "safe-to-deploy" +delta = "0.2.149 -> 0.2.151" +notes = "More new functions, types, and constants, as is usual for the `libc` crate, as well as various minor code cleanups." + +[[audits.bytecode-alliance.audits.libc]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.2.151 -> 0.2.153" +notes = "More bindings for more platforms. I have not verified that everything is exactly as-is on the platform as specified but nothing major is otherwise introduced as part of this bump." + +[[audits.bytecode-alliance.audits.nu-ansi-term]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.46.0" +notes = "one use of unsafe to call windows specific api to get console handle." + +[[audits.bytecode-alliance.audits.overload]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.1.1" +notes = "small crate, only defines macro-rules!, nicely documented as well" + +[[audits.bytecode-alliance.audits.pkg-config]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.3.25" +notes = "This crate shells out to the pkg-config executable, but it appears to sanitize inputs reasonably." + +[[audits.bytecode-alliance.audits.pkg-config]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.3.26 -> 0.3.29" +notes = """ +No `unsafe` additions or anything outside of the purview of the crate in this +change. +""" + +[[audits.bytecode-alliance.audits.sharded-slab]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.1.4" +notes = "I always really enjoy reading eliza's code, she left perfect comments at every use of unsafe." + +[[audits.bytecode-alliance.audits.tracing-subscriber]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.3.17" + +[audits.fermyon.audits] + +[[audits.google.audits.pin-project-lite]] +who = "David Koloski " +criteria = "safe-to-deploy" +version = "0.2.9" +notes = "Reviewed on https://fxrev.dev/824504" +aggregated-from = "https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/third_party/rust_crates/supply-chain/audits.toml?format=TEXT" + +[[audits.google.audits.utf8parse]] +who = "David Koloski " +criteria = "safe-to-deploy" +version = "0.2.1" +notes = "Reviewed on https://fxrev.dev/904811" +aggregated-from = "https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/third_party/rust_crates/supply-chain/audits.toml?format=TEXT" + +[[audits.isrg.audits.once_cell]] +who = "Brandon Pitman " +criteria = "safe-to-deploy" +delta = "1.18.0 -> 1.19.0" + +[[audits.mozilla.wildcard-audits.core-foundation-sys]] +who = "Bobby Holley " +criteria = "safe-to-deploy" +user-id = 5946 # Jeff Muizelaar (jrmuizel) +start = "2020-10-14" +end = "2023-05-04" +renew = false +notes = "I've reviewed every source contribution that was neither authored nor reviewed by Mozilla." +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Alex Franchuk " +criteria = "safe-to-deploy" +delta = "1.3.2 -> 2.0.2" +notes = "Removal of some unsafe code/methods. No changes to externals, just some refactoring (mostly internal)." +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Nicolas Silva " +criteria = "safe-to-deploy" +delta = "2.0.2 -> 2.1.0" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Teodor Tanasoaia " +criteria = "safe-to-deploy" +delta = "2.2.1 -> 2.3.2" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "2.3.3 -> 2.4.0" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Jan-Erik Rediger " +criteria = "safe-to-deploy" +delta = "2.4.0 -> 2.4.1" +notes = "Only allowing new clippy lints" +aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.heck]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "0.4.0 -> 0.4.1" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.lazy_static]] +who = "Nika Layzell " +criteria = "safe-to-deploy" +version = "1.4.0" +notes = "I have read over the macros, and audited the unsafe code." +aggregated-from = "https://raw.githubusercontent.com/mozilla/cargo-vet/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.libc]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "0.2.147 -> 0.2.148" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.log]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +version = "0.4.17" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.log]] +who = "Jan-Erik Rediger " +criteria = "safe-to-deploy" +delta = "0.4.17 -> 0.4.18" +notes = "One dependency removed, others updated (which we don't rely on), some APIs (which we don't use) changed." +aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.pkg-config]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "0.3.25 -> 0.3.26" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.zcash.audits.log]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.4.18 -> 0.4.19" +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" + +[[audits.zcash.audits.log]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.4.19 -> 0.4.20" +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" + +[[audits.zcash.audits.pin-project-lite]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.2.9 -> 0.2.13" +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" + +[[audits.zcash.audits.sharded-slab]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.1.4 -> 0.1.7" +notes = "Only change to an `unsafe` block is to fix a clippy lint." +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" + +[[audits.zcash.audits.tracing-subscriber]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.3.17 -> 0.3.18" +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" diff --git a/src/bestool/Cargo.toml b/src/bestool/Cargo.toml new file mode 100644 index 0000000..bdb2a0b --- /dev/null +++ b/src/bestool/Cargo.toml @@ -0,0 +1,16 @@ +[package] +authors = { workspace = true } +description = "Command-line utility for BES2300 chips." +edition = { workspace = true } +homepage = { workspace = true } +# license = { workspace = true } # TODO: Specify license with REUSE. +name = "bestool" +repository = { workspace = true } +rust-version = { workspace = true } +version = { workspace = true } + +[dependencies] +beslib = { path = "../beslib" } +clap = { workspace = true } +crc = { workspace = true } +serialport = { workspace = true } diff --git a/src/bestool/supply-chain/audits.toml b/src/bestool/supply-chain/audits.toml new file mode 100644 index 0000000..29f91fd --- /dev/null +++ b/src/bestool/supply-chain/audits.toml @@ -0,0 +1,253 @@ + +# cargo-vet audits file + +[[audits.bitflags]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "2.4.1 -> 2.4.2" + +[[audits.io-kit-sys]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +version = "0.4.0" + +[[audits.pkg-config]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "0.3.26 -> 0.3.27" + +[[audits.pkg-config]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "0.3.29 -> 0.3.30" + +[[audits.serialport]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "4.2.2 -> 4.3.0" + +[[audits.strsim]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +delta = "0.10.0 -> 0.11.0" + +[[audits.unescaper]] +who = "Ben V. Brown " +criteria = "safe-to-deploy" +version = "0.1.4" + +[[trusted.aho-corasick]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-03-28" +end = "2024-11-26" + +[[trusted.anstream]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-03-16" +end = "2024-11-26" + +[[trusted.anstyle]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2022-05-18" +end = "2024-11-26" + +[[trusted.anstyle-parse]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-03-08" +end = "2024-11-26" + +[[trusted.anstyle-query]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-04-13" +end = "2024-11-26" + +[[trusted.anstyle-wincon]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-03-08" +end = "2024-11-26" + +[[trusted.clap]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2021-12-08" +end = "2024-11-26" + +[[trusted.clap_builder]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-03-28" +end = "2024-11-26" + +[[trusted.clap_derive]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2021-12-08" +end = "2024-11-26" + +[[trusted.clap_lex]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2022-04-15" +end = "2024-11-26" + +[[trusted.colorchoice]] +criteria = "safe-to-deploy" +user-id = 6743 # Ed Page (epage) +start = "2023-04-13" +end = "2024-11-26" + +[[trusted.libc]] +criteria = "safe-to-deploy" +user-id = 2915 # Amanieu d'Antras (Amanieu) +start = "2021-01-27" +end = "2024-11-26" + +[[trusted.mach2]] +criteria = "safe-to-deploy" +user-id = 51017 # Yuki Okushi (JohnTitor) +start = "2021-11-15" +end = "2025-02-17" + +[[trusted.memchr]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-07-07" +end = "2024-11-26" + +[[trusted.proc-macro2]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-04-23" +end = "2024-11-26" + +[[trusted.quote]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-04-09" +end = "2024-11-26" + +[[trusted.regex]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-02-27" +end = "2024-11-26" + +[[trusted.regex-automata]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-02-25" +end = "2024-11-26" + +[[trusted.regex-syntax]] +criteria = "safe-to-deploy" +user-id = 189 # Andrew Gallant (BurntSushi) +start = "2019-03-30" +end = "2024-11-26" + +[[trusted.scopeguard]] +criteria = "safe-to-deploy" +user-id = 2915 # Amanieu d'Antras (Amanieu) +start = "2020-02-16" +end = "2024-11-26" + +[[trusted.smallvec]] +criteria = "safe-to-deploy" +user-id = 2017 # Matt Brubeck (mbrubeck) +start = "2019-10-28" +end = "2024-11-26" + +[[trusted.syn]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-03-01" +end = "2024-11-26" + +[[trusted.thiserror]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-10-09" +end = "2024-11-26" + +[[trusted.thiserror-impl]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2019-10-09" +end = "2024-11-26" + +[[trusted.thread_local]] +criteria = "safe-to-deploy" +user-id = 2915 # Amanieu d'Antras (Amanieu) +start = "2019-09-07" +end = "2024-11-26" + +[[trusted.unicode-ident]] +criteria = "safe-to-deploy" +user-id = 3618 # David Tolnay (dtolnay) +start = "2021-10-02" +end = "2024-11-26" + +[[trusted.valuable]] +criteria = "safe-to-deploy" +user-id = 10 # Carl Lerche (carllerche) +start = "2022-01-03" +end = "2024-11-26" + +[[trusted.windows-sys]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-11-15" +end = "2024-11-26" + +[[trusted.windows-targets]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2022-09-09" +end = "2024-11-26" + +[[trusted.windows_aarch64_gnullvm]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2022-09-01" +end = "2024-11-26" + +[[trusted.windows_aarch64_msvc]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-11-05" +end = "2024-11-26" + +[[trusted.windows_i686_gnu]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-10-28" +end = "2024-11-26" + +[[trusted.windows_i686_msvc]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-10-27" +end = "2024-11-26" + +[[trusted.windows_x86_64_gnu]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-10-28" +end = "2024-11-26" + +[[trusted.windows_x86_64_gnullvm]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2022-09-01" +end = "2024-11-26" + +[[trusted.windows_x86_64_msvc]] +criteria = "safe-to-deploy" +user-id = 64539 # Kenny Kerr (kennykerr) +start = "2021-10-27" +end = "2024-11-26" diff --git a/src/bestool/supply-chain/config.toml b/src/bestool/supply-chain/config.toml new file mode 100644 index 0000000..ee79313 --- /dev/null +++ b/src/bestool/supply-chain/config.toml @@ -0,0 +1,87 @@ + +# cargo-vet config file + +[cargo-vet] +version = "0.9" + +[imports.bytecode-alliance] +url = "https://raw.githubusercontent.com/bytecodealliance/wasmtime/main/supply-chain/audits.toml" + +[imports.fermyon] +url = "https://raw.githubusercontent.com/fermyon/spin/main/supply-chain/audits.toml" + +[imports.google] +url = "https://raw.githubusercontent.com/google/supply-chain/main/audits.toml" + +[imports.isrg] +url = "https://raw.githubusercontent.com/divviup/libprio-rs/main/supply-chain/audits.toml" + +[imports.mozilla] +url = "https://raw.githubusercontent.com/mozilla/supply-chain/main/audits.toml" + +[imports.zcash] +url = "https://raw.githubusercontent.com/zcash/rust-ecosystem/main/supply-chain/audits.toml" + +[[exemptions.bitflags]] +version = "1.3.2" +criteria = "safe-to-deploy" + +[[exemptions.crc]] +version = "3.0.1" +criteria = "safe-to-deploy" + +[[exemptions.crc-catalog]] +version = "2.4.0" +criteria = "safe-to-deploy" + +[[exemptions.libudev]] +version = "0.3.0" +criteria = "safe-to-deploy" + +[[exemptions.libudev-sys]] +version = "0.1.4" +criteria = "safe-to-deploy" + +[[exemptions.nix]] +version = "0.26.4" +criteria = "safe-to-deploy" + +[[exemptions.once_cell]] +version = "1.18.0" +criteria = "safe-to-deploy" + +[[exemptions.serialport]] +version = "4.2.2" +criteria = "safe-to-deploy" + +[[exemptions.strsim]] +version = "0.10.0" +criteria = "safe-to-deploy" + +[[exemptions.tracing]] +version = "0.1.40" +criteria = "safe-to-deploy" + +[[exemptions.tracing-attributes]] +version = "0.1.27" +criteria = "safe-to-deploy" + +[[exemptions.tracing-core]] +version = "0.1.32" +criteria = "safe-to-deploy" + +[[exemptions.tracing-log]] +version = "0.2.0" +criteria = "safe-to-deploy" + +[[exemptions.winapi]] +version = "0.3.9" +criteria = "safe-to-deploy" + +[[exemptions.winapi-i686-pc-windows-gnu]] +version = "0.4.0" +criteria = "safe-to-deploy" + +[[exemptions.winapi-x86_64-pc-windows-gnu]] +version = "0.4.0" +criteria = "safe-to-deploy" diff --git a/src/bestool/supply-chain/imports.lock b/src/bestool/supply-chain/imports.lock new file mode 100644 index 0000000..595672a --- /dev/null +++ b/src/bestool/supply-chain/imports.lock @@ -0,0 +1,495 @@ + +# cargo-vet imports lock + +[[publisher.aho-corasick]] +version = "1.1.2" +when = "2023-10-09" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.anstream]] +version = "0.6.11" +when = "2024-01-18" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.anstyle]] +version = "1.0.6" +when = "2024-02-05" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.anstyle-parse]] +version = "0.2.3" +when = "2023-12-04" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.anstyle-query]] +version = "1.0.2" +when = "2023-12-08" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.anstyle-wincon]] +version = "3.0.2" +when = "2023-12-04" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.clap]] +version = "4.5.1" +when = "2024-02-16" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.clap_builder]] +version = "4.5.1" +when = "2024-02-16" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.clap_derive]] +version = "4.5.0" +when = "2024-02-08" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.clap_lex]] +version = "0.7.0" +when = "2024-02-08" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.colorchoice]] +version = "1.0.0" +when = "2023-04-13" +user-id = 6743 +user-login = "epage" +user-name = "Ed Page" + +[[publisher.core-foundation-sys]] +version = "0.8.4" +when = "2023-04-03" +user-id = 5946 +user-login = "jrmuizel" +user-name = "Jeff Muizelaar" + +[[publisher.libc]] +version = "0.2.146" +when = "2023-06-06" +user-id = 2915 +user-login = "Amanieu" +user-name = "Amanieu d'Antras" + +[[publisher.mach2]] +version = "0.4.2" +when = "2023-12-19" +user-id = 51017 +user-login = "JohnTitor" +user-name = "Yuki Okushi" + +[[publisher.memchr]] +version = "2.7.1" +when = "2023-12-28" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.proc-macro2]] +version = "1.0.78" +when = "2024-01-21" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.quote]] +version = "1.0.35" +when = "2024-01-02" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.regex]] +version = "1.10.3" +when = "2024-01-21" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.regex-automata]] +version = "0.4.5" +when = "2024-01-25" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.regex-syntax]] +version = "0.8.2" +when = "2023-10-14" +user-id = 189 +user-login = "BurntSushi" +user-name = "Andrew Gallant" + +[[publisher.scopeguard]] +version = "1.2.0" +when = "2023-07-17" +user-id = 2915 +user-login = "Amanieu" +user-name = "Amanieu d'Antras" + +[[publisher.smallvec]] +version = "1.13.1" +when = "2024-01-19" +user-id = 2017 +user-login = "mbrubeck" +user-name = "Matt Brubeck" + +[[publisher.syn]] +version = "2.0.49" +when = "2024-02-16" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.thiserror]] +version = "1.0.57" +when = "2024-02-11" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.thiserror-impl]] +version = "1.0.57" +when = "2024-02-11" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.thread_local]] +version = "1.1.7" +when = "2023-02-12" +user-id = 2915 +user-login = "Amanieu" +user-name = "Amanieu d'Antras" + +[[publisher.unicode-ident]] +version = "1.0.12" +when = "2023-09-13" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.valuable]] +version = "0.1.0" +when = "2022-01-03" +user-id = 10 +user-login = "carllerche" +user-name = "Carl Lerche" + +[[publisher.windows-sys]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows-targets]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_aarch64_gnullvm]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_aarch64_msvc]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_i686_gnu]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_i686_msvc]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_x86_64_gnu]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_x86_64_gnullvm]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[publisher.windows_x86_64_msvc]] +version = "0.52.0" +when = "2023-11-15" +user-id = 64539 +user-login = "kennykerr" +user-name = "Kenny Kerr" + +[[audits.bytecode-alliance.audits.bitflags]] +who = "Jamey Sharp " +criteria = "safe-to-deploy" +delta = "2.1.0 -> 2.2.1" +notes = """ +This version adds unsafe impls of traits from the bytemuck crate when built +with that library enabled, but I believe the impls satisfy the documented +safety requirements for bytemuck. The other changes are minor. +""" + +[[audits.bytecode-alliance.audits.bitflags]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "2.3.2 -> 2.3.3" +notes = """ +Nothing outside the realm of what one would expect from a bitflags generator, +all as expected. +""" + +[[audits.bytecode-alliance.audits.cfg-if]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "1.0.0" +notes = "I am the author of this crate." + +[[audits.bytecode-alliance.audits.core-foundation-sys]] +who = "Dan Gohman " +criteria = "safe-to-deploy" +delta = "0.8.4 -> 0.8.6" +notes = """ +The changes here are all typical bindings updates: new functions, types, and +constants. I have not audited all the bindings for ABI conformance. +""" + +[[audits.bytecode-alliance.audits.heck]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +version = "0.4.0" +notes = "Contains `forbid_unsafe` and only uses `std::fmt` from the standard library. Otherwise only contains string manipulation." + +[[audits.bytecode-alliance.audits.libc]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.2.146 -> 0.2.147" +notes = "Only new type definitions and updating others for some platforms, no major changes" + +[[audits.bytecode-alliance.audits.libc]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.2.148 -> 0.2.149" +notes = "Lots of new functions and constants for new platforms and nothing out of the ordinary for what one would expect of the `libc` crate." + +[[audits.bytecode-alliance.audits.libc]] +who = "Dan Gohman " +criteria = "safe-to-deploy" +delta = "0.2.149 -> 0.2.151" +notes = "More new functions, types, and constants, as is usual for the `libc` crate, as well as various minor code cleanups." + +[[audits.bytecode-alliance.audits.libc]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.2.151 -> 0.2.153" +notes = "More bindings for more platforms. I have not verified that everything is exactly as-is on the platform as specified but nothing major is otherwise introduced as part of this bump." + +[[audits.bytecode-alliance.audits.nu-ansi-term]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.46.0" +notes = "one use of unsafe to call windows specific api to get console handle." + +[[audits.bytecode-alliance.audits.overload]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.1.1" +notes = "small crate, only defines macro-rules!, nicely documented as well" + +[[audits.bytecode-alliance.audits.pkg-config]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.3.25" +notes = "This crate shells out to the pkg-config executable, but it appears to sanitize inputs reasonably." + +[[audits.bytecode-alliance.audits.pkg-config]] +who = "Alex Crichton " +criteria = "safe-to-deploy" +delta = "0.3.26 -> 0.3.29" +notes = """ +No `unsafe` additions or anything outside of the purview of the crate in this +change. +""" + +[[audits.bytecode-alliance.audits.sharded-slab]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.1.4" +notes = "I always really enjoy reading eliza's code, she left perfect comments at every use of unsafe." + +[[audits.bytecode-alliance.audits.tracing-subscriber]] +who = "Pat Hickey " +criteria = "safe-to-deploy" +version = "0.3.17" + +[audits.fermyon.audits] + +[[audits.google.audits.pin-project-lite]] +who = "David Koloski " +criteria = "safe-to-deploy" +version = "0.2.9" +notes = "Reviewed on https://fxrev.dev/824504" +aggregated-from = "https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/third_party/rust_crates/supply-chain/audits.toml?format=TEXT" + +[[audits.google.audits.utf8parse]] +who = "David Koloski " +criteria = "safe-to-deploy" +version = "0.2.1" +notes = "Reviewed on https://fxrev.dev/904811" +aggregated-from = "https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/third_party/rust_crates/supply-chain/audits.toml?format=TEXT" + +[[audits.isrg.audits.once_cell]] +who = "Brandon Pitman " +criteria = "safe-to-deploy" +delta = "1.18.0 -> 1.19.0" + +[[audits.mozilla.wildcard-audits.core-foundation-sys]] +who = "Bobby Holley " +criteria = "safe-to-deploy" +user-id = 5946 # Jeff Muizelaar (jrmuizel) +start = "2020-10-14" +end = "2023-05-04" +renew = false +notes = "I've reviewed every source contribution that was neither authored nor reviewed by Mozilla." +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Alex Franchuk " +criteria = "safe-to-deploy" +delta = "1.3.2 -> 2.0.2" +notes = "Removal of some unsafe code/methods. No changes to externals, just some refactoring (mostly internal)." +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Nicolas Silva " +criteria = "safe-to-deploy" +delta = "2.0.2 -> 2.1.0" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Teodor Tanasoaia " +criteria = "safe-to-deploy" +delta = "2.2.1 -> 2.3.2" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "2.3.3 -> 2.4.0" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.bitflags]] +who = "Jan-Erik Rediger " +criteria = "safe-to-deploy" +delta = "2.4.0 -> 2.4.1" +notes = "Only allowing new clippy lints" +aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.heck]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "0.4.0 -> 0.4.1" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.lazy_static]] +who = "Nika Layzell " +criteria = "safe-to-deploy" +version = "1.4.0" +notes = "I have read over the macros, and audited the unsafe code." +aggregated-from = "https://raw.githubusercontent.com/mozilla/cargo-vet/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.libc]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "0.2.147 -> 0.2.148" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.log]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +version = "0.4.17" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.mozilla.audits.log]] +who = "Jan-Erik Rediger " +criteria = "safe-to-deploy" +delta = "0.4.17 -> 0.4.18" +notes = "One dependency removed, others updated (which we don't rely on), some APIs (which we don't use) changed." +aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml" + +[[audits.mozilla.audits.pkg-config]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "0.3.25 -> 0.3.26" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + +[[audits.zcash.audits.log]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.4.18 -> 0.4.19" +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" + +[[audits.zcash.audits.log]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.4.19 -> 0.4.20" +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" + +[[audits.zcash.audits.pin-project-lite]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.2.9 -> 0.2.13" +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" + +[[audits.zcash.audits.sharded-slab]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.1.4 -> 0.1.7" +notes = "Only change to an `unsafe` block is to fix a clippy lint." +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" + +[[audits.zcash.audits.tracing-subscriber]] +who = "Jack Grigg " +criteria = "safe-to-deploy" +delta = "0.3.17 -> 0.3.18" +aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml" From c5caf37e335bd65399ba2fb6be306050a5088ee0 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sat, 9 Mar 2024 23:59:42 +0000 Subject: [PATCH 03/16] refactor: Add initial `lib.rs` stub for `beslib` Signed-off-by: Dom Rodriguez --- src/beslib/src/lib.rs | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/beslib/src/lib.rs diff --git a/src/beslib/src/lib.rs b/src/beslib/src/lib.rs new file mode 100644 index 0000000..e69de29 From cc3103b448586dae734641558df363c9947b8028 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sun, 10 Mar 2024 00:00:49 +0000 Subject: [PATCH 04/16] refactor: Add initial clap handling modules Signed-off-by: Dom Rodriguez --- src/bestool/src/command.rs | 24 ++++++++++++ src/bestool/src/command/flash.rs | 21 +++++++++++ src/bestool/src/command/flash/read_flash.rs | 5 +++ src/bestool/src/command/flash/write_flash.rs | 5 +++ src/bestool/src/command/serial.rs | 22 +++++++++++ src/bestool/src/command/serial/monitor.rs | 5 +++ src/bestool/src/main.rs | 39 ++++++++++++++++++++ 7 files changed, 121 insertions(+) create mode 100644 src/bestool/src/command.rs create mode 100644 src/bestool/src/command/flash.rs create mode 100644 src/bestool/src/command/flash/read_flash.rs create mode 100644 src/bestool/src/command/flash/write_flash.rs create mode 100644 src/bestool/src/command/serial.rs create mode 100644 src/bestool/src/command/serial/monitor.rs create mode 100644 src/bestool/src/main.rs diff --git a/src/bestool/src/command.rs b/src/bestool/src/command.rs new file mode 100644 index 0000000..0699277 --- /dev/null +++ b/src/bestool/src/command.rs @@ -0,0 +1,24 @@ +use std::io::Result; +use clap::Subcommand; + +pub(crate) mod flash; +pub(crate) mod serial; + +#[derive(Subcommand)] +#[command(infer_subcommands = true)] +pub(crate) enum BestoolCmd { + #[command(flatten)] + Flash(flash::Cmd), + + #[command(flatten)] + Serial(serial::Cmd), +} + +impl BestoolCmd { + pub(crate) fn run(self) -> Result<()> { + match self { + Self::Flash(flash) => flash.run(), + Self::Serial(serial) => serial.run(), + } + } +} diff --git a/src/bestool/src/command/flash.rs b/src/bestool/src/command/flash.rs new file mode 100644 index 0000000..076f10a --- /dev/null +++ b/src/bestool/src/command/flash.rs @@ -0,0 +1,21 @@ +use std::io::Result; +use clap::Subcommand; + +pub(crate) mod write_flash; +pub(crate) mod read_flash; + +#[derive(Subcommand, Debug)] +#[command(infer_subcommands = true)] +pub(crate) enum Cmd { + WriteFlash, // Use `(write_flash::Cmd)` (with args `--monitor`) + ReadFlash, // Use `(read_flash::Cmd)` +} + +impl Cmd { + pub(crate) fn run(self) -> Result<()> { + match self { + Self::WriteFlash => write_flash::run(), + Self::ReadFlash => read_flash::run(), + } + } +} diff --git a/src/bestool/src/command/flash/read_flash.rs b/src/bestool/src/command/flash/read_flash.rs new file mode 100644 index 0000000..ac68191 --- /dev/null +++ b/src/bestool/src/command/flash/read_flash.rs @@ -0,0 +1,5 @@ +use std::io::Result; + +pub(super) fn run() -> Result<()> { + unimplemented!() +} diff --git a/src/bestool/src/command/flash/write_flash.rs b/src/bestool/src/command/flash/write_flash.rs new file mode 100644 index 0000000..ac68191 --- /dev/null +++ b/src/bestool/src/command/flash/write_flash.rs @@ -0,0 +1,5 @@ +use std::io::Result; + +pub(super) fn run() -> Result<()> { + unimplemented!() +} diff --git a/src/bestool/src/command/serial.rs b/src/bestool/src/command/serial.rs new file mode 100644 index 0000000..f01fe5f --- /dev/null +++ b/src/bestool/src/command/serial.rs @@ -0,0 +1,22 @@ +use std::io::Result; + +use clap::Subcommand; + +pub(crate) mod enumerate_serial_ports; +pub(crate) mod monitor; + +#[derive(Subcommand, Debug)] +#[command(infer_subcommands = true)] +pub(crate) enum Cmd { + EnumerateSerialPorts, + Monitor, // Add `(monitor::Cmd)` here. +} + +impl Cmd { + pub(crate) fn run(self) -> Result<()> { + match self { + Self::EnumerateSerialPorts => enumerate_serial_ports::run(), + Self::Monitor => monitor::run(), + } + } +} diff --git a/src/bestool/src/command/serial/monitor.rs b/src/bestool/src/command/serial/monitor.rs new file mode 100644 index 0000000..c743333 --- /dev/null +++ b/src/bestool/src/command/serial/monitor.rs @@ -0,0 +1,5 @@ +use std::io::Result; + +pub fn run() -> Result<()> { + unimplemented!() +} diff --git a/src/bestool/src/main.rs b/src/bestool/src/main.rs new file mode 100644 index 0000000..f6a89f1 --- /dev/null +++ b/src/bestool/src/main.rs @@ -0,0 +1,39 @@ +#![warn(clippy::pedantic, clippy::nursery)] + +use clap::Parser; +pub(crate) mod command; +use command::BestoolCmd; +use std::io::Result; + +const VERSION: &'static str = env!("CARGO_PKG_VERSION"); + +static HELP_TEMPLATE: &'static str = "\ +{before-help}{name} {version} +{author} +{about} + +{usage-heading} + {usage} + +{all-args}{after-help}"; + +#[derive(Parser)] +#[command( + author = "Ben V. Brown ", + version = VERSION, + help_template = HELP_TEMPLATE, +)] +struct Bestool { + #[command(subcommand)] + bestool: BestoolCmd, +} + +impl Bestool { + fn run(self) -> Result<()> { + self.bestool.run() + } +} + +fn main() -> Result<()> { + Ok(Bestool::parse().run()?) +} From 65d0c0ef8f4e28f396e4cc53c2c84dc7ddf8ffc8 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sun, 10 Mar 2024 00:01:02 +0000 Subject: [PATCH 05/16] refactor: Add refactored serial port enumeration code Signed-off-by: Dom Rodriguez --- .../command/serial/enumerate_serial_ports.rs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/bestool/src/command/serial/enumerate_serial_ports.rs diff --git a/src/bestool/src/command/serial/enumerate_serial_ports.rs b/src/bestool/src/command/serial/enumerate_serial_ports.rs new file mode 100644 index 0000000..5dee2c8 --- /dev/null +++ b/src/bestool/src/command/serial/enumerate_serial_ports.rs @@ -0,0 +1,36 @@ +use serialport::SerialPortType; +use std::io::Result; + +fn get_port_type(port: SerialPortType) -> Option { + match port { + #[cfg(windows)] + SerialPortType::UsbPort(info) => Some(format!("USB {:04X}:{:04X}", info.vid, info.pid)), + #[cfg(unix)] + SerialPortType::UsbPort(info) => Some(format!("USB {:04x}:{:04x}", info.vid, info.pid)), + SerialPortType::PciPort => Some(String::from("PCI")), + SerialPortType::BluetoothPort => Some(String::from("Bluetooth")), + SerialPortType::Unknown => None, + } +} + +pub fn run() -> Result<()> { + match serialport::available_ports() { + Ok(ports) => { + if ports.is_empty() { + eprintln!("No serial ports found"); + return Ok(()); + } + println!("Detected serial ports and their type:"); + for port in ports { + if let Some(port_type) = get_port_type(port.port_type) { + println!("{}\t[{}]", port.port_name, port_type); + } else { + continue; + } + } + } + Err(e) => eprintln!("Could not list ports due to {e:?}"), + } + + Ok(()) +} From 88d319f7bd1eff9fcae24bc4affec79be2ef3028 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sat, 16 Mar 2024 14:00:13 +0000 Subject: [PATCH 06/16] refactor: Add partial rewrite of `message.rs` and checksum utils Signed-off-by: Dom Rodriguez --- src/beslib/src/lib.rs | 3 + src/beslib/src/message.rs | 98 ++++++++++++++++++++++++++++++++ src/beslib/src/utils.rs | 3 + src/beslib/src/utils/checksum.rs | 25 ++++++++ 4 files changed, 129 insertions(+) create mode 100644 src/beslib/src/message.rs create mode 100644 src/beslib/src/utils.rs create mode 100644 src/beslib/src/utils/checksum.rs diff --git a/src/beslib/src/lib.rs b/src/beslib/src/lib.rs index e69de29..299f328 100644 --- a/src/beslib/src/lib.rs +++ b/src/beslib/src/lib.rs @@ -0,0 +1,3 @@ +pub mod consts; +pub mod message; +pub mod utils; diff --git a/src/beslib/src/message.rs b/src/beslib/src/message.rs new file mode 100644 index 0000000..acb8406 --- /dev/null +++ b/src/beslib/src/message.rs @@ -0,0 +1,98 @@ +use std::borrow::BorrowMut; + +use tracing::{debug, error, info, warn}; + +#[derive(Default, Debug, Eq, PartialEq, Clone, Copy)] +#[repr(u8)] +pub enum MessageKind { + DeviceCommand = 0x00, // General commands to the device + FlashRead = 0x03, // Debugging message that lets you dump from address space + Sync = 0x50, // Seems to be used at boot for locking with ROM + StartProgrammer = 0x53, + ProgrammerRunning = 0x54, + ProgrammerStart = 0x55, + ProgrammerInit = 0x60, + EraseBurnStart = 0x61, + FlashBurnData = 0x62, + FlashCommand = 0x65, // Suspect used to push extra commands to flash controller/chip/die + #[default] + UnknownOrInfo = 0x66, // Unknown at this point in time, but references "OR Info"; suspect NOR flash info +} + +impl From for u8 { + fn from(v: MessageKind) -> Self { + v as Self + } +} + +impl From for MessageKind { + fn from(v: u8) -> Self { + match v { + 0x00 => Self::DeviceCommand, + 0x03 => Self::FlashRead, + 0x50 => Self::Sync, + 0x53 => Self::StartProgrammer, + 0x54 => Self::ProgrammerRunning, + 0x55 => Self::ProgrammerStart, + 0x60 => Self::ProgrammerInit, + 0x61 => Self::EraseBurnStart, + 0x62 => Self::FlashBurnData, + 0x65 => Self::FlashCommand, + 0x66 | _ => Self::UnknownOrInfo, + } + } +} + +#[derive(Debug, Eq, PartialEq, Clone)] +pub struct BesMessage { + pub sync: u8, + pub msg_type: MessageKind, + pub payload: Vec, + pub checksum: u8, +} + +impl From<&mut BesMessage> for Vec { + fn from(value: &mut BesMessage) -> Self { + value.into() + } +} + +impl From> for BesMessage { + fn from(v: Vec) -> Self { + let mut msg = BesMessage { + sync: v[0], + msg_type: MessageKind::Sync, + payload: vec![], + checksum: v[v.len() - 1], + }; + + if let Ok(msg_type) = v[1].try_into() { + msg.msg_type = msg_type; + } else { + eprintln!("Encountered an unknown packet type: 0x{:02x}", v[1]); + } + + msg.payload = v[2..v.len() - 1].to_vec(); + + msg + } +} +impl Into> for BesMessage { + fn into(mut self) -> Vec { + let mut packet: Vec = vec![]; + packet.push(self.sync); + packet.push(self.msg_type.into()); + packet.append(&mut self.payload); + packet.push(self.checksum); + + packet + } +} + +impl BesMessage { + pub fn set_checksum(&mut self) { + let mut v: Vec = self.into(); + v.pop(); + self.checksum = crate::utils::calculate_message_checksum(&v); + } +} diff --git a/src/beslib/src/utils.rs b/src/beslib/src/utils.rs new file mode 100644 index 0000000..846a679 --- /dev/null +++ b/src/beslib/src/utils.rs @@ -0,0 +1,3 @@ +mod checksum; + +pub use self::checksum::*; diff --git a/src/beslib/src/utils/checksum.rs b/src/beslib/src/utils/checksum.rs new file mode 100644 index 0000000..1314fc8 --- /dev/null +++ b/src/beslib/src/utils/checksum.rs @@ -0,0 +1,25 @@ +use std::io::Error as BESLinkError; + +pub fn validate_packet_checksum(packet: &[u8]) -> Result<(), BESLinkError> { + let checksum = calculate_message_checksum(&packet[1..packet.len()]); + if checksum == packet[packet.len() - 1] { + return Ok(()); + } +// let e = BESLinkError::BadChecksumError { +// failed_packet: packet.to_vec(), +// got: packet[packet.len() - 1], +// wanted: checksum, +// }; +// warn!("Bad Checksum!! {:?}", e); + + Err(BESLinkError::other("Error.")) +} + +pub fn calculate_message_checksum(packet: &[u8]) -> u8 { + let mut sum: u32 = 0; + for b in packet { + sum += u32::from(*b); + sum &= 0xFF; + } + (0xFF - sum) as u8 +} From e2c757ac987884898f5e753cb747a788111eca78 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sat, 16 Mar 2024 14:00:47 +0000 Subject: [PATCH 07/16] refactor: Add common BES consts Signed-off-by: Dom Rodriguez --- src/beslib/src/consts.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/beslib/src/consts.rs diff --git a/src/beslib/src/consts.rs b/src/beslib/src/consts.rs new file mode 100644 index 0000000..a1a00a8 --- /dev/null +++ b/src/beslib/src/consts.rs @@ -0,0 +1,6 @@ +pub struct BesConsts; + +impl BesConsts { + pub const BES_DEFAULT_PROGRAMMING_BAUDRATE: u32 = 921_600; + pub const BES_SYNC: u8 = 0xBE; +} From db704ed226567b905491852619ee4492334a7646 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sat, 16 Mar 2024 14:01:10 +0000 Subject: [PATCH 08/16] refactor(beslib): Add `tracing` dep Signed-off-by: Dom Rodriguez --- src/beslib/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/beslib/Cargo.toml b/src/beslib/Cargo.toml index adca061..59d053a 100644 --- a/src/beslib/Cargo.toml +++ b/src/beslib/Cargo.toml @@ -12,3 +12,4 @@ version = { workspace = true } [dependencies] crc = { workspace = true } serialport = { workspace = true } +tracing = { workspace = true } From 9b5eb9260b322bb53b6ee16569d391e1071f6963 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Sat, 16 Mar 2024 14:31:53 +0000 Subject: [PATCH 09/16] chore(cargo): Bump Cargo.lock Signed-off-by: Dom Rodriguez --- Cargo.lock | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index ca28eda..807019a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,6 +65,7 @@ version = "0.3.0" dependencies = [ "crc", "serialport", + "tracing", ] [[package]] @@ -230,6 +231,18 @@ dependencies = [ "libc", ] +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + [[package]] name = "pkg-config" version = "0.3.30" @@ -345,6 +358,37 @@ dependencies = [ "syn", ] +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + [[package]] name = "unescaper" version = "0.1.4" From 700d8444f7ca1283819dcc0fbed9ab5620ac7c9c Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Mon, 18 Mar 2024 21:38:18 +0000 Subject: [PATCH 10/16] chore(clippy): Fix Clippy lints in executable crate --- src/bestool/src/command.rs | 14 +++++++------- src/bestool/src/command/flash.rs | 10 +++++----- src/bestool/src/command/flash/read_flash.rs | 2 +- src/bestool/src/command/flash/write_flash.rs | 2 +- src/bestool/src/command/serial.rs | 8 ++++---- .../src/command/serial/enumerate_serial_ports.rs | 12 ++++++------ src/bestool/src/main.rs | 10 +++++----- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/bestool/src/command.rs b/src/bestool/src/command.rs index 0699277..f56315e 100644 --- a/src/bestool/src/command.rs +++ b/src/bestool/src/command.rs @@ -1,21 +1,21 @@ -use std::io::Result; use clap::Subcommand; +use std::io::Result; -pub(crate) mod flash; -pub(crate) mod serial; +mod flash; +mod serial; #[derive(Subcommand)] #[command(infer_subcommands = true)] -pub(crate) enum BestoolCmd { - #[command(flatten)] - Flash(flash::Cmd), +pub enum BestoolCmd { + #[command(flatten)] + Flash(flash::Cmd), #[command(flatten)] Serial(serial::Cmd), } impl BestoolCmd { - pub(crate) fn run(self) -> Result<()> { + pub fn run(self) -> Result<()> { match self { Self::Flash(flash) => flash.run(), Self::Serial(serial) => serial.run(), diff --git a/src/bestool/src/command/flash.rs b/src/bestool/src/command/flash.rs index 076f10a..66555fc 100644 --- a/src/bestool/src/command/flash.rs +++ b/src/bestool/src/command/flash.rs @@ -1,18 +1,18 @@ -use std::io::Result; use clap::Subcommand; +use std::io::Result; -pub(crate) mod write_flash; -pub(crate) mod read_flash; +mod read_flash; +mod write_flash; #[derive(Subcommand, Debug)] #[command(infer_subcommands = true)] -pub(crate) enum Cmd { +pub enum Cmd { WriteFlash, // Use `(write_flash::Cmd)` (with args `--monitor`) ReadFlash, // Use `(read_flash::Cmd)` } impl Cmd { - pub(crate) fn run(self) -> Result<()> { + pub fn run(self) -> Result<()> { match self { Self::WriteFlash => write_flash::run(), Self::ReadFlash => read_flash::run(), diff --git a/src/bestool/src/command/flash/read_flash.rs b/src/bestool/src/command/flash/read_flash.rs index ac68191..c743333 100644 --- a/src/bestool/src/command/flash/read_flash.rs +++ b/src/bestool/src/command/flash/read_flash.rs @@ -1,5 +1,5 @@ use std::io::Result; -pub(super) fn run() -> Result<()> { +pub fn run() -> Result<()> { unimplemented!() } diff --git a/src/bestool/src/command/flash/write_flash.rs b/src/bestool/src/command/flash/write_flash.rs index ac68191..c743333 100644 --- a/src/bestool/src/command/flash/write_flash.rs +++ b/src/bestool/src/command/flash/write_flash.rs @@ -1,5 +1,5 @@ use std::io::Result; -pub(super) fn run() -> Result<()> { +pub fn run() -> Result<()> { unimplemented!() } diff --git a/src/bestool/src/command/serial.rs b/src/bestool/src/command/serial.rs index f01fe5f..8474fca 100644 --- a/src/bestool/src/command/serial.rs +++ b/src/bestool/src/command/serial.rs @@ -2,18 +2,18 @@ use std::io::Result; use clap::Subcommand; -pub(crate) mod enumerate_serial_ports; -pub(crate) mod monitor; +mod enumerate_serial_ports; +mod monitor; #[derive(Subcommand, Debug)] #[command(infer_subcommands = true)] -pub(crate) enum Cmd { +pub enum Cmd { EnumerateSerialPorts, Monitor, // Add `(monitor::Cmd)` here. } impl Cmd { - pub(crate) fn run(self) -> Result<()> { + pub fn run(self) -> Result<()> { match self { Self::EnumerateSerialPorts => enumerate_serial_ports::run(), Self::Monitor => monitor::run(), diff --git a/src/bestool/src/command/serial/enumerate_serial_ports.rs b/src/bestool/src/command/serial/enumerate_serial_ports.rs index 5dee2c8..c958ca2 100644 --- a/src/bestool/src/command/serial/enumerate_serial_ports.rs +++ b/src/bestool/src/command/serial/enumerate_serial_ports.rs @@ -18,19 +18,19 @@ pub fn run() -> Result<()> { Ok(ports) => { if ports.is_empty() { eprintln!("No serial ports found"); - return Ok(()); } println!("Detected serial ports and their type:"); for port in ports { if let Some(port_type) = get_port_type(port.port_type) { println!("{}\t[{}]", port.port_name, port_type); - } else { - continue; } } + Ok(()) + } + Err(e) => { + eprintln!("Could not list ports due to {e:?}"); + // Implement err. + Ok(()) } - Err(e) => eprintln!("Could not list ports due to {e:?}"), } - - Ok(()) } diff --git a/src/bestool/src/main.rs b/src/bestool/src/main.rs index f6a89f1..cfa7002 100644 --- a/src/bestool/src/main.rs +++ b/src/bestool/src/main.rs @@ -1,13 +1,13 @@ -#![warn(clippy::pedantic, clippy::nursery)] +#![warn(clippy::all)] use clap::Parser; -pub(crate) mod command; +mod command; use command::BestoolCmd; use std::io::Result; -const VERSION: &'static str = env!("CARGO_PKG_VERSION"); +const VERSION: &str = env!("CARGO_PKG_VERSION"); -static HELP_TEMPLATE: &'static str = "\ +static HELP_TEMPLATE: &str = "\ {before-help}{name} {version} {author} {about} @@ -35,5 +35,5 @@ impl Bestool { } fn main() -> Result<()> { - Ok(Bestool::parse().run()?) + Bestool::parse().run() } From 41d5fefbef2ee32d715c2ab6c1b78f820c961898 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Tue, 19 Mar 2024 23:08:03 +0000 Subject: [PATCH 11/16] refactor: Fix recursive loop with `From`/`Into` traits Amateur mistake. --- src/beslib/src/message.rs | 49 ++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/beslib/src/message.rs b/src/beslib/src/message.rs index acb8406..708b40d 100644 --- a/src/beslib/src/message.rs +++ b/src/beslib/src/message.rs @@ -51,9 +51,43 @@ pub struct BesMessage { pub checksum: u8, } +impl From for Vec { + fn from(mut val: BesMessage) -> Self { + debug!("Converting BesMessage to Vec"); + let mut packet: Vec = vec![]; + packet.push(val.sync); + packet.push(val.msg_type.into()); + packet.append(&mut val.payload); + packet.push(val.checksum); + + packet + } +} + impl From<&mut BesMessage> for Vec { - fn from(value: &mut BesMessage) -> Self { - value.into() + fn from(val: &mut BesMessage) -> Self { + debug!("Converting &mut BesMessage to Vec"); + let mut packet: Vec = vec![]; + packet.push(val.sync); + packet.push(val.msg_type.into()); + packet.append(&mut val.payload); + packet.push(val.checksum); + + packet + } +} + +impl From<&BesMessage> for Vec { + fn from(val: &BesMessage) -> Self { + debug!("Converting &BesMessage to Vec"); + let mut val = val.clone(); + let mut packet: Vec = vec![]; + packet.push(val.sync); + packet.push(val.msg_type.into()); + packet.append(&mut val.payload); + packet.push(val.checksum); + + packet } } @@ -77,17 +111,6 @@ impl From> for BesMessage { msg } } -impl Into> for BesMessage { - fn into(mut self) -> Vec { - let mut packet: Vec = vec![]; - packet.push(self.sync); - packet.push(self.msg_type.into()); - packet.append(&mut self.payload); - packet.push(self.checksum); - - packet - } -} impl BesMessage { pub fn set_checksum(&mut self) { From af5db3bab7fbd3fd370540ae27291a589168a853 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Tue, 19 Mar 2024 23:08:36 +0000 Subject: [PATCH 12/16] refactor: Simplify `msg_type` assignment code --- src/beslib/src/message.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/beslib/src/message.rs b/src/beslib/src/message.rs index 708b40d..8eef373 100644 --- a/src/beslib/src/message.rs +++ b/src/beslib/src/message.rs @@ -100,12 +100,7 @@ impl From> for BesMessage { checksum: v[v.len() - 1], }; - if let Ok(msg_type) = v[1].try_into() { - msg.msg_type = msg_type; - } else { - eprintln!("Encountered an unknown packet type: 0x{:02x}", v[1]); - } - + msg.msg_type = v[1].into(); msg.payload = v[2..v.len() - 1].to_vec(); msg From d9656f02b922581689cc388f19854d7952b556fc Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Tue, 19 Mar 2024 23:09:03 +0000 Subject: [PATCH 13/16] fix: Use wildcard match, with `Default` trait --- src/beslib/src/message.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/beslib/src/message.rs b/src/beslib/src/message.rs index 8eef373..bedebae 100644 --- a/src/beslib/src/message.rs +++ b/src/beslib/src/message.rs @@ -38,7 +38,7 @@ impl From for MessageKind { 0x61 => Self::EraseBurnStart, 0x62 => Self::FlashBurnData, 0x65 => Self::FlashCommand, - 0x66 | _ => Self::UnknownOrInfo, + _ => Self::default(), } } } From ce881f7eea418d91f9ffac2450342e66ac866687 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Tue, 19 Mar 2024 23:09:53 +0000 Subject: [PATCH 14/16] feat: Add `send_packet` method to `BesMessage` struct Discussed with @Ralim over Telegram, and initial feedback was to use `Write` trait, as for a transport-agnostic writer. However, I'm not sure how this will fit in with `serialport`. --- src/beslib/src/message.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/beslib/src/message.rs b/src/beslib/src/message.rs index bedebae..8974e71 100644 --- a/src/beslib/src/message.rs +++ b/src/beslib/src/message.rs @@ -1,4 +1,4 @@ -use std::borrow::BorrowMut; +use std::io::Write; use tracing::{debug, error, info, warn}; @@ -113,4 +113,27 @@ impl BesMessage { v.pop(); self.checksum = crate::utils::calculate_message_checksum(&v); } + + pub fn send_packet(&self, writer: &mut dyn Write) -> std::io::Result<()> { + let packet: Vec; + + if let Ok(p) = self.try_into() { + packet = p; + } else { + panic!("Failed to convert BesMessage to Vec"); + }// Return Error. + + return match writer.write_all(packet.as_slice()) { + Ok(_) => { + debug!("Sent message to chip: {packet:X?}", packet = packet); + debug!("Wrote {len} bytes.", len = packet.len()); + + // Serial port should be flushed? + + info!("Sent message type: {:?}", self.msg_type); + Ok(()) + } + Err(e) => Err(e), + }; + } } From bcde41e031c21d97c6f700092061004f9c5446c3 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Tue, 19 Mar 2024 23:11:18 +0000 Subject: [PATCH 15/16] chore: Remove unused imports and testing `debug!` invocations --- src/beslib/src/message.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/beslib/src/message.rs b/src/beslib/src/message.rs index 8974e71..1393499 100644 --- a/src/beslib/src/message.rs +++ b/src/beslib/src/message.rs @@ -1,6 +1,6 @@ use std::io::Write; -use tracing::{debug, error, info, warn}; +use tracing::{debug, info}; #[derive(Default, Debug, Eq, PartialEq, Clone, Copy)] #[repr(u8)] @@ -53,7 +53,6 @@ pub struct BesMessage { impl From for Vec { fn from(mut val: BesMessage) -> Self { - debug!("Converting BesMessage to Vec"); let mut packet: Vec = vec![]; packet.push(val.sync); packet.push(val.msg_type.into()); @@ -66,7 +65,6 @@ impl From for Vec { impl From<&mut BesMessage> for Vec { fn from(val: &mut BesMessage) -> Self { - debug!("Converting &mut BesMessage to Vec"); let mut packet: Vec = vec![]; packet.push(val.sync); packet.push(val.msg_type.into()); @@ -79,7 +77,6 @@ impl From<&mut BesMessage> for Vec { impl From<&BesMessage> for Vec { fn from(val: &BesMessage) -> Self { - debug!("Converting &BesMessage to Vec"); let mut val = val.clone(); let mut packet: Vec = vec![]; packet.push(val.sync); From fca9dcdbd27fed4d79e9c5f8e7ec85f6f6612869 Mon Sep 17 00:00:00 2001 From: Dom Rodriguez Date: Fri, 3 May 2024 19:20:38 +0100 Subject: [PATCH 16/16] refactor: Refactor `send` method --- src/beslib/src/message.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/beslib/src/message.rs b/src/beslib/src/message.rs index 1393499..9b20e77 100644 --- a/src/beslib/src/message.rs +++ b/src/beslib/src/message.rs @@ -1,5 +1,5 @@ -use std::io::Write; - +use std::io::{Result as IoResult, Write}; +use crate::utils::calculate_message_checksum; use tracing::{debug, info}; #[derive(Default, Debug, Eq, PartialEq, Clone, Copy)] @@ -111,21 +111,23 @@ impl BesMessage { self.checksum = crate::utils::calculate_message_checksum(&v); } - pub fn send_packet(&self, writer: &mut dyn Write) -> std::io::Result<()> { + pub fn send(self, out: &mut dyn Write) -> IoResult<()> + { let packet: Vec; - if let Ok(p) = self.try_into() { + #[allow(clippy::unnecessary_fallible_conversions)] + if let Ok(p) = self.clone().try_into() { packet = p; } else { panic!("Failed to convert BesMessage to Vec"); }// Return Error. - return match writer.write_all(packet.as_slice()) { + return match out.write_all(packet.as_slice()) { Ok(_) => { debug!("Sent message to chip: {packet:X?}", packet = packet); debug!("Wrote {len} bytes.", len = packet.len()); - // Serial port should be flushed? + // TODO: Should the caller flush the target device? (i.e, serial port). info!("Sent message type: {:?}", self.msg_type); Ok(())