MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / dump_dgpu_eeprom

Function dump_dgpu_eeprom

framework_lib/src/commandline/mod.rs:1131–1195  ·  view source on GitHub ↗
(ec: &CrosEc, dump_path: &str)

Source from the content-addressed store, hash-verified

1129}
1130
1131fn dump_dgpu_eeprom(ec: &CrosEc, dump_path: &str) {
1132 // Read raw bytes from EEPROM
1133 let raw_bytes = match ec.read_ec_gpu_chunk(0x00, 256) {
1134 Ok(data) => data,
1135 Err(err) => {
1136 error!("Failed to read EEPROM: {:?}", err);
1137 return;
1138 }
1139 };
1140
1141 // For stdout, just print the raw bytes
1142 if dump_path == "-" {
1143 println!("{:02X?}", raw_bytes);
1144 println!("Read {} bytes from EEPROM", raw_bytes.len());
1145 return;
1146 }
1147
1148 // Check if header is valid by examining magic bytes
1149 let expected_magic = [0x32, 0xAC, 0x00, 0x00];
1150 let has_valid_header = raw_bytes.len() >= 4 && raw_bytes[0..4] == expected_magic;
1151
1152 let flash_bin = if has_valid_header {
1153 // Header looks valid, try to read the full descriptor
1154 match ec.read_gpu_descriptor() {
1155 Ok(data) => data,
1156 Err(err) => {
1157 error!("GPU descriptor read failed: {:?}", err);
1158 println!("Falling back to raw EEPROM dump (256 bytes)");
1159 raw_bytes
1160 }
1161 }
1162 } else {
1163 error!(
1164 "GPU descriptor invalid: magic {:02X?} != expected {:02X?}",
1165 &raw_bytes[0..4],
1166 expected_magic
1167 );
1168 println!("Dumping raw EEPROM (256 bytes)");
1169 raw_bytes
1170 };
1171
1172 #[cfg(not(feature = "uefi"))]
1173 {
1174 match fs::File::create(dump_path) {
1175 Ok(mut file) => {
1176 if let Err(err) = file.write_all(&flash_bin) {
1177 error!("Failed to write file: {:?}", err);
1178 return;
1179 }
1180 }
1181 Err(err) => {
1182 error!("Failed to create file: {:?}", err);
1183 return;
1184 }
1185 }
1186 }
1187 #[cfg(feature = "uefi")]
1188 {

Callers 1

run_with_argsFunction · 0.85

Calls 3

shell_write_fileFunction · 0.85
read_ec_gpu_chunkMethod · 0.80
read_gpu_descriptorMethod · 0.80

Tested by

no test coverage detected