(ec: &CrosEc)
| 2086 | } |
| 2087 | |
| 2088 | fn selftest(ec: &CrosEc) -> Option<()> { |
| 2089 | if let Some(platform) = smbios::get_platform() { |
| 2090 | println!(" SMBIOS Platform: {:?}", platform); |
| 2091 | } else { |
| 2092 | println!(" SMBIOS Platform: Unknown"); |
| 2093 | println!(); |
| 2094 | println!("Specify custom platform parameters with --pd-ports --pd-addrs"); |
| 2095 | return None; |
| 2096 | }; |
| 2097 | let family = smbios::get_platform().and_then(Platform::which_family); |
| 2098 | |
| 2099 | println!(" Dump EC memory region"); |
| 2100 | if let Some(mem) = ec.dump_mem_region() { |
| 2101 | util::print_multiline_buffer(&mem, 0); |
| 2102 | } else { |
| 2103 | println!(" Failed to read EC memory region"); |
| 2104 | return None; |
| 2105 | } |
| 2106 | |
| 2107 | println!(" Checking EC memory mapped magic bytes"); |
| 2108 | print_err(ec.check_mem_magic())?; |
| 2109 | println!(" Verified that Framework EC is present!"); |
| 2110 | |
| 2111 | println!(" Reading EC Build Version"); |
| 2112 | print_err(ec.version_info())?; |
| 2113 | |
| 2114 | print!(" Reading EC Flash by EC"); |
| 2115 | ec.flash_version()?; |
| 2116 | println!(" - OK"); |
| 2117 | |
| 2118 | println!(" Reading EC Flash directly - See below"); |
| 2119 | ec.test_ec_flash_read().ok()?; |
| 2120 | |
| 2121 | print!(" Getting power info from EC"); |
| 2122 | power::power_info(ec)?; |
| 2123 | println!(" - OK"); |
| 2124 | |
| 2125 | println!(" Getting AC info from EC"); |
| 2126 | if family != Some(PlatformFamily::FrameworkDesktop) { |
| 2127 | // All our laptops have at least 4 PD ports so far |
| 2128 | if power::get_pd_info(ec, 4).iter().any(|x| x.is_err()) { |
| 2129 | println!(" Failed to get PD Info from EC"); |
| 2130 | return None; |
| 2131 | } |
| 2132 | } |
| 2133 | |
| 2134 | print!("Reading PD Version from EC"); |
| 2135 | if let Err(err) = power::read_pd_version(ec) { |
| 2136 | // TGL does not have this command, so we have to ignore it |
| 2137 | if err != EcError::Response(EcResponseStatus::InvalidCommand) { |
| 2138 | println!(); |
| 2139 | println!("Err: {:?}", err); |
| 2140 | } else { |
| 2141 | println!(" - Skipped"); |
| 2142 | } |
| 2143 | } else { |
| 2144 | println!(" - OK"); |
| 2145 | } |
no test coverage detected