(ec: &CrosEc, ec_bin_path: &str, flash_type: EcFlashType, dry_run: bool)
| 1085 | } |
| 1086 | |
| 1087 | fn flash_ec(ec: &CrosEc, ec_bin_path: &str, flash_type: EcFlashType, dry_run: bool) { |
| 1088 | #[cfg(feature = "uefi")] |
| 1089 | let data = crate::fw_uefi::fs::shell_read_file(ec_bin_path); |
| 1090 | #[cfg(not(feature = "uefi"))] |
| 1091 | let data: Option<Vec<u8>> = { |
| 1092 | match fs::read(ec_bin_path) { |
| 1093 | Ok(data) => Some(data), |
| 1094 | // TODO: Perhaps a more user-friendly error |
| 1095 | Err(e) => { |
| 1096 | println!("Error {:?}", e); |
| 1097 | None |
| 1098 | } |
| 1099 | } |
| 1100 | }; |
| 1101 | |
| 1102 | if let Some(data) = data { |
| 1103 | println!("File"); |
| 1104 | println!(" Size: {:>20} B", data.len()); |
| 1105 | println!(" Size: {:>20} KB", data.len() / 1024); |
| 1106 | if let Err(err) = ec.reflash(&data, flash_type, dry_run) { |
| 1107 | println!("Error: {:?}", err); |
| 1108 | } else { |
| 1109 | println!("Success!"); |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | fn dump_ec_flash(ec: &CrosEc, dump_path: &str) { |
| 1115 | let flash_bin = ec.get_entire_ec_flash().unwrap(); |
no test coverage detected