@@ -742,14 +742,16 @@ impl CrosEc {
742
742
743
743
println ! ( "Erasing RW region" ) ;
744
744
self . erase_ec_flash ( FLASH_BASE + FLASH_RW_BASE , FLASH_RW_SIZE ) ?;
745
+ println ! ( " Done" ) ;
745
746
746
747
println ! ( "Writing RW region" ) ;
747
748
self . write_ec_flash ( FLASH_BASE + FLASH_RW_BASE , rw_data) ?;
749
+ println ! ( " Done" ) ;
748
750
749
751
println ! ( "Verifying RW region" ) ;
750
752
let flash_rw_data = self . read_ec_flash ( FLASH_BASE + FLASH_RW_BASE , FLASH_RW_SIZE ) ?;
751
753
if rw_data == flash_rw_data {
752
- println ! ( "RW verify success" ) ;
754
+ println ! ( " RW verify success" ) ;
753
755
} else {
754
756
println ! ( "RW verify fail" ) ;
755
757
}
@@ -760,14 +762,16 @@ impl CrosEc {
760
762
761
763
println ! ( "Erasing RO region" ) ;
762
764
self . erase_ec_flash ( FLASH_BASE + FLASH_RO_BASE , FLASH_RO_SIZE ) ?;
765
+ println ! ( " Done" ) ;
763
766
764
767
println ! ( "Writing RO region" ) ;
765
768
self . write_ec_flash ( FLASH_BASE + FLASH_RO_BASE , ro_data) ?;
769
+ println ! ( " Done" ) ;
766
770
767
771
println ! ( "Verifying RO region" ) ;
768
772
let flash_ro_data = self . read_ec_flash ( FLASH_BASE + FLASH_RO_BASE , FLASH_RO_SIZE ) ?;
769
773
if ro_data == flash_ro_data {
770
- println ! ( "RO verify success" ) ;
774
+ println ! ( " RO verify success" ) ;
771
775
} else {
772
776
println ! ( "RO verify fail" ) ;
773
777
}
@@ -777,34 +781,39 @@ impl CrosEc {
777
781
self . flash_notify ( MecFlashNotify :: AccessSpiDone ) ?;
778
782
self . flash_notify ( MecFlashNotify :: FirmwareDone ) ?;
779
783
780
- println ! ( "Flashing EC done. You can reboot the EC now" ) ;
781
- // TODO: Should we force a reboot if currently running one was reflashed?
784
+ if res. is_ok ( ) {
785
+ println ! ( "Flashing EC done. You can reboot the EC now" ) ;
786
+ }
782
787
783
788
Ok ( ( ) )
784
789
}
785
790
786
791
/// Write a big section of EC flash. Must be unlocked already
787
792
fn write_ec_flash ( & self , addr : u32 , data : & [ u8 ] ) -> EcResult < ( ) > {
788
- let info = EcRequestFlashInfo { } . send_command ( self ) ? ;
789
- println ! ( "Flash info: {:?}" , info ) ;
793
+ // TODO: Use flash info to help guide ideal chunk size
794
+ // let info = EcRequestFlashInfo {}.send_command(self)? ;
790
795
//let chunk_size = ((0x80 / info.write_ideal_size) * info.write_ideal_size) as usize;
796
+
791
797
let chunk_size = 0x80 ;
792
798
793
799
let chunks = data. len ( ) / chunk_size;
800
+ println ! (
801
+ " Will write flash from 0x{:X} to 0x{:X} in {}*{}B chunks" ,
802
+ addr,
803
+ data. len( ) ,
804
+ chunks,
805
+ chunk_size
806
+ ) ;
794
807
for chunk_no in 0 ..chunks {
795
808
let offset = chunk_no * chunk_size;
796
809
// Current chunk might be smaller if it's the last
797
810
let cur_chunk_size = std:: cmp:: min ( chunk_size, data. len ( ) - chunk_no * chunk_size) ;
798
811
799
812
if chunk_no % 100 == 0 {
800
- println ! ( ) ;
801
- print ! (
802
- "Writing chunk {:>4}/{:>4} ({:>6}/{:>6}): X" ,
803
- chunk_no,
804
- chunks,
805
- offset,
806
- cur_chunk_size * chunks
807
- ) ;
813
+ if chunk_no != 0 {
814
+ println ! ( ) ;
815
+ }
816
+ print ! ( " Chunk {:>4}: X" , chunk_no) ;
808
817
} else {
809
818
print ! ( "X" ) ;
810
819
}
0 commit comments