├── .gitignore ├── .rustfmt.toml ├── Cargo.toml ├── README.md ├── src ├── dummy.rs ├── progress.rs ├── main.rs └── ftdi.rs ├── Cargo.lock └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width = 80 2 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rfsx" 3 | version = "0.1.0" 4 | edition = "2021" 5 | license = "MPL-2.0" 6 | authors = ["Matt Keeter "] 7 | 8 | [dependencies] 9 | anyhow = "1" 10 | clap = { version = "3", features = ["derive"] } 11 | ftdi = "0.1" 12 | indicatif = "0.16" 13 | libftdi1-sys = "1" 14 | parse_int = "0.6.0" 15 | xmodem = { git = "https://github.com/oxidecomputer/xmodem.rs/" } 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | `rfsx` is a simple XMODEM sender. 2 | 3 | It sidesteps the OS serial device (`/dev/tty.usbserial...`) in favor of using 4 | [`libftdi`](https://www.intra2net.com/en/developer/libftdi/). This lets us 5 | work around an apparent bug in the macOS serial driver, which cuts off midway 6 | through a large file transfer. 7 | 8 | For more details, see [this blog post](https://www.mattkeeter.com/blog/2022-05-31-xmodem/). 9 | -------------------------------------------------------------------------------- /src/dummy.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | use std::io::{Read, Result, Write}; 6 | 7 | use crate::ACK; 8 | 9 | pub enum Dummy { 10 | Start, 11 | Running, 12 | } 13 | 14 | pub fn new() -> Dummy { 15 | Dummy::Start 16 | } 17 | 18 | impl Read for Dummy { 19 | fn read(&mut self, buf: &mut [u8]) -> Result { 20 | if buf.is_empty() { 21 | return Ok(0); 22 | } 23 | match self { 24 | Self::Start => buf[0] = b'C', 25 | Self::Running => buf[0] = ACK, 26 | } 27 | Ok(1) 28 | } 29 | } 30 | 31 | impl Write for Dummy { 32 | fn write(&mut self, buf: &[u8]) -> Result { 33 | *self = Self::Running; 34 | Ok(buf.len()) 35 | } 36 | fn flush(&mut self) -> Result<()> { 37 | Ok(()) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/progress.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | use crate::ACK; 6 | use indicatif::ProgressBar; 7 | use std::io::{Read, Result, Write}; 8 | 9 | pub struct Progress(D, ProgressBar); 10 | 11 | impl Read for Progress { 12 | fn read(&mut self, buf: &mut [u8]) -> Result { 13 | let i = self.0.read(buf)?; 14 | self.1 15 | .inc(buf[0..i].iter().filter(|c| **c == ACK).count() as u64); 16 | Ok(i) 17 | } 18 | } 19 | 20 | impl Write for Progress { 21 | fn write(&mut self, buf: &[u8]) -> Result { 22 | self.0.write(buf) 23 | } 24 | fn flush(&mut self) -> Result<()> { 25 | self.0.flush() 26 | } 27 | } 28 | 29 | impl Progress { 30 | pub fn new(d: D, blocks: u64) -> Self { 31 | let bar = ProgressBar::new(blocks); 32 | Self(d, bar) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | use std::io::{Read, Write}; 6 | 7 | use anyhow::{anyhow, Context, Result}; 8 | use clap::Parser; 9 | 10 | mod dummy; 11 | mod ftdi; 12 | mod progress; 13 | 14 | const ACK: u8 = 0x06; 15 | 16 | fn run(dev: D, filename: &str) -> Result { 17 | let mut file = std::fs::File::open(filename) 18 | .context(format!("Could not open file '{}' to send", filename))?; 19 | let blocks = (file.metadata().unwrap().len() + 1023) / 1024; 20 | 21 | // Wrap the device in a snazzy progress bar 22 | let mut dev = progress::Progress::new(dev, blocks); 23 | 24 | let mut x = xmodem::Xmodem::new(); 25 | x.block_length = xmodem::BlockLength::OneK; 26 | x.send(&mut dev, &mut file).map_err(|e| anyhow!("{:?}", e)) 27 | } 28 | 29 | /// Simple XMODEM sender 30 | #[derive(Parser, Debug)] 31 | #[clap(author, version, about, long_about = None)] 32 | struct Args { 33 | /// Use a dummy backend 34 | #[clap(short, long)] 35 | dummy: bool, 36 | 37 | /// Vendor ID of USB device 38 | #[clap(short, long, conflicts_with = "dummy", 39 | parse(try_from_str=parse_int::parse))] 40 | vid: Option, 41 | 42 | /// Product ID of USB device 43 | #[clap(short, long, conflicts_with = "dummy", 44 | parse(try_from_str=parse_int::parse))] 45 | pid: Option, 46 | 47 | filename: String, 48 | } 49 | 50 | fn main() -> Result<()> { 51 | let args = Args::parse(); 52 | 53 | if args.dummy { 54 | run(dummy::new(), &args.filename) 55 | } else { 56 | run(ftdi::new(args.vid, args.pid)?, &args.filename) 57 | }?; 58 | Ok(()) 59 | } 60 | -------------------------------------------------------------------------------- /src/ftdi.rs: -------------------------------------------------------------------------------- 1 | // This Source Code Form is subject to the terms of the Mozilla Public 2 | // License, v. 2.0. If a copy of the MPL was not distributed with this 3 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. 4 | 5 | use std::io::{ErrorKind, Read, Result, Write}; 6 | use std::time::{Duration, Instant}; 7 | 8 | use anyhow::bail; 9 | use libftdi1_sys as ffi; 10 | 11 | const TIMEOUT: Duration = Duration::from_secs(30); 12 | 13 | /// Handle which wraps an FTDI device and adds retries / timeouts 14 | pub struct Device(ftdi::Device, usize); 15 | 16 | impl Read for Device { 17 | fn read(&mut self, buf: &mut [u8]) -> Result { 18 | let timeout = Instant::now() + TIMEOUT; 19 | let mut i = 0; 20 | 21 | while i < buf.len() { 22 | if let Ok(d) = self.0.read(&mut buf[i..]) { 23 | i += d; 24 | } 25 | if Instant::now() > timeout { 26 | return Err(ErrorKind::TimedOut.into()); 27 | } 28 | } 29 | Ok(i) 30 | } 31 | } 32 | 33 | impl Write for Device { 34 | fn write(&mut self, buf: &[u8]) -> Result { 35 | let timeout = Instant::now() + TIMEOUT; 36 | let mut i = 0; 37 | 38 | while i < buf.len() { 39 | match self.0.write(&buf[i..]) { 40 | Ok(d) => i += d, 41 | Err(_) => continue, 42 | } 43 | if Instant::now() > timeout { 44 | return Err(ErrorKind::TimedOut.into()); 45 | } 46 | } 47 | Ok(i) 48 | } 49 | fn flush(&mut self) -> Result<()> { 50 | self.0.flush() 51 | } 52 | } 53 | 54 | //////////////////////////////////////////////////////////////////////////////// 55 | 56 | pub fn new(vid: Option, pid: Option) -> anyhow::Result { 57 | let mut device = 58 | ftdi::find_by_vid_pid(vid.unwrap_or(0x0403), pid.unwrap_or(0x6011)) 59 | .interface(ftdi::Interface::A) 60 | .open()?; 61 | 62 | device.usb_reset()?; 63 | device.configure( 64 | ftdi::Bits::Eight, 65 | ftdi::StopBits::One, 66 | ftdi::Parity::None, 67 | )?; 68 | device.usb_purge_buffers()?; 69 | device.set_baud_rate(3_000_000)?; 70 | device.set_latency_timer(1)?; 71 | device.set_flow_control(ftdi::FlowControl::RtsCts)?; 72 | device.set_bitmode(0xFF, ftdi::BitMode::Reset)?; 73 | if unsafe { ffi::ftdi_setdtr_rts(device.libftdi_context(), 1, 1) } != 0 { 74 | bail!("Could not set DTR / RTS"); 75 | } 76 | Ok(Device(device, 0)) 77 | } 78 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "anyhow" 7 | version = "1.0.57" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" 10 | 11 | [[package]] 12 | name = "atty" 13 | version = "0.2.14" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 16 | dependencies = [ 17 | "hermit-abi", 18 | "libc", 19 | "winapi", 20 | ] 21 | 22 | [[package]] 23 | name = "autocfg" 24 | version = "1.1.0" 25 | source = "registry+https://github.com/rust-lang/crates.io-index" 26 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 27 | 28 | [[package]] 29 | name = "bitflags" 30 | version = "1.3.2" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 33 | 34 | [[package]] 35 | name = "cfg-if" 36 | version = "1.0.0" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 39 | 40 | [[package]] 41 | name = "clap" 42 | version = "3.1.18" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" 45 | dependencies = [ 46 | "atty", 47 | "bitflags", 48 | "clap_derive", 49 | "clap_lex", 50 | "indexmap", 51 | "lazy_static", 52 | "strsim", 53 | "termcolor", 54 | "textwrap", 55 | ] 56 | 57 | [[package]] 58 | name = "clap_derive" 59 | version = "3.1.18" 60 | source = "registry+https://github.com/rust-lang/crates.io-index" 61 | checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c" 62 | dependencies = [ 63 | "heck", 64 | "proc-macro-error", 65 | "proc-macro2", 66 | "quote", 67 | "syn", 68 | ] 69 | 70 | [[package]] 71 | name = "clap_lex" 72 | version = "0.2.0" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" 75 | dependencies = [ 76 | "os_str_bytes", 77 | ] 78 | 79 | [[package]] 80 | name = "console" 81 | version = "0.15.0" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31" 84 | dependencies = [ 85 | "encode_unicode", 86 | "libc", 87 | "once_cell", 88 | "terminal_size", 89 | "winapi", 90 | ] 91 | 92 | [[package]] 93 | name = "crc16" 94 | version = "0.3.4" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "11a65c4797332f3e3a5945e0377875afc79b1bdc87082a4f98ac1ef15b47e2dd" 97 | 98 | [[package]] 99 | name = "encode_unicode" 100 | version = "0.3.6" 101 | source = "registry+https://github.com/rust-lang/crates.io-index" 102 | checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" 103 | 104 | [[package]] 105 | name = "ftdi" 106 | version = "0.1.3" 107 | source = "registry+https://github.com/rust-lang/crates.io-index" 108 | checksum = "2f9c8c625c6b8634ce70cd8cbb2ab8a103e4c2b4185c86d9954d2e16b1ef7c4a" 109 | dependencies = [ 110 | "ftdi-mpsse", 111 | "libftdi1-sys", 112 | "thiserror", 113 | ] 114 | 115 | [[package]] 116 | name = "ftdi-mpsse" 117 | version = "0.1.1" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "fa7cfcda69930a8d2fdcdd7ffb9234fe4c79a8c73934ed4904327d77bfb5078a" 120 | dependencies = [ 121 | "static_assertions", 122 | ] 123 | 124 | [[package]] 125 | name = "hashbrown" 126 | version = "0.11.2" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 129 | 130 | [[package]] 131 | name = "heck" 132 | version = "0.4.0" 133 | source = "registry+https://github.com/rust-lang/crates.io-index" 134 | checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 135 | 136 | [[package]] 137 | name = "hermit-abi" 138 | version = "0.1.19" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 141 | dependencies = [ 142 | "libc", 143 | ] 144 | 145 | [[package]] 146 | name = "indexmap" 147 | version = "1.8.1" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" 150 | dependencies = [ 151 | "autocfg", 152 | "hashbrown", 153 | ] 154 | 155 | [[package]] 156 | name = "indicatif" 157 | version = "0.16.2" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | checksum = "2d207dc617c7a380ab07ff572a6e52fa202a2a8f355860ac9c38e23f8196be1b" 160 | dependencies = [ 161 | "console", 162 | "lazy_static", 163 | "number_prefix", 164 | "regex", 165 | ] 166 | 167 | [[package]] 168 | name = "lazy_static" 169 | version = "1.4.0" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 172 | 173 | [[package]] 174 | name = "libc" 175 | version = "0.2.125" 176 | source = "registry+https://github.com/rust-lang/crates.io-index" 177 | checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" 178 | 179 | [[package]] 180 | name = "libftdi1-sys" 181 | version = "1.1.2" 182 | source = "registry+https://github.com/rust-lang/crates.io-index" 183 | checksum = "3ff6928872c7d13bec3c8a60c4c92f41f6252f3369b7552a5b4f9c90c8ba2338" 184 | dependencies = [ 185 | "cfg-if", 186 | "libc", 187 | "pkg-config", 188 | "vcpkg", 189 | ] 190 | 191 | [[package]] 192 | name = "log" 193 | version = "0.3.9" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" 196 | dependencies = [ 197 | "log 0.4.17", 198 | ] 199 | 200 | [[package]] 201 | name = "log" 202 | version = "0.4.17" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 205 | dependencies = [ 206 | "cfg-if", 207 | ] 208 | 209 | [[package]] 210 | name = "num-traits" 211 | version = "0.2.15" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 214 | dependencies = [ 215 | "autocfg", 216 | ] 217 | 218 | [[package]] 219 | name = "number_prefix" 220 | version = "0.4.0" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" 223 | 224 | [[package]] 225 | name = "once_cell" 226 | version = "1.10.0" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" 229 | 230 | [[package]] 231 | name = "os_str_bytes" 232 | version = "6.0.0" 233 | source = "registry+https://github.com/rust-lang/crates.io-index" 234 | checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" 235 | 236 | [[package]] 237 | name = "parse_int" 238 | version = "0.6.0" 239 | source = "registry+https://github.com/rust-lang/crates.io-index" 240 | checksum = "2d695b79916a2c08bcff7be7647ab60d1402885265005a6658ffe6d763553c5a" 241 | dependencies = [ 242 | "num-traits", 243 | ] 244 | 245 | [[package]] 246 | name = "pkg-config" 247 | version = "0.3.25" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" 250 | 251 | [[package]] 252 | name = "proc-macro-error" 253 | version = "1.0.4" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 256 | dependencies = [ 257 | "proc-macro-error-attr", 258 | "proc-macro2", 259 | "quote", 260 | "syn", 261 | "version_check", 262 | ] 263 | 264 | [[package]] 265 | name = "proc-macro-error-attr" 266 | version = "1.0.4" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 269 | dependencies = [ 270 | "proc-macro2", 271 | "quote", 272 | "version_check", 273 | ] 274 | 275 | [[package]] 276 | name = "proc-macro2" 277 | version = "1.0.38" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa" 280 | dependencies = [ 281 | "unicode-xid", 282 | ] 283 | 284 | [[package]] 285 | name = "quote" 286 | version = "1.0.18" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" 289 | dependencies = [ 290 | "proc-macro2", 291 | ] 292 | 293 | [[package]] 294 | name = "regex" 295 | version = "1.5.5" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" 298 | dependencies = [ 299 | "regex-syntax", 300 | ] 301 | 302 | [[package]] 303 | name = "regex-syntax" 304 | version = "0.6.25" 305 | source = "registry+https://github.com/rust-lang/crates.io-index" 306 | checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" 307 | 308 | [[package]] 309 | name = "rfsx" 310 | version = "0.1.0" 311 | dependencies = [ 312 | "anyhow", 313 | "clap", 314 | "ftdi", 315 | "indicatif", 316 | "libftdi1-sys", 317 | "parse_int", 318 | "xmodem", 319 | ] 320 | 321 | [[package]] 322 | name = "static_assertions" 323 | version = "1.1.0" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 326 | 327 | [[package]] 328 | name = "strsim" 329 | version = "0.10.0" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 332 | 333 | [[package]] 334 | name = "syn" 335 | version = "1.0.93" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "04066589568b72ec65f42d65a1a52436e954b168773148893c020269563decf2" 338 | dependencies = [ 339 | "proc-macro2", 340 | "quote", 341 | "unicode-xid", 342 | ] 343 | 344 | [[package]] 345 | name = "termcolor" 346 | version = "1.1.3" 347 | source = "registry+https://github.com/rust-lang/crates.io-index" 348 | checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 349 | dependencies = [ 350 | "winapi-util", 351 | ] 352 | 353 | [[package]] 354 | name = "terminal_size" 355 | version = "0.1.17" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" 358 | dependencies = [ 359 | "libc", 360 | "winapi", 361 | ] 362 | 363 | [[package]] 364 | name = "textwrap" 365 | version = "0.15.0" 366 | source = "registry+https://github.com/rust-lang/crates.io-index" 367 | checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" 368 | 369 | [[package]] 370 | name = "thiserror" 371 | version = "1.0.31" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" 374 | dependencies = [ 375 | "thiserror-impl", 376 | ] 377 | 378 | [[package]] 379 | name = "thiserror-impl" 380 | version = "1.0.31" 381 | source = "registry+https://github.com/rust-lang/crates.io-index" 382 | checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" 383 | dependencies = [ 384 | "proc-macro2", 385 | "quote", 386 | "syn", 387 | ] 388 | 389 | [[package]] 390 | name = "unicode-xid" 391 | version = "0.2.3" 392 | source = "registry+https://github.com/rust-lang/crates.io-index" 393 | checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" 394 | 395 | [[package]] 396 | name = "vcpkg" 397 | version = "0.2.15" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 400 | 401 | [[package]] 402 | name = "version_check" 403 | version = "0.9.4" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 406 | 407 | [[package]] 408 | name = "winapi" 409 | version = "0.3.9" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 412 | dependencies = [ 413 | "winapi-i686-pc-windows-gnu", 414 | "winapi-x86_64-pc-windows-gnu", 415 | ] 416 | 417 | [[package]] 418 | name = "winapi-i686-pc-windows-gnu" 419 | version = "0.4.0" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 422 | 423 | [[package]] 424 | name = "winapi-util" 425 | version = "0.1.5" 426 | source = "registry+https://github.com/rust-lang/crates.io-index" 427 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 428 | dependencies = [ 429 | "winapi", 430 | ] 431 | 432 | [[package]] 433 | name = "winapi-x86_64-pc-windows-gnu" 434 | version = "0.4.0" 435 | source = "registry+https://github.com/rust-lang/crates.io-index" 436 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 437 | 438 | [[package]] 439 | name = "xmodem" 440 | version = "0.4.0" 441 | source = "git+https://github.com/oxidecomputer/xmodem.rs/#4d6a1ffb528ad1e51749ba0539a4677168d59f30" 442 | dependencies = [ 443 | "crc16", 444 | "log 0.3.9", 445 | ] 446 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | --------------------------------------------------------------------------------