MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / reflash

Method reflash

framework_lib/src/chromium_ec/mod.rs:874–1044  ·  view source on GitHub ↗

Overwrite RO and RW regions of EC flash MEC/Legacy EC | Start | End | Size | Region | | 00000 | 3BFFF | 3C000 | RO Region | | 3C000 | 3FFFF | 04000 | Preserved | | 40000 | 78FFF | 39000 | RW Region | | 79000 | 79FFF | 01000 | Preserved | | 80000 | 80FFF | 01000 | Flash Flags | NPC/Zephyr | Start | End | Size | Region | | 00000 | 3BFFF | 3C000 | RO Region | | 3C000 | 3FFF

(&self, data: &[u8], ft: EcFlashType, dry_run: bool)

Source from the content-addressed store, hash-verified

872 /// | 40000 | 78FFF | 39000 | RW Region |
873 /// | 7F000 | 7FFFF | 01000 | Flash Flags |
874 pub fn reflash(&self, data: &[u8], ft: EcFlashType, dry_run: bool) -> EcResult<()> {
875 let mut res = Ok(());
876
877 let cur_ver = self.version_info()?;
878 let platform = if let Some(ver) = ec_binary::parse_ec_version_str(&cur_ver) {
879 ver.platform
880 } else {
881 return Err(EcError::DeviceError(
882 "Cannot determine currently running platform.".to_string(),
883 ));
884 };
885
886 if matches!(ft, EcFlashType::Full | EcFlashType::Both | EcFlashType::Ro) {
887 if let Some(version) = ec_binary::read_ec_version(data, true) {
888 println!("EC RO Version in File: {:?}", version.version);
889 if version.details.platform != platform {
890 return Err(EcError::DeviceError(format!(
891 "RO Firmware file is for platform {}. Currently running {}",
892 version.details.platform, platform
893 )));
894 }
895 } else {
896 return Err(EcError::DeviceError(
897 "File does not contain valid EC RO firmware".to_string(),
898 ));
899 }
900 }
901 if matches!(ft, EcFlashType::Full | EcFlashType::Both | EcFlashType::Rw) {
902 if let Some(version) = ec_binary::read_ec_version(data, false) {
903 println!("EC RW Version in File: {:?}", version.version);
904 if version.details.platform != platform {
905 return Err(EcError::DeviceError(format!(
906 "RW Firmware file is for platform {}. Currently running {}",
907 version.details.platform, platform
908 )));
909 }
910 } else {
911 return Err(EcError::DeviceError(
912 "File does not contain valid EW RW firmware".to_string(),
913 ));
914 }
915 }
916
917 // Determine recommended flash parameters
918 let info = EcRequestFlashInfo {}.send_command(self)?;
919
920 // Check that our hardcoded offsets are valid for the available flash
921 if FLASH_RO_SIZE + FLASH_RW_SIZE > info.flash_size {
922 return Err(EcError::DeviceError(format!(
923 "RO+RW larger than flash 0x{:X}",
924 { info.flash_size }
925 )));
926 }
927 if FLASH_RW_BASE + FLASH_RW_SIZE > info.flash_size {
928 return Err(EcError::DeviceError(format!(
929 "RW overruns end of flash 0x{:X}",
930 { info.flash_size }
931 )));

Callers 1

flash_ecFunction · 0.80

Calls 8

parse_ec_version_strFunction · 0.85
read_ec_versionFunction · 0.85
version_infoMethod · 0.80
flash_notifyMethod · 0.80
erase_ec_flashMethod · 0.80
write_ec_flashMethod · 0.80
read_ec_flashMethod · 0.80
send_commandMethod · 0.45

Tested by

no test coverage detected