mirror of
https://github.com/Dasharo/ecflash.git
synced 2026-03-06 15:02:38 -08:00
Update redox_hwio to fix building dependencies on nightly. Fix warnings: - deprecated - bare_trait_objects - unused_must_use - clippy::chars_next_cmp - clippy::while_let_on_iterator - clippy::redundant_field_names - clippy::needless_borrow - clippy::println_empty_string Silence warnings: - dead_code - clippy::missing_safety_doc - clippy::needless_range_loop - clippy::result_unit_err Signed-off-by: Tim Crawford <tcrawford@system76.com>
36 lines
871 B
Rust
36 lines
871 B
Rust
extern crate ecflash;
|
|
|
|
use ecflash::{EcFlash, Flasher};
|
|
use std::{fs, io, process};
|
|
|
|
fn main() {
|
|
extern {
|
|
fn iopl(level: isize) -> isize;
|
|
}
|
|
|
|
// Get I/O Permission
|
|
unsafe {
|
|
if iopl(3) < 0 {
|
|
eprintln!("Failed to get I/O permission: {}", io::Error::last_os_error());
|
|
process::exit(1);
|
|
}
|
|
|
|
let ec = EcFlash::new(true).expect("Failed to find EC");
|
|
|
|
let mut flasher = Flasher::new(ec);
|
|
|
|
if flasher.start() == Ok(51) {
|
|
if let Ok(data) = flasher.read(|x| { eprint!("\r{} KB", x / 1024) }) {
|
|
eprintln!();
|
|
let _ = fs::write("read.rom", data);
|
|
} else {
|
|
eprintln!("Failed to read data");
|
|
}
|
|
|
|
let _ = flasher.stop();
|
|
} else {
|
|
eprintln!("Failed to start flasher");
|
|
}
|
|
}
|
|
}
|