@@ -202,6 +202,7 @@ pub struct Cli {
202202 pub info : bool ,
203203 pub flash_gpu_descriptor : Option < ( u8 , String ) > ,
204204 pub flash_gpu_descriptor_file : Option < String > ,
205+ pub dump_gpu_descriptor_file : Option < String > ,
205206 // UEFI only
206207 pub allupdate : bool ,
207208 pub paginate : bool ,
@@ -680,6 +681,24 @@ fn dump_ec_flash(ec: &CrosEc, dump_path: &str) {
680681 }
681682}
682683
684+ fn dump_dgpu_eeprom ( ec : & CrosEc , dump_path : & str ) {
685+ let flash_bin = ec. read_gpu_descriptor ( ) . unwrap ( ) ;
686+
687+ #[ cfg( not( feature = "uefi" ) ) ]
688+ {
689+ let mut file = fs:: File :: create ( dump_path) . unwrap ( ) ;
690+ file. write_all ( & flash_bin) . unwrap ( ) ;
691+ }
692+ #[ cfg( feature = "uefi" ) ]
693+ {
694+ let ret = crate :: uefi:: fs:: shell_write_file ( dump_path, & flash_bin) ;
695+ if ret. is_err ( ) {
696+ println ! ( "Failed to dump EC FW image." ) ;
697+ }
698+ }
699+ println ! ( "Wrote {} bytes to {}" , flash_bin. len( ) , dump_path) ;
700+ }
701+
683702fn compare_version ( device : Option < HardwareDeviceType > , version : String , ec : & CrosEc ) -> i32 {
684703 println ! ( "Target Version {:?}" , version) ;
685704
@@ -1270,6 +1289,9 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
12701289 } else {
12711290 println ! ( "Unsupported on this platform" ) ;
12721291 }
1292+ } else if let Some ( dump_path) = & args. dump_gpu_descriptor_file {
1293+ println ! ( "Dumping to {}" , dump_path) ;
1294+ dump_dgpu_eeprom ( & ec, dump_path) ;
12731295 }
12741296
12751297 0
0 commit comments