tool: Assume ROM size is total flash size
Remove the hard-coded assumption that the EC is always 128K, as ITE
chips can also be 256K (which Clevo has started using since addw4).
Instead assume the ROM is correctly sized, which we do since
0d83819a21 ("Pad binary file to total flash size") and proprietary
firmware has always done.
Signed-off-by: Tim Crawford <tcrawford@system76.com>
			
			
This commit is contained in:
		
				
					committed by
					
						 Jeremy Soller
						Jeremy Soller
					
				
			
			
				
	
			
			
			
						parent
						
							183778c32f
						
					
				
				
					commit
					acf67d4413
				
			| @@ -63,11 +63,13 @@ unsafe fn flash_read<S: Spi>(spi: &mut SpiRom<S, StdTimeout>, rom: &mut [u8], se | |||||||
| } | } | ||||||
|  |  | ||||||
| unsafe fn flash_inner(ec: &mut Ec<Box<dyn Access>>, firmware: &Firmware, target: SpiTarget, scratch: bool) -> Result<(), Error> { | unsafe fn flash_inner(ec: &mut Ec<Box<dyn Access>>, firmware: &Firmware, target: SpiTarget, scratch: bool) -> Result<(), Error> { | ||||||
|     let rom_size = 128 * 1024; |     let new_rom = firmware.data.to_vec(); | ||||||
|  |  | ||||||
|     let mut new_rom = firmware.data.to_vec(); |     // XXX: Get flash size programatically? | ||||||
|     while new_rom.len() < rom_size { |     let rom_size = new_rom.len(); | ||||||
|         new_rom.push(0xFF); |     if rom_size % 1024 != 0 { | ||||||
|  |         println!("ROM size of {} is not valid", rom_size); | ||||||
|  |         return Err(ectool::Error::Verify); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     let mut spi_bus = ec.spi(target, scratch)?; |     let mut spi_bus = ec.spi(target, scratch)?; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user